aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ide.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r--include/linux/ide.h193
1 files changed, 124 insertions, 69 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 4726126f5a59..d67ccca2b964 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -178,6 +178,7 @@ typedef struct hw_regs_s {
178 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ 178 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
179 hwif_chipset_t chipset; 179 hwif_chipset_t chipset;
180 struct device *dev, *parent; 180 struct device *dev, *parent;
181 unsigned long config;
181} hw_regs_t; 182} hw_regs_t;
182 183
183void ide_init_port_data(struct hwif_s *, unsigned int); 184void ide_init_port_data(struct hwif_s *, unsigned int);
@@ -307,7 +308,65 @@ struct ide_acpi_drive_link;
307struct ide_acpi_hwif_link; 308struct ide_acpi_hwif_link;
308#endif 309#endif
309 310
310typedef struct ide_drive_s { 311/* ATAPI device flags */
312enum {
313 IDE_AFLAG_DRQ_INTERRUPT = (1 << 0),
314 IDE_AFLAG_MEDIA_CHANGED = (1 << 1),
315
316 /* ide-cd */
317 /* Drive cannot lock the door. */
318 IDE_AFLAG_NO_DOORLOCK = (1 << 2),
319 /* Drive cannot eject the disc. */
320 IDE_AFLAG_NO_EJECT = (1 << 3),
321 /* Drive is a pre ATAPI 1.2 drive. */
322 IDE_AFLAG_PRE_ATAPI12 = (1 << 4),
323 /* TOC addresses are in BCD. */
324 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5),
325 /* TOC track numbers are in BCD. */
326 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6),
327 /*
328 * Drive does not provide data in multiples of SECTOR_SIZE
329 * when more than one interrupt is needed.
330 */
331 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7),
332 /* Seeking in progress. */
333 IDE_AFLAG_SEEKING = (1 << 8),
334 /* Saved TOC information is current. */
335 IDE_AFLAG_TOC_VALID = (1 << 9),
336 /* We think that the drive door is locked. */
337 IDE_AFLAG_DOOR_LOCKED = (1 << 10),
338 /* SET_CD_SPEED command is unsupported. */
339 IDE_AFLAG_NO_SPEED_SELECT = (1 << 11),
340 IDE_AFLAG_VERTOS_300_SSD = (1 << 12),
341 IDE_AFLAG_VERTOS_600_ESD = (1 << 13),
342 IDE_AFLAG_SANYO_3CD = (1 << 14),
343 IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15),
344 IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16),
345 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17),
346
347 /* ide-floppy */
348 /* Format in progress */
349 IDE_AFLAG_FORMAT_IN_PROGRESS = (1 << 18),
350 /* Avoid commands not supported in Clik drive */
351 IDE_AFLAG_CLIK_DRIVE = (1 << 19),
352 /* Requires BH algorithm for packets */
353 IDE_AFLAG_ZIP_DRIVE = (1 << 20),
354
355 /* ide-tape */
356 IDE_AFLAG_IGNORE_DSC = (1 << 21),
357 /* 0 When the tape position is unknown */
358 IDE_AFLAG_ADDRESS_VALID = (1 << 22),
359 /* Device already opened */
360 IDE_AFLAG_BUSY = (1 << 23),
361 /* Attempt to auto-detect the current user block size */
362 IDE_AFLAG_DETECT_BS = (1 << 24),
363 /* Currently on a filemark */
364 IDE_AFLAG_FILEMARK = (1 << 25),
365 /* 0 = no tape is loaded, so we don't rewind after ejecting */
366 IDE_AFLAG_MEDIUM_PRESENT = (1 << 26)
367};
368
369struct ide_drive_s {
311 char name[4]; /* drive name, such as "hda" */ 370 char name[4]; /* drive name, such as "hda" */
312 char driver_req[10]; /* requests specific driver */ 371 char driver_req[10]; /* requests specific driver */
313 372
@@ -355,7 +414,6 @@ typedef struct ide_drive_s {
355 unsigned nodma : 1; /* disallow DMA */ 414 unsigned nodma : 1; /* disallow DMA */
356 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ 415 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
357 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ 416 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
358 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */
359 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ 417 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */
360 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ 418 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */
361 unsigned post_reset : 1; 419 unsigned post_reset : 1;
@@ -400,7 +458,14 @@ typedef struct ide_drive_s {
400 struct list_head list; 458 struct list_head list;
401 struct device gendev; 459 struct device gendev;
402 struct completion gendev_rel_comp; /* to deal with device release() */ 460 struct completion gendev_rel_comp; /* to deal with device release() */
403} ide_drive_t; 461
462 /* callback for packet commands */
463 void (*pc_callback)(struct ide_drive_s *);
464
465 unsigned long atapi_flags;
466};
467
468typedef struct ide_drive_s ide_drive_t;
404 469
405#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) 470#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
406 471
@@ -408,8 +473,28 @@ typedef struct ide_drive_s {
408 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) 473 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
409#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) 474#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
410 475
476struct ide_task_s;
411struct ide_port_info; 477struct ide_port_info;
412 478
479struct ide_tp_ops {
480 void (*exec_command)(struct hwif_s *, u8);
481 u8 (*read_status)(struct hwif_s *);
482 u8 (*read_altstatus)(struct hwif_s *);
483 u8 (*read_sff_dma_status)(struct hwif_s *);
484
485 void (*set_irq)(struct hwif_s *, int);
486
487 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
488 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
489
490 void (*input_data)(ide_drive_t *, struct request *, void *,
491 unsigned int);
492 void (*output_data)(ide_drive_t *, struct request *, void *,
493 unsigned int);
494};
495
496extern const struct ide_tp_ops default_tp_ops;
497
413struct ide_port_ops { 498struct ide_port_ops {
414 /* host specific initialization of a device */ 499 /* host specific initialization of a device */
415 void (*init_dev)(ide_drive_t *); 500 void (*init_dev)(ide_drive_t *);
@@ -447,8 +532,6 @@ struct ide_dma_ops {
447 void (*dma_timeout)(struct ide_drive_s *); 532 void (*dma_timeout)(struct ide_drive_s *);
448}; 533};
449 534
450struct ide_task_s;
451
452typedef struct hwif_s { 535typedef struct hwif_s {
453 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 536 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
454 struct hwif_s *mate; /* other hwif from same PCI chip */ 537 struct hwif_s *mate; /* other hwif from same PCI chip */
@@ -486,22 +569,12 @@ typedef struct hwif_s {
486 569
487 void (*rw_disk)(ide_drive_t *, struct request *); 570 void (*rw_disk)(ide_drive_t *, struct request *);
488 571
572 const struct ide_tp_ops *tp_ops;
489 const struct ide_port_ops *port_ops; 573 const struct ide_port_ops *port_ops;
490 const struct ide_dma_ops *dma_ops; 574 const struct ide_dma_ops *dma_ops;
491 575
492 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
493 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
494
495 void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
496 void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
497
498 void (*ide_dma_clear_irq)(ide_drive_t *drive); 576 void (*ide_dma_clear_irq)(ide_drive_t *drive);
499 577
500 void (*OUTB)(u8 addr, unsigned long port);
501 void (*OUTBSYNC)(struct hwif_s *hwif, u8 addr, unsigned long port);
502
503 u8 (*INB)(unsigned long port);
504
505 /* dma physical region descriptor table (cpu view) */ 578 /* dma physical region descriptor table (cpu view) */
506 unsigned int *dmatable_cpu; 579 unsigned int *dmatable_cpu;
507 /* dma physical region descriptor table (dma view) */ 580 /* dma physical region descriptor table (dma view) */
@@ -524,8 +597,6 @@ typedef struct hwif_s {
524 int irq; /* our irq number */ 597 int irq; /* our irq number */
525 598
526 unsigned long dma_base; /* base addr for dma ports */ 599 unsigned long dma_base; /* base addr for dma ports */
527 unsigned long dma_command; /* dma command register */
528 unsigned long dma_status; /* dma status register */
529 600
530 unsigned long config_data; /* for use by chipset-specific code */ 601 unsigned long config_data; /* for use by chipset-specific code */
531 unsigned long select_data; /* for use by chipset-specific code */ 602 unsigned long select_data; /* for use by chipset-specific code */
@@ -552,6 +623,11 @@ typedef struct hwif_s {
552#endif 623#endif
553} ____cacheline_internodealigned_in_smp ide_hwif_t; 624} ____cacheline_internodealigned_in_smp ide_hwif_t;
554 625
626struct ide_host {
627 ide_hwif_t *ports[MAX_HWIFS];
628 unsigned int n_ports;
629};
630
555/* 631/*
556 * internal ide interrupt handler type 632 * internal ide interrupt handler type
557 */ 633 */
@@ -611,8 +687,6 @@ enum {
611 PC_FLAG_WRITING = (1 << 6), 687 PC_FLAG_WRITING = (1 << 6),
612 /* command timed out */ 688 /* command timed out */
613 PC_FLAG_TIMEDOUT = (1 << 7), 689 PC_FLAG_TIMEDOUT = (1 << 7),
614 PC_FLAG_ZIP_DRIVE = (1 << 8),
615 PC_FLAG_DRQ_INTERRUPT = (1 << 9),
616}; 690};
617 691
618struct ide_atapi_pc { 692struct ide_atapi_pc {
@@ -646,8 +720,6 @@ struct ide_atapi_pc {
646 */ 720 */
647 u8 pc_buf[256]; 721 u8 pc_buf[256];
648 722
649 void (*callback)(ide_drive_t *);
650
651 /* idetape only */ 723 /* idetape only */
652 struct idetape_bh *bh; 724 struct idetape_bh *bh;
653 char *b_data; 725 char *b_data;
@@ -807,13 +879,6 @@ int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsig
807extern int ide_vlb_clk; 879extern int ide_vlb_clk;
808extern int ide_pci_clk; 880extern int ide_pci_clk;
809 881
810ide_hwif_t *ide_find_port_slot(const struct ide_port_info *);
811
812static inline ide_hwif_t *ide_find_port(void)
813{
814 return ide_find_port_slot(NULL);
815}
816
817extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 882extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
818int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 883int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
819 int uptodate, int nr_sectors); 884 int uptodate, int nr_sectors);
@@ -884,6 +949,7 @@ enum {
884 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | 949 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
885 IDE_TFLAG_IN_HOB_NSECT | 950 IDE_TFLAG_IN_HOB_NSECT |
886 IDE_TFLAG_IN_HOB_LBA, 951 IDE_TFLAG_IN_HOB_LBA,
952 IDE_TFLAG_IN_FEATURE = (1 << 1),
887 IDE_TFLAG_IN_NSECT = (1 << 25), 953 IDE_TFLAG_IN_NSECT = (1 << 25),
888 IDE_TFLAG_IN_LBAL = (1 << 26), 954 IDE_TFLAG_IN_LBAL = (1 << 26),
889 IDE_TFLAG_IN_LBAM = (1 << 27), 955 IDE_TFLAG_IN_LBAM = (1 << 27),
@@ -948,9 +1014,25 @@ typedef struct ide_task_s {
948 1014
949void ide_tf_dump(const char *, struct ide_taskfile *); 1015void ide_tf_dump(const char *, struct ide_taskfile *);
950 1016
1017void ide_exec_command(ide_hwif_t *, u8);
1018u8 ide_read_status(ide_hwif_t *);
1019u8 ide_read_altstatus(ide_hwif_t *);
1020u8 ide_read_sff_dma_status(ide_hwif_t *);
1021
1022void ide_set_irq(ide_hwif_t *, int);
1023
1024void ide_tf_load(ide_drive_t *, ide_task_t *);
1025void ide_tf_read(ide_drive_t *, ide_task_t *);
1026
1027void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
1028void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
1029
951extern void SELECT_DRIVE(ide_drive_t *); 1030extern void SELECT_DRIVE(ide_drive_t *);
952void SELECT_MASK(ide_drive_t *, int); 1031void SELECT_MASK(ide_drive_t *, int);
953 1032
1033u8 ide_read_error(ide_drive_t *);
1034void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *);
1035
954extern int drive_is_ready(ide_drive_t *); 1036extern int drive_is_ready(ide_drive_t *);
955 1037
956void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 1038void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
@@ -1000,12 +1082,15 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
1000#define ide_pci_register_driver(d) pci_register_driver(d) 1082#define ide_pci_register_driver(d) pci_register_driver(d)
1001#endif 1083#endif
1002 1084
1003void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); 1085void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int,
1086 hw_regs_t *, hw_regs_t **);
1004void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1087void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1005 1088
1006#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1089#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1007int ide_pci_set_master(struct pci_dev *, const char *); 1090int ide_pci_set_master(struct pci_dev *, const char *);
1008unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); 1091unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
1092extern const struct ide_dma_ops sff_dma_ops;
1093int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *);
1009int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1094int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
1010#else 1095#else
1011static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, 1096static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
@@ -1015,10 +1100,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1015} 1100}
1016#endif 1101#endif
1017 1102
1018extern void default_hwif_iops(ide_hwif_t *);
1019extern void default_hwif_mmiops(ide_hwif_t *);
1020extern void default_hwif_transport(ide_hwif_t *);
1021
1022typedef struct ide_pci_enablebit_s { 1103typedef struct ide_pci_enablebit_s {
1023 u8 reg; /* byte pci reg holding the enable-bit */ 1104 u8 reg; /* byte pci reg holding the enable-bit */
1024 u8 mask; /* mask to isolate the enable-bit */ 1105 u8 mask; /* mask to isolate the enable-bit */
@@ -1081,7 +1162,6 @@ enum {
1081 IDE_HFLAG_IO_32BIT = (1 << 24), 1162 IDE_HFLAG_IO_32BIT = (1 << 24),
1082 /* unmask IRQs */ 1163 /* unmask IRQs */
1083 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1164 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1084 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1085 /* serialize ports if DMA is possible (for sl82c105) */ 1165 /* serialize ports if DMA is possible (for sl82c105) */
1086 IDE_HFLAG_SERIALIZE_DMA = (1 << 27), 1166 IDE_HFLAG_SERIALIZE_DMA = (1 << 27),
1087 /* force host out of "simplex" mode */ 1167 /* force host out of "simplex" mode */
@@ -1092,8 +1172,6 @@ enum {
1092 IDE_HFLAG_NO_IO_32BIT = (1 << 30), 1172 IDE_HFLAG_NO_IO_32BIT = (1 << 30),
1093 /* never unmask IRQs */ 1173 /* never unmask IRQs */
1094 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), 1174 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31),
1095 /* host uses VDMA (disabled for now) */
1096 IDE_HFLAG_VDMA = 0,
1097}; 1175};
1098 1176
1099#ifdef CONFIG_BLK_DEV_OFFBOARD 1177#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1110,6 +1188,7 @@ struct ide_port_info {
1110 int (*init_dma)(ide_hwif_t *, 1188 int (*init_dma)(ide_hwif_t *,
1111 const struct ide_port_info *); 1189 const struct ide_port_info *);
1112 1190
1191 const struct ide_tp_ops *tp_ops;
1113 const struct ide_port_ops *port_ops; 1192 const struct ide_port_ops *port_ops;
1114 const struct ide_dma_ops *dma_ops; 1193 const struct ide_dma_ops *dma_ops;
1115 1194
@@ -1163,7 +1242,6 @@ void ide_destroy_dmatable(ide_drive_t *);
1163extern int ide_build_dmatable(ide_drive_t *, struct request *); 1242extern int ide_build_dmatable(ide_drive_t *, struct request *);
1164int ide_allocate_dma_engine(ide_hwif_t *); 1243int ide_allocate_dma_engine(ide_hwif_t *);
1165void ide_release_dma_engine(ide_hwif_t *); 1244void ide_release_dma_engine(ide_hwif_t *);
1166void ide_setup_dma(ide_hwif_t *, unsigned long);
1167 1245
1168void ide_dma_host_set(ide_drive_t *, int); 1246void ide_dma_host_set(ide_drive_t *, int);
1169extern int ide_dma_setup(ide_drive_t *); 1247extern int ide_dma_setup(ide_drive_t *);
@@ -1217,8 +1295,14 @@ void ide_undecoded_slave(ide_drive_t *);
1217 1295
1218void ide_port_apply_params(ide_hwif_t *); 1296void ide_port_apply_params(ide_hwif_t *);
1219 1297
1220int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1298struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **);
1221int ide_device_add(u8 idx[4], const struct ide_port_info *); 1299struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
1300void ide_host_free(struct ide_host *);
1301int ide_host_register(struct ide_host *, const struct ide_port_info *,
1302 hw_regs_t **);
1303int ide_host_add(const struct ide_port_info *, hw_regs_t **,
1304 struct ide_host **);
1305void ide_host_remove(struct ide_host *);
1222int ide_legacy_device_add(const struct ide_port_info *, unsigned long); 1306int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
1223void ide_port_unregister_devices(ide_hwif_t *); 1307void ide_port_unregister_devices(ide_hwif_t *);
1224void ide_port_scan(ide_hwif_t *); 1308void ide_port_scan(ide_hwif_t *);
@@ -1350,33 +1434,4 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1350 1434
1351 return &hwif->drives[(drive->dn ^ 1) & 1]; 1435 return &hwif->drives[(drive->dn ^ 1) & 1];
1352} 1436}
1353
1354static inline void ide_set_irq(ide_drive_t *drive, int on)
1355{
1356 ide_hwif_t *hwif = drive->hwif;
1357
1358 hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | (on ? 0 : 2),
1359 hwif->io_ports.ctl_addr);
1360}
1361
1362static inline u8 ide_read_status(ide_drive_t *drive)
1363{
1364 ide_hwif_t *hwif = drive->hwif;
1365
1366 return hwif->INB(hwif->io_ports.status_addr);
1367}
1368
1369static inline u8 ide_read_altstatus(ide_drive_t *drive)
1370{
1371 ide_hwif_t *hwif = drive->hwif;
1372
1373 return hwif->INB(hwif->io_ports.ctl_addr);
1374}
1375
1376static inline u8 ide_read_error(ide_drive_t *drive)
1377{
1378 ide_hwif_t *hwif = drive->hwif;
1379
1380 return hwif->INB(hwif->io_ports.error_addr);
1381}
1382#endif /* _IDE_H */ 1437#endif /* _IDE_H */