4 * linux/include/linux/ide.h
6 * Copyright (C) 1994-1998 Linus Torvalds & authors
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 <asm/hdreg.h>
19 * This is the multiple IDE interface driver, as evolved from hd.c.
20 * It supports up to four IDE interfaces, on one or more IRQs (usually 14 & 15).
21 * There can be up to two drives per interface, as per the ATA-2 spec.
23 * Primary i/f: ide0: major=3; (hda) minor=0; (hdb) minor=64
24 * Secondary i/f: ide1: major=22; (hdc or hd1a) minor=0; (hdd or hd1b) minor=64
25 * Tertiary i/f: ide2: major=33; (hde) minor=0; (hdf) minor=64
26 * Quaternary i/f: ide3: major=34; (hdg) minor=0; (hdh) minor=64
29 /******************************************************************************
30 * IDE driver configuration options (play with these as desired):
32 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary
34 #undef REALLY_FAST_IO /* define if ide ports are perfect */
35 #define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */
37 #ifndef SUPPORT_SLOW_DATA_PORTS /* 1 to support slow data ports */
38 #define SUPPORT_SLOW_DATA_PORTS 1 /* 0 to reduce kernel size */
40 #ifndef SUPPORT_VLB_SYNC /* 1 to support weird 32-bit chips */
41 #define SUPPORT_VLB_SYNC 1 /* 0 to reduce kernel size */
43 #ifndef DISK_RECOVERY_TIME /* off=0; on=access_delay_time */
44 #define DISK_RECOVERY_TIME 0 /* for hardware that needs it */
46 #ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */
47 #define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */
49 #ifndef FANCY_STATUS_DUMPS /* 1 for human-readable drive errors */
50 #define FANCY_STATUS_DUMPS 1 /* 0 to reduce kernel size */
53 #ifdef CONFIG_BLK_DEV_CMD640
54 #if 0 /* change to 1 when debugging cmd640 problems */
55 void cmd640_dump_regs (void);
56 #define CMD640_DUMP_REGS cmd640_dump_regs() /* for debugging cmd640 chipset */
58 #endif /* CONFIG_BLK_DEV_CMD640 */
61 * IDE_DRIVE_CMD is used to implement many features of the hdparm utility
63 #define IDE_DRIVE_CMD 99 /* (magic) undef to reduce kernel size*/
66 * "No user-serviceable parts" beyond this point :)
67 *****************************************************************************/
69 typedef unsigned char byte
; /* used everywhere */
72 * Probably not wise to fiddle with these
74 #define ERROR_MAX 8 /* Max read/write errors per sector */
75 #define ERROR_RESET 3 /* Reset controller every 4th retry */
76 #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
79 * Ensure that various configuration flags have compatible settings
85 #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif))
86 #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
89 * Definitions for accessing IDE controller registers
91 #define IDE_NR_PORTS (10)
93 #define IDE_DATA_OFFSET (0)
94 #define IDE_ERROR_OFFSET (1)
95 #define IDE_NSECTOR_OFFSET (2)
96 #define IDE_SECTOR_OFFSET (3)
97 #define IDE_LCYL_OFFSET (4)
98 #define IDE_HCYL_OFFSET (5)
99 #define IDE_SELECT_OFFSET (6)
100 #define IDE_STATUS_OFFSET (7)
101 #define IDE_CONTROL_OFFSET (8)
102 #define IDE_IRQ_OFFSET (9)
104 #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
105 #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
107 #define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
108 #define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
109 #define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
110 #define IDE_SECTOR_REG (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
111 #define IDE_LCYL_REG (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
112 #define IDE_HCYL_REG (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
113 #define IDE_SELECT_REG (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
114 #define IDE_STATUS_REG (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
115 #define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
116 #define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
118 #define IDE_FEATURE_REG IDE_ERROR_REG
119 #define IDE_COMMAND_REG IDE_STATUS_REG
120 #define IDE_ALTSTATUS_REG IDE_CONTROL_REG
121 #define IDE_IREASON_REG IDE_NSECTOR_REG
122 #define IDE_BCOUNTL_REG IDE_LCYL_REG
123 #define IDE_BCOUNTH_REG IDE_HCYL_REG
125 #ifdef REALLY_FAST_IO
126 #define OUT_BYTE(b,p) outb((b),(p))
127 #define IN_BYTE(p) (byte)inb(p)
129 #define OUT_BYTE(b,p) outb_p((b),(p))
130 #define IN_BYTE(p) (byte)inb_p(p)
131 #endif /* REALLY_FAST_IO */
133 #define GET_ERR() IN_BYTE(IDE_ERROR_REG)
134 #define GET_STAT() IN_BYTE(IDE_STATUS_REG)
135 #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
136 #define BAD_R_STAT (BUSY_STAT | ERR_STAT)
137 #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT)
138 #define BAD_STAT (BAD_R_STAT | DRQ_STAT)
139 #define DRIVE_READY (READY_STAT | SEEK_STAT)
140 #define DATA_READY (DRQ_STAT)
143 * Some more useful definitions
145 #define IDE_MAJOR_NAME "ide" /* the same for all i/f; see also genhd.c */
146 #define MAJOR_NAME IDE_MAJOR_NAME
147 #define PARTN_BITS 6 /* number of minor dev bits for partitions */
148 #define PARTN_MASK ((1<<PARTN_BITS)-1) /* a useful bit mask */
149 #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */
150 #define SECTOR_WORDS (512 / 4) /* number of 32bit words per sector */
151 #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
152 #define IDE_MIN(a,b) ((a)<(b) ? (a):(b))
153 #define IDE_MAX(a,b) ((a)>(b) ? (a):(b))
156 * Timeouts for various operations:
158 #define WAIT_DRQ (5*HZ/100) /* 50msec - spec allows up to 20ms */
160 #define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */
162 #define WAIT_READY (3*HZ/100) /* 30msec - should be instantaneous */
163 #endif /* CONFIG_APM */
164 #define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?)
165 if all ATAPI CD is closed at boot */
166 #define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */
167 #define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */
168 #define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */
170 #define SELECT_DRIVE(hwif,drive) \
172 if (hwif->selectproc) \
173 hwif->selectproc(drive); \
174 OUT_BYTE((drive)->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); \
178 * Check for an interrupt and acknowledge the interrupt status
181 typedef int (ide_ack_intr_t
)(struct hwif_s
*);
184 * Structure to hold all information about the location of this port
186 typedef struct hw_regs_s
{
187 ide_ioreg_t io_ports
[IDE_NR_PORTS
]; /* task file registers */
188 int irq
; /* our irq number */
189 ide_ack_intr_t
*ack_intr
; /* acknowledge interrupt */
190 void *priv
; /* interface specific data */
194 * Register new hardware with ide
196 int ide_register_hw(hw_regs_t
*hw
, struct hwif_s
**hwifp
);
199 * Set up hw_regs_t structure before calling ide_register_hw (optional)
201 void ide_setup_ports( hw_regs_t
*hw
,
206 ide_ack_intr_t
*ack_intr
,
212 * Now for the data we need to maintain per-drive: ide_drive_t
215 #define ide_scsi 0x21
216 #define ide_disk 0x20
217 #define ide_optical 0x7
218 #define ide_cdrom 0x5
220 #define ide_floppy 0x0
223 unsigned all
: 8; /* all of the bits together */
225 unsigned set_geometry
: 1; /* respecify drive geometry */
226 unsigned recalibrate
: 1; /* seek to cyl 0 */
227 unsigned set_multmode
: 1; /* set multmode count */
228 unsigned set_tune
: 1; /* tune interface for drive */
229 unsigned reserved
: 4; /* unused */
233 typedef struct ide_drive_s
{
234 struct request
*queue
; /* request queue */
235 struct ide_drive_s
*next
; /* circular list of hwgroup drives */
236 unsigned long sleep
; /* sleep until this time */
237 unsigned long service_start
; /* time we started last request */
238 unsigned long service_time
; /* service time of last request */
239 unsigned long timeout
; /* max time to wait for irq */
240 special_t special
; /* special action flags */
241 byte keep_settings
; /* restore settings after drive reset */
242 byte using_dma
; /* disk is using dma for read/write */
243 byte waiting_for_dma
; /* dma currently in progress */
244 byte unmask
; /* flag: okay to unmask other irqs */
245 byte slow
; /* flag: slow data port */
246 byte bswap
; /* flag: byte swap data */
247 byte dsc_overlap
; /* flag: DSC overlap */
248 byte nice1
; /* flag: give potential excess bandwidth */
249 unsigned present
: 1; /* drive is physically present */
250 unsigned noprobe
: 1; /* from: hdx=noprobe */
251 unsigned busy
: 1; /* currently doing revalidate_disk() */
252 unsigned removable
: 1; /* 1 if need to do check_media_change */
253 unsigned forced_geom
: 1; /* 1 if hdx=c,h,s was given at boot */
254 unsigned no_unmask
: 1; /* disallow setting unmask bit */
255 unsigned no_io_32bit
: 1; /* disallow enabling 32bit I/O */
256 unsigned nobios
: 1; /* flag: do not probe bios for drive */
257 unsigned revalidate
: 1; /* request revalidation */
258 unsigned atapi_overlap
: 1; /* flag: ATAPI overlap (not supported) */
259 unsigned nice0
: 1; /* flag: give obvious excess bandwidth */
260 unsigned nice2
: 1; /* flag: give a share in our own bandwidth */
261 unsigned doorlocking
: 1; /* flag: for removable only: door lock/unlock works */
262 unsigned autotune
: 2; /* 1=autotune, 2=noautotune, 0=default */
263 unsigned remap_0_to_1
: 2; /* 0=remap if ezdrive, 1=remap, 2=noremap */
264 unsigned ata_flash
: 1; /* 1=present, 0=default */
265 byte media
; /* disk, cdrom, tape, floppy, ... */
266 select_t select
; /* basic drive/head select reg value */
267 byte ctl
; /* "normal" value for IDE_CONTROL_REG */
268 byte ready_stat
; /* min status value for drive ready */
269 byte mult_count
; /* current multiple sector setting */
270 byte mult_req
; /* requested multiple sector setting */
271 byte tune_req
; /* requested drive tuning setting */
272 byte io_32bit
; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
273 byte bad_wstat
; /* used for ignoring WRERR_STAT */
274 byte nowerr
; /* used for ignoring WRERR_STAT */
275 byte sect0
; /* offset of first sector for DM6:DDO */
276 byte usage
; /* current "open()" count for drive */
277 byte head
; /* "real" number of heads */
278 byte sect
; /* "real" sectors per track */
279 byte bios_head
; /* BIOS/fdisk/LILO number of heads */
280 byte bios_sect
; /* BIOS/fdisk/LILO sectors per track */
281 unsigned int bios_cyl
; /* BIOS/fdisk/LILO number of cyls */
282 unsigned int cyl
; /* "real" number of cyls */
283 unsigned long capacity
; /* total number of sectors */
284 unsigned int drive_data
; /* for use by tuneproc/selectproc as needed */
285 void *hwif
; /* actually (ide_hwif_t *) */
286 wait_queue_head_t wqueue
; /* used to wait for drive in open() */
287 struct hd_driveid
*id
; /* drive model identification info */
288 struct hd_struct
*part
; /* drive partition table */
289 char name
[4]; /* drive name, such as "hda" */
290 void *driver
; /* (ide_driver_t *) */
291 void *driver_data
; /* extra driver data */
292 struct proc_dir_entry
*proc
; /* /proc/ide/ directory entry */
293 void *settings
; /* /proc/ide/ drive settings */
294 char driver_req
[10]; /* requests specific driver */
296 struct thresholds_s
*smart_thresholds
;
297 struct values_s
*smart_values
;
299 thresholds_t smart_thresholds
;
300 values_t smart_values
;
305 * An ide_dmaproc_t() initiates/aborts DMA read/write operations on a drive.
307 * The caller is assumed to have selected the drive and programmed the drive's
308 * sector address using CHS or LBA. All that remains is to prepare for DMA
309 * and then issue the actual read/write DMA/PIO command to the drive.
311 * Returns 0 if all went well.
312 * Returns 1 if DMA read/write could not be started, in which case the caller
313 * should either try again later, or revert to PIO for the current request.
315 typedef enum { ide_dma_read
, ide_dma_write
, ide_dma_begin
,
316 ide_dma_end
, ide_dma_check
, ide_dma_on
,
317 ide_dma_off
, ide_dma_off_quietly
, ide_dma_test_irq
,
318 ide_dma_bad_drive
, ide_dma_good_drive
,
319 ide_dma_lostirq
, ide_dma_timeout
322 typedef int (ide_dmaproc_t
)(ide_dma_action_t
, ide_drive_t
*);
326 * An ide_tuneproc_t() is used to set the speed of an IDE interface
327 * to a particular PIO mode. The "byte" parameter is used
328 * to select the PIO mode by number (0,1,2,3,4,5), and a value of 255
329 * indicates that the interface driver should "auto-tune" the PIO mode
330 * according to the drive capabilities in drive->id;
332 * Not all interface types support tuning, and not all of those
333 * support all possible PIO settings. They may silently ignore
334 * or round values as they see fit.
336 typedef void (ide_tuneproc_t
)(ide_drive_t
*, byte
);
339 * This is used to provide support for strange interfaces
341 typedef void (ide_selectproc_t
) (ide_drive_t
*);
342 typedef void (ide_resetproc_t
) (ide_drive_t
*);
345 * hwif_chipset_t is used to keep track of the specific hardware
346 * chipset used by each IDE interface, if known.
348 typedef enum { ide_unknown
, ide_generic
, ide_pci
,
349 ide_cmd640
, ide_dtc2278
, ide_ali14xx
,
350 ide_qd6580
, ide_umc8672
, ide_ht6560b
,
351 ide_pdc4030
, ide_rz1000
, ide_trm290
,
352 ide_cmd646
, ide_cy82c693
, ide_4drives
355 typedef struct ide_pci_devid_s
{
360 #define IDE_PCI_DEVID_NULL ((ide_pci_devid_t){0,0})
361 #define IDE_PCI_DEVID_EQ(a,b) (a.vid == b.vid && a.did == b.did)
363 typedef struct hwif_s
{
364 struct hwif_s
*next
; /* for linked-list in ide_hwgroup_t */
365 void *hwgroup
; /* actually (ide_hwgroup_t *) */
366 ide_ioreg_t io_ports
[IDE_NR_PORTS
]; /* task file registers */
367 hw_regs_t hw
; /* Hardware info */
368 ide_drive_t drives
[MAX_DRIVES
]; /* drive info */
369 struct gendisk
*gd
; /* gendisk structure */
370 ide_tuneproc_t
*tuneproc
; /* routine to tune PIO mode for drives */
371 ide_selectproc_t
*selectproc
; /* tweaks hardware to select drive */
372 ide_resetproc_t
*resetproc
; /* routine to reset controller after a disk reset */
373 ide_dmaproc_t
*dmaproc
; /* dma read/write/abort routine */
374 unsigned long *dmatable
; /* dma physical region descriptor table */
375 struct hwif_s
*mate
; /* other hwif from same PCI chip */
376 unsigned long dma_base
; /* base addr for dma ports */
377 unsigned dma_extra
; /* extra addr for dma ports */
378 unsigned long config_data
; /* for use by chipset-specific code */
379 unsigned long select_data
; /* for use by chipset-specific code */
380 struct proc_dir_entry
*proc
; /* /proc/ide/ directory entry */
381 int irq
; /* our irq number */
382 byte major
; /* our major number */
383 char name
[6]; /* name of interface, eg. "ide0" */
384 byte index
; /* 0 for ide0; 1 for ide1; ... */
385 hwif_chipset_t chipset
; /* sub-module for tuning.. */
386 unsigned noprobe
: 1; /* don't probe for this interface */
387 unsigned present
: 1; /* this interface exists */
388 unsigned serialized
: 1; /* serialized operation with mate hwif */
389 unsigned sharing_irq
: 1; /* 1 = sharing irq with another hwif */
390 unsigned reset
: 1; /* reset after probe */
391 unsigned autodma
: 1; /* automatically try to enable DMA at boot */
392 unsigned udma_four
: 1; /* 1=ATA-66 capable, 0=default */
393 byte channel
; /* for dual-port chips: 0=primary, 1=secondary */
394 struct pci_dev
*pci_dev
; /* for pci chipsets */
395 ide_pci_devid_t pci_devid
; /* for pci chipsets: {VID,DID} */
396 #if (DISK_RECOVERY_TIME > 0)
397 unsigned long last_time
; /* time when previous rq was done */
402 * internal ide interrupt handler type
404 typedef void (ide_handler_t
)(ide_drive_t
*);
406 typedef struct hwgroup_s
{
407 spinlock_t spinlock
; /* protects "busy" and "handler" */
408 ide_handler_t
*handler
;/* irq handler, if active */
409 int busy
; /* BOOL: protects all fields below */
410 ide_drive_t
*drive
; /* current drive */
411 ide_hwif_t
*hwif
; /* ptr to current hwif in linked-list */
412 struct request
*rq
; /* current request */
413 struct timer_list timer
; /* failsafe timer */
414 struct request wrq
; /* local copy of current write rq */
415 unsigned long poll_timeout
; /* timeout value during long polls */
419 * configurable drive settings
427 #define SETTING_READ (1 << 0)
428 #define SETTING_WRITE (1 << 1)
429 #define SETTING_RW (SETTING_READ | SETTING_WRITE)
431 typedef int (ide_procset_t
)(ide_drive_t
*, int);
432 typedef struct ide_settings_s
{
445 struct ide_settings_s
*next
;
448 void 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
);
449 void ide_remove_setting(ide_drive_t
*drive
, char *name
);
450 ide_settings_t
*ide_find_setting_by_name(ide_drive_t
*drive
, char *name
);
451 int ide_read_setting(ide_drive_t
*t
, ide_settings_t
*setting
);
452 int ide_write_setting(ide_drive_t
*drive
, ide_settings_t
*setting
, int val
);
453 void ide_add_generic_settings(ide_drive_t
*drive
);
456 * /proc/ide interface
461 read_proc_t
*read_proc
;
462 write_proc_t
*write_proc
;
465 #ifdef CONFIG_PROC_FS
466 void proc_ide_create(void);
467 void proc_ide_destroy(void);
468 void destroy_proc_ide_drives(ide_hwif_t
*);
469 void create_proc_ide_interfaces(void);
470 void ide_add_proc_entries(struct proc_dir_entry
*dir
, ide_proc_entry_t
*p
, void *data
);
471 void ide_remove_proc_entries(struct proc_dir_entry
*dir
, ide_proc_entry_t
*p
);
472 read_proc_t proc_ide_read_capacity
;
473 read_proc_t proc_ide_read_geometry
;
476 * Standard exit stuff:
478 #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \
487 *start = page + off; \
491 #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
495 * Subdrivers support.
497 #define IDE_SUBDRIVER_VERSION 1
499 typedef int (ide_cleanup_proc
)(ide_drive_t
*);
500 typedef void (ide_do_request_proc
)(ide_drive_t
*, struct request
*, unsigned long);
501 typedef void (ide_end_request_proc
)(byte
, ide_hwgroup_t
*);
502 typedef int (ide_ioctl_proc
)(ide_drive_t
*, struct inode
*, struct file
*, unsigned int, unsigned long);
503 typedef int (ide_open_proc
)(struct inode
*, struct file
*, ide_drive_t
*);
504 typedef void (ide_release_proc
)(struct inode
*, struct file
*, ide_drive_t
*);
505 typedef int (ide_check_media_change_proc
)(ide_drive_t
*);
506 typedef void (ide_pre_reset_proc
)(ide_drive_t
*);
507 typedef unsigned long (ide_capacity_proc
)(ide_drive_t
*);
508 typedef void (ide_special_proc
)(ide_drive_t
*);
509 typedef void (ide_setting_proc
)(ide_drive_t
*);
511 typedef struct ide_driver_s
{
516 unsigned supports_dma
: 1;
517 unsigned supports_dsc_overlap
: 1;
518 ide_cleanup_proc
*cleanup
;
519 ide_do_request_proc
*do_request
;
520 ide_end_request_proc
*end_request
;
521 ide_ioctl_proc
*ioctl
;
523 ide_release_proc
*release
;
524 ide_check_media_change_proc
*media_change
;
525 ide_pre_reset_proc
*pre_reset
;
526 ide_capacity_proc
*capacity
;
527 ide_special_proc
*special
;
528 ide_proc_entry_t
*proc
;
531 #define DRIVER(drive) ((ide_driver_t *)((drive)->driver))
536 #define IDE_CHIPSET_MODULE 0 /* not supported yet */
537 #define IDE_PROBE_MODULE 1
538 #define IDE_DRIVER_MODULE 2
540 typedef int (ide_module_init_proc
)(void);
542 typedef struct ide_module_s
{
544 ide_module_init_proc
*init
;
546 struct ide_module_s
*next
;
550 * ide_hwifs[] is the master data structure used to keep track
551 * of just about everything in ide.c. Whenever possible, routines
552 * should be using pointers to a drive (ide_drive_t *) or
553 * pointers to a hwif (ide_hwif_t *), rather than indexing this
554 * structure directly (the allocation/layout may change!).
558 extern ide_hwif_t ide_hwifs
[]; /* master data repository */
559 extern ide_module_t
*ide_modules
;
563 * We need blk.h, but we replace its end_request by our own version.
565 #define IDE_DRIVER /* Toggle some magic bits in blk.h */
566 #define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */
567 #include <linux/blk.h>
569 void ide_end_request(byte uptodate
, ide_hwgroup_t
*hwgroup
);
572 * This is used for (nearly) all data transfers from/to the IDE interface
574 void ide_input_data (ide_drive_t
*drive
, void *buffer
, unsigned int wcount
);
575 void ide_output_data (ide_drive_t
*drive
, void *buffer
, unsigned int wcount
);
578 * This is used for (nearly) all ATAPI data transfers from/to the IDE interface
580 void atapi_input_bytes (ide_drive_t
*drive
, void *buffer
, unsigned int bytecount
);
581 void atapi_output_bytes (ide_drive_t
*drive
, void *buffer
, unsigned int bytecount
);
584 * This is used on exit from the driver, to designate the next irq handler
585 * and also to start the safety timer.
587 void ide_set_handler (ide_drive_t
*drive
, ide_handler_t
*handler
);
590 * Error reporting, in human readable form (luxurious, but a memory hog).
592 byte
ide_dump_status (ide_drive_t
*drive
, const char *msg
, byte stat
);
595 * ide_error() takes action based on the error returned by the controller.
596 * The calling function must return afterwards, to restart the request.
598 void ide_error (ide_drive_t
*drive
, const char *msg
, byte stat
);
601 * Issue a simple drive command
602 * The drive must be selected beforehand.
604 void ide_cmd(ide_drive_t
*drive
, byte cmd
, byte nsect
, ide_handler_t
*handler
);
607 * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
608 * removing leading/trailing blanks and compressing internal blanks.
609 * It is primarily used to tidy up the model name/number fields as
610 * returned by the WIN_[P]IDENTIFY commands.
612 void ide_fixstring (byte
*s
, const int bytecount
, const int byteswap
);
615 * This routine busy-waits for the drive status to be not "busy".
616 * It then checks the status for all of the "good" bits and none
617 * of the "bad" bits, and if all is okay it returns 0. All other
618 * cases return 1 after invoking ide_error() -- caller should return.
621 int ide_wait_stat (ide_drive_t
*drive
, byte good
, byte bad
, unsigned long timeout
);
624 * This routine is called from the partition-table code in genhd.c
625 * to "convert" a drive to a logical geometry with fewer than 1024 cyls.
627 int ide_xlate_1024 (kdev_t
, int, int, const char *);
630 * Convert kdev_t structure into ide_drive_t * one.
632 ide_drive_t
*get_info_ptr (kdev_t i_rdev
);
635 * Return the current idea about the total capacity of this drive.
637 unsigned long current_capacity (ide_drive_t
*drive
);
640 * Start a reset operation for an IDE interface.
641 * The caller should return immediately after invoking this.
643 void ide_do_reset (ide_drive_t
*);
646 * This function is intended to be used prior to invoking ide_do_drive_cmd().
648 void ide_init_drive_cmd (struct request
*rq
);
651 * "action" parameter type for ide_do_drive_cmd() below.
654 {ide_wait
, /* insert rq at end of list, and wait for it */
655 ide_next
, /* insert rq immediately after current request */
656 ide_preempt
, /* insert rq in front of current request */
657 ide_end
} /* insert rq at end of list, but don't wait for it */
661 * This function issues a special IDE device request
662 * onto the request queue.
664 * If action is ide_wait, then the rq is queued at the end of the
665 * request queue, and the function sleeps until it has been processed.
666 * This is for use when invoked from an ioctl handler.
668 * If action is ide_preempt, then the rq is queued at the head of
669 * the request queue, displacing the currently-being-processed
670 * request and this function returns immediately without waiting
671 * for the new rq to be completed. This is VERY DANGEROUS, and is
672 * intended for careful use by the ATAPI tape/cdrom driver code.
674 * If action is ide_next, then the rq is queued immediately after
675 * the currently-being-processed-request (if any), and the function
676 * returns without waiting for the new rq to be completed. As above,
677 * This is VERY DANGEROUS, and is intended for careful use by the
678 * ATAPI tape/cdrom driver code.
680 * If action is ide_end, then the rq is queued at the end of the
681 * request queue, and the function returns immediately without waiting
682 * for the new rq to be completed. This is again intended for careful
683 * use by the ATAPI tape/cdrom driver code.
685 int ide_do_drive_cmd (ide_drive_t
*drive
, struct request
*rq
, ide_action_t action
);
688 * Clean up after success/failure of an explicit drive cmd.
689 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD).
691 void ide_end_drive_cmd (ide_drive_t
*drive
, byte stat
, byte err
);
694 * Issue ATA command and wait for completion.
696 int ide_wait_cmd (ide_drive_t
*drive
, int cmd
, int nsect
, int feature
, int sectors
, byte
*buf
);
698 void ide_delay_50ms (void);
699 int ide_config_drive_speed (ide_drive_t
*drive
, byte speed
);
702 * ide_system_bus_speed() returns what we think is the system VESA/PCI
703 * bus speed (in MHz). This is used for calculating interface PIO timings.
704 * The default is 40 for known PCI systems, 50 otherwise.
705 * The "idebus=xx" parameter can be used to override this value.
707 int ide_system_bus_speed (void);
710 * ide_multwrite() transfers a block of up to mcount sectors of data
711 * to a drive as part of a disk multwrite operation.
713 void ide_multwrite (ide_drive_t
*drive
, unsigned int mcount
);
716 * ide_stall_queue() can be used by a drive to give excess bandwidth back
717 * to the hwgroup by sleeping for timeout jiffies.
719 void ide_stall_queue (ide_drive_t
*drive
, unsigned long timeout
);
722 * ide_get_queue() returns the queue which corresponds to a given device.
724 struct request
**ide_get_queue (kdev_t dev
);
727 * CompactFlash cards and their brethern pretend to be removable hard disks,
728 * but they never have a slave unit, and they don't have doorlock mechanisms.
729 * This test catches them, and is invoked elsewhere when setting appropriate config bits.
731 int drive_is_flashcard (ide_drive_t
*drive
);
733 int ide_spin_wait_hwgroup(ide_drive_t
*drive
, unsigned long *flags
);
734 void ide_timer_expiry (unsigned long data
);
735 void ide_intr (int irq
, void *dev_id
, struct pt_regs
*regs
);
736 void ide_geninit (struct gendisk
*gd
);
737 void do_ide0_request (void);
739 void do_ide1_request (void);
742 void do_ide2_request (void);
745 void do_ide3_request (void);
748 void do_ide4_request (void);
751 void do_ide5_request (void);
754 void do_ide6_request (void);
757 void do_ide7_request (void);
760 void do_ide8_request (void);
763 void do_ide9_request (void);
765 void ide_init_subdrivers (void);
768 extern struct file_operations ide_fops
[];
769 extern ide_proc_entry_t generic_subdriver_entries
[];
773 #ifdef CONFIG_BLK_DEV_IDE
774 int ideprobe_init (void);
775 #endif /* CONFIG_BLK_DEV_IDE */
776 #ifdef CONFIG_BLK_DEV_IDEDISK
777 int idedisk_init (void);
778 #endif /* CONFIG_BLK_DEV_IDEDISK */
779 #ifdef CONFIG_BLK_DEV_IDECD
780 int ide_cdrom_init (void);
781 #endif /* CONFIG_BLK_DEV_IDECD */
782 #ifdef CONFIG_BLK_DEV_IDETAPE
783 int idetape_init (void);
784 #endif /* CONFIG_BLK_DEV_IDETAPE */
785 #ifdef CONFIG_BLK_DEV_IDEFLOPPY
786 int idefloppy_init (void);
787 #endif /* CONFIG_BLK_DEV_IDEFLOPPY */
788 #ifdef CONFIG_BLK_DEV_IDESCSI
789 int idescsi_init (void);
790 #endif /* CONFIG_BLK_DEV_IDESCSI */
793 int ide_register_module (ide_module_t
*module
);
794 void ide_unregister_module (ide_module_t
*module
);
795 ide_drive_t
*ide_scan_devices (byte media
, const char *name
, ide_driver_t
*driver
, int n
);
796 int ide_register_subdriver (ide_drive_t
*drive
, ide_driver_t
*driver
, int version
);
797 int ide_unregister_subdriver (ide_drive_t
*drive
);
798 int ide_replace_subdriver(ide_drive_t
*drive
, const char *driver
);
800 #ifdef CONFIG_BLK_DEV_IDEPCI
802 #define NEVER_BOARD 0
803 #ifdef CONFIG_BLK_DEV_OFFBOARD
804 # define OFF_BOARD ON_BOARD
805 #else /* CONFIG_BLK_DEV_OFFBOARD */
806 # define OFF_BOARD NEVER_BOARD
807 #endif /* CONFIG_BLK_DEV_OFFBOARD */
808 unsigned long ide_find_free_region (unsigned short size
) __init
;
809 void ide_scan_pcibus (void) __init
;
811 #ifdef CONFIG_BLK_DEV_IDEDMA
812 #define BAD_DMA_DRIVE 0
813 #define GOOD_DMA_DRIVE 1
814 int ide_build_dmatable (ide_drive_t
*drive
, ide_dma_action_t func
);
815 void ide_dma_intr (ide_drive_t
*drive
);
816 int check_drive_lists (ide_drive_t
*drive
, int good_bad
);
817 int ide_dmaproc (ide_dma_action_t func
, ide_drive_t
*drive
);
818 int ide_release_dma (ide_hwif_t
*hwif
);
819 void ide_setup_dma (ide_hwif_t
*hwif
, unsigned long dmabase
, unsigned int num_ports
) __init
;
820 unsigned long ide_get_or_set_dma_base (ide_hwif_t
*hwif
, int extra
, const char *name
) __init
;