diff options
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r-- | include/linux/ide.h | 316 |
1 files changed, 204 insertions, 112 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index 1524829f73f2..a9d82d6e6bdd 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/ioport.h> | 10 | #include <linux/ioport.h> |
11 | #include <linux/hdreg.h> | 11 | #include <linux/ata.h> |
12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
13 | #include <linux/proc_fs.h> | 13 | #include <linux/proc_fs.h> |
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | #include <linux/completion.h> | 19 | #include <linux/completion.h> |
20 | #include <linux/pm.h> | ||
20 | #ifdef CONFIG_BLK_DEV_IDEACPI | 21 | #ifdef CONFIG_BLK_DEV_IDEACPI |
21 | #include <acpi/acpi.h> | 22 | #include <acpi/acpi.h> |
22 | #endif | 23 | #endif |
@@ -87,12 +88,13 @@ struct ide_io_ports { | |||
87 | }; | 88 | }; |
88 | 89 | ||
89 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) | 90 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) |
90 | #define BAD_R_STAT (BUSY_STAT | ERR_STAT) | ||
91 | #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT) | ||
92 | #define BAD_STAT (BAD_R_STAT | DRQ_STAT) | ||
93 | #define DRIVE_READY (READY_STAT | SEEK_STAT) | ||
94 | 91 | ||
95 | #define BAD_CRC (ABRT_ERR | ICRC_ERR) | 92 | #define BAD_R_STAT (ATA_BUSY | ATA_ERR) |
93 | #define BAD_W_STAT (BAD_R_STAT | ATA_DF) | ||
94 | #define BAD_STAT (BAD_R_STAT | ATA_DRQ) | ||
95 | #define DRIVE_READY (ATA_DRDY | ATA_DSC) | ||
96 | |||
97 | #define BAD_CRC (ATA_ABORTED | ATA_ICRC) | ||
96 | 98 | ||
97 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ | 99 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ |
98 | 100 | ||
@@ -125,24 +127,41 @@ struct ide_io_ports { | |||
125 | #define PARTN_BITS 6 /* number of minor dev bits for partitions */ | 127 | #define PARTN_BITS 6 /* number of minor dev bits for partitions */ |
126 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ | 128 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ |
127 | #define SECTOR_SIZE 512 | 129 | #define SECTOR_SIZE 512 |
128 | #define SECTOR_WORDS (SECTOR_SIZE / 4) /* number of 32bit words per sector */ | 130 | |
129 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) | 131 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) |
130 | 132 | ||
131 | /* | 133 | /* |
132 | * Timeouts for various operations: | 134 | * Timeouts for various operations: |
133 | */ | 135 | */ |
134 | #define WAIT_DRQ (HZ/10) /* 100msec - spec allows up to 20ms */ | 136 | enum { |
135 | #define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */ | 137 | /* spec allows up to 20ms */ |
136 | #define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?), if all ATAPI CD is closed at boot */ | 138 | WAIT_DRQ = HZ / 10, /* 100ms */ |
137 | #define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */ | 139 | /* some laptops are very slow */ |
138 | #define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */ | 140 | WAIT_READY = 5 * HZ, /* 5s */ |
139 | #define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ | 141 | /* should be less than 3ms (?), if all ATAPI CD is closed at boot */ |
142 | WAIT_PIDENTIFY = 10 * HZ, /* 10s */ | ||
143 | /* worst case when spinning up */ | ||
144 | WAIT_WORSTCASE = 30 * HZ, /* 30s */ | ||
145 | /* maximum wait for an IRQ to happen */ | ||
146 | WAIT_CMD = 10 * HZ, /* 10s */ | ||
147 | /* Some drives require a longer IRQ timeout. */ | ||
148 | WAIT_FLOPPY_CMD = 50 * HZ, /* 50s */ | ||
149 | /* | ||
150 | * Some drives (for example, Seagate STT3401A Travan) require a very | ||
151 | * long timeout, because they don't return an interrupt or clear their | ||
152 | * BSY bit until after the command completes (even retension commands). | ||
153 | */ | ||
154 | WAIT_TAPE_CMD = 900 * HZ, /* 900s */ | ||
155 | /* minimum sleep time */ | ||
156 | WAIT_MIN_SLEEP = HZ / 50, /* 20ms */ | ||
157 | }; | ||
140 | 158 | ||
141 | /* | 159 | /* |
142 | * Op codes for special requests to be handled by ide_special_rq(). | 160 | * Op codes for special requests to be handled by ide_special_rq(). |
143 | * Values should be in the range of 0x20 to 0x3f. | 161 | * Values should be in the range of 0x20 to 0x3f. |
144 | */ | 162 | */ |
145 | #define REQ_DRIVE_RESET 0x20 | 163 | #define REQ_DRIVE_RESET 0x20 |
164 | #define REQ_DEVSET_EXEC 0x21 | ||
146 | 165 | ||
147 | /* | 166 | /* |
148 | * Check for an interrupt and acknowledge the interrupt status | 167 | * Check for an interrupt and acknowledge the interrupt status |
@@ -303,8 +322,8 @@ typedef enum { | |||
303 | ide_started, /* a drive operation was started, handler was set */ | 322 | ide_started, /* a drive operation was started, handler was set */ |
304 | } ide_startstop_t; | 323 | } ide_startstop_t; |
305 | 324 | ||
325 | struct ide_devset; | ||
306 | struct ide_driver_s; | 326 | struct ide_driver_s; |
307 | struct ide_settings_s; | ||
308 | 327 | ||
309 | #ifdef CONFIG_BLK_DEV_IDEACPI | 328 | #ifdef CONFIG_BLK_DEV_IDEACPI |
310 | struct ide_acpi_drive_link; | 329 | struct ide_acpi_drive_link; |
@@ -315,10 +334,10 @@ struct ide_acpi_hwif_link; | |||
315 | enum { | 334 | enum { |
316 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), | 335 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), |
317 | IDE_AFLAG_MEDIA_CHANGED = (1 << 1), | 336 | IDE_AFLAG_MEDIA_CHANGED = (1 << 1), |
318 | |||
319 | /* ide-cd */ | ||
320 | /* Drive cannot lock the door. */ | 337 | /* Drive cannot lock the door. */ |
321 | IDE_AFLAG_NO_DOORLOCK = (1 << 2), | 338 | IDE_AFLAG_NO_DOORLOCK = (1 << 2), |
339 | |||
340 | /* ide-cd */ | ||
322 | /* Drive cannot eject the disc. */ | 341 | /* Drive cannot eject the disc. */ |
323 | IDE_AFLAG_NO_EJECT = (1 << 3), | 342 | IDE_AFLAG_NO_EJECT = (1 << 3), |
324 | /* Drive is a pre ATAPI 1.2 drive. */ | 343 | /* Drive is a pre ATAPI 1.2 drive. */ |
@@ -354,19 +373,25 @@ enum { | |||
354 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), | 373 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), |
355 | /* Requires BH algorithm for packets */ | 374 | /* Requires BH algorithm for packets */ |
356 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), | 375 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), |
376 | /* Write protect */ | ||
377 | IDE_AFLAG_WP = (1 << 21), | ||
378 | /* Supports format progress report */ | ||
379 | IDE_AFLAG_SRFP = (1 << 22), | ||
357 | 380 | ||
358 | /* ide-tape */ | 381 | /* ide-tape */ |
359 | IDE_AFLAG_IGNORE_DSC = (1 << 21), | 382 | IDE_AFLAG_IGNORE_DSC = (1 << 23), |
360 | /* 0 When the tape position is unknown */ | 383 | /* 0 When the tape position is unknown */ |
361 | IDE_AFLAG_ADDRESS_VALID = (1 << 22), | 384 | IDE_AFLAG_ADDRESS_VALID = (1 << 24), |
362 | /* Device already opened */ | 385 | /* Device already opened */ |
363 | IDE_AFLAG_BUSY = (1 << 23), | 386 | IDE_AFLAG_BUSY = (1 << 25), |
364 | /* Attempt to auto-detect the current user block size */ | 387 | /* Attempt to auto-detect the current user block size */ |
365 | IDE_AFLAG_DETECT_BS = (1 << 24), | 388 | IDE_AFLAG_DETECT_BS = (1 << 26), |
366 | /* Currently on a filemark */ | 389 | /* Currently on a filemark */ |
367 | IDE_AFLAG_FILEMARK = (1 << 25), | 390 | IDE_AFLAG_FILEMARK = (1 << 27), |
368 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | 391 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ |
369 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 26) | 392 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), |
393 | |||
394 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), | ||
370 | }; | 395 | }; |
371 | 396 | ||
372 | struct ide_drive_s { | 397 | struct ide_drive_s { |
@@ -378,10 +403,10 @@ struct ide_drive_s { | |||
378 | struct request *rq; /* current request */ | 403 | struct request *rq; /* current request */ |
379 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | 404 | struct ide_drive_s *next; /* circular list of hwgroup drives */ |
380 | void *driver_data; /* extra driver data */ | 405 | void *driver_data; /* extra driver data */ |
381 | struct hd_driveid *id; /* drive model identification info */ | 406 | u16 *id; /* identification info */ |
382 | #ifdef CONFIG_IDE_PROC_FS | 407 | #ifdef CONFIG_IDE_PROC_FS |
383 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 408 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
384 | struct ide_settings_s *settings;/* /proc/ide/ drive settings */ | 409 | const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ |
385 | #endif | 410 | #endif |
386 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ | 411 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ |
387 | 412 | ||
@@ -393,16 +418,16 @@ struct ide_drive_s { | |||
393 | special_t special; /* special action flags */ | 418 | special_t special; /* special action flags */ |
394 | select_t select; /* basic drive/head select reg value */ | 419 | select_t select; /* basic drive/head select reg value */ |
395 | 420 | ||
396 | u8 keep_settings; /* restore settings after drive reset */ | ||
397 | u8 using_dma; /* disk is using dma for read/write */ | ||
398 | u8 retry_pio; /* retrying dma capable host in pio */ | 421 | u8 retry_pio; /* retrying dma capable host in pio */ |
399 | u8 state; /* retry state */ | 422 | u8 state; /* retry state */ |
400 | u8 waiting_for_dma; /* dma currently in progress */ | 423 | u8 waiting_for_dma; /* dma currently in progress */ |
401 | u8 unmask; /* okay to unmask other irqs */ | ||
402 | u8 noflush; /* don't attempt flushes */ | ||
403 | u8 dsc_overlap; /* DSC overlap */ | ||
404 | u8 nice1; /* give potential excess bandwidth */ | ||
405 | 424 | ||
425 | unsigned keep_settings : 1; /* restore settings after drive reset */ | ||
426 | unsigned using_dma : 1; /* disk is using dma for read/write */ | ||
427 | unsigned unmask : 1; /* okay to unmask other irqs */ | ||
428 | unsigned noflush : 1; /* don't attempt flushes */ | ||
429 | unsigned dsc_overlap : 1; /* DSC overlap */ | ||
430 | unsigned nice1 : 1; /* give potential excess bandwidth */ | ||
406 | unsigned present : 1; /* drive is physically present */ | 431 | unsigned present : 1; /* drive is physically present */ |
407 | unsigned dead : 1; /* device ejected hint */ | 432 | unsigned dead : 1; /* device ejected hint */ |
408 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ | 433 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ |
@@ -412,23 +437,22 @@ struct ide_drive_s { | |||
412 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ | 437 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ |
413 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | 438 | unsigned no_unmask : 1; /* disallow setting unmask bit */ |
414 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | 439 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ |
415 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ | ||
416 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | 440 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ |
417 | unsigned nodma : 1; /* disallow DMA */ | 441 | unsigned nodma : 1; /* disallow DMA */ |
418 | unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ | ||
419 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ | 442 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ |
420 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ | 443 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ |
421 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ | 444 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ |
422 | unsigned post_reset : 1; | 445 | unsigned post_reset : 1; |
423 | unsigned udma33_warned : 1; | 446 | unsigned udma33_warned : 1; |
447 | unsigned addressing : 2; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
448 | unsigned wcache : 1; /* status of write cache */ | ||
449 | unsigned nowerr : 1; /* used for ignoring ATA_DF */ | ||
424 | 450 | ||
425 | u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
426 | u8 quirk_list; /* considered quirky, set for a specific host */ | 451 | u8 quirk_list; /* considered quirky, set for a specific host */ |
427 | u8 init_speed; /* transfer rate set at boot */ | 452 | u8 init_speed; /* transfer rate set at boot */ |
428 | u8 current_speed; /* current transfer rate set */ | 453 | u8 current_speed; /* current transfer rate set */ |
429 | u8 desired_speed; /* desired transfer rate set */ | 454 | u8 desired_speed; /* desired transfer rate set */ |
430 | u8 dn; /* now wide spread use */ | 455 | u8 dn; /* now wide spread use */ |
431 | u8 wcache; /* status of write cache */ | ||
432 | u8 acoustic; /* acoustic management */ | 456 | u8 acoustic; /* acoustic management */ |
433 | u8 media; /* disk, cdrom, tape, floppy, ... */ | 457 | u8 media; /* disk, cdrom, tape, floppy, ... */ |
434 | u8 ready_stat; /* min status value for drive ready */ | 458 | u8 ready_stat; /* min status value for drive ready */ |
@@ -436,9 +460,7 @@ struct ide_drive_s { | |||
436 | u8 mult_req; /* requested multiple sector setting */ | 460 | u8 mult_req; /* requested multiple sector setting */ |
437 | u8 tune_req; /* requested drive tuning setting */ | 461 | u8 tune_req; /* requested drive tuning setting */ |
438 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ | 462 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ |
439 | u8 bad_wstat; /* used for ignoring WRERR_STAT */ | 463 | u8 bad_wstat; /* used for ignoring ATA_DF */ |
440 | u8 nowerr; /* used for ignoring WRERR_STAT */ | ||
441 | u8 sect0; /* offset of first sector for DM6:DDO */ | ||
442 | u8 head; /* "real" number of heads */ | 464 | u8 head; /* "real" number of heads */ |
443 | u8 sect; /* "real" sectors per track */ | 465 | u8 sect; /* "real" sectors per track */ |
444 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ | 466 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ |
@@ -472,10 +494,6 @@ typedef struct ide_drive_s ide_drive_t; | |||
472 | 494 | ||
473 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) | 495 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) |
474 | 496 | ||
475 | #define IDE_CHIPSET_PCI_MASK \ | ||
476 | ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) | ||
477 | #define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) | ||
478 | |||
479 | struct ide_task_s; | 497 | struct ide_task_s; |
480 | struct ide_port_info; | 498 | struct ide_port_info; |
481 | 499 | ||
@@ -565,7 +583,6 @@ typedef struct hwif_s { | |||
565 | u8 major; /* our major number */ | 583 | u8 major; /* our major number */ |
566 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 584 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
567 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ | 585 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ |
568 | u8 bus_state; /* power state of the IDE bus */ | ||
569 | 586 | ||
570 | u32 host_flags; | 587 | u32 host_flags; |
571 | 588 | ||
@@ -643,6 +660,7 @@ struct ide_host { | |||
643 | ide_hwif_t *ports[MAX_HWIFS]; | 660 | ide_hwif_t *ports[MAX_HWIFS]; |
644 | unsigned int n_ports; | 661 | unsigned int n_ports; |
645 | struct device *dev[2]; | 662 | struct device *dev[2]; |
663 | unsigned int (*init_chipset)(struct pci_dev *); | ||
646 | unsigned long host_flags; | 664 | unsigned long host_flags; |
647 | void *host_priv; | 665 | void *host_priv; |
648 | }; | 666 | }; |
@@ -690,9 +708,61 @@ typedef struct ide_driver_s ide_driver_t; | |||
690 | 708 | ||
691 | extern struct mutex ide_setting_mtx; | 709 | extern struct mutex ide_setting_mtx; |
692 | 710 | ||
693 | int set_io_32bit(ide_drive_t *, int); | 711 | /* |
694 | int set_pio_mode(ide_drive_t *, int); | 712 | * configurable drive settings |
695 | int set_using_dma(ide_drive_t *, int); | 713 | */ |
714 | |||
715 | #define DS_SYNC (1 << 0) | ||
716 | |||
717 | struct ide_devset { | ||
718 | int (*get)(ide_drive_t *); | ||
719 | int (*set)(ide_drive_t *, int); | ||
720 | unsigned int flags; | ||
721 | }; | ||
722 | |||
723 | #define __DEVSET(_flags, _get, _set) { \ | ||
724 | .flags = _flags, \ | ||
725 | .get = _get, \ | ||
726 | .set = _set, \ | ||
727 | } | ||
728 | |||
729 | #define ide_devset_get(name, field) \ | ||
730 | static int get_##name(ide_drive_t *drive) \ | ||
731 | { \ | ||
732 | return drive->field; \ | ||
733 | } | ||
734 | |||
735 | #define ide_devset_set(name, field) \ | ||
736 | static int set_##name(ide_drive_t *drive, int arg) \ | ||
737 | { \ | ||
738 | drive->field = arg; \ | ||
739 | return 0; \ | ||
740 | } | ||
741 | |||
742 | #define __IDE_DEVSET(_name, _flags, _get, _set) \ | ||
743 | const struct ide_devset ide_devset_##_name = \ | ||
744 | __DEVSET(_flags, _get, _set) | ||
745 | |||
746 | #define IDE_DEVSET(_name, _flags, _get, _set) \ | ||
747 | static __IDE_DEVSET(_name, _flags, _get, _set) | ||
748 | |||
749 | #define ide_devset_rw(_name, _func) \ | ||
750 | IDE_DEVSET(_name, 0, get_##_func, set_##_func) | ||
751 | |||
752 | #define ide_devset_w(_name, _func) \ | ||
753 | IDE_DEVSET(_name, 0, NULL, set_##_func) | ||
754 | |||
755 | #define ide_devset_rw_sync(_name, _func) \ | ||
756 | IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | ||
757 | |||
758 | #define ide_decl_devset(_name) \ | ||
759 | extern const struct ide_devset ide_devset_##_name | ||
760 | |||
761 | ide_decl_devset(io_32bit); | ||
762 | ide_decl_devset(keepsettings); | ||
763 | ide_decl_devset(pio_mode); | ||
764 | ide_decl_devset(unmaskirq); | ||
765 | ide_decl_devset(using_dma); | ||
696 | 766 | ||
697 | /* ATAPI packet command flags */ | 767 | /* ATAPI packet command flags */ |
698 | enum { | 768 | enum { |
@@ -708,6 +778,12 @@ enum { | |||
708 | PC_FLAG_TIMEDOUT = (1 << 7), | 778 | PC_FLAG_TIMEDOUT = (1 << 7), |
709 | }; | 779 | }; |
710 | 780 | ||
781 | /* | ||
782 | * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. | ||
783 | * This is used for several packet commands (not for READ/WRITE commands). | ||
784 | */ | ||
785 | #define IDE_PC_BUFFER_SIZE 256 | ||
786 | |||
711 | struct ide_atapi_pc { | 787 | struct ide_atapi_pc { |
712 | /* actual packet bytes */ | 788 | /* actual packet bytes */ |
713 | u8 c[12]; | 789 | u8 c[12]; |
@@ -737,7 +813,7 @@ struct ide_atapi_pc { | |||
737 | * those are more or less driver-specific and some of them are subject | 813 | * those are more or less driver-specific and some of them are subject |
738 | * to change/removal later. | 814 | * to change/removal later. |
739 | */ | 815 | */ |
740 | u8 pc_buf[256]; | 816 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; |
741 | 817 | ||
742 | /* idetape only */ | 818 | /* idetape only */ |
743 | struct idetape_bh *bh; | 819 | struct idetape_bh *bh; |
@@ -755,37 +831,34 @@ struct ide_atapi_pc { | |||
755 | 831 | ||
756 | #ifdef CONFIG_IDE_PROC_FS | 832 | #ifdef CONFIG_IDE_PROC_FS |
757 | /* | 833 | /* |
758 | * configurable drive settings | 834 | * /proc/ide interface |
759 | */ | 835 | */ |
760 | 836 | ||
761 | #define TYPE_INT 0 | 837 | #define ide_devset_rw_field(_name, _field) \ |
762 | #define TYPE_BYTE 1 | 838 | ide_devset_get(_name, _field); \ |
763 | #define TYPE_SHORT 2 | 839 | ide_devset_set(_name, _field); \ |
840 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
841 | |||
842 | struct ide_proc_devset { | ||
843 | const char *name; | ||
844 | const struct ide_devset *setting; | ||
845 | int min, max; | ||
846 | int (*mulf)(ide_drive_t *); | ||
847 | int (*divf)(ide_drive_t *); | ||
848 | }; | ||
764 | 849 | ||
765 | #define SETTING_READ (1 << 0) | 850 | #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ |
766 | #define SETTING_WRITE (1 << 1) | 851 | .name = __stringify(_name), \ |
767 | #define SETTING_RW (SETTING_READ | SETTING_WRITE) | 852 | .setting = &ide_devset_##_name, \ |
853 | .min = _min, \ | ||
854 | .max = _max, \ | ||
855 | .mulf = _mulf, \ | ||
856 | .divf = _divf, \ | ||
857 | } | ||
768 | 858 | ||
769 | typedef int (ide_procset_t)(ide_drive_t *, int); | 859 | #define IDE_PROC_DEVSET(_name, _min, _max) \ |
770 | typedef struct ide_settings_s { | 860 | __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) |
771 | char *name; | ||
772 | int rw; | ||
773 | int data_type; | ||
774 | int min; | ||
775 | int max; | ||
776 | int mul_factor; | ||
777 | int div_factor; | ||
778 | void *data; | ||
779 | ide_procset_t *set; | ||
780 | int auto_remove; | ||
781 | struct ide_settings_s *next; | ||
782 | } ide_settings_t; | ||
783 | |||
784 | int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set); | ||
785 | 861 | ||
786 | /* | ||
787 | * /proc/ide interface | ||
788 | */ | ||
789 | typedef struct { | 862 | typedef struct { |
790 | const char *name; | 863 | const char *name; |
791 | mode_t mode; | 864 | mode_t mode; |
@@ -802,8 +875,6 @@ void ide_proc_unregister_port(ide_hwif_t *); | |||
802 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 875 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); |
803 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 876 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); |
804 | 877 | ||
805 | void ide_add_generic_settings(ide_drive_t *); | ||
806 | |||
807 | read_proc_t proc_ide_read_capacity; | 878 | read_proc_t proc_ide_read_capacity; |
808 | read_proc_t proc_ide_read_geometry; | 879 | read_proc_t proc_ide_read_geometry; |
809 | 880 | ||
@@ -831,7 +902,6 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | |||
831 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 902 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
832 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 903 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
833 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 904 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
834 | static inline void ide_add_generic_settings(ide_drive_t *drive) { ; } | ||
835 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 905 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
836 | #endif | 906 | #endif |
837 | 907 | ||
@@ -877,7 +947,6 @@ enum { | |||
877 | struct ide_driver_s { | 947 | struct ide_driver_s { |
878 | const char *version; | 948 | const char *version; |
879 | u8 media; | 949 | u8 media; |
880 | unsigned supports_dsc_overlap : 1; | ||
881 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 950 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
882 | int (*end_request)(ide_drive_t *, int, int); | 951 | int (*end_request)(ide_drive_t *, int, int); |
883 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | 952 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); |
@@ -887,7 +956,8 @@ struct ide_driver_s { | |||
887 | void (*resume)(ide_drive_t *); | 956 | void (*resume)(ide_drive_t *); |
888 | void (*shutdown)(ide_drive_t *); | 957 | void (*shutdown)(ide_drive_t *); |
889 | #ifdef CONFIG_IDE_PROC_FS | 958 | #ifdef CONFIG_IDE_PROC_FS |
890 | ide_proc_entry_t *proc; | 959 | ide_proc_entry_t *proc; |
960 | const struct ide_proc_devset *settings; | ||
891 | #endif | 961 | #endif |
892 | }; | 962 | }; |
893 | 963 | ||
@@ -896,7 +966,17 @@ struct ide_driver_s { | |||
896 | int ide_device_get(ide_drive_t *); | 966 | int ide_device_get(ide_drive_t *); |
897 | void ide_device_put(ide_drive_t *); | 967 | void ide_device_put(ide_drive_t *); |
898 | 968 | ||
899 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); | 969 | struct ide_ioctl_devset { |
970 | unsigned int get_ioctl; | ||
971 | unsigned int set_ioctl; | ||
972 | const struct ide_devset *setting; | ||
973 | }; | ||
974 | |||
975 | int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int, | ||
976 | unsigned long, const struct ide_ioctl_devset *); | ||
977 | |||
978 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, | ||
979 | unsigned, unsigned long); | ||
900 | 980 | ||
901 | extern int ide_vlb_clk; | 981 | extern int ide_vlb_clk; |
902 | extern int ide_pci_clk; | 982 | extern int ide_pci_clk; |
@@ -918,14 +998,19 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | |||
918 | 998 | ||
919 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); | 999 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); |
920 | 1000 | ||
921 | extern void ide_fix_driveid(struct hd_driveid *); | 1001 | void ide_fix_driveid(u16 *); |
922 | 1002 | ||
923 | extern void ide_fixstring(u8 *, const int, const int); | 1003 | extern void ide_fixstring(u8 *, const int, const int); |
924 | 1004 | ||
1005 | int ide_busy_sleep(ide_hwif_t *, unsigned long, int); | ||
1006 | |||
925 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); | 1007 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); |
926 | 1008 | ||
927 | extern ide_startstop_t ide_do_reset (ide_drive_t *); | 1009 | extern ide_startstop_t ide_do_reset (ide_drive_t *); |
928 | 1010 | ||
1011 | extern int ide_devset_execute(ide_drive_t *drive, | ||
1012 | const struct ide_devset *setting, int arg); | ||
1013 | |||
929 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); | 1014 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); |
930 | 1015 | ||
931 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); | 1016 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); |
@@ -1049,6 +1134,8 @@ void ide_tf_read(ide_drive_t *, ide_task_t *); | |||
1049 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); | 1134 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); |
1050 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); | 1135 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); |
1051 | 1136 | ||
1137 | int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int); | ||
1138 | |||
1052 | extern void SELECT_DRIVE(ide_drive_t *); | 1139 | extern void SELECT_DRIVE(ide_drive_t *); |
1053 | void SELECT_MASK(ide_drive_t *, int); | 1140 | void SELECT_MASK(ide_drive_t *, int); |
1054 | 1141 | ||
@@ -1059,11 +1146,36 @@ extern int drive_is_ready(ide_drive_t *); | |||
1059 | 1146 | ||
1060 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | 1147 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); |
1061 | 1148 | ||
1149 | int ide_check_atapi_device(ide_drive_t *, const char *); | ||
1150 | |||
1151 | void ide_init_pc(struct ide_atapi_pc *); | ||
1152 | |||
1153 | /* | ||
1154 | * Special requests for ide-tape block device strategy routine. | ||
1155 | * | ||
1156 | * In order to service a character device command, we add special requests to | ||
1157 | * the tail of our block device request queue and wait for their completion. | ||
1158 | */ | ||
1159 | enum { | ||
1160 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ | ||
1161 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ | ||
1162 | REQ_IDETAPE_READ = (1 << 2), | ||
1163 | REQ_IDETAPE_WRITE = (1 << 3), | ||
1164 | }; | ||
1165 | |||
1166 | void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *, | ||
1167 | struct request *); | ||
1168 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); | ||
1169 | |||
1170 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); | ||
1171 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); | ||
1172 | int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); | ||
1173 | |||
1062 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 1174 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, |
1063 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1175 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
1064 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1176 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |
1065 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 1177 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), |
1066 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, | 1178 | int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, |
1067 | int)); | 1179 | int)); |
1068 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | 1180 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, |
1069 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1181 | ide_handler_t *, unsigned int, ide_expiry_t *); |
@@ -1078,8 +1190,6 @@ int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); | |||
1078 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); | 1190 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); |
1079 | 1191 | ||
1080 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); | 1192 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); |
1081 | int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
1082 | int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
1083 | 1193 | ||
1084 | extern int ide_driveid_update(ide_drive_t *); | 1194 | extern int ide_driveid_update(ide_drive_t *); |
1085 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 1195 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
@@ -1090,7 +1200,6 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); | |||
1090 | 1200 | ||
1091 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); | 1201 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); |
1092 | 1202 | ||
1093 | extern int ide_spin_wait_hwgroup(ide_drive_t *); | ||
1094 | extern void ide_timer_expiry(unsigned long); | 1203 | extern void ide_timer_expiry(unsigned long); |
1095 | extern irqreturn_t ide_intr(int irq, void *dev_id); | 1204 | extern irqreturn_t ide_intr(int irq, void *dev_id); |
1096 | extern void do_ide_request(struct request_queue *); | 1205 | extern void do_ide_request(struct request_queue *); |
@@ -1227,6 +1336,14 @@ int ide_pci_init_two(struct pci_dev *, struct pci_dev *, | |||
1227 | const struct ide_port_info *, void *); | 1336 | const struct ide_port_info *, void *); |
1228 | void ide_pci_remove(struct pci_dev *); | 1337 | void ide_pci_remove(struct pci_dev *); |
1229 | 1338 | ||
1339 | #ifdef CONFIG_PM | ||
1340 | int ide_pci_suspend(struct pci_dev *, pm_message_t); | ||
1341 | int ide_pci_resume(struct pci_dev *); | ||
1342 | #else | ||
1343 | #define ide_pci_suspend NULL | ||
1344 | #define ide_pci_resume NULL | ||
1345 | #endif | ||
1346 | |||
1230 | void ide_map_sg(ide_drive_t *, struct request *); | 1347 | void ide_map_sg(ide_drive_t *, struct request *); |
1231 | void ide_init_sg_cmd(ide_drive_t *, struct request *); | 1348 | void ide_init_sg_cmd(ide_drive_t *, struct request *); |
1232 | 1349 | ||
@@ -1238,7 +1355,7 @@ struct drive_list_entry { | |||
1238 | const char *id_firmware; | 1355 | const char *id_firmware; |
1239 | }; | 1356 | }; |
1240 | 1357 | ||
1241 | int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *); | 1358 | int ide_in_drive_list(u16 *, const struct drive_list_entry *); |
1242 | 1359 | ||
1243 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1360 | #ifdef CONFIG_BLK_DEV_IDEDMA |
1244 | int __ide_dma_bad_drive(ide_drive_t *); | 1361 | int __ide_dma_bad_drive(ide_drive_t *); |
@@ -1345,24 +1462,6 @@ const char *ide_xfer_verbose(u8 mode); | |||
1345 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); | 1462 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); |
1346 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); | 1463 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); |
1347 | 1464 | ||
1348 | static inline int ide_dev_has_iordy(struct hd_driveid *id) | ||
1349 | { | ||
1350 | return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0; | ||
1351 | } | ||
1352 | |||
1353 | static inline int ide_dev_is_sata(struct hd_driveid *id) | ||
1354 | { | ||
1355 | /* | ||
1356 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
1357 | * verifying that word 80 by casting it to a signed type -- | ||
1358 | * this trick allows us to filter out the reserved values of | ||
1359 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
1360 | */ | ||
1361 | if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020) | ||
1362 | return 1; | ||
1363 | return 0; | ||
1364 | } | ||
1365 | |||
1366 | u64 ide_get_lba_addr(struct ide_taskfile *, int); | 1465 | u64 ide_get_lba_addr(struct ide_taskfile *, int); |
1367 | u8 ide_dump_status(ide_drive_t *, const char *, u8); | 1466 | u8 ide_dump_status(ide_drive_t *, const char *, u8); |
1368 | 1467 | ||
@@ -1434,13 +1533,6 @@ extern struct mutex ide_cfg_mtx; | |||
1434 | extern struct bus_type ide_bus_type; | 1533 | extern struct bus_type ide_bus_type; |
1435 | extern struct class *ide_port_class; | 1534 | extern struct class *ide_port_class; |
1436 | 1535 | ||
1437 | /* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ | ||
1438 | #define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) | ||
1439 | |||
1440 | /* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */ | ||
1441 | #define ide_id_has_flush_cache_ext(id) \ | ||
1442 | (((id)->cfs_enable_2 & 0x2400) == 0x2400) | ||
1443 | |||
1444 | static inline void ide_dump_identify(u8 *id) | 1536 | static inline void ide_dump_identify(u8 *id) |
1445 | { | 1537 | { |
1446 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); | 1538 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); |
@@ -1451,10 +1543,10 @@ static inline int hwif_to_node(ide_hwif_t *hwif) | |||
1451 | return hwif->dev ? dev_to_node(hwif->dev) : -1; | 1543 | return hwif->dev ? dev_to_node(hwif->dev) : -1; |
1452 | } | 1544 | } |
1453 | 1545 | ||
1454 | static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive) | 1546 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) |
1455 | { | 1547 | { |
1456 | ide_hwif_t *hwif = HWIF(drive); | 1548 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; |
1457 | 1549 | ||
1458 | return &hwif->drives[(drive->dn ^ 1) & 1]; | 1550 | return peer->present ? peer : NULL; |
1459 | } | 1551 | } |
1460 | #endif /* _IDE_H */ | 1552 | #endif /* _IDE_H */ |