1 #ifndef _IDE_H
2 #define _IDE_H
3 /*
4 * linux/include/linux/ide.h
5 *
6 * Copyright (C) 1994-2002 Linus Torvalds & authors
7 */
8
9 #include <linux/config.h>
10 #include <linux/init.h>
11 #include <linux/ioport.h>
12 #include <linux/hdreg.h>
13 #include <linux/hdsmart.h>
14 #include <linux/blkdev.h>
15 #include <linux/proc_fs.h>
16 #include <linux/devfs_fs_kernel.h>
17 #include <linux/interrupt.h>
18 #include <linux/bitops.h>
19 #include <linux/highmem.h>
20 #include <linux/pci.h>
21 #include <asm/byteorder.h>
22 #include <asm/system.h>
23 #include <asm/hdreg.h>
24 #include <asm/io.h>
25
26 #define CLASSIC_BUILTINS_METHOD 1
27 //#undef CLASSIC_BUILTINS_METHOD
28 #define HWIF_PROBE_CLASSIC_METHOD 1
29 //#undef HWIF_PROBE_CLASSIC_METHOD
30
31 #ifdef CLASSIC_BUILTINS_METHOD
32 # undef FAKE_CLASSIC_ATTACH_METHOD
33 # undef DIRECT_HWIF_PROBE_ATTACH_METHOD
34 #else /* ! CLASSIC_BUILTINS_METHOD */
35 # ifdef HWIF_PROBE_CLASSIC_METHOD
36 # undef FAKE_CLASSIC_ATTACH_METHOD
37 # undef DIRECT_HWIF_PROBE_ATTACH_METHOD
38 # else /* ! HWIF_PROBE_CLASSIC_METHOD */
39 //# define FAKE_CLASSIC_ATTACH_METHOD 1
40 # undef FAKE_CLASSIC_ATTACH_METHOD
41 # ifdef FAKE_CLASSIC_ATTACH_METHOD
42 # undef DIRECT_HWIF_PROBE_ATTACH_METHOD
43 # else /* ! FAKE_CLASSIC_ATTACH_METHOD */
44 # define DIRECT_HWIF_PROBE_ATTACH_METHOD 1
45 # endif /* FAKE_CLASSIC_ATTACH_METHOD */
46 # endif /* HWIF_PROBE_CLASSIC_METHOD */
47 #endif /* CLASSIC_BUILTINS_METHOD */
48
49 /*
50 * This is the multiple IDE interface driver, as evolved from hd.c.
51 * It supports up to four IDE interfaces, on one or more IRQs (usually 14 & 15).
52 * There can be up to two drives per interface, as per the ATA-2 spec.
53 *
54 * Primary i/f: ide0: major=3; (hda) minor=0; (hdb) minor=64
55 * Secondary i/f: ide1: major=22; (hdc or hd1a) minor=0; (hdd or hd1b) minor=64
56 * Tertiary i/f: ide2: major=33; (hde) minor=0; (hdf) minor=64
57 * Quaternary i/f: ide3: major=34; (hdg) minor=0; (hdh) minor=64
58 */
59
60 /******************************************************************************
61 * IDE driver configuration options (play with these as desired):
62 *
63 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary
64 */
65 #undef REALLY_FAST_IO /* define if ide ports are perfect */
66 #define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */
67
68 #ifndef SUPPORT_SLOW_DATA_PORTS /* 1 to support slow data ports */
69 #define SUPPORT_SLOW_DATA_PORTS 1 /* 0 to reduce kernel size */
70 #endif
71 #ifndef SUPPORT_VLB_SYNC /* 1 to support weird 32-bit chips */
72 #define SUPPORT_VLB_SYNC 1 /* 0 to reduce kernel size */
73 #endif
74 #ifndef DISK_RECOVERY_TIME /* off=0; on=access_delay_time */
75 #define DISK_RECOVERY_TIME 0 /* for hardware that needs it */
76 #endif
77 #ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */
78 #define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */
79 #endif
80 #ifndef FANCY_STATUS_DUMPS /* 1 for human-readable drive errors */
81 #define FANCY_STATUS_DUMPS 1 /* 0 to reduce kernel size */
82 #endif
83
84 #ifdef CONFIG_BLK_DEV_CMD640
85 #if 0 /* change to 1 when debugging cmd640 problems */
86 void cmd640_dump_regs (void);
87 #define CMD640_DUMP_REGS cmd640_dump_regs() /* for debugging cmd640 chipset */
88 #endif
89 #endif /* CONFIG_BLK_DEV_CMD640 */
90
91 #ifndef DISABLE_IRQ_NOSYNC
92 #define DISABLE_IRQ_NOSYNC 0
93 #endif
94
95 /*
96 * Used to indicate "no IRQ", should be a value that cannot be an IRQ
97 * number.
98 */
99
100 #define IDE_NO_IRQ (-1)
101
102 /*
103 * IDE_DRIVE_CMD is used to implement many features of the hdparm utility
104 */
105 #define IDE_DRIVE_CMD 99 /* (magic) undef to reduce kernel size*/
106
107 #define IDE_DRIVE_TASK 98
108
109 /*
110 * IDE_DRIVE_TASKFILE is used to implement many features needed for raw tasks
111 */
112 #define IDE_DRIVE_TASKFILE 97
113
114 /*
115 * "No user-serviceable parts" beyond this point :)
116 *****************************************************************************/
117
118 typedef unsigned char byte; /* used everywhere */
119
120 /*
121 * Probably not wise to fiddle with these
122 */
123 #define ERROR_MAX 8 /* Max read/write errors per sector */
124 #define ERROR_RESET 3 /* Reset controller every 4th retry */
125 #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
126
127 /*
128 * Tune flags
129 */
130 #define IDE_TUNE_BIOS 3
131 #define IDE_TUNE_NOAUTO 2
132 #define IDE_TUNE_AUTO 1
133 #define IDE_TUNE_DEFAULT 0
134
135 /*
136 * state flags
137 */
138
139 #define DMA_PIO_RETRY 1 /* retrying in PIO */
140
141 /*
142 * Ensure that various configuration flags have compatible settings
143 */
144 #ifdef REALLY_SLOW_IO
145 #undef REALLY_FAST_IO
146 #endif
147
148 #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif))
149 #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
150
151 /*
152 * Definitions for accessing IDE controller registers
153 */
154 #define IDE_NR_PORTS (10)
155
156 #define IDE_DATA_OFFSET (0)
157 #define IDE_ERROR_OFFSET (1)
158 #define IDE_NSECTOR_OFFSET (2)
159 #define IDE_SECTOR_OFFSET (3)
160 #define IDE_LCYL_OFFSET (4)
161 #define IDE_HCYL_OFFSET (5)
162 #define IDE_SELECT_OFFSET (6)
163 #define IDE_STATUS_OFFSET (7)
164 #define IDE_CONTROL_OFFSET (8)
165 #define IDE_IRQ_OFFSET (9)
166
167 #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
168 #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
169
170 #define IDE_DATA_OFFSET_HOB (0)
171 #define IDE_ERROR_OFFSET_HOB (1)
172 #define IDE_NSECTOR_OFFSET_HOB (2)
173 #define IDE_SECTOR_OFFSET_HOB (3)
174 #define IDE_LCYL_OFFSET_HOB (4)
175 #define IDE_HCYL_OFFSET_HOB (5)
176 #define IDE_SELECT_OFFSET_HOB (6)
177 #define IDE_CONTROL_OFFSET_HOB (7)
178
179 #define IDE_FEATURE_OFFSET_HOB IDE_ERROR_OFFSET_HOB
180
181 #define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
182 #define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
183 #define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
184 #define IDE_SECTOR_REG (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
185 #define IDE_LCYL_REG (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
186 #define IDE_HCYL_REG (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
187 #define IDE_SELECT_REG (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
188 #define IDE_STATUS_REG (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
189 #define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
190 #define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
191
192 #define IDE_DATA_REG_HOB (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
193 #define IDE_ERROR_REG_HOB (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
194 #define IDE_NSECTOR_REG_HOB (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
195 #define IDE_SECTOR_REG_HOB (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
196 #define IDE_LCYL_REG_HOB (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
197 #define IDE_HCYL_REG_HOB (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
198 #define IDE_SELECT_REG_HOB (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
199 #define IDE_STATUS_REG_HOB (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
200 #define IDE_CONTROL_REG_HOB (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
201
202 #define IDE_FEATURE_REG IDE_ERROR_REG
203 #define IDE_COMMAND_REG IDE_STATUS_REG
204 #define IDE_ALTSTATUS_REG IDE_CONTROL_REG
205 #define IDE_IREASON_REG IDE_NSECTOR_REG
206 #define IDE_BCOUNTL_REG IDE_LCYL_REG
207 #define IDE_BCOUNTH_REG IDE_HCYL_REG
208
209 #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
210 #define BAD_R_STAT (BUSY_STAT | ERR_STAT)
211 #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT)
212 #define BAD_STAT (BAD_R_STAT | DRQ_STAT)
213 #define DRIVE_READY (READY_STAT | SEEK_STAT)
214 #define DATA_READY (DRQ_STAT)
215
216 #define BAD_CRC (ABRT_ERR | ICRC_ERR)
217
218 #define SATA_NR_PORTS (3) /* 16 possible ?? */
219
220 #define SATA_STATUS_OFFSET (0)
221 #define SATA_STATUS_REG (HWIF(drive)->sata_scr[SATA_STATUS_OFFSET])
222 #define SATA_ERROR_OFFSET (1)
223 #define SATA_ERROR_REG (HWIF(drive)->sata_scr[SATA_ERROR_OFFSET])
224 #define SATA_CONTROL_OFFSET (2)
225 #define SATA_CONTROL_REG (HWIF(drive)->sata_scr[SATA_CONTROL_OFFSET])
226
227 #define SATA_MISC_OFFSET (0)
228 #define SATA_MISC_REG (HWIF(drive)->sata_misc[SATA_MISC_OFFSET])
229 #define SATA_PHY_OFFSET (1)
230 #define SATA_PHY_REG (HWIF(drive)->sata_misc[SATA_PHY_OFFSET])
231 #define SATA_IEN_OFFSET (2)
232 #define SATA_IEN_REG (HWIF(drive)->sata_misc[SATA_IEN_OFFSET])
233
234 /*
235 * Our Physical Region Descriptor (PRD) table should be large enough
236 * to handle the biggest I/O request we are likely to see. Since requests
237 * can have no more than 256 sectors, and since the typical blocksize is
238 * two or more sectors, we could get by with a limit of 128 entries here for
239 * the usual worst case. Most requests seem to include some contiguous blocks,
240 * further reducing the number of table entries required.
241 *
242 * The driver reverts to PIO mode for individual requests that exceed
243 * this limit (possible with 512 byte blocksizes, eg. MSDOS f/s), so handling
244 * 100% of all crazy scenarios here is not necessary.
245 *
246 * As it turns out though, we must allocate a full 4KB page for this,
247 * so the two PRD tables (ide0 & ide1) will each get half of that,
248 * allowing each to have about 256 entries (8 bytes each) from this.
249 */
250 #define PRD_BYTES 8
251 #define PRD_ENTRIES (PAGE_SIZE / (2 * PRD_BYTES))
252
253 /*
254 * Some more useful definitions
255 */
256 #define IDE_MAJOR_NAME "hd" /* the same for all i/f; see also genhd.c */
257 #define MAJOR_NAME IDE_MAJOR_NAME
258 #define PARTN_BITS 6 /* number of minor dev bits for partitions */
259 #define PARTN_MASK ((1<<PARTN_BITS)-1) /* a useful bit mask */
260 #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */
261 #define SECTOR_SIZE 512
262 #define SECTOR_WORDS (SECTOR_SIZE / 4) /* number of 32bit words per sector */
263 #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
264 #define IDE_MIN(a,b) ((a)<(b) ? (a):(b))
265 #define IDE_MAX(a,b) ((a)>(b) ? (a):(b))
266
267 /*
268 * Timeouts for various operations:
269 */
270 #define WAIT_DRQ (5*HZ/100) /* 50msec - spec allows up to 20ms */
271 #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
272 #define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */
273 #else
274 #define WAIT_READY (3*HZ/100) /* 30msec - should be instantaneous */
275 #endif /* CONFIG_APM || CONFIG_APM_MODULE */
276 #define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?), if all ATAPI CD is closed at boot */
277 #define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */
278 #define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */
279 #define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */
280
281 #define HOST(hwif,chipset) \
282 { \
283 return ((hwif)->chipset == chipset) ? 1 : 0; \
284 }
285
286 /*
287 * Check for an interrupt and acknowledge the interrupt status
288 */
289 struct hwif_s;
290 typedef int (ide_ack_intr_t)(struct hwif_s *);
291
292 #ifndef NO_DMA
293 #define NO_DMA 255
294 #endif
295
296 /*
297 * hwif_chipset_t is used to keep track of the specific hardware
298 * chipset used by each IDE interface, if known.
299 */
300 typedef enum { ide_unknown, ide_generic, ide_pci,
301 ide_cmd640, ide_dtc2278, ide_ali14xx,
302 ide_qd65xx, ide_umc8672, ide_ht6560b,
303 ide_pdc4030, ide_rz1000, ide_trm290,
304 ide_cmd646, ide_cy82c693, ide_4drives,
305 ide_pmac, ide_etrax100, ide_acorn
306 } hwif_chipset_t;
307
308 /*
309 * Structure to hold all information about the location of this port
310 */
311 typedef struct hw_regs_s {
312 ide_ioreg_t io_ports[IDE_NR_PORTS]; /* task file registers */
313 int irq; /* our irq number */
314 int dma; /* our dma entry */
315 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
316 void *priv; /* interface specific data */
317 hwif_chipset_t chipset;
318 sata_ioreg_t sata_scr[SATA_NR_PORTS];
319 sata_ioreg_t sata_misc[SATA_NR_PORTS];
320 } hw_regs_t;
321
322 /*
323 * Register new hardware with ide
324 */
325 int ide_register_hw(hw_regs_t *hw, struct hwif_s **hwifp);
326
327 /*
328 * Set up hw_regs_t structure before calling ide_register_hw (optional)
329 */
330 void ide_setup_ports( hw_regs_t *hw,
331 ide_ioreg_t base,
332 int *offsets,
333 ide_ioreg_t ctrl,
334 ide_ioreg_t intr,
335 ide_ack_intr_t *ack_intr,
336 #if 0
337 ide_io_ops_t *iops,
338 #endif
339 int irq);
340
341 #include <asm/ide.h>
342
343 /* Currently only m68k, apus and m8xx need it */
344 #ifndef IDE_ARCH_ACK_INTR
345 # define ide_ack_intr(hwif) (1)
346 #endif
347
348 /* Currently only Atari needs it */
349 #ifndef IDE_ARCH_LOCK
350 # define ide_release_lock() do {} while (0)
351 # define ide_get_lock(hdlr, data) do {} while (0)
352 #endif /* IDE_ARCH_LOCK */
353
354 /*
355 * Now for the data we need to maintain per-drive: ide_drive_t
356 */
357
358 #define ide_scsi 0x21
359 #define ide_disk 0x20
360 #define ide_optical 0x7
361 #define ide_cdrom 0x5
362 #define ide_tape 0x1
363 #define ide_floppy 0x0
364
365 /*
366 * Special Driver Flags
367 *
368 * set_geometry : respecify drive geometry
369 * recalibrate : seek to cyl 0
370 * set_multmode : set multmode count
371 * set_tune : tune interface for drive
372 * serviced : service command
373 * reserved : unused
374 */
375 typedef union {
376 unsigned all : 8;
377 struct {
378 #if defined(__LITTLE_ENDIAN_BITFIELD)
379 unsigned set_geometry : 1;
380 unsigned recalibrate : 1;
381 unsigned set_multmode : 1;
382 unsigned set_tune : 1;
383 unsigned serviced : 1;
384 unsigned reserved : 3;
385 #elif defined(__BIG_ENDIAN_BITFIELD)
386 unsigned reserved : 3;
387 unsigned serviced : 1;
388 unsigned set_tune : 1;
389 unsigned set_multmode : 1;
390 unsigned recalibrate : 1;
391 unsigned set_geometry : 1;
392 #else
393 #error "Please fix <asm/byteorder.h>"
394 #endif
395 } b;
396 } special_t;
397
398 /*
399 * ATA DATA Register Special.
400 * ATA NSECTOR Count Register().
401 * ATAPI Byte Count Register.
402 * Channel index ordering pairs.
403 */
404 typedef union {
405 unsigned all :16;
406 struct {
407 #if defined(__LITTLE_ENDIAN_BITFIELD)
408 unsigned low :8; /* LSB */
409 unsigned high :8; /* MSB */
410 #elif defined(__BIG_ENDIAN_BITFIELD)
411 unsigned high :8; /* MSB */
412 unsigned low :8; /* LSB */
413 #else
414 #error "Please fix <asm/byteorder.h>"
415 #endif
416 } b;
417 } ata_nsector_t, ata_data_t, atapi_bcount_t, ata_index_t;
418
419 /*
420 * ATA-IDE Error Register
421 *
422 * mark : Bad address mark
423 * tzero : Couldn't find track 0
424 * abrt : Aborted Command
425 * mcr : Media Change Request
426 * id : ID field not found
427 * mce : Media Change Event
428 * ecc : Uncorrectable ECC error
429 * bdd : dual meaing
430 */
431 typedef union {
432 unsigned all :8;
433 struct {
434 #if defined(__LITTLE_ENDIAN_BITFIELD)
435 unsigned mark :1;
436 unsigned tzero :1;
437 unsigned abrt :1;
438 unsigned mcr :1;
439 unsigned id :1;
440 unsigned mce :1;
441 unsigned ecc :1;
442 unsigned bdd :1;
443 #elif defined(__BIG_ENDIAN_BITFIELD)
444 unsigned bdd :1;
445 unsigned ecc :1;
446 unsigned mce :1;
447 unsigned id :1;
448 unsigned mcr :1;
449 unsigned abrt :1;
450 unsigned tzero :1;
451 unsigned mark :1;
452 #else
453 #error "Please fix <asm/byteorder.h>"
454 #endif
455 } b;
456 } ata_error_t;
457
458 /*
459 * ATA-IDE Select Register, aka Device-Head
460 *
461 * head : always zeros here
462 * unit : drive select number: 0/1
463 * bit5 : always 1
464 * lba : using LBA instead of CHS
465 * bit7 : always 1
466 */
467 typedef union {
468 unsigned all : 8;
469 struct {
470 #if defined(__LITTLE_ENDIAN_BITFIELD)
471 unsigned head : 4;
472 unsigned unit : 1;
473 unsigned bit5 : 1;
474 unsigned lba : 1;
475 unsigned bit7 : 1;
476 #elif defined(__BIG_ENDIAN_BITFIELD)
477 unsigned bit7 : 1;
478 unsigned lba : 1;
479 unsigned bit5 : 1;
480 unsigned unit : 1;
481 unsigned head : 4;
482 #else
483 #error "Please fix <asm/byteorder.h>"
484 #endif
485 } b;
486 } select_t, ata_select_t;
487
488 /*
489 * The ATA-IDE Status Register.
490 * The ATAPI Status Register.
491 *
492 * check : Error occurred
493 * idx : Index Error
494 * corr : Correctable error occurred
495 * drq : Data is request by the device
496 * dsc : Disk Seek Complete : ata
497 * : Media access command finished : atapi
498 * df : Device Fault : ata
499 * : Reserved : atapi
500 * drdy : Ready, Command Mode Capable : ata
501 * : Ignored for ATAPI commands : atapi
502 * bsy : Disk is Busy
503 * : The device has access to the command block
504 */
505 typedef union {
506 unsigned all :8;
507 struct {
508 #if defined(__LITTLE_ENDIAN_BITFIELD)
509 unsigned check :1;
510 unsigned idx :1;
511 unsigned corr :1;
512 unsigned drq :1;
513 unsigned dsc :1;
514 unsigned df :1;
515 unsigned drdy :1;
516 unsigned bsy :1;
517 #elif defined(__BIG_ENDIAN_BITFIELD)
518 unsigned bsy :1;
519 unsigned drdy :1;
520 unsigned df :1;
521 unsigned dsc :1;
522 unsigned drq :1;
523 unsigned corr :1;
524 unsigned idx :1;
525 unsigned check :1;
526 #else
527 #error "Please fix <asm/byteorder.h>"
528 #endif
529 } b;
530 } ata_status_t, atapi_status_t;
531
532 /*
533 * ATA-IDE Control Register
534 *
535 * bit0 : Should be set to zero
536 * nIEN : device INTRQ to host
537 * SRST : host soft reset bit
538 * bit3 : ATA-2 thingy, Should be set to 1
539 * reserved456 : Reserved
540 * HOB : 48-bit address ordering, High Ordered Bit
541 */
542 typedef union {
543 unsigned all : 8;
544 struct {
545 #if defined(__LITTLE_ENDIAN_BITFIELD)
546 unsigned bit0 : 1;
547 unsigned nIEN : 1;
548 unsigned SRST : 1;
549 unsigned bit3 : 1;
550 unsigned reserved456 : 3;
551 unsigned HOB : 1;
552 #elif defined(__BIG_ENDIAN_BITFIELD)
553 unsigned HOB : 1;
554 unsigned reserved456 : 3;
555 unsigned bit3 : 1;
556 unsigned SRST : 1;
557 unsigned nIEN : 1;
558 unsigned bit0 : 1;
559 #else
560 #error "Please fix <asm/byteorder.h>"
561 #endif
562 } b;
563 } ata_control_t;
564
565 /*
566 * ATAPI Feature Register
567 *
568 * dma : Using DMA or PIO
569 * reserved321 : Reserved
570 * reserved654 : Reserved (Tag Type)
571 * reserved7 : Reserved
572 */
573 typedef union {
574 unsigned all :8;
575 struct {
576 #if defined(__LITTLE_ENDIAN_BITFIELD)
577 unsigned dma :1;
578 unsigned reserved321 :3;
579 unsigned reserved654 :3;
580 unsigned reserved7 :1;
581 #elif defined(__BIG_ENDIAN_BITFIELD)
582 unsigned reserved7 :1;
583 unsigned reserved654 :3;
584 unsigned reserved321 :3;
585 unsigned dma :1;
586 #else
587 #error "Please fix <asm/byteorder.h>"
588 #endif
589 } b;
590 } atapi_feature_t;
591
592 /*
593 * ATAPI Interrupt Reason Register.
594 *
595 * cod : Information transferred is command (1) or data (0)
596 * io : The device requests us to read (1) or write (0)
597 * reserved : Reserved
598 */
599 typedef union {
600 unsigned all :8;
601 struct {
602 #if defined(__LITTLE_ENDIAN_BITFIELD)
603 unsigned cod :1;
604 unsigned io :1;
605 unsigned reserved :6;
606 #elif defined(__BIG_ENDIAN_BITFIELD)
607 unsigned reserved :6;
608 unsigned io :1;
609 unsigned cod :1;
610 #else
611 #error "Please fix <asm/byteorder.h>"
612 #endif
613 } b;
614 } atapi_ireason_t;
615
616 /*
617 * The ATAPI error register.
618 *
619 * ili : Illegal Length Indication
620 * eom : End Of Media Detected
621 * abrt : Aborted command - As defined by ATA
622 * mcr : Media Change Requested - As defined by ATA
623 * sense_key : Sense key of the last failed packet command
624 */
625 typedef union {
626 unsigned all :8;
627 struct {
628 #if defined(__LITTLE_ENDIAN_BITFIELD)
629 unsigned ili :1;
630 unsigned eom :1;
631 unsigned abrt :1;
632 unsigned mcr :1;
633 unsigned sense_key :4;
634 #elif defined(__BIG_ENDIAN_BITFIELD)
635 unsigned sense_key :4;
636 unsigned mcr :1;
637 unsigned abrt :1;
638 unsigned eom :1;
639 unsigned ili :1;
640 #else
641 #error "Please fix <asm/byteorder.h>"
642 #endif
643 } b;
644 } atapi_error_t;
645
646 /*
647 * ATAPI floppy Drive Select Register
648 *
649 * sam_lun : Logical unit number
650 * reserved3 : Reserved
651 * drv : The responding drive will be drive 0 (0) or drive 1 (1)
652 * one5 : Should be set to 1
653 * reserved6 : Reserved
654 * one7 : Should be set to 1
655 */
656 typedef union {
657 unsigned all :8;
658 struct {
659 #if defined(__LITTLE_ENDIAN_BITFIELD)
660 unsigned sam_lun :3;
661 unsigned reserved3 :1;
662 unsigned drv :1;
663 unsigned one5 :1;
664 unsigned reserved6 :1;
665 unsigned one7 :1;
666 #elif defined(__BIG_ENDIAN_BITFIELD)
667 unsigned one7 :1;
668 unsigned reserved6 :1;
669 unsigned one5 :1;
670 unsigned drv :1;
671 unsigned reserved3 :1;
672 unsigned sam_lun :3;
673 #else
674 #error "Please fix <asm/byteorder.h>"
675 #endif
676 } b;
677 } atapi_select_t;
678
679 struct ide_driver_s;
680 struct ide_settings_s;
681
682 /*
683 * Status returned from various ide_ functions
684 */
685 typedef enum {
686 ide_stopped, /* no drive operation was started */
687 ide_started /* a drive operation was started, handler was set */
688 } ide_startstop_t;
689
690
691 typedef struct ide_drive_s {
692 char name[4]; /* drive name, such as "hda" */
693 char driver_req[10]; /* requests specific driver */
694
695 request_queue_t queue; /* request queue */
696
697 wait_queue_head_t wqueue; /* used to wait for drive in open() */
698 struct request *rq; /* current request */
699 struct ide_drive_s *next; /* circular list of hwgroup drives */
700 struct ide_driver_s *driver;/* (ide_driver_t *) */
701 void *driver_data; /* extra driver data */
702 struct hd_driveid *id; /* drive model identification info */
703 struct hd_struct *part; /* drive partition table */
704 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
705 struct ide_settings_s *settings;/* /proc/ide/ drive settings */
706 devfs_handle_t de; /* directory for device */
707
708 struct hwif_s *hwif; /* actually (ide_hwif_t *) */
709
710 unsigned long sleep; /* sleep until this time */
711 unsigned long service_start; /* time we started last request */
712 unsigned long service_time; /* service time of last request */
713 unsigned long timeout; /* max time to wait for irq */
714
715 special_t special; /* special action flags */
716 select_t select; /* basic drive/head select reg value */
717
718 u8 keep_settings; /* restore settings after drive reset */
719 u8 autodma; /* device can safely use dma on host */
720 u8 using_dma; /* disk is using dma for read/write */
721 u8 using_tcq; /* disk is using queueing */
722 u8 retry_pio; /* retrying dma capable host in pio */
723 u8 state; /* retry state */
724 u8 waiting_for_dma; /* dma currently in progress */
725 u8 unmask; /* okay to unmask other irqs */
726 u8 slow; /* slow data port */
727 u8 bswap; /* byte swap data */
728 u8 dsc_overlap; /* DSC overlap */
729 u8 nice1; /* give potential excess bandwidth */
730
731 unsigned present : 1; /* drive is physically present */
732 unsigned noprobe : 1; /* from: hdx=noprobe */
733 unsigned busy : 1; /* currently doing revalidate_disk() */
734 unsigned removable : 1; /* 1 if need to do check_media_change */
735 unsigned is_flash : 1; /* 1 if probed as flash */
736 unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */
737 unsigned no_unmask : 1; /* disallow setting unmask bit */
738 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
739 unsigned nobios : 1; /* do not probe bios for drive */
740 unsigned revalidate : 1; /* request revalidation */
741 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */
742 unsigned nice0 : 1; /* give obvious excess bandwidth */
743 unsigned nice2 : 1; /* give a share in our own bandwidth */
744 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */
745 unsigned autotune : 2; /* 1=autotune, 2=noautotune, 0=default */
746 unsigned remap_0_to_1 : 2; /* 0=remap if ezdrive, 1=remap, 2=noremap */
747 unsigned ata_flash : 1; /* 1=present, 0=default */
748 unsigned dead : 1; /* 1=dead, no new attachments */
749 unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */
750 unsigned addressing; /* : 3;
751 * 0=28-bit
752 * 1=48-bit
753 * 2=48-bit doing 28-bit
754 * 3=64-bit
755 */
756
757 u8 scsi; /* 0=default, 1=skip current ide-subdriver for ide-scsi emulation */
758 u8 quirk_list; /* considered quirky, set for a specific host */
759 u8 suspend_reset; /* drive suspend mode flag, soft-reset recovers */
760 u8 init_speed; /* transfer rate set at boot */
761 u8 pio_speed; /* unused by core, used by some drivers for fallback from DMA */
762 u8 current_speed; /* current transfer rate set */
763 u8 dn; /* now wide spread use */
764 u8 wcache; /* status of write cache */
765 u8 acoustic; /* acoustic management */
766 u8 media; /* disk, cdrom, tape, floppy, ... */
767 u8 ctl; /* "normal" value for IDE_CONTROL_REG */
768 u8 ready_stat; /* min status value for drive ready */
769 u8 mult_count; /* current multiple sector setting */
770 u8 mult_req; /* requested multiple sector setting */
771 u8 tune_req; /* requested drive tuning setting */
772 u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
773 u8 bad_wstat; /* used for ignoring WRERR_STAT */
774 u8 nowerr; /* used for ignoring WRERR_STAT */
775 u8 sect0; /* offset of first sector for DM6:DDO */
776 u8 head; /* "real" number of heads */
777 u8 sect; /* "real" sectors per track */
778 u8 bios_head; /* BIOS/fdisk/LILO number of heads */
779 u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */
780
781 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
782 unsigned int cyl; /* "real" number of cyls */
783 unsigned int drive_data; /* use by tuneproc/selectproc */
784 unsigned int usage; /* current "open()" count for drive */
785 unsigned int failures; /* current failure count */
786 unsigned int max_failures; /* maximum allowed failure count */
787
788 u32 capacity; /* total number of sectors */
789 u64 capacity48; /* total number of sectors */
790
791 int last_lun; /* last logical unit */
792 int forced_lun; /* if hdxlun was given at boot */
793 int lun; /* logical unit */
794 int crc_count; /* crc counter to reduce drive speed */
795 } ide_drive_t;
796
797 typedef struct ide_pio_ops_s {
798 void (*ata_input_data)(ide_drive_t *, void *, u32);
799 void (*ata_output_data)(ide_drive_t *, void *, u32);
800
801 void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
802 void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
803 } ide_pio_ops_t;
804
805 typedef struct ide_dma_ops_s {
806 /* insert dma operations here! */
807 int (*ide_dma_read)(ide_drive_t *drive);
808 int (*ide_dma_write)(ide_drive_t *drive);
809 int (*ide_dma_begin)(ide_drive_t *drive);
810 int (*ide_dma_end)(ide_drive_t *drive);
811 int (*ide_dma_check)(ide_drive_t *drive);
812 int (*ide_dma_on)(ide_drive_t *drive);
813 int (*ide_dma_off)(ide_drive_t *drive);
814 int (*ide_dma_off_quietly)(ide_drive_t *drive);
815 int (*ide_dma_test_irq)(ide_drive_t *drive);
816 int (*ide_dma_host_on)(ide_drive_t *drive);
817 int (*ide_dma_host_off)(ide_drive_t *drive);
818 int (*ide_dma_bad_drive)(ide_drive_t *drive);
819 int (*ide_dma_good_drive)(ide_drive_t *drive);
820 int (*ide_dma_count)(ide_drive_t *drive);
821 int (*ide_dma_verbose)(ide_drive_t *drive);
822 int (*ide_dma_retune)(ide_drive_t *drive);
823 int (*ide_dma_lostirq)(ide_drive_t *drive);
824 int (*ide_dma_timeout)(ide_drive_t *drive);
825 } ide_dma_ops_t;
826
827 /*
828 * mapping stuff, prepare for highmem...
829 *
830 * temporarily mapping a (possible) highmem bio for PIO transfer
831 */
832 #define ide_rq_offset(rq) \
833 (((rq)->hard_cur_sectors - (rq)->current_nr_sectors) << 9)
834
ide_map_buffer(struct request * rq,unsigned long * flags)835 static inline void *ide_map_buffer(struct request *rq, unsigned long *flags)
836 {
837 return bh_kmap_irq(rq->bh, flags) + ide_rq_offset(rq);
838 }
839
ide_unmap_buffer(char * buffer,unsigned long * flags)840 static inline void ide_unmap_buffer(char *buffer, unsigned long *flags)
841 {
842 bh_kunmap_irq(buffer, flags);
843 }
844
845 #define IDE_CHIPSET_PCI_MASK \
846 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
847 #define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
848
849 struct ide_pci_device_s;
850
851 typedef struct hwif_s {
852 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
853 struct hwif_s *mate; /* other hwif from same PCI chip */
854 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
855 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
856 struct gendisk *gd; /* gendisk structure */
857
858 char name[6]; /* name of interface, eg. "ide0" */
859
860 /* task file registers for pata and sata */
861 ide_ioreg_t io_ports[IDE_NR_PORTS];
862 sata_ioreg_t sata_scr[SATA_NR_PORTS];
863 sata_ioreg_t sata_misc[SATA_NR_PORTS];
864
865 hw_regs_t hw; /* Hardware info */
866 ide_drive_t drives[MAX_DRIVES]; /* drive info */
867
868 u8 major; /* our major number */
869 u8 index; /* 0 for ide0; 1 for ide1; ... */
870 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */
871 u8 straight8; /* Alan's straight 8 check */
872 u8 bus_state; /* power state of the IDE bus */
873
874 u8 atapi_dma; /* host supports atapi_dma */
875 u8 ultra_mask;
876 u8 mwdma_mask;
877 u8 swdma_mask;
878
879 hwif_chipset_t chipset; /* sub-module for tuning.. */
880
881 struct pci_dev *pci_dev; /* for pci chipsets */
882 struct ide_pci_device_s *cds; /* chipset device struct */
883
884 ide_startstop_t (*rw_disk)(ide_drive_t *, struct request *, unsigned long);
885
886 #if 0
887 ide_hwif_ops_t *hwifops;
888 #else
889 /* routine is for HBA specific IDENTITY operations */
890 int (*identify)(ide_drive_t *);
891 /* routine to tune PIO mode for drives */
892 void (*tuneproc)(ide_drive_t *, u8);
893 /* routine to retune DMA modes for drives */
894 int (*speedproc)(ide_drive_t *, u8);
895 /* tweaks hardware to select drive */
896 void (*selectproc)(ide_drive_t *);
897 /* chipset polling based on hba specifics */
898 int (*reset_poll)(ide_drive_t *);
899 /* chipset specific changes to default for device-hba resets */
900 void (*pre_reset)(ide_drive_t *);
901 /* routine to reset controller after a disk reset */
902 void (*resetproc)(ide_drive_t *);
903 /* special interrupt handling for shared pci interrupts */
904 void (*intrproc)(ide_drive_t *);
905 /* special host masking for drive selection */
906 void (*maskproc)(ide_drive_t *, int);
907 /* check host's drive quirk list */
908 int (*quirkproc)(ide_drive_t *);
909 /* driver soft-power interface */
910 int (*busproc)(ide_drive_t *, int);
911 // /* host rate limiter */
912 // u8 (*ratemask)(ide_drive_t *);
913 // /* device rate limiter */
914 // u8 (*ratefilter)(ide_drive_t *, u8);
915 #endif
916
917 #if 0
918 ide_pio_ops_t *pioops;
919 #else
920 void (*ata_input_data)(ide_drive_t *, void *, u32);
921 void (*ata_output_data)(ide_drive_t *, void *, u32);
922
923 void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
924 void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
925 #endif
926
927 #if 0
928 ide_dma_ops_t *dmaops;
929 #else
930 int (*ide_dma_read)(ide_drive_t *drive);
931 int (*ide_dma_write)(ide_drive_t *drive);
932 int (*ide_dma_begin)(ide_drive_t *drive);
933 int (*ide_dma_end)(ide_drive_t *drive);
934 int (*ide_dma_check)(ide_drive_t *drive);
935 int (*ide_dma_on)(ide_drive_t *drive);
936 int (*ide_dma_off)(ide_drive_t *drive);
937 int (*ide_dma_off_quietly)(ide_drive_t *drive);
938 int (*ide_dma_test_irq)(ide_drive_t *drive);
939 int (*ide_dma_host_on)(ide_drive_t *drive);
940 int (*ide_dma_host_off)(ide_drive_t *drive);
941 int (*ide_dma_bad_drive)(ide_drive_t *drive);
942 int (*ide_dma_good_drive)(ide_drive_t *drive);
943 int (*ide_dma_count)(ide_drive_t *drive);
944 int (*ide_dma_verbose)(ide_drive_t *drive);
945 int (*ide_dma_retune)(ide_drive_t *drive);
946 int (*ide_dma_lostirq)(ide_drive_t *drive);
947 int (*ide_dma_timeout)(ide_drive_t *drive);
948 #endif
949
950 void (*OUTB)(u8 addr, unsigned long port);
951 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
952 void (*OUTW)(u16 addr, unsigned long port);
953 void (*OUTL)(u32 addr, unsigned long port);
954 void (*OUTSW)(unsigned long port, void *addr, u32 count);
955 void (*OUTSL)(unsigned long port, void *addr, u32 count);
956
957 u8 (*INB)(unsigned long port);
958 u16 (*INW)(unsigned long port);
959 u32 (*INL)(unsigned long port);
960 void (*INSW)(unsigned long port, void *addr, u32 count);
961 void (*INSL)(unsigned long port, void *addr, u32 count);
962
963 /* dma physical region descriptor table (cpu view) */
964 unsigned int *dmatable_cpu;
965 /* dma physical region descriptor table (dma view) */
966 dma_addr_t dmatable_dma;
967 /* Scatter-gather list used to build the above */
968 struct scatterlist *sg_table;
969 int sg_nents; /* Current number of entries in it */
970 int sg_dma_direction; /* dma transfer direction */
971 int sg_dma_active; /* is it in use */
972
973 int mmio; /* hosts iomio (0), mmio (1) or custom (2) select */
974 int rqsize; /* max sectors per request */
975 int addressing; /* hosts addressing */
976 int irq; /* our irq number */
977 int initializing; /* set while initializing self */
978
979 unsigned long dma_master; /* reference base addr dmabase */
980 unsigned long dma_base; /* base addr for dma ports */
981 unsigned long dma_command; /* dma command register */
982 unsigned long dma_vendor1; /* dma vendor 1 register */
983 unsigned long dma_status; /* dma status register */
984 unsigned long dma_vendor3; /* dma vendor 3 register */
985 unsigned long dma_prdtable; /* actual prd table address */
986 unsigned long dma_base2; /* extended base addr for dma ports */
987
988 unsigned dma_extra; /* extra addr for dma ports */
989 unsigned long config_data; /* for use by chipset-specific code */
990 unsigned long select_data; /* for use by chipset-specific code */
991 #if (DISK_RECOVERY_TIME > 0)
992 unsigned long last_time; /* time when previous rq was done */
993 #endif
994
995
996 unsigned noprobe : 1; /* don't probe for this interface */
997 unsigned present : 1; /* this interface exists */
998 unsigned hold : 1; /* this interface is always present */
999 unsigned serialized : 1; /* serialized all channel operation */
1000 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
1001 unsigned reset : 1; /* reset after probe */
1002 unsigned autodma : 1; /* auto-attempt using DMA at boot */
1003 unsigned udma_four : 1; /* 1=ATA-66 capable, 0=default */
1004 unsigned highmem : 1; /* can do full 32-bit dma */
1005 unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
1006 unsigned sata : 1; /* 0 PATA, 1 SATA */
1007
1008 void *hwif_data; /* extra hwif data */
1009 } ide_hwif_t;
1010
1011 /*
1012 * internal ide interrupt handler type
1013 */
1014 typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *);
1015 typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
1016 typedef ide_startstop_t (ide_post_handler_t)(ide_drive_t *);
1017 typedef int (ide_expiry_t)(ide_drive_t *);
1018
1019 typedef struct hwgroup_s {
1020 /* irq handler, if active */
1021 ide_startstop_t (*handler)(ide_drive_t *);
1022 /* irq handler, suspended if active */
1023 ide_startstop_t (*handler_save)(ide_drive_t *);
1024 /* BOOL: protects all fields below */
1025 volatile int busy;
1026 /* BOOL: wake us up on timer expiry */
1027 int sleeping;
1028 /* current drive */
1029 ide_drive_t *drive;
1030 /* ptr to current hwif in linked-list */
1031 ide_hwif_t *hwif;
1032
1033 /* for pci chipsets */
1034 struct pci_dev *pci_dev;
1035 /* chipset device struct */
1036 struct ide_pci_device_s *cds;
1037
1038 /* current request */
1039 struct request *rq;
1040 /* failsafe timer */
1041 struct timer_list timer;
1042 /* local copy of current write rq */
1043 struct request wrq;
1044 /* timeout value during long polls */
1045 unsigned long poll_timeout;
1046 /* queried upon timeouts */
1047 int (*expiry)(ide_drive_t *);
1048 /* ide_system_bus_speed */
1049 int pio_clock;
1050 } ide_hwgroup_t;
1051
1052 /* structure attached to the request for IDE_TASK_CMDS */
1053
1054 /*
1055 * configurable drive settings
1056 */
1057
1058 #define TYPE_INT 0
1059 #define TYPE_INTA 1
1060 #define TYPE_BYTE 2
1061 #define TYPE_SHORT 3
1062
1063 #define SETTING_READ (1 << 0)
1064 #define SETTING_WRITE (1 << 1)
1065 #define SETTING_RW (SETTING_READ | SETTING_WRITE)
1066
1067 typedef int (ide_procset_t)(ide_drive_t *, int);
1068 typedef struct ide_settings_s {
1069 char *name;
1070 int rw;
1071 int read_ioctl;
1072 int write_ioctl;
1073 int data_type;
1074 int min;
1075 int max;
1076 int mul_factor;
1077 int div_factor;
1078 void *data;
1079 ide_procset_t *set;
1080 int auto_remove;
1081 struct ide_settings_s *next;
1082 } ide_settings_t;
1083
1084 extern struct semaphore ide_setting_sem;
1085 extern int ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set);
1086 extern void ide_remove_setting(ide_drive_t *drive, char *name);
1087 extern ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name);
1088 extern int ide_read_setting(ide_drive_t *t, ide_settings_t *setting);
1089 extern int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val);
1090 extern void ide_add_generic_settings(ide_drive_t *drive);
1091
1092 /*
1093 * /proc/ide interface
1094 */
1095 typedef struct {
1096 const char *name;
1097 mode_t mode;
1098 read_proc_t *read_proc;
1099 write_proc_t *write_proc;
1100 } ide_proc_entry_t;
1101
1102 #ifdef CONFIG_PROC_FS
1103 extern void proc_ide_create(void);
1104 extern void proc_ide_destroy(void);
1105 extern void destroy_proc_ide_device(ide_hwif_t *, ide_drive_t *);
1106 extern void destroy_proc_ide_drives(ide_hwif_t *);
1107 extern void create_proc_ide_interfaces(void);
1108 extern void ide_add_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *, void *);
1109 extern void ide_remove_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *);
1110 read_proc_t proc_ide_read_capacity;
1111 read_proc_t proc_ide_read_geometry;
1112
1113 /*
1114 * Standard exit stuff:
1115 */
1116 #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \
1117 { \
1118 len -= off; \
1119 if (len < count) { \
1120 *eof = 1; \
1121 if (len <= 0) \
1122 return 0; \
1123 } else \
1124 len = count; \
1125 *start = page + off; \
1126 return len; \
1127 }
1128 #else
1129 #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
1130 #endif
1131
1132 /*
1133 * Subdrivers support.
1134 */
1135 #define IDE_SUBDRIVER_VERSION 1
1136
1137 typedef struct ide_driver_s {
1138 const char *name;
1139 const char *version;
1140 u8 media;
1141 unsigned busy : 1;
1142 unsigned supports_dma : 1;
1143 unsigned supports_dsc_overlap : 1;
1144 int (*cleanup)(ide_drive_t *);
1145 int (*shutdown)(ide_drive_t *);
1146 int (*standby)(ide_drive_t *);
1147 int (*suspend)(ide_drive_t *);
1148 int (*resume)(ide_drive_t *);
1149 int (*flushcache)(ide_drive_t *);
1150 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, unsigned long);
1151 int (*end_request)(ide_drive_t *, int);
1152 u8 (*sense)(ide_drive_t *, const char *, u8);
1153 ide_startstop_t (*error)(ide_drive_t *, const char *, u8);
1154 ide_startstop_t (*abort)(ide_drive_t *, const char *);
1155 int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1156 int (*open)(struct inode *, struct file *, ide_drive_t *);
1157 void (*release)(struct inode *, struct file *, ide_drive_t *);
1158 int (*media_change)(ide_drive_t *);
1159 void (*revalidate)(ide_drive_t *);
1160 void (*pre_reset)(ide_drive_t *);
1161 unsigned long (*capacity)(ide_drive_t *);
1162 ide_startstop_t (*special)(ide_drive_t *);
1163 ide_proc_entry_t *proc;
1164 int (*init)(void);
1165 int (*attach)(ide_drive_t *);
1166 void (*ata_prebuilder)(ide_drive_t *);
1167 void (*atapi_prebuilder)(ide_drive_t *);
1168 } ide_driver_t;
1169
1170 #define DRIVER(drive) ((drive)->driver)
1171
1172 /*
1173 * IDE modules.
1174 */
1175 #define IDE_CHIPSET_MODULE 0 /* not supported yet */
1176 #define IDE_PROBE_MODULE 1
1177 #define IDE_DRIVER_MODULE 2
1178
1179 typedef int (ide_module_init_proc)(void);
1180
1181 typedef struct ide_module_s {
1182 int type;
1183 ide_module_init_proc *init;
1184 void *info;
1185 struct ide_module_s *next;
1186 } ide_module_t;
1187
1188 typedef struct ide_devices_s {
1189 char name[4]; /* hdX */
1190 unsigned attached : 1; /* native */
1191 unsigned alttached : 1; /* alternate */
1192 struct ide_devices_s *next;
1193 } ide_devices_t;
1194
1195 #if 0
1196 typedef enum {
1197 IDE_MEDIA_FLOPPY = ide_floppy,
1198 IDE_MEDIA_TAPE = ide_tape,
1199 IDE_MEDIA_CDROM = ide_cdrom,
1200 IDE_MEDIA_OPTICAL = ide_optical,
1201 IDE_MEDIA_DISK = ide_disk,
1202 IDE_MEDIA_SCSI = ide_scsi,
1203 } ide_media_type;
1204
1205 struct ide_media {
1206 ide_media_type type;
1207 char name[4];
1208 atomic_t refcount; /* Maybe this should be a struct module*
1209 with MOD_INC instead */
1210 struct list_head devices;
1211 };
1212
1213 struct {
1214 struct ide_media floppy;
1215 struct ide_media tape;
1216 struct ide_media cdrom;
1217 struct ide_media optical;
1218 struct ide_media disk;
1219 struct ide_media scsi;
1220 } ide_medias;
1221
1222 void __init init_media(void)
1223 {
1224 memset(&ide_medias, 0, sizeof(ide_medias));
1225
1226 ide_medias.floppy.type = IDE_MEDIA_FLOPPY;
1227 ide_medias.tape.type = IDE_MEDIA_TAPE;
1228 ide_medias.cdrom.type = IDE_MEDIA_CDROM;
1229 ide_medias.optical.type = IDE_MEDIA_OPTICAL;
1230 ide_medias.disk.type = IDE_MEDIA_DISK;
1231 ide_medias.scsi.type = IDE_MEDIA_SCSI;
1232 };
1233 #endif
1234
1235 /*
1236 * ide_hwifs[] is the master data structure used to keep track
1237 * of just about everything in ide.c. Whenever possible, routines
1238 * should be using pointers to a drive (ide_drive_t *) or
1239 * pointers to a hwif (ide_hwif_t *), rather than indexing this
1240 * structure directly (the allocation/layout may change!).
1241 *
1242 */
1243 #ifndef _IDE_C
1244 extern ide_hwif_t ide_hwifs[]; /* master data repository */
1245 extern ide_module_t *ide_chipsets;
1246 extern ide_module_t *ide_modules;
1247 extern ide_module_t *ide_probe;
1248
1249 extern ide_devices_t *idedisk;
1250 extern ide_devices_t *idecd;
1251 extern ide_devices_t *idefloppy;
1252 extern ide_devices_t *idetape;
1253 extern ide_devices_t *idescsi;
1254
1255 #endif
1256 extern int noautodma;
1257
1258 /*
1259 * We need blk.h, but we replace its end_request by our own version.
1260 */
1261 #define IDE_DRIVER /* Toggle some magic bits in blk.h */
1262 #define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */
1263 //#define DEVICE_NR(device) (MINOR(device) >> PARTN_BITS)
1264 #include <linux/blk.h>
1265
1266 extern int ide_end_request(ide_drive_t *, int /* uptodate */);
1267
1268 /*
1269 * This is used on exit from the driver to designate the next irq handler
1270 * and also to start the safety timer.
1271 */
1272 extern void ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int, ide_expiry_t *);
1273
1274 /*
1275 * This is used on exit from the driver to designate the next irq handler
1276 * and start the safety time safely and atomically from the IRQ handler
1277 * with respect to the command issue (which it also does)
1278 */
1279 extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *);
1280
1281 /*
1282 * Error reporting, in human readable form (luxurious, but a memory hog).
1283 *
1284 * (drive, msg, status)
1285 */
1286 extern u8 ide_dump_status(ide_drive_t *, const char *, u8);
1287
1288 /*
1289 * ide_error() takes action based on the error returned by the controller.
1290 * The caller should return immediately after invoking this.
1291 *
1292 * (drive, msg, status)
1293 */
1294 extern ide_startstop_t ide_error(ide_drive_t *, const char *, u8);
1295 extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
1296
1297 /*
1298 * Issue a simple drive command
1299 * The drive must be selected beforehand.
1300 *
1301 * (drive, command, nsector, handler)
1302 */
1303 extern void ide_cmd(ide_drive_t *, u8, u8, ide_handler_t *);
1304
1305 extern void ide_fix_driveid(struct hd_driveid *);
1306 /*
1307 * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
1308 * removing leading/trailing blanks and compressing internal blanks.
1309 * It is primarily used to tidy up the model name/number fields as
1310 * returned by the WIN_[P]IDENTIFY commands.
1311 *
1312 * (s, bytecount, byteswap)
1313 */
1314 extern void ide_fixstring(u8 *, const int, const int);
1315
1316 /*
1317 * This routine busy-waits for the drive status to be not "busy".
1318 * It then checks the status for all of the "good" bits and none
1319 * of the "bad" bits, and if all is okay it returns 0. All other
1320 * cases return 1 after doing "*startstop = ide_error()", and the
1321 * caller should return the updated value of "startstop" in this case.
1322 * "startstop" is unchanged when the function returns 0;
1323 * (startstop, drive, good, bad, timeout)
1324 */
1325 extern int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
1326
1327 /*
1328 * This routine is called from the partition-table code in genhd.c
1329 * to "convert" a drive to a logical geometry with fewer than 1024 cyls.
1330 */
1331 extern int ide_xlate_1024(kdev_t, int, int, const char *);
1332
1333 /*
1334 * Convert kdev_t structure into ide_drive_t * one. If force is set the
1335 * non present drives can be opened.
1336 */
1337 extern ide_drive_t *ide_info_ptr(kdev_t i_rdev, int force);
1338
1339 /*
1340 * Return the current idea about the total capacity of this drive.
1341 */
1342 extern unsigned long current_capacity(ide_drive_t *);
1343
1344 extern void ide_revalidate_drive(ide_drive_t *);
1345
1346 /*
1347 * Start a reset operation for an IDE interface.
1348 * The caller should return immediately after invoking this.
1349 */
1350 extern ide_startstop_t ide_do_reset(ide_drive_t *);
1351
1352 /*
1353 * This function is intended to be used prior to invoking ide_do_drive_cmd().
1354 */
1355 extern void ide_init_drive_cmd(struct request *);
1356
1357 /*
1358 * "action" parameter type for ide_do_drive_cmd() below.
1359 */
1360 typedef enum {
1361 ide_wait, /* insert rq at end of list, and wait for it */
1362 ide_next, /* insert rq immediately after current request */
1363 ide_preempt, /* insert rq in front of current request */
1364 ide_end /* insert rq at end of list, but don't wait for it */
1365 } ide_action_t;
1366
1367 /*
1368 * This function issues a special IDE device request
1369 * onto the request queue.
1370 *
1371 * If action is ide_wait, then the rq is queued at the end of the
1372 * request queue, and the function sleeps until it has been processed.
1373 * This is for use when invoked from an ioctl handler.
1374 *
1375 * If action is ide_preempt, then the rq is queued at the head of
1376 * the request queue, displacing the currently-being-processed
1377 * request and this function returns immediately without waiting
1378 * for the new rq to be completed. This is VERY DANGEROUS, and is
1379 * intended for careful use by the ATAPI tape/cdrom driver code.
1380 *
1381 * If action is ide_next, then the rq is queued immediately after
1382 * the currently-being-processed-request (if any), and the function
1383 * returns without waiting for the new rq to be completed. As above,
1384 * This is VERY DANGEROUS, and is intended for careful use by the
1385 * ATAPI tape/cdrom driver code.
1386 *
1387 * If action is ide_end, then the rq is queued at the end of the
1388 * request queue, and the function returns immediately without waiting
1389 * for the new rq to be completed. This is again intended for careful
1390 * use by the ATAPI tape/cdrom driver code.
1391 */
1392 extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
1393
1394 /*
1395 * Clean up after success/failure of an explicit drive cmd.
1396 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD).
1397 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASK_MASK).
1398 *
1399 * (ide_drive_t *drive, u8 stat, u8 err)
1400 */
1401 extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
1402
1403 /*
1404 * Issue ATA command and wait for completion.
1405 * Use for implementing commands in kernel
1406 *
1407 * (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
1408 */
1409 extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);
1410
1411 /* (ide_drive_t *drive, u8 *buf) */
1412 extern int ide_wait_cmd_task(ide_drive_t *, u8 *);
1413
1414 typedef struct ide_task_s {
1415 /*
1416 * struct hd_drive_task_hdr tf;
1417 * task_struct_t tf;
1418 * struct hd_drive_hob_hdr hobf;
1419 * hob_struct_t hobf;
1420 */
1421 task_ioreg_t tfRegister[8];
1422 task_ioreg_t hobRegister[8];
1423 ide_reg_valid_t tf_out_flags;
1424 ide_reg_valid_t tf_in_flags;
1425 int data_phase;
1426 int command_type;
1427 ide_pre_handler_t *prehandler;
1428 ide_handler_t *handler;
1429 ide_post_handler_t *posthandler;
1430 struct request *rq; /* copy of request */
1431 void *special; /* valid_t generally */
1432 } ide_task_t;
1433
1434 typedef struct pkt_task_s {
1435 /*
1436 * struct hd_drive_task_hdr pktf;
1437 * task_struct_t pktf;
1438 * u8 pkcdb[12];
1439 */
1440 task_ioreg_t tfRegister[8];
1441 int data_phase;
1442 int command_type;
1443 ide_handler_t *handler;
1444 struct request *rq; /* copy of request */
1445 void *special;
1446 } pkt_task_t;
1447
1448 extern void SELECT_DRIVE(ide_drive_t *);
1449 extern void SELECT_INTERRUPT(ide_drive_t *);
1450 extern void SELECT_MASK(ide_drive_t *, int);
1451 extern void QUIRK_LIST(ide_drive_t *);
1452
1453 extern void ata_input_data(ide_drive_t *, void *, u32);
1454 extern void ata_output_data(ide_drive_t *, void *, u32);
1455 extern void atapi_input_bytes(ide_drive_t *, void *, u32);
1456 extern void atapi_output_bytes(ide_drive_t *, void *, u32);
1457 extern void taskfile_input_data(ide_drive_t *, void *, u32);
1458 extern void taskfile_output_data(ide_drive_t *, void *, u32);
1459
1460 extern int drive_is_ready(ide_drive_t *);
1461 extern int wait_for_ready(ide_drive_t *, int /* timeout */);
1462
1463 /*
1464 * taskfile io for disks for now...and builds request from ide_ioctl
1465 */
1466 extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1467
1468 /* (ide_drive_t *drive, u8 stat, u8 err) */
1469 extern void ide_end_taskfile(ide_drive_t *, u8, u8);
1470
1471 /*
1472 * Special Flagged Register Validation Caller
1473 */
1474 extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);
1475
1476 extern ide_startstop_t set_multmode_intr(ide_drive_t *);
1477 extern ide_startstop_t set_geometry_intr(ide_drive_t *);
1478 extern ide_startstop_t recal_intr(ide_drive_t *);
1479 extern ide_startstop_t task_no_data_intr(ide_drive_t *);
1480 extern ide_startstop_t task_in_intr(ide_drive_t *);
1481 extern ide_startstop_t task_mulin_intr(ide_drive_t *);
1482 extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
1483 extern ide_startstop_t task_out_intr(ide_drive_t *);
1484 extern ide_startstop_t pre_task_mulout_intr(ide_drive_t *, struct request *);
1485 extern ide_startstop_t task_mulout_intr(ide_drive_t *);
1486 extern void ide_init_drive_taskfile(struct request *);
1487
1488 extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);
1489
1490 extern ide_pre_handler_t * ide_pre_handler_parser(struct hd_drive_task_hdr *, struct hd_drive_hob_hdr *);
1491
1492 extern ide_handler_t * ide_handler_parser(struct hd_drive_task_hdr *, struct hd_drive_hob_hdr *);
1493
1494 extern ide_post_handler_t * ide_post_handler_parser(struct hd_drive_task_hdr *, struct hd_drive_hob_hdr *);
1495
1496 /* Expects args is a full set of TF registers and parses the command type */
1497 extern int ide_cmd_type_parser(ide_task_t *);
1498
1499 int ide_taskfile_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1500 int ide_cmd_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1501 int ide_task_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1502
1503 #if 0
1504
1505 #define IDEFLOPPY_PC_BUFFER_SIZE 256
1506 #define IDETAPE_PC_BUFFER_SIZE 256
1507 #define IDE_PC_BUFFER_SIZE 256
1508
1509 typedef struct ide_packet_command_s {
1510 /* Actual packet bytes */
1511 u8 c[12];
1512 /* On each retry, we increment retries */
1513 int retries;
1514 /* Error code */
1515 int error;
1516 /* Bytes to transfer */
1517 int request_transfer;
1518 /* Bytes actually transferred */
1519 int actually_transferred;
1520 /* Size of our data buffer */
1521 int buffer_size;
1522
1523 struct buffer_head *bh;
1524 u8 *b_data;
1525 /* The corresponding request */
1526 struct request *rq;
1527 # if 0
1528 /* Scatter gather table */
1529 struct scatterlist *sg;
1530 # endif
1531 int b_count;
1532 /* Data buffer */
1533 u8 *buffer;
1534 /* Pointer into the above buffer */
1535 u8 *current_position;
1536 /* Called when this packet command is completed */
1537 ide_startstop_t (*callback) (ide_drive_t *);
1538 /* Temporary buffer */
1539 u8 pc_buffer[IDE_PC_BUFFER_SIZE];
1540 /* Status/Action bit flags: long for set_bit */
1541 unsigned long flags;
1542 } ide_pc_t;
1543
1544 ide-cd orthoginal :-/
1545 struct packet_command {
1546 char *buffer;
1547 int buflen;
1548 int stat;
1549 int quiet;
1550 int timeout;
1551 struct request_sense *sense;
1552 unsigned char c[12];
1553 };
1554
1555 #endif
1556
1557 #ifdef CONFIG_PKT_TASK_IOCTL
1558 extern int pkt_taskfile_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1559 #endif /* CONFIG_PKT_TASK_IOCTL */
1560
1561 extern void ide_delay_50ms(void);
1562 extern int system_bus_clock(void);
1563
1564 extern u8 ide_auto_reduce_xfer(ide_drive_t *);
1565 extern int ide_driveid_update(ide_drive_t *);
1566 extern int ide_ata66_check(ide_drive_t *, ide_task_t *);
1567 extern int ide_config_drive_speed(ide_drive_t *, u8);
1568 extern u8 eighty_ninty_three (ide_drive_t *);
1569 extern int set_transfer(ide_drive_t *, ide_task_t *);
1570 extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *);
1571
1572 extern ide_startstop_t __ide_do_rw_disk(ide_drive_t *, struct request *, unsigned long);
1573 /*
1574 * ide_system_bus_speed() returns what we think is the system VESA/PCI
1575 * bus speed (in MHz). This is used for calculating interface PIO timings.
1576 * The default is 40 for known PCI systems, 50 otherwise.
1577 * The "idebus=xx" parameter can be used to override this value.
1578 */
1579 extern int ide_system_bus_speed(void);
1580
1581 /*
1582 * ide_stall_queue() can be used by a drive to give excess bandwidth back
1583 * to the hwgroup by sleeping for timeout jiffies.
1584 */
1585 extern void ide_stall_queue(ide_drive_t *, unsigned long);
1586
1587 /*
1588 * ide_get_queue() returns the queue which corresponds to a given device.
1589 */
1590 extern request_queue_t *ide_get_queue(kdev_t dev);
1591
1592 extern int ide_spin_wait_hwgroup(ide_drive_t *);
1593 extern void ide_timer_expiry(unsigned long);
1594 extern void ide_intr(int irq, void *dev_id, struct pt_regs *regs);
1595 extern void do_ide_request(request_queue_t *);
1596 extern void ide_init_subdrivers(void);
1597
1598 extern struct block_device_operations ide_fops[];
1599 extern ide_proc_entry_t generic_subdriver_entries[];
1600
1601 extern int ide_attach_drive(ide_drive_t *);
1602
1603 extern int ideprobe_init(void);
1604 extern int idedefault_attach(ide_drive_t *);
1605 extern int idedefault_init(void);
1606 extern int idedisk_attach(ide_drive_t *);
1607 extern int idedisk_init(void);
1608 extern int ide_cdrom_attach(ide_drive_t *);
1609 extern int ide_cdrom_init(void);
1610 extern int idetape_attach(ide_drive_t *);
1611 extern int idetape_init(void);
1612 extern int idefloppy_attach(ide_drive_t *);
1613 extern int idefloppy_init(void);
1614 extern int idescsi_attach(ide_drive_t *);
1615 extern int idescsi_init(void);
1616
1617 extern void ide_scan_pcibus(int scan_direction) __init;
1618 extern int ide_pci_register_driver(struct pci_driver *driver);
1619 extern void ide_pci_unregister_driver(struct pci_driver *driver);
1620
1621 extern void default_hwif_iops(ide_hwif_t *);
1622 extern void default_hwif_mmiops(ide_hwif_t *);
1623 extern void default_hwif_transport(ide_hwif_t *);
1624
1625
1626 extern int ide_register_module(ide_module_t *module);
1627 extern void ide_unregister_module(ide_module_t *module);
1628 extern ide_drive_t *ide_scan_devices(u8, const char *, ide_driver_t *, int);
1629 extern int ide_register_subdriver(ide_drive_t *, ide_driver_t *, int /* ver */);
1630 extern int ide_unregister_subdriver(ide_drive_t *);
1631 extern int ide_replace_subdriver(ide_drive_t *, const char * /* driver*/);
1632
1633 #ifdef CONFIG_PROC_FS
1634 typedef struct ide_pci_host_proc_s {
1635 char *name;
1636 u8 set;
1637 get_info_t *get_info;
1638 struct proc_dir_entry *parent;
1639 struct ide_pci_host_proc_s *next;
1640 } ide_pci_host_proc_t;
1641
1642 void ide_pci_register_host_proc(ide_pci_host_proc_t *);
1643 #endif /* CONFIG_PROC_FS */
1644
1645 #define ON_BOARD 1
1646 #define NEVER_BOARD 0
1647
1648 #ifdef CONFIG_BLK_DEV_OFFBOARD
1649 # define OFF_BOARD ON_BOARD
1650 #else /* CONFIG_BLK_DEV_OFFBOARD */
1651 # define OFF_BOARD NEVER_BOARD
1652 #endif /* CONFIG_BLK_DEV_OFFBOARD */
1653
1654 #define NODMA 0
1655 #define NOAUTODMA 1
1656 #define AUTODMA 2
1657 #define EOL 255
1658
1659 typedef struct ide_pci_enablebit_s {
1660 u8 reg; /* byte pci reg holding the enable-bit */
1661 u8 mask; /* mask to isolate the enable-bit */
1662 u8 val; /* value of masked reg when "enabled" */
1663 } ide_pci_enablebit_t;
1664
1665 typedef struct ide_pci_device_s {
1666 u16 vendor;
1667 u16 device;
1668 char *name;
1669 void (*init_setup)(struct pci_dev *, struct ide_pci_device_s *);
1670 unsigned int (*init_chipset)(struct pci_dev *, const char *);
1671 void (*init_iops)(ide_hwif_t *);
1672 void (*init_hwif)(ide_hwif_t *);
1673 void (*init_dma)(ide_hwif_t *, unsigned long);
1674 u8 channels;
1675 u8 autodma;
1676 ide_pci_enablebit_t enablebits[2];
1677 u8 bootable;
1678 unsigned int extra;
1679 struct ide_pci_device_s *next;
1680 } ide_pci_device_t;
1681
1682 extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
1683 extern void ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);
1684
1685 #define BAD_DMA_DRIVE 0
1686 #define GOOD_DMA_DRIVE 1
1687
1688 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1689 extern int ide_build_dmatable(ide_drive_t *, struct request *, int);
1690 extern void ide_destroy_dmatable(ide_drive_t *);
1691 extern ide_startstop_t ide_dma_intr(ide_drive_t *);
1692 extern int ide_release_dma(ide_hwif_t *);
1693 extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);
1694 extern void ide_setup_no_dma(ide_hwif_t *);
1695
1696 extern int __ide_dma_host_off(ide_drive_t *);
1697 extern int __ide_dma_off_quietly(ide_drive_t *);
1698 extern int __ide_dma_off(ide_drive_t *);
1699 extern int __ide_dma_host_on(ide_drive_t *);
1700 extern int __ide_dma_on(ide_drive_t *);
1701 extern int __ide_dma_check(ide_drive_t *);
1702 extern int __ide_dma_read(ide_drive_t *);
1703 extern int __ide_dma_write(ide_drive_t *);
1704 extern int __ide_dma_begin(ide_drive_t *);
1705 extern int __ide_dma_end(ide_drive_t *);
1706 extern int __ide_dma_test_irq(ide_drive_t *);
1707 extern int __ide_dma_bad_drive(ide_drive_t *);
1708 extern int __ide_dma_good_drive(ide_drive_t *);
1709 extern int __ide_dma_count(ide_drive_t *);
1710 extern int __ide_dma_verbose(ide_drive_t *);
1711 extern int __ide_dma_retune(ide_drive_t *);
1712 extern int __ide_dma_lostirq(ide_drive_t *);
1713 extern int __ide_dma_timeout(ide_drive_t *);
1714 #else
ide_setup_dma(ide_hwif_t * x,unsigned long y,unsigned int z)1715 static inline void ide_setup_dma(ide_hwif_t *x, unsigned long y, unsigned int z) {;}
ide_release_dma(ide_hwif_t * x)1716 static inline void ide_release_dma(ide_hwif_t *x) {;}
ide_setup_no_dma(ide_hwif_t * x)1717 static inline void ide_setup_no_dma(ide_hwif_t *x) {;}
1718 #endif
1719
1720 extern void hwif_unregister(ide_hwif_t *);
1721
1722 extern void ide_probe_reset(ide_hwif_t *);
1723 extern void ide_tune_drives(ide_hwif_t *);
1724 extern int ide_wait_hwif_ready(ide_hwif_t *);
1725 extern u8 ide_probe_for_drive(ide_drive_t *);
1726
1727
1728 extern void export_ide_init_queue(ide_drive_t *);
1729 extern u8 export_probe_for_drive(ide_drive_t *);
1730 extern int probe_hwif_init(ide_hwif_t *);
1731
ide_get_hwifdata(ide_hwif_t * hwif)1732 static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1733 {
1734 return hwif->hwif_data;
1735 }
1736
ide_set_hwifdata(ide_hwif_t * hwif,void * data)1737 static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
1738 {
1739 hwif->hwif_data = data;
1740 }
1741
1742 /* ide-lib.c */
1743 extern u8 ide_dma_speed(ide_drive_t *drive, u8 mode);
1744 extern u8 ide_rate_filter(u8 mode, u8 speed);
1745 extern int ide_dma_enable(ide_drive_t *drive);
1746 extern char *ide_xfer_verbose(u8 xfer_rate);
1747 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1748 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1749
1750 /* ide driver registration */
1751 typedef void (*ide_driver_call)(void);
1752 extern void __init ide_register_driver(ide_driver_call);
1753
1754 /* ide locks for 2.4 */
1755
1756 #define ide_lock (io_request_lock)
1757 #define DRIVE_LOCK(drive) ((drive)->queue.queue_lock)
1758
1759
1760 #endif /* _IDE_H */
1761