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.h250
1 files changed, 108 insertions, 142 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index e99c56de7f56..3644f6323384 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -33,24 +33,13 @@
33#endif 33#endif
34 34
35/* 35/*
36 * Used to indicate "no IRQ", should be a value that cannot be an IRQ
37 * number.
38 */
39
40#define IDE_NO_IRQ (-1)
41
42typedef unsigned char byte; /* used everywhere */
43
44/*
45 * Probably not wise to fiddle with these 36 * Probably not wise to fiddle with these
46 */ 37 */
38#define IDE_DEFAULT_MAX_FAILURES 1
47#define ERROR_MAX 8 /* Max read/write errors per sector */ 39#define ERROR_MAX 8 /* Max read/write errors per sector */
48#define ERROR_RESET 3 /* Reset controller every 4th retry */ 40#define ERROR_RESET 3 /* Reset controller every 4th retry */
49#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ 41#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
50 42
51#define HWIF(drive) ((ide_hwif_t *)((drive)->hwif))
52#define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
53
54/* 43/*
55 * Definitions for accessing IDE controller registers 44 * Definitions for accessing IDE controller registers
56 */ 45 */
@@ -192,9 +181,6 @@ typedef struct hw_regs_s {
192 unsigned long config; 181 unsigned long config;
193} hw_regs_t; 182} hw_regs_t;
194 183
195void ide_init_port_data(struct hwif_s *, unsigned int);
196void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
197
198static inline void ide_std_init_ports(hw_regs_t *hw, 184static inline void ide_std_init_ports(hw_regs_t *hw,
199 unsigned long io_addr, 185 unsigned long io_addr,
200 unsigned long ctl_addr) 186 unsigned long ctl_addr)
@@ -403,6 +389,7 @@ enum {
403 * This is used for several packet commands (not for READ/WRITE commands). 389 * This is used for several packet commands (not for READ/WRITE commands).
404 */ 390 */
405#define IDE_PC_BUFFER_SIZE 256 391#define IDE_PC_BUFFER_SIZE 256
392#define ATAPI_WAIT_PC (60 * HZ)
406 393
407struct ide_atapi_pc { 394struct ide_atapi_pc {
408 /* actual packet bytes */ 395 /* actual packet bytes */
@@ -439,18 +426,14 @@ struct ide_atapi_pc {
439 struct idetape_bh *bh; 426 struct idetape_bh *bh;
440 char *b_data; 427 char *b_data;
441 428
442 /* idescsi only for now */
443 struct scatterlist *sg; 429 struct scatterlist *sg;
444 unsigned int sg_cnt; 430 unsigned int sg_cnt;
445 431
446 struct scsi_cmnd *scsi_cmd;
447 void (*done) (struct scsi_cmnd *);
448
449 unsigned long timeout; 432 unsigned long timeout;
450}; 433};
451 434
452struct ide_devset; 435struct ide_devset;
453struct ide_driver_s; 436struct ide_driver;
454 437
455#ifdef CONFIG_BLK_DEV_IDEACPI 438#ifdef CONFIG_BLK_DEV_IDEACPI
456struct ide_acpi_drive_link; 439struct ide_acpi_drive_link;
@@ -480,53 +463,53 @@ enum {
480 463
481 /* ide-cd */ 464 /* ide-cd */
482 /* Drive cannot eject the disc. */ 465 /* Drive cannot eject the disc. */
483 IDE_AFLAG_NO_EJECT = (1 << 3), 466 IDE_AFLAG_NO_EJECT = (1 << 1),
484 /* Drive is a pre ATAPI 1.2 drive. */ 467 /* Drive is a pre ATAPI 1.2 drive. */
485 IDE_AFLAG_PRE_ATAPI12 = (1 << 4), 468 IDE_AFLAG_PRE_ATAPI12 = (1 << 2),
486 /* TOC addresses are in BCD. */ 469 /* TOC addresses are in BCD. */
487 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5), 470 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3),
488 /* TOC track numbers are in BCD. */ 471 /* TOC track numbers are in BCD. */
489 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6), 472 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4),
490 /* 473 /*
491 * Drive does not provide data in multiples of SECTOR_SIZE 474 * Drive does not provide data in multiples of SECTOR_SIZE
492 * when more than one interrupt is needed. 475 * when more than one interrupt is needed.
493 */ 476 */
494 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), 477 IDE_AFLAG_LIMIT_NFRAMES = (1 << 5),
495 /* Saved TOC information is current. */ 478 /* Saved TOC information is current. */
496 IDE_AFLAG_TOC_VALID = (1 << 9), 479 IDE_AFLAG_TOC_VALID = (1 << 6),
497 /* We think that the drive door is locked. */ 480 /* We think that the drive door is locked. */
498 IDE_AFLAG_DOOR_LOCKED = (1 << 10), 481 IDE_AFLAG_DOOR_LOCKED = (1 << 7),
499 /* SET_CD_SPEED command is unsupported. */ 482 /* SET_CD_SPEED command is unsupported. */
500 IDE_AFLAG_NO_SPEED_SELECT = (1 << 11), 483 IDE_AFLAG_NO_SPEED_SELECT = (1 << 8),
501 IDE_AFLAG_VERTOS_300_SSD = (1 << 12), 484 IDE_AFLAG_VERTOS_300_SSD = (1 << 9),
502 IDE_AFLAG_VERTOS_600_ESD = (1 << 13), 485 IDE_AFLAG_VERTOS_600_ESD = (1 << 10),
503 IDE_AFLAG_SANYO_3CD = (1 << 14), 486 IDE_AFLAG_SANYO_3CD = (1 << 11),
504 IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15), 487 IDE_AFLAG_FULL_CAPS_PAGE = (1 << 12),
505 IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16), 488 IDE_AFLAG_PLAY_AUDIO_OK = (1 << 13),
506 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), 489 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 14),
507 490
508 /* ide-floppy */ 491 /* ide-floppy */
509 /* Avoid commands not supported in Clik drive */ 492 /* Avoid commands not supported in Clik drive */
510 IDE_AFLAG_CLIK_DRIVE = (1 << 19), 493 IDE_AFLAG_CLIK_DRIVE = (1 << 15),
511 /* Requires BH algorithm for packets */ 494 /* Requires BH algorithm for packets */
512 IDE_AFLAG_ZIP_DRIVE = (1 << 20), 495 IDE_AFLAG_ZIP_DRIVE = (1 << 16),
513 /* Supports format progress report */ 496 /* Supports format progress report */
514 IDE_AFLAG_SRFP = (1 << 22), 497 IDE_AFLAG_SRFP = (1 << 17),
515 498
516 /* ide-tape */ 499 /* ide-tape */
517 IDE_AFLAG_IGNORE_DSC = (1 << 23), 500 IDE_AFLAG_IGNORE_DSC = (1 << 18),
518 /* 0 When the tape position is unknown */ 501 /* 0 When the tape position is unknown */
519 IDE_AFLAG_ADDRESS_VALID = (1 << 24), 502 IDE_AFLAG_ADDRESS_VALID = (1 << 19),
520 /* Device already opened */ 503 /* Device already opened */
521 IDE_AFLAG_BUSY = (1 << 25), 504 IDE_AFLAG_BUSY = (1 << 20),
522 /* Attempt to auto-detect the current user block size */ 505 /* Attempt to auto-detect the current user block size */
523 IDE_AFLAG_DETECT_BS = (1 << 26), 506 IDE_AFLAG_DETECT_BS = (1 << 21),
524 /* Currently on a filemark */ 507 /* Currently on a filemark */
525 IDE_AFLAG_FILEMARK = (1 << 27), 508 IDE_AFLAG_FILEMARK = (1 << 22),
526 /* 0 = no tape is loaded, so we don't rewind after ejecting */ 509 /* 0 = no tape is loaded, so we don't rewind after ejecting */
527 IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), 510 IDE_AFLAG_MEDIUM_PRESENT = (1 << 23),
528 511
529 IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), 512 IDE_AFLAG_NO_AUTOCLOSE = (1 << 24),
530}; 513};
531 514
532/* device flags */ 515/* device flags */
@@ -565,28 +548,26 @@ enum {
565 IDE_DFLAG_NODMA = (1 << 16), 548 IDE_DFLAG_NODMA = (1 << 16),
566 /* powermanagment told us not to do anything, so sleep nicely */ 549 /* powermanagment told us not to do anything, so sleep nicely */
567 IDE_DFLAG_BLOCKED = (1 << 17), 550 IDE_DFLAG_BLOCKED = (1 << 17),
568 /* ide-scsi emulation */
569 IDE_DFLAG_SCSI = (1 << 18),
570 /* sleeping & sleep field valid */ 551 /* sleeping & sleep field valid */
571 IDE_DFLAG_SLEEPING = (1 << 19), 552 IDE_DFLAG_SLEEPING = (1 << 18),
572 IDE_DFLAG_POST_RESET = (1 << 20), 553 IDE_DFLAG_POST_RESET = (1 << 19),
573 IDE_DFLAG_UDMA33_WARNED = (1 << 21), 554 IDE_DFLAG_UDMA33_WARNED = (1 << 20),
574 IDE_DFLAG_LBA48 = (1 << 22), 555 IDE_DFLAG_LBA48 = (1 << 21),
575 /* status of write cache */ 556 /* status of write cache */
576 IDE_DFLAG_WCACHE = (1 << 23), 557 IDE_DFLAG_WCACHE = (1 << 22),
577 /* used for ignoring ATA_DF */ 558 /* used for ignoring ATA_DF */
578 IDE_DFLAG_NOWERR = (1 << 24), 559 IDE_DFLAG_NOWERR = (1 << 23),
579 /* retrying in PIO */ 560 /* retrying in PIO */
580 IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), 561 IDE_DFLAG_DMA_PIO_RETRY = (1 << 24),
581 IDE_DFLAG_LBA = (1 << 26), 562 IDE_DFLAG_LBA = (1 << 25),
582 /* don't unload heads */ 563 /* don't unload heads */
583 IDE_DFLAG_NO_UNLOAD = (1 << 27), 564 IDE_DFLAG_NO_UNLOAD = (1 << 26),
584 /* heads unloaded, please don't reset port */ 565 /* heads unloaded, please don't reset port */
585 IDE_DFLAG_PARKED = (1 << 28), 566 IDE_DFLAG_PARKED = (1 << 27),
586 IDE_DFLAG_MEDIA_CHANGED = (1 << 29), 567 IDE_DFLAG_MEDIA_CHANGED = (1 << 28),
587 /* write protect */ 568 /* write protect */
588 IDE_DFLAG_WP = (1 << 30), 569 IDE_DFLAG_WP = (1 << 29),
589 IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 31), 570 IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 30),
590}; 571};
591 572
592struct ide_drive_s { 573struct ide_drive_s {
@@ -596,7 +577,6 @@ struct ide_drive_s {
596 struct request_queue *queue; /* request queue */ 577 struct request_queue *queue; /* request queue */
597 578
598 struct request *rq; /* current request */ 579 struct request *rq; /* current request */
599 struct ide_drive_s *next; /* circular list of hwgroup drives */
600 void *driver_data; /* extra driver data */ 580 void *driver_data; /* extra driver data */
601 u16 *id; /* identification info */ 581 u16 *id; /* identification info */
602#ifdef CONFIG_IDE_PROC_FS 582#ifdef CONFIG_IDE_PROC_FS
@@ -610,8 +590,6 @@ struct ide_drive_s {
610 unsigned long dev_flags; 590 unsigned long dev_flags;
611 591
612 unsigned long sleep; /* sleep until this time */ 592 unsigned long sleep; /* sleep until this time */
613 unsigned long service_start; /* time we started last request */
614 unsigned long service_time; /* service time of last request */
615 unsigned long timeout; /* max time to wait for irq */ 593 unsigned long timeout; /* max time to wait for irq */
616 594
617 special_t special; /* special action flags */ 595 special_t special; /* special action flags */
@@ -672,6 +650,8 @@ struct ide_drive_s {
672 int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, 650 int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *,
673 unsigned int, int); 651 unsigned int, int);
674 652
653 ide_startstop_t (*irq_handler)(struct ide_drive_s *);
654
675 unsigned long atapi_flags; 655 unsigned long atapi_flags;
676 656
677 struct ide_atapi_pc request_sense_pc; 657 struct ide_atapi_pc request_sense_pc;
@@ -694,7 +674,6 @@ struct ide_tp_ops {
694 void (*exec_command)(struct hwif_s *, u8); 674 void (*exec_command)(struct hwif_s *, u8);
695 u8 (*read_status)(struct hwif_s *); 675 u8 (*read_status)(struct hwif_s *);
696 u8 (*read_altstatus)(struct hwif_s *); 676 u8 (*read_altstatus)(struct hwif_s *);
697 u8 (*read_sff_dma_status)(struct hwif_s *);
698 677
699 void (*set_irq)(struct hwif_s *, int); 678 void (*set_irq)(struct hwif_s *, int);
700 679
@@ -755,14 +734,17 @@ struct ide_dma_ops {
755 int (*dma_test_irq)(struct ide_drive_s *); 734 int (*dma_test_irq)(struct ide_drive_s *);
756 void (*dma_lost_irq)(struct ide_drive_s *); 735 void (*dma_lost_irq)(struct ide_drive_s *);
757 void (*dma_timeout)(struct ide_drive_s *); 736 void (*dma_timeout)(struct ide_drive_s *);
737 /*
738 * The following method is optional and only required to be
739 * implemented for the SFF-8038i compatible controllers.
740 */
741 u8 (*dma_sff_read_status)(struct hwif_s *);
758}; 742};
759 743
760struct ide_host; 744struct ide_host;
761 745
762typedef struct hwif_s { 746typedef struct hwif_s {
763 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
764 struct hwif_s *mate; /* other hwif from same PCI chip */ 747 struct hwif_s *mate; /* other hwif from same PCI chip */
765 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
766 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 748 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
767 749
768 struct ide_host *host; 750 struct ide_host *host;
@@ -773,7 +755,7 @@ typedef struct hwif_s {
773 755
774 unsigned long sata_scr[SATA_NR_PORTS]; 756 unsigned long sata_scr[SATA_NR_PORTS];
775 757
776 ide_drive_t drives[MAX_DRIVES]; /* drive info */ 758 ide_drive_t *devices[MAX_DRIVES + 1];
777 759
778 u8 major; /* our major number */ 760 u8 major; /* our major number */
779 u8 index; /* 0 for ide0; 1 for ide1; ... */ 761 u8 index; /* 0 for ide0; 1 for ide1; ... */
@@ -839,7 +821,7 @@ typedef struct hwif_s {
839 unsigned extra_ports; /* number of extra dma ports */ 821 unsigned extra_ports; /* number of extra dma ports */
840 822
841 unsigned present : 1; /* this interface exists */ 823 unsigned present : 1; /* this interface exists */
842 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 824 unsigned busy : 1; /* serializes devices on a port */
843 825
844 struct device gendev; 826 struct device gendev;
845 struct device *portdev; 827 struct device *portdev;
@@ -851,19 +833,49 @@ typedef struct hwif_s {
851#ifdef CONFIG_BLK_DEV_IDEACPI 833#ifdef CONFIG_BLK_DEV_IDEACPI
852 struct ide_acpi_hwif_link *acpidata; 834 struct ide_acpi_hwif_link *acpidata;
853#endif 835#endif
836
837 /* IRQ handler, if active */
838 ide_startstop_t (*handler)(ide_drive_t *);
839
840 /* BOOL: polling active & poll_timeout field valid */
841 unsigned int polling : 1;
842
843 /* current drive */
844 ide_drive_t *cur_dev;
845
846 /* current request */
847 struct request *rq;
848
849 /* failsafe timer */
850 struct timer_list timer;
851 /* timeout value during long polls */
852 unsigned long poll_timeout;
853 /* queried upon timeouts */
854 int (*expiry)(ide_drive_t *);
855
856 int req_gen;
857 int req_gen_timer;
858
859 spinlock_t lock;
854} ____cacheline_internodealigned_in_smp ide_hwif_t; 860} ____cacheline_internodealigned_in_smp ide_hwif_t;
855 861
856#define MAX_HOST_PORTS 4 862#define MAX_HOST_PORTS 4
857 863
858struct ide_host { 864struct ide_host {
859 ide_hwif_t *ports[MAX_HOST_PORTS]; 865 ide_hwif_t *ports[MAX_HOST_PORTS + 1];
860 unsigned int n_ports; 866 unsigned int n_ports;
861 struct device *dev[2]; 867 struct device *dev[2];
862 unsigned int (*init_chipset)(struct pci_dev *); 868 unsigned int (*init_chipset)(struct pci_dev *);
863 unsigned long host_flags; 869 unsigned long host_flags;
864 void *host_priv; 870 void *host_priv;
871 ide_hwif_t *cur_port; /* for hosts requiring serialization */
872
873 /* used for hosts requiring serialization */
874 volatile long host_busy;
865}; 875};
866 876
877#define IDE_HOST_BUSY 0
878
867/* 879/*
868 * internal ide interrupt handler type 880 * internal ide interrupt handler type
869 */ 881 */
@@ -873,40 +885,6 @@ typedef int (ide_expiry_t)(ide_drive_t *);
873/* used by ide-cd, ide-floppy, etc. */ 885/* used by ide-cd, ide-floppy, etc. */
874typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); 886typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned);
875 887
876typedef struct hwgroup_s {
877 /* irq handler, if active */
878 ide_startstop_t (*handler)(ide_drive_t *);
879
880 /* BOOL: protects all fields below */
881 volatile int busy;
882 /* BOOL: wake us up on timer expiry */
883 unsigned int sleeping : 1;
884 /* BOOL: polling active & poll_timeout field valid */
885 unsigned int polling : 1;
886
887 /* current drive */
888 ide_drive_t *drive;
889 /* ptr to current hwif in linked-list */
890 ide_hwif_t *hwif;
891
892 /* current request */
893 struct request *rq;
894
895 /* failsafe timer */
896 struct timer_list timer;
897 /* timeout value during long polls */
898 unsigned long poll_timeout;
899 /* queried upon timeouts */
900 int (*expiry)(ide_drive_t *);
901
902 int req_gen;
903 int req_gen_timer;
904
905 spinlock_t lock;
906} ide_hwgroup_t;
907
908typedef struct ide_driver_s ide_driver_t;
909
910extern struct mutex ide_setting_mtx; 888extern struct mutex ide_setting_mtx;
911 889
912/* 890/*
@@ -1032,8 +1010,8 @@ void ide_proc_register_port(ide_hwif_t *);
1032void ide_proc_port_register_devices(ide_hwif_t *); 1010void ide_proc_port_register_devices(ide_hwif_t *);
1033void ide_proc_unregister_device(ide_drive_t *); 1011void ide_proc_unregister_device(ide_drive_t *);
1034void ide_proc_unregister_port(ide_hwif_t *); 1012void ide_proc_unregister_port(ide_hwif_t *);
1035void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 1013void ide_proc_register_driver(ide_drive_t *, struct ide_driver *);
1036void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 1014void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *);
1037 1015
1038read_proc_t proc_ide_read_capacity; 1016read_proc_t proc_ide_read_capacity;
1039read_proc_t proc_ide_read_geometry; 1017read_proc_t proc_ide_read_geometry;
@@ -1060,8 +1038,10 @@ static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; }
1060static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } 1038static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; }
1061static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } 1039static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; }
1062static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 1040static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
1063static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 1041static inline void ide_proc_register_driver(ide_drive_t *drive,
1064static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 1042 struct ide_driver *driver) { ; }
1043static inline void ide_proc_unregister_driver(ide_drive_t *drive,
1044 struct ide_driver *driver) { ; }
1065#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; 1045#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
1066#endif 1046#endif
1067 1047
@@ -1130,11 +1110,10 @@ void ide_check_pm_state(ide_drive_t *, struct request *);
1130 * The gendriver.owner field should be set to the module owner of this driver. 1110 * The gendriver.owner field should be set to the module owner of this driver.
1131 * The gendriver.name field should be set to the name of this driver 1111 * The gendriver.name field should be set to the name of this driver
1132 */ 1112 */
1133struct ide_driver_s { 1113struct ide_driver {
1134 const char *version; 1114 const char *version;
1135 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 1115 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
1136 int (*end_request)(ide_drive_t *, int, int); 1116 int (*end_request)(ide_drive_t *, int, int);
1137 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
1138 struct device_driver gen_driver; 1117 struct device_driver gen_driver;
1139 int (*probe)(ide_drive_t *); 1118 int (*probe)(ide_drive_t *);
1140 void (*remove)(ide_drive_t *); 1119 void (*remove)(ide_drive_t *);
@@ -1146,7 +1125,7 @@ struct ide_driver_s {
1146#endif 1125#endif
1147}; 1126};
1148 1127
1149#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 1128#define to_ide_driver(drv) container_of(drv, struct ide_driver, gen_driver)
1150 1129
1151int ide_device_get(ide_drive_t *); 1130int ide_device_get(ide_drive_t *);
1152void ide_device_put(ide_drive_t *); 1131void ide_device_put(ide_drive_t *);
@@ -1178,9 +1157,7 @@ void ide_execute_pkt_cmd(ide_drive_t *);
1178 1157
1179void ide_pad_transfer(ide_drive_t *, int, int); 1158void ide_pad_transfer(ide_drive_t *, int, int);
1180 1159
1181ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); 1160ide_startstop_t ide_error(ide_drive_t *, const char *, u8);
1182
1183ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
1184 1161
1185void ide_fix_driveid(u16 *); 1162void ide_fix_driveid(u16 *);
1186 1163
@@ -1204,7 +1181,6 @@ void ide_tf_dump(const char *, struct ide_taskfile *);
1204void ide_exec_command(ide_hwif_t *, u8); 1181void ide_exec_command(ide_hwif_t *, u8);
1205u8 ide_read_status(ide_hwif_t *); 1182u8 ide_read_status(ide_hwif_t *);
1206u8 ide_read_altstatus(ide_hwif_t *); 1183u8 ide_read_altstatus(ide_hwif_t *);
1207u8 ide_read_sff_dma_status(ide_hwif_t *);
1208 1184
1209void ide_set_irq(ide_hwif_t *, int); 1185void ide_set_irq(ide_hwif_t *, int);
1210 1186
@@ -1258,14 +1234,11 @@ int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1258void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); 1234void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
1259void ide_retry_pc(ide_drive_t *, struct gendisk *); 1235void ide_retry_pc(ide_drive_t *, struct gendisk *);
1260 1236
1261static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) 1237int ide_cd_expiry(ide_drive_t *);
1262{
1263 return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies);
1264}
1265 1238
1266int ide_scsi_expiry(ide_drive_t *); 1239int ide_cd_get_xferlen(struct request *);
1267 1240
1268ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); 1241ide_startstop_t ide_issue_pc(ide_drive_t *);
1269 1242
1270ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1243ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1271 1244
@@ -1322,11 +1295,11 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1322} 1295}
1323#endif 1296#endif
1324 1297
1325typedef struct ide_pci_enablebit_s { 1298struct ide_pci_enablebit {
1326 u8 reg; /* byte pci reg holding the enable-bit */ 1299 u8 reg; /* byte pci reg holding the enable-bit */
1327 u8 mask; /* mask to isolate the enable-bit */ 1300 u8 mask; /* mask to isolate the enable-bit */
1328 u8 val; /* value of masked reg when "enabled" */ 1301 u8 val; /* value of masked reg when "enabled" */
1329} ide_pci_enablebit_t; 1302};
1330 1303
1331enum { 1304enum {
1332 /* Uses ISA control ports not PCI ones. */ 1305 /* Uses ISA control ports not PCI ones. */
@@ -1415,7 +1388,8 @@ struct ide_port_info {
1415 const struct ide_port_ops *port_ops; 1388 const struct ide_port_ops *port_ops;
1416 const struct ide_dma_ops *dma_ops; 1389 const struct ide_dma_ops *dma_ops;
1417 1390
1418 ide_pci_enablebit_t enablebits[2]; 1391 struct ide_pci_enablebit enablebits[2];
1392
1419 hwif_chipset_t chipset; 1393 hwif_chipset_t chipset;
1420 1394
1421 u16 max_sectors; /* if < than the default one */ 1395 u16 max_sectors; /* if < than the default one */
@@ -1487,6 +1461,7 @@ void ide_dma_exec_cmd(ide_drive_t *, u8);
1487extern void ide_dma_start(ide_drive_t *); 1461extern void ide_dma_start(ide_drive_t *);
1488int ide_dma_end(ide_drive_t *); 1462int ide_dma_end(ide_drive_t *);
1489int ide_dma_test_irq(ide_drive_t *); 1463int ide_dma_test_irq(ide_drive_t *);
1464u8 ide_dma_sff_read_status(ide_hwif_t *);
1490extern const struct ide_dma_ops sff_dma_ops; 1465extern const struct ide_dma_ops sff_dma_ops;
1491#else 1466#else
1492static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } 1467static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
@@ -1524,15 +1499,13 @@ static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; }
1524static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} 1499static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
1525#endif 1500#endif
1526 1501
1527void ide_remove_port_from_hwgroup(ide_hwif_t *);
1528void ide_unregister(ide_hwif_t *);
1529
1530void ide_register_region(struct gendisk *); 1502void ide_register_region(struct gendisk *);
1531void ide_unregister_region(struct gendisk *); 1503void ide_unregister_region(struct gendisk *);
1532 1504
1533void ide_undecoded_slave(ide_drive_t *); 1505void ide_undecoded_slave(ide_drive_t *);
1534 1506
1535void ide_port_apply_params(ide_hwif_t *); 1507void ide_port_apply_params(ide_hwif_t *);
1508int ide_sysfs_register_port(ide_hwif_t *);
1536 1509
1537struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); 1510struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
1538void ide_host_free(struct ide_host *); 1511void ide_host_free(struct ide_host *);
@@ -1610,23 +1583,9 @@ static inline void ide_set_max_pio(ide_drive_t *drive)
1610 ide_set_pio(drive, 255); 1583 ide_set_pio(drive, 255);
1611} 1584}
1612 1585
1613extern spinlock_t ide_lock; 1586char *ide_media_string(ide_drive_t *);
1614extern struct mutex ide_cfg_mtx;
1615/*
1616 * Structure locking:
1617 *
1618 * ide_cfg_mtx and hwgroup->lock together protect changes to
1619 * ide_hwif_t->next
1620 * ide_drive_t->next
1621 *
1622 * ide_hwgroup_t->busy: hwgroup->lock
1623 * ide_hwgroup_t->hwif: hwgroup->lock
1624 * ide_hwif_t->{hwgroup,mate}: constant, no locking
1625 * ide_drive_t->hwif: constant, no locking
1626 */
1627
1628#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0)
1629 1587
1588extern struct device_attribute ide_dev_attrs[];
1630extern struct bus_type ide_bus_type; 1589extern struct bus_type ide_bus_type;
1631extern struct class *ide_port_class; 1590extern struct class *ide_port_class;
1632 1591
@@ -1642,8 +1601,15 @@ static inline int hwif_to_node(ide_hwif_t *hwif)
1642 1601
1643static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) 1602static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
1644{ 1603{
1645 ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; 1604 ide_drive_t *peer = drive->hwif->devices[(drive->dn ^ 1) & 1];
1646 1605
1647 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; 1606 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL;
1648} 1607}
1608
1609#define ide_port_for_each_dev(i, dev, port) \
1610 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
1611
1612#define ide_host_for_each_port(i, port, host) \
1613 for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++)
1614
1649#endif /* _IDE_H */ 1615#endif /* _IDE_H */