2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
25 * AppleATAPIIXTiming.h - Timing tables.
31 #ifndef _APPLEATAPIIXTIMING_H
32 #define _APPLEATAPIIXTIMING_H
35 * Supported transfer protocols. Entries in this table must map to the
36 * entries in ATATimingProtocol table.
47 * PIIX PIO/DMA timing table.
50 UInt8 pioMode
; // PIO mode
51 UInt8 swDMAMode
; // single-word DMA mode (obsolete)
52 UInt8 mwDMAMode
; // multiword DMA mode
53 UInt8 isp
; // IORDY sample point in PCI clocks
54 UInt8 rtc
; // Recovery time in PCI clocks
55 UInt16 cycle
; // cycle time in ns
58 #define _NVM_ 0xff // not a valid mode
61 PIIXTiming PIIXPIOTimingTable
[] = {
62 /* PIO SW MW ISP RTC CYCLE (ns) */
64 {1, 1, _NVM_
, 5, 4, 600},
65 {2, 2, _NVM_
, 4, 4, 240},
66 {3, _NVM_
, 1, 3, 3, 180},
67 {4, _NVM_
, 2, 3, 1, 120},
68 {5, _NVM_
, 2, 3, 1, 120},
71 static const UInt8 PIIXPIOTimingTableSize
= sizeof(PIIXPIOTimingTable
) /
72 sizeof(PIIXPIOTimingTable
[0]);
75 * PIIX Ultra-DMA/33 timing table.
78 UInt8 mode
; // mode number
79 UInt8 ct
; // cycle time in PCI clocks
80 UInt8 rp
; // Ready to Pause time in PCI clocks
81 UInt8 bits
; // register bit setting
82 UInt16 strobe
; // strobe period (cycle) in ns
86 PIIXUDMATiming PIIXUDMATimingTable
[] = {
87 /* MODE CT RP BITS STROBE/CYCLE (ns) */
94 PIIXUDMATimingTableSize
= sizeof(PIIXUDMATimingTable
) /
95 sizeof(PIIXUDMATimingTable
[0]);
98 * For each drive, the following table will store the chosen timings
99 * for each supported protocol.
102 UInt8 activeTimings
[kPIIXProtocolLast
]; // selected timings
103 UInt8 validTimings
[kPIIXProtocolLast
]; // calculated timings
106 } PIIXSelectedTimings
;
109 * Convert from ATATimingProtocol to PIIXProtocol.
111 inline PIIXProtocol
ataToPIIXProtocol(ATATimingProtocol timingProtocol
)
113 int piixProtocol
= kPIIXProtocolPIO
;
114 int ataProtocol
= timingProtocol
;
116 while (ataProtocol
!= 1) {
117 ataProtocol
>>= 1; piixProtocol
++;
119 return ((PIIXProtocol
) piixProtocol
);
123 * Misc macros to get information from the PIIXSelectedTimings table.
125 #define PIIX_ACTIVATE_PROTOCOL(p) { \
126 timings[unit].activeTimings[p] = timings[unit].validTimings[p]; \
127 timings[unit].activeFlag |= (1 << (p)); \
130 #define PIIX_DEACTIVATE_PROTOCOL(p) { \
131 timings[unit].activeFlag &= ~(1 << (p)); \
134 #define PIIX_GET_ACTIVE_TIMING(p) (timings[unit].activeTimings[p])
136 #define PIIX_PROTOCOL_IS_ACTIVE(p) ((bool) \
137 (timings[unit].activeFlag & (1 << (p))))
139 #define PIIX_PROTOCOL_IS_VALID(p) ((bool) \
140 (timings[unit].validFlag & (1 << (p))))
142 #endif /* !_APPLEATAPIIXTIMING_H */