15 #include <linux/bitops.h>
17 #include <linux/pci.h>
21 #ifdef CONFIG_BLK_DEV_IDEACPI
24 #include <asm/byteorder.h>
28 #include <linux/cdrom.h>
30 #if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
31 # define SUPPORT_VLB_SYNC 0
33 # define SUPPORT_VLB_SYNC 1
39 #define IDE_DEFAULT_MAX_FAILURES 1
56 #define IDE_NR_PORTS (10)
83 #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
85 #define BAD_R_STAT (ATA_BUSY | ATA_ERR)
86 #define BAD_W_STAT (BAD_R_STAT | ATA_DF)
87 #define BAD_STAT (BAD_R_STAT | ATA_DRQ)
88 #define DRIVE_READY (ATA_DRDY | ATA_DSC)
90 #define BAD_CRC (ATA_ABORTED | ATA_ICRC)
92 #define SATA_NR_PORTS (3)
94 #define SATA_STATUS_OFFSET (0)
95 #define SATA_ERROR_OFFSET (1)
96 #define SATA_CONTROL_OFFSET (2)
115 #define PRD_ENTRIES 256
122 #define SECTOR_SIZE 512
154 #define REQ_DRIVE_RESET 0x20
155 #define REQ_DEVSET_EXEC 0x21
156 #define REQ_PARK_HEADS 0x22
157 #define REQ_UNPARK_HEADS 0x23
186 static inline void ide_std_init_ports(
struct ide_hw *
hw,
188 unsigned long ctl_addr)
192 for (i = 0; i <= 7; i++)
204 #define ide_scsi 0x21
205 #define ide_disk 0x20
206 #define ide_optical 0x7
207 #define ide_cdrom 0x5
209 #define ide_floppy 0x0
328 #define ATAPI_WAIT_PC (60 * HZ)
355 #ifdef CONFIG_BLK_DEV_IDEACPI
495 #ifdef CONFIG_IDE_PROC_FS
497 const struct ide_proc_devset *settings;
549 #ifdef CONFIG_BLK_DEV_IDEACPI
579 #define to_ide_device(dev) container_of(dev, ide_drive_t, gendev)
581 #define to_ide_drv(obj, cont_type) \
582 container_of(obj, struct cont_type, dev)
584 #define ide_drv_g(disk, cont_type) \
585 container_of((disk)->private_data, struct cont_type, driver)
600 void *,
unsigned int);
602 void *,
unsigned int);
744 #ifdef CONFIG_BLK_DEV_IDEACPI
773 #define MAX_HOST_PORTS 4
798 #define IDE_HOST_BUSY 0
815 #define DS_SYNC (1 << 0)
818 int (*
get)(ide_drive_t *);
823 #define __DEVSET(_flags, _get, _set) { \
829 #define ide_devset_get(name, field) \
830 static int get_##name(ide_drive_t *drive) \
832 return drive->field; \
835 #define ide_devset_set(name, field) \
836 static int set_##name(ide_drive_t *drive, int arg) \
838 drive->field = arg; \
842 #define ide_devset_get_flag(name, flag) \
843 static int get_##name(ide_drive_t *drive) \
845 return !!(drive->dev_flags & flag); \
848 #define ide_devset_set_flag(name, flag) \
849 static int set_##name(ide_drive_t *drive, int arg) \
852 drive->dev_flags |= flag; \
854 drive->dev_flags &= ~flag; \
858 #define __IDE_DEVSET(_name, _flags, _get, _set) \
859 const struct ide_devset ide_devset_##_name = \
860 __DEVSET(_flags, _get, _set)
862 #define IDE_DEVSET(_name, _flags, _get, _set) \
863 static __IDE_DEVSET(_name, _flags, _get, _set)
865 #define ide_devset_rw(_name, _func) \
866 IDE_DEVSET(_name, 0, get_##_func, set_##_func)
868 #define ide_devset_w(_name, _func) \
869 IDE_DEVSET(_name, 0, NULL, set_##_func)
871 #define ide_ext_devset_rw(_name, _func) \
872 __IDE_DEVSET(_name, 0, get_##_func, set_##_func)
874 #define ide_ext_devset_rw_sync(_name, _func) \
875 __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func)
877 #define ide_decl_devset(_name) \
878 extern const struct ide_devset ide_devset_##_name
886 #ifdef CONFIG_IDE_PROC_FS
891 #define ide_devset_rw_field(_name, _field) \
892 ide_devset_get(_name, _field); \
893 ide_devset_set(_name, _field); \
894 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name)
896 #define ide_devset_rw_flag(_name, _field) \
897 ide_devset_get_flag(_name, _field); \
898 ide_devset_set_flag(_name, _field); \
899 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name)
901 struct ide_proc_devset {
905 int (*mulf)(ide_drive_t *);
906 int (*divf)(ide_drive_t *);
909 #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \
910 .name = __stringify(_name), \
911 .setting = &ide_devset_##_name, \
918 #define IDE_PROC_DEVSET(_name, _min, _max) \
919 __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL)
965 #define __ide_debug_log(lvl, fmt, args...) \
967 if (unlikely(drive->debug_mask & lvl)) \
968 printk(KERN_INFO DRV_NAME ": %s: " fmt "\n", \
969 __func__, ## args); \
1025 #ifdef CONFIG_IDE_PROC_FS
1026 ide_proc_entry_t * (*proc_entries)(ide_drive_t *);
1027 const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *);
1031 #define to_ide_driver(drv) container_of(drv, struct ide_driver, gen_driver)
1114 const char *
buf,
size_t len);
1130 void *,
unsigned int);
1167 extern void ide_stall_queue(ide_drive_t *drive,
unsigned long timeout);
1176 #ifdef CONFIG_IDEPCI_PCIBUS_ORDER
1178 #define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)
1180 #define ide_pci_register_driver(d) pci_register_driver(d)
1183 static inline int ide_pci_is_in_compatibility_mode(
struct pci_dev *
dev)
1194 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1195 int ide_pci_set_master(
struct pci_dev *,
const char *);
1196 unsigned long ide_pci_dma_base(ide_hwif_t *,
const struct ide_port_info *);
1197 int ide_pci_check_simplex(ide_hwif_t *,
const struct ide_port_info *);
1198 int ide_hwif_setup_dma(ide_hwif_t *,
const struct ide_port_info *);
1200 static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1282 #ifdef CONFIG_BLK_DEV_OFFBOARD
1283 # define IDE_HFLAG_OFF_BOARD 0
1285 # define IDE_HFLAG_OFF_BOARD IDE_HFLAG_NON_BOOTABLE
1330 #define ide_pci_suspend NULL
1331 #define ide_pci_resume NULL
1337 #define BAD_DMA_DRIVE 0
1338 #define GOOD_DMA_DRIVE 1
1347 #ifdef CONFIG_BLK_DEV_IDEDMA
1353 static inline u8 ide_max_dma_mode(ide_drive_t *drive)
1371 #ifdef CONFIG_BLK_DEV_IDEDMA_SFF
1391 static inline u8 ide_max_dma_mode(ide_drive_t *drive) {
return 0; }
1393 static inline void ide_dma_off(ide_drive_t *drive) { ; }
1394 static inline void ide_dma_on(ide_drive_t *drive) { ; }
1395 static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1396 static inline int ide_set_dma(ide_drive_t *drive) {
return 1; }
1407 #ifdef CONFIG_BLK_DEV_IDEACPI
1418 static inline bool ide_port_acpi(ide_hwif_t *hwif) {
return 0; }
1448 static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1453 static inline void ide_set_hwifdata (ide_hwif_t * hwif,
void *
data)
1497 #ifdef CONFIG_IDE_XFER_MODE
1510 static inline void ide_set_max_pio(ide_drive_t *drive)
1521 static inline void ide_dump_identify(
u8 *
id)
1526 static inline int hwif_to_node(ide_hwif_t *hwif)
1528 return hwif->
dev ? dev_to_node(hwif->
dev) : -1;
1531 static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
1533 ide_drive_t *peer = drive->
hwif->devices[(drive->
dn ^ 1) & 1];
1538 static inline void *ide_get_drivedata(ide_drive_t *drive)
1543 static inline void ide_set_drivedata(ide_drive_t *drive,
void *
data)
1548 #define ide_port_for_each_dev(i, dev, port) \
1549 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
1551 #define ide_port_for_each_present_dev(i, dev, port) \
1552 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) \
1553 if ((dev)->dev_flags & IDE_DFLAG_PRESENT)
1555 #define ide_host_for_each_port(i, port, host) \
1556 for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++)