diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ata.h | 112 | ||||
| -rw-r--r-- | include/linux/ide.h | 316 |
2 files changed, 314 insertions, 114 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index be00973d1a8c..a53318b8cbd0 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #define __LINUX_ATA_H__ | 30 | #define __LINUX_ATA_H__ |
| 31 | 31 | ||
| 32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
| 33 | #include <asm/byteorder.h> | ||
| 33 | 34 | ||
| 34 | /* defines only for the constants which don't work well as enums */ | 35 | /* defines only for the constants which don't work well as enums */ |
| 35 | #define ATA_DMA_BOUNDARY 0xffffUL | 36 | #define ATA_DMA_BOUNDARY 0xffffUL |
| @@ -558,6 +559,15 @@ static inline int ata_id_has_flush(const u16 *id) | |||
| 558 | return id[ATA_ID_COMMAND_SET_2] & (1 << 12); | 559 | return id[ATA_ID_COMMAND_SET_2] & (1 << 12); |
| 559 | } | 560 | } |
| 560 | 561 | ||
| 562 | static inline int ata_id_flush_enabled(const u16 *id) | ||
| 563 | { | ||
| 564 | if (ata_id_has_flush(id) == 0) | ||
| 565 | return 0; | ||
| 566 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) | ||
| 567 | return 0; | ||
| 568 | return id[ATA_ID_CFS_ENABLE_2] & (1 << 12); | ||
| 569 | } | ||
| 570 | |||
| 561 | static inline int ata_id_has_flush_ext(const u16 *id) | 571 | static inline int ata_id_has_flush_ext(const u16 *id) |
| 562 | { | 572 | { |
| 563 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) | 573 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
| @@ -565,6 +575,19 @@ static inline int ata_id_has_flush_ext(const u16 *id) | |||
| 565 | return id[ATA_ID_COMMAND_SET_2] & (1 << 13); | 575 | return id[ATA_ID_COMMAND_SET_2] & (1 << 13); |
| 566 | } | 576 | } |
| 567 | 577 | ||
| 578 | static inline int ata_id_flush_ext_enabled(const u16 *id) | ||
| 579 | { | ||
| 580 | if (ata_id_has_flush_ext(id) == 0) | ||
| 581 | return 0; | ||
| 582 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) | ||
| 583 | return 0; | ||
| 584 | /* | ||
| 585 | * some Maxtor disks have bit 13 defined incorrectly | ||
| 586 | * so check bit 10 too | ||
| 587 | */ | ||
| 588 | return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; | ||
| 589 | } | ||
| 590 | |||
| 568 | static inline int ata_id_has_lba48(const u16 *id) | 591 | static inline int ata_id_has_lba48(const u16 *id) |
| 569 | { | 592 | { |
| 570 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) | 593 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
| @@ -574,6 +597,15 @@ static inline int ata_id_has_lba48(const u16 *id) | |||
| 574 | return id[ATA_ID_COMMAND_SET_2] & (1 << 10); | 597 | return id[ATA_ID_COMMAND_SET_2] & (1 << 10); |
| 575 | } | 598 | } |
| 576 | 599 | ||
| 600 | static inline int ata_id_lba48_enabled(const u16 *id) | ||
| 601 | { | ||
| 602 | if (ata_id_has_lba48(id) == 0) | ||
| 603 | return 0; | ||
| 604 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) | ||
| 605 | return 0; | ||
| 606 | return id[ATA_ID_CFS_ENABLE_2] & (1 << 10); | ||
| 607 | } | ||
| 608 | |||
| 577 | static inline int ata_id_hpa_enabled(const u16 *id) | 609 | static inline int ata_id_hpa_enabled(const u16 *id) |
| 578 | { | 610 | { |
| 579 | /* Yes children, word 83 valid bits cover word 82 data */ | 611 | /* Yes children, word 83 valid bits cover word 82 data */ |
| @@ -645,7 +677,15 @@ static inline unsigned int ata_id_major_version(const u16 *id) | |||
| 645 | 677 | ||
| 646 | static inline int ata_id_is_sata(const u16 *id) | 678 | static inline int ata_id_is_sata(const u16 *id) |
| 647 | { | 679 | { |
| 648 | return ata_id_major_version(id) >= 5 && id[ATA_ID_HW_CONFIG] == 0; | 680 | /* |
| 681 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
| 682 | * verifying that word 80 by casting it to a signed type -- | ||
| 683 | * this trick allows us to filter out the reserved values of | ||
| 684 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
| 685 | */ | ||
| 686 | if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020) | ||
| 687 | return 1; | ||
| 688 | return 0; | ||
| 649 | } | 689 | } |
| 650 | 690 | ||
| 651 | static inline int ata_id_has_tpm(const u16 *id) | 691 | static inline int ata_id_has_tpm(const u16 *id) |
| @@ -742,6 +782,76 @@ static inline int atapi_id_dmadir(const u16 *dev_id) | |||
| 742 | return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); | 782 | return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); |
| 743 | } | 783 | } |
| 744 | 784 | ||
| 785 | /* | ||
| 786 | * ata_id_is_lba_capacity_ok() performs a sanity check on | ||
| 787 | * the claimed LBA capacity value for the device. | ||
| 788 | * | ||
| 789 | * Returns 1 if LBA capacity looks sensible, 0 otherwise. | ||
| 790 | * | ||
| 791 | * It is called only once for each device. | ||
| 792 | */ | ||
| 793 | static inline int ata_id_is_lba_capacity_ok(u16 *id) | ||
| 794 | { | ||
| 795 | unsigned long lba_sects, chs_sects, head, tail; | ||
| 796 | |||
| 797 | /* No non-LBA info .. so valid! */ | ||
| 798 | if (id[ATA_ID_CYLS] == 0) | ||
| 799 | return 1; | ||
| 800 | |||
| 801 | lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | ||
| 802 | |||
| 803 | /* | ||
| 804 | * The ATA spec tells large drives to return | ||
| 805 | * C/H/S = 16383/16/63 independent of their size. | ||
| 806 | * Some drives can be jumpered to use 15 heads instead of 16. | ||
| 807 | * Some drives can be jumpered to use 4092 cyls instead of 16383. | ||
| 808 | */ | ||
| 809 | if ((id[ATA_ID_CYLS] == 16383 || | ||
| 810 | (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) && | ||
| 811 | id[ATA_ID_SECTORS] == 63 && | ||
| 812 | (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && | ||
| 813 | (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) | ||
| 814 | return 1; | ||
| 815 | |||
| 816 | chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; | ||
| 817 | |||
| 818 | /* perform a rough sanity check on lba_sects: within 10% is OK */ | ||
| 819 | if (lba_sects - chs_sects < chs_sects/10) | ||
| 820 | return 1; | ||
| 821 | |||
| 822 | /* some drives have the word order reversed */ | ||
| 823 | head = (lba_sects >> 16) & 0xffff; | ||
| 824 | tail = lba_sects & 0xffff; | ||
| 825 | lba_sects = head | (tail << 16); | ||
| 826 | |||
| 827 | if (lba_sects - chs_sects < chs_sects/10) { | ||
| 828 | *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); | ||
| 829 | return 1; /* LBA capacity is (now) good */ | ||
| 830 | } | ||
| 831 | |||
| 832 | return 0; /* LBA capacity value may be bad */ | ||
| 833 | } | ||
| 834 | |||
| 835 | static inline void ata_id_to_hd_driveid(u16 *id) | ||
| 836 | { | ||
| 837 | #ifdef __BIG_ENDIAN | ||
| 838 | /* accessed in struct hd_driveid as 8-bit values */ | ||
| 839 | id[ATA_ID_MAX_MULTSECT] = __cpu_to_le16(id[ATA_ID_MAX_MULTSECT]); | ||
| 840 | id[ATA_ID_CAPABILITY] = __cpu_to_le16(id[ATA_ID_CAPABILITY]); | ||
| 841 | id[ATA_ID_OLD_PIO_MODES] = __cpu_to_le16(id[ATA_ID_OLD_PIO_MODES]); | ||
| 842 | id[ATA_ID_OLD_DMA_MODES] = __cpu_to_le16(id[ATA_ID_OLD_DMA_MODES]); | ||
| 843 | id[ATA_ID_MULTSECT] = __cpu_to_le16(id[ATA_ID_MULTSECT]); | ||
| 844 | |||
| 845 | /* as 32-bit values */ | ||
| 846 | *(u32 *)&id[ATA_ID_LBA_CAPACITY] = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | ||
| 847 | *(u32 *)&id[ATA_ID_SPG] = ata_id_u32(id, ATA_ID_SPG); | ||
| 848 | |||
| 849 | /* as 64-bit value */ | ||
| 850 | *(u64 *)&id[ATA_ID_LBA_CAPACITY_2] = | ||
| 851 | ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); | ||
| 852 | #endif | ||
| 853 | } | ||
| 854 | |||
| 745 | static inline int is_multi_taskfile(struct ata_taskfile *tf) | 855 | static inline int is_multi_taskfile(struct ata_taskfile *tf) |
| 746 | { | 856 | { |
| 747 | return (tf->command == ATA_CMD_READ_MULTI) || | 857 | return (tf->command == ATA_CMD_READ_MULTI) || |
diff --git a/include/linux/ide.h b/include/linux/ide.h index 6514db8fd2e4..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,21 +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), |
| 370 | 393 | ||
| 371 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 27), | 394 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), |
| 372 | }; | 395 | }; |
| 373 | 396 | ||
| 374 | struct ide_drive_s { | 397 | struct ide_drive_s { |
| @@ -380,10 +403,10 @@ struct ide_drive_s { | |||
| 380 | struct request *rq; /* current request */ | 403 | struct request *rq; /* current request */ |
| 381 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | 404 | struct ide_drive_s *next; /* circular list of hwgroup drives */ |
| 382 | void *driver_data; /* extra driver data */ | 405 | void *driver_data; /* extra driver data */ |
| 383 | struct hd_driveid *id; /* drive model identification info */ | 406 | u16 *id; /* identification info */ |
| 384 | #ifdef CONFIG_IDE_PROC_FS | 407 | #ifdef CONFIG_IDE_PROC_FS |
| 385 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 408 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
| 386 | struct ide_settings_s *settings;/* /proc/ide/ drive settings */ | 409 | const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ |
| 387 | #endif | 410 | #endif |
| 388 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ | 411 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ |
| 389 | 412 | ||
| @@ -395,16 +418,16 @@ struct ide_drive_s { | |||
| 395 | special_t special; /* special action flags */ | 418 | special_t special; /* special action flags */ |
| 396 | select_t select; /* basic drive/head select reg value */ | 419 | select_t select; /* basic drive/head select reg value */ |
| 397 | 420 | ||
| 398 | u8 keep_settings; /* restore settings after drive reset */ | ||
| 399 | u8 using_dma; /* disk is using dma for read/write */ | ||
| 400 | u8 retry_pio; /* retrying dma capable host in pio */ | 421 | u8 retry_pio; /* retrying dma capable host in pio */ |
| 401 | u8 state; /* retry state */ | 422 | u8 state; /* retry state */ |
| 402 | u8 waiting_for_dma; /* dma currently in progress */ | 423 | u8 waiting_for_dma; /* dma currently in progress */ |
| 403 | u8 unmask; /* okay to unmask other irqs */ | ||
| 404 | u8 noflush; /* don't attempt flushes */ | ||
| 405 | u8 dsc_overlap; /* DSC overlap */ | ||
| 406 | u8 nice1; /* give potential excess bandwidth */ | ||
| 407 | 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 */ | ||
| 408 | unsigned present : 1; /* drive is physically present */ | 431 | unsigned present : 1; /* drive is physically present */ |
| 409 | unsigned dead : 1; /* device ejected hint */ | 432 | unsigned dead : 1; /* device ejected hint */ |
| 410 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ | 433 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ |
| @@ -414,23 +437,22 @@ struct ide_drive_s { | |||
| 414 | 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 */ |
| 415 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | 438 | unsigned no_unmask : 1; /* disallow setting unmask bit */ |
| 416 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | 439 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ |
| 417 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ | ||
| 418 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | 440 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ |
| 419 | unsigned nodma : 1; /* disallow DMA */ | 441 | unsigned nodma : 1; /* disallow DMA */ |
| 420 | unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ | ||
| 421 | 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 */ |
| 422 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ | 443 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ |
| 423 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ | 444 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ |
| 424 | unsigned post_reset : 1; | 445 | unsigned post_reset : 1; |
| 425 | 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 */ | ||
| 426 | 450 | ||
| 427 | u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
| 428 | u8 quirk_list; /* considered quirky, set for a specific host */ | 451 | u8 quirk_list; /* considered quirky, set for a specific host */ |
| 429 | u8 init_speed; /* transfer rate set at boot */ | 452 | u8 init_speed; /* transfer rate set at boot */ |
| 430 | u8 current_speed; /* current transfer rate set */ | 453 | u8 current_speed; /* current transfer rate set */ |
| 431 | u8 desired_speed; /* desired transfer rate set */ | 454 | u8 desired_speed; /* desired transfer rate set */ |
| 432 | u8 dn; /* now wide spread use */ | 455 | u8 dn; /* now wide spread use */ |
| 433 | u8 wcache; /* status of write cache */ | ||
| 434 | u8 acoustic; /* acoustic management */ | 456 | u8 acoustic; /* acoustic management */ |
| 435 | u8 media; /* disk, cdrom, tape, floppy, ... */ | 457 | u8 media; /* disk, cdrom, tape, floppy, ... */ |
| 436 | u8 ready_stat; /* min status value for drive ready */ | 458 | u8 ready_stat; /* min status value for drive ready */ |
| @@ -438,9 +460,7 @@ struct ide_drive_s { | |||
| 438 | u8 mult_req; /* requested multiple sector setting */ | 460 | u8 mult_req; /* requested multiple sector setting */ |
| 439 | u8 tune_req; /* requested drive tuning setting */ | 461 | u8 tune_req; /* requested drive tuning setting */ |
| 440 | 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 */ |
| 441 | u8 bad_wstat; /* used for ignoring WRERR_STAT */ | 463 | u8 bad_wstat; /* used for ignoring ATA_DF */ |
| 442 | u8 nowerr; /* used for ignoring WRERR_STAT */ | ||
| 443 | u8 sect0; /* offset of first sector for DM6:DDO */ | ||
| 444 | u8 head; /* "real" number of heads */ | 464 | u8 head; /* "real" number of heads */ |
| 445 | u8 sect; /* "real" sectors per track */ | 465 | u8 sect; /* "real" sectors per track */ |
| 446 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ | 466 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ |
| @@ -474,10 +494,6 @@ typedef struct ide_drive_s ide_drive_t; | |||
| 474 | 494 | ||
| 475 | #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) |
| 476 | 496 | ||
| 477 | #define IDE_CHIPSET_PCI_MASK \ | ||
| 478 | ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) | ||
| 479 | #define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) | ||
| 480 | |||
| 481 | struct ide_task_s; | 497 | struct ide_task_s; |
| 482 | struct ide_port_info; | 498 | struct ide_port_info; |
| 483 | 499 | ||
| @@ -567,7 +583,6 @@ typedef struct hwif_s { | |||
| 567 | u8 major; /* our major number */ | 583 | u8 major; /* our major number */ |
| 568 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 584 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
| 569 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ | 585 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ |
| 570 | u8 bus_state; /* power state of the IDE bus */ | ||
| 571 | 586 | ||
| 572 | u32 host_flags; | 587 | u32 host_flags; |
| 573 | 588 | ||
| @@ -645,6 +660,7 @@ struct ide_host { | |||
| 645 | ide_hwif_t *ports[MAX_HWIFS]; | 660 | ide_hwif_t *ports[MAX_HWIFS]; |
| 646 | unsigned int n_ports; | 661 | unsigned int n_ports; |
| 647 | struct device *dev[2]; | 662 | struct device *dev[2]; |
| 663 | unsigned int (*init_chipset)(struct pci_dev *); | ||
| 648 | unsigned long host_flags; | 664 | unsigned long host_flags; |
| 649 | void *host_priv; | 665 | void *host_priv; |
| 650 | }; | 666 | }; |
| @@ -692,9 +708,61 @@ typedef struct ide_driver_s ide_driver_t; | |||
| 692 | 708 | ||
| 693 | extern struct mutex ide_setting_mtx; | 709 | extern struct mutex ide_setting_mtx; |
| 694 | 710 | ||
| 695 | int set_io_32bit(ide_drive_t *, int); | 711 | /* |
| 696 | int set_pio_mode(ide_drive_t *, int); | 712 | * configurable drive settings |
| 697 | 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); | ||
| 698 | 766 | ||
| 699 | /* ATAPI packet command flags */ | 767 | /* ATAPI packet command flags */ |
| 700 | enum { | 768 | enum { |
| @@ -710,6 +778,12 @@ enum { | |||
| 710 | PC_FLAG_TIMEDOUT = (1 << 7), | 778 | PC_FLAG_TIMEDOUT = (1 << 7), |
| 711 | }; | 779 | }; |
| 712 | 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 | |||
| 713 | struct ide_atapi_pc { | 787 | struct ide_atapi_pc { |
| 714 | /* actual packet bytes */ | 788 | /* actual packet bytes */ |
| 715 | u8 c[12]; | 789 | u8 c[12]; |
| @@ -739,7 +813,7 @@ struct ide_atapi_pc { | |||
| 739 | * 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 |
| 740 | * to change/removal later. | 814 | * to change/removal later. |
| 741 | */ | 815 | */ |
| 742 | u8 pc_buf[256]; | 816 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; |
| 743 | 817 | ||
| 744 | /* idetape only */ | 818 | /* idetape only */ |
| 745 | struct idetape_bh *bh; | 819 | struct idetape_bh *bh; |
| @@ -757,37 +831,34 @@ struct ide_atapi_pc { | |||
| 757 | 831 | ||
| 758 | #ifdef CONFIG_IDE_PROC_FS | 832 | #ifdef CONFIG_IDE_PROC_FS |
| 759 | /* | 833 | /* |
| 760 | * configurable drive settings | 834 | * /proc/ide interface |
| 761 | */ | 835 | */ |
| 762 | 836 | ||
| 763 | #define TYPE_INT 0 | 837 | #define ide_devset_rw_field(_name, _field) \ |
| 764 | #define TYPE_BYTE 1 | 838 | ide_devset_get(_name, _field); \ |
| 765 | #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 | }; | ||
| 766 | 849 | ||
| 767 | #define SETTING_READ (1 << 0) | 850 | #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ |
| 768 | #define SETTING_WRITE (1 << 1) | 851 | .name = __stringify(_name), \ |
| 769 | #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 | } | ||
| 770 | 858 | ||
| 771 | typedef int (ide_procset_t)(ide_drive_t *, int); | 859 | #define IDE_PROC_DEVSET(_name, _min, _max) \ |
| 772 | typedef struct ide_settings_s { | 860 | __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) |
| 773 | char *name; | ||
| 774 | int rw; | ||
| 775 | int data_type; | ||
| 776 | int min; | ||
| 777 | int max; | ||
| 778 | int mul_factor; | ||
| 779 | int div_factor; | ||
| 780 | void *data; | ||
| 781 | ide_procset_t *set; | ||
| 782 | int auto_remove; | ||
| 783 | struct ide_settings_s *next; | ||
| 784 | } ide_settings_t; | ||
| 785 | |||
| 786 | int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set); | ||
| 787 | 861 | ||
| 788 | /* | ||
| 789 | * /proc/ide interface | ||
| 790 | */ | ||
| 791 | typedef struct { | 862 | typedef struct { |
| 792 | const char *name; | 863 | const char *name; |
| 793 | mode_t mode; | 864 | mode_t mode; |
| @@ -804,8 +875,6 @@ void ide_proc_unregister_port(ide_hwif_t *); | |||
| 804 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 875 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); |
| 805 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 876 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); |
| 806 | 877 | ||
| 807 | void ide_add_generic_settings(ide_drive_t *); | ||
| 808 | |||
| 809 | read_proc_t proc_ide_read_capacity; | 878 | read_proc_t proc_ide_read_capacity; |
| 810 | read_proc_t proc_ide_read_geometry; | 879 | read_proc_t proc_ide_read_geometry; |
| 811 | 880 | ||
| @@ -833,7 +902,6 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | |||
| 833 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 902 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
| 834 | 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) { ; } |
| 835 | 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) { ; } |
| 836 | static inline void ide_add_generic_settings(ide_drive_t *drive) { ; } | ||
| 837 | #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; |
| 838 | #endif | 906 | #endif |
| 839 | 907 | ||
| @@ -879,7 +947,6 @@ enum { | |||
| 879 | struct ide_driver_s { | 947 | struct ide_driver_s { |
| 880 | const char *version; | 948 | const char *version; |
| 881 | u8 media; | 949 | u8 media; |
| 882 | unsigned supports_dsc_overlap : 1; | ||
| 883 | 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); |
| 884 | int (*end_request)(ide_drive_t *, int, int); | 951 | int (*end_request)(ide_drive_t *, int, int); |
| 885 | 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); |
| @@ -889,7 +956,8 @@ struct ide_driver_s { | |||
| 889 | void (*resume)(ide_drive_t *); | 956 | void (*resume)(ide_drive_t *); |
| 890 | void (*shutdown)(ide_drive_t *); | 957 | void (*shutdown)(ide_drive_t *); |
| 891 | #ifdef CONFIG_IDE_PROC_FS | 958 | #ifdef CONFIG_IDE_PROC_FS |
| 892 | ide_proc_entry_t *proc; | 959 | ide_proc_entry_t *proc; |
| 960 | const struct ide_proc_devset *settings; | ||
| 893 | #endif | 961 | #endif |
| 894 | }; | 962 | }; |
| 895 | 963 | ||
| @@ -898,7 +966,17 @@ struct ide_driver_s { | |||
| 898 | int ide_device_get(ide_drive_t *); | 966 | int ide_device_get(ide_drive_t *); |
| 899 | void ide_device_put(ide_drive_t *); | 967 | void ide_device_put(ide_drive_t *); |
| 900 | 968 | ||
| 901 | 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); | ||
| 902 | 980 | ||
| 903 | extern int ide_vlb_clk; | 981 | extern int ide_vlb_clk; |
| 904 | extern int ide_pci_clk; | 982 | extern int ide_pci_clk; |
| @@ -920,14 +998,19 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | |||
| 920 | 998 | ||
| 921 | 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); |
| 922 | 1000 | ||
| 923 | extern void ide_fix_driveid(struct hd_driveid *); | 1001 | void ide_fix_driveid(u16 *); |
| 924 | 1002 | ||
| 925 | extern void ide_fixstring(u8 *, const int, const int); | 1003 | extern void ide_fixstring(u8 *, const int, const int); |
| 926 | 1004 | ||
| 1005 | int ide_busy_sleep(ide_hwif_t *, unsigned long, int); | ||
| 1006 | |||
| 927 | 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); |
| 928 | 1008 | ||
| 929 | extern ide_startstop_t ide_do_reset (ide_drive_t *); | 1009 | extern ide_startstop_t ide_do_reset (ide_drive_t *); |
| 930 | 1010 | ||
| 1011 | extern int ide_devset_execute(ide_drive_t *drive, | ||
| 1012 | const struct ide_devset *setting, int arg); | ||
| 1013 | |||
| 931 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); | 1014 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); |
| 932 | 1015 | ||
| 933 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); | 1016 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); |
| @@ -1051,6 +1134,8 @@ void ide_tf_read(ide_drive_t *, ide_task_t *); | |||
| 1051 | 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); |
| 1052 | 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); |
| 1053 | 1136 | ||
| 1137 | int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int); | ||
| 1138 | |||
| 1054 | extern void SELECT_DRIVE(ide_drive_t *); | 1139 | extern void SELECT_DRIVE(ide_drive_t *); |
| 1055 | void SELECT_MASK(ide_drive_t *, int); | 1140 | void SELECT_MASK(ide_drive_t *, int); |
| 1056 | 1141 | ||
| @@ -1061,11 +1146,36 @@ extern int drive_is_ready(ide_drive_t *); | |||
| 1061 | 1146 | ||
| 1062 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | 1147 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); |
| 1063 | 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 | |||
| 1064 | 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, |
| 1065 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1175 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
| 1066 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1176 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |
| 1067 | 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 *), |
| 1068 | 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, |
| 1069 | int)); | 1179 | int)); |
| 1070 | 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 *, |
| 1071 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1181 | ide_handler_t *, unsigned int, ide_expiry_t *); |
| @@ -1080,8 +1190,6 @@ int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); | |||
| 1080 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); | 1190 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); |
| 1081 | 1191 | ||
| 1082 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); | 1192 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); |
| 1083 | int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
| 1084 | int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
| 1085 | 1193 | ||
| 1086 | extern int ide_driveid_update(ide_drive_t *); | 1194 | extern int ide_driveid_update(ide_drive_t *); |
| 1087 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 1195 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
| @@ -1092,7 +1200,6 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); | |||
| 1092 | 1200 | ||
| 1093 | 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); |
| 1094 | 1202 | ||
| 1095 | extern int ide_spin_wait_hwgroup(ide_drive_t *); | ||
| 1096 | extern void ide_timer_expiry(unsigned long); | 1203 | extern void ide_timer_expiry(unsigned long); |
| 1097 | extern irqreturn_t ide_intr(int irq, void *dev_id); | 1204 | extern irqreturn_t ide_intr(int irq, void *dev_id); |
| 1098 | extern void do_ide_request(struct request_queue *); | 1205 | extern void do_ide_request(struct request_queue *); |
| @@ -1229,6 +1336,14 @@ int ide_pci_init_two(struct pci_dev *, struct pci_dev *, | |||
| 1229 | const struct ide_port_info *, void *); | 1336 | const struct ide_port_info *, void *); |
| 1230 | void ide_pci_remove(struct pci_dev *); | 1337 | void ide_pci_remove(struct pci_dev *); |
| 1231 | 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 | |||
| 1232 | void ide_map_sg(ide_drive_t *, struct request *); | 1347 | void ide_map_sg(ide_drive_t *, struct request *); |
| 1233 | void ide_init_sg_cmd(ide_drive_t *, struct request *); | 1348 | void ide_init_sg_cmd(ide_drive_t *, struct request *); |
| 1234 | 1349 | ||
| @@ -1240,7 +1355,7 @@ struct drive_list_entry { | |||
| 1240 | const char *id_firmware; | 1355 | const char *id_firmware; |
| 1241 | }; | 1356 | }; |
| 1242 | 1357 | ||
| 1243 | 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 *); |
| 1244 | 1359 | ||
| 1245 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1360 | #ifdef CONFIG_BLK_DEV_IDEDMA |
| 1246 | int __ide_dma_bad_drive(ide_drive_t *); | 1361 | int __ide_dma_bad_drive(ide_drive_t *); |
| @@ -1347,24 +1462,6 @@ const char *ide_xfer_verbose(u8 mode); | |||
| 1347 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); | 1462 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); |
| 1348 | 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); |
| 1349 | 1464 | ||
| 1350 | static inline int ide_dev_has_iordy(struct hd_driveid *id) | ||
| 1351 | { | ||
| 1352 | return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0; | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | static inline int ide_dev_is_sata(struct hd_driveid *id) | ||
| 1356 | { | ||
| 1357 | /* | ||
| 1358 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
| 1359 | * verifying that word 80 by casting it to a signed type -- | ||
| 1360 | * this trick allows us to filter out the reserved values of | ||
| 1361 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
| 1362 | */ | ||
| 1363 | if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020) | ||
| 1364 | return 1; | ||
| 1365 | return 0; | ||
| 1366 | } | ||
| 1367 | |||
| 1368 | u64 ide_get_lba_addr(struct ide_taskfile *, int); | 1465 | u64 ide_get_lba_addr(struct ide_taskfile *, int); |
| 1369 | u8 ide_dump_status(ide_drive_t *, const char *, u8); | 1466 | u8 ide_dump_status(ide_drive_t *, const char *, u8); |
| 1370 | 1467 | ||
| @@ -1436,13 +1533,6 @@ extern struct mutex ide_cfg_mtx; | |||
| 1436 | extern struct bus_type ide_bus_type; | 1533 | extern struct bus_type ide_bus_type; |
| 1437 | extern struct class *ide_port_class; | 1534 | extern struct class *ide_port_class; |
| 1438 | 1535 | ||
| 1439 | /* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ | ||
| 1440 | #define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) | ||
| 1441 | |||
| 1442 | /* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */ | ||
| 1443 | #define ide_id_has_flush_cache_ext(id) \ | ||
| 1444 | (((id)->cfs_enable_2 & 0x2400) == 0x2400) | ||
| 1445 | |||
| 1446 | static inline void ide_dump_identify(u8 *id) | 1536 | static inline void ide_dump_identify(u8 *id) |
| 1447 | { | 1537 | { |
| 1448 | 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); |
| @@ -1453,10 +1543,10 @@ static inline int hwif_to_node(ide_hwif_t *hwif) | |||
| 1453 | return hwif->dev ? dev_to_node(hwif->dev) : -1; | 1543 | return hwif->dev ? dev_to_node(hwif->dev) : -1; |
| 1454 | } | 1544 | } |
| 1455 | 1545 | ||
| 1456 | 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) |
| 1457 | { | 1547 | { |
| 1458 | ide_hwif_t *hwif = HWIF(drive); | 1548 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; |
| 1459 | 1549 | ||
| 1460 | return &hwif->drives[(drive->dn ^ 1) & 1]; | 1550 | return peer->present ? peer : NULL; |
| 1461 | } | 1551 | } |
| 1462 | #endif /* _IDE_H */ | 1552 | #endif /* _IDE_H */ |
