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.h144
1 files changed, 83 insertions, 61 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9918772bf274..4726126f5a59 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -139,6 +139,12 @@ struct ide_io_ports {
139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ 139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */
140 140
141/* 141/*
142 * Op codes for special requests to be handled by ide_special_rq().
143 * Values should be in the range of 0x20 to 0x3f.
144 */
145#define REQ_DRIVE_RESET 0x20
146
147/*
142 * Check for an interrupt and acknowledge the interrupt status 148 * Check for an interrupt and acknowledge the interrupt status
143 */ 149 */
144struct hwif_s; 150struct hwif_s;
@@ -171,7 +177,7 @@ typedef struct hw_regs_s {
171 int irq; /* our irq number */ 177 int irq; /* our irq number */
172 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ 178 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
173 hwif_chipset_t chipset; 179 hwif_chipset_t chipset;
174 struct device *dev; 180 struct device *dev, *parent;
175} hw_regs_t; 181} hw_regs_t;
176 182
177void ide_init_port_data(struct hwif_s *, unsigned int); 183void ide_init_port_data(struct hwif_s *, unsigned int);
@@ -189,6 +195,21 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
189 hw->io_ports.ctl_addr = ctl_addr; 195 hw->io_ports.ctl_addr = ctl_addr;
190} 196}
191 197
198/* for IDE PCI controllers in legacy mode, temporary */
199static inline int __ide_default_irq(unsigned long base)
200{
201 switch (base) {
202#ifdef CONFIG_IA64
203 case 0x1f0: return isa_irq_to_vector(14);
204 case 0x170: return isa_irq_to_vector(15);
205#else
206 case 0x1f0: return 14;
207 case 0x170: return 15;
208#endif
209 }
210 return 0;
211}
212
192#include <asm/ide.h> 213#include <asm/ide.h>
193 214
194#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED) 215#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED)
@@ -349,7 +370,6 @@ typedef struct ide_drive_s {
349 u8 wcache; /* status of write cache */ 370 u8 wcache; /* status of write cache */
350 u8 acoustic; /* acoustic management */ 371 u8 acoustic; /* acoustic management */
351 u8 media; /* disk, cdrom, tape, floppy, ... */ 372 u8 media; /* disk, cdrom, tape, floppy, ... */
352 u8 ctl; /* "normal" value for Control register */
353 u8 ready_stat; /* min status value for drive ready */ 373 u8 ready_stat; /* min status value for drive ready */
354 u8 mult_count; /* current multiple sector setting */ 374 u8 mult_count; /* current multiple sector setting */
355 u8 mult_req; /* requested multiple sector setting */ 375 u8 mult_req; /* requested multiple sector setting */
@@ -391,8 +411,8 @@ typedef struct ide_drive_s {
391struct ide_port_info; 411struct ide_port_info;
392 412
393struct ide_port_ops { 413struct ide_port_ops {
394 /* host specific initialization of devices on a port */ 414 /* host specific initialization of a device */
395 void (*port_init_devs)(struct hwif_s *); 415 void (*init_dev)(ide_drive_t *);
396 /* routine to program host for PIO mode */ 416 /* routine to program host for PIO mode */
397 void (*set_pio_mode)(ide_drive_t *, const u8); 417 void (*set_pio_mode)(ide_drive_t *, const u8);
398 /* routine to program host for DMA mode */ 418 /* routine to program host for DMA mode */
@@ -478,7 +498,7 @@ typedef struct hwif_s {
478 void (*ide_dma_clear_irq)(ide_drive_t *drive); 498 void (*ide_dma_clear_irq)(ide_drive_t *drive);
479 499
480 void (*OUTB)(u8 addr, unsigned long port); 500 void (*OUTB)(u8 addr, unsigned long port);
481 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); 501 void (*OUTBSYNC)(struct hwif_s *hwif, u8 addr, unsigned long port);
482 502
483 u8 (*INB)(unsigned long port); 503 u8 (*INB)(unsigned long port);
484 504
@@ -517,7 +537,6 @@ typedef struct hwif_s {
517 unsigned serialized : 1; /* serialized all channel operation */ 537 unsigned serialized : 1; /* serialized all channel operation */
518 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 538 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
519 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 539 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
520 unsigned mmio : 1; /* host uses MMIO */
521 540
522 struct device gendev; 541 struct device gendev;
523 struct device *portdev; 542 struct device *portdev;
@@ -552,8 +571,6 @@ typedef struct hwgroup_s {
552 unsigned int sleeping : 1; 571 unsigned int sleeping : 1;
553 /* BOOL: polling active & poll_timeout field valid */ 572 /* BOOL: polling active & poll_timeout field valid */
554 unsigned int polling : 1; 573 unsigned int polling : 1;
555 /* BOOL: in a polling reset situation. Must not trigger another reset yet */
556 unsigned int resetting : 1;
557 574
558 /* current drive */ 575 /* current drive */
559 ide_drive_t *drive; 576 ide_drive_t *drive;
@@ -589,12 +606,13 @@ enum {
589 PC_FLAG_SUPPRESS_ERROR = (1 << 1), 606 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
590 PC_FLAG_WAIT_FOR_DSC = (1 << 2), 607 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
591 PC_FLAG_DMA_OK = (1 << 3), 608 PC_FLAG_DMA_OK = (1 << 3),
592 PC_FLAG_DMA_RECOMMENDED = (1 << 4), 609 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
593 PC_FLAG_DMA_IN_PROGRESS = (1 << 5), 610 PC_FLAG_DMA_ERROR = (1 << 5),
594 PC_FLAG_DMA_ERROR = (1 << 6), 611 PC_FLAG_WRITING = (1 << 6),
595 PC_FLAG_WRITING = (1 << 7),
596 /* command timed out */ 612 /* command timed out */
597 PC_FLAG_TIMEDOUT = (1 << 8), 613 PC_FLAG_TIMEDOUT = (1 << 7),
614 PC_FLAG_ZIP_DRIVE = (1 << 8),
615 PC_FLAG_DRQ_INTERRUPT = (1 << 9),
598}; 616};
599 617
600struct ide_atapi_pc { 618struct ide_atapi_pc {
@@ -627,8 +645,8 @@ struct ide_atapi_pc {
627 * to change/removal later. 645 * to change/removal later.
628 */ 646 */
629 u8 pc_buf[256]; 647 u8 pc_buf[256];
630 void (*idefloppy_callback) (ide_drive_t *); 648
631 ide_startstop_t (*idetape_callback) (ide_drive_t *); 649 void (*callback)(ide_drive_t *);
632 650
633 /* idetape only */ 651 /* idetape only */
634 struct idetape_bh *bh; 652 struct idetape_bh *bh;
@@ -772,7 +790,6 @@ struct ide_driver_s {
772 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 790 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
773 int (*end_request)(ide_drive_t *, int, int); 791 int (*end_request)(ide_drive_t *, int, int);
774 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 792 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
775 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
776 struct device_driver gen_driver; 793 struct device_driver gen_driver;
777 int (*probe)(ide_drive_t *); 794 int (*probe)(ide_drive_t *);
778 void (*remove)(ide_drive_t *); 795 void (*remove)(ide_drive_t *);
@@ -787,22 +804,6 @@ struct ide_driver_s {
787 804
788int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 805int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
789 806
790/*
791 * ide_hwifs[] is the master data structure used to keep track
792 * of just about everything in ide.c. Whenever possible, routines
793 * should be using pointers to a drive (ide_drive_t *) or
794 * pointers to a hwif (ide_hwif_t *), rather than indexing this
795 * structure directly (the allocation/layout may change!).
796 *
797 */
798#ifndef _IDE_C
799extern ide_hwif_t ide_hwifs[]; /* master data repository */
800#endif
801extern int ide_noacpi;
802extern int ide_acpigtf;
803extern int ide_acpionboot;
804extern int noautodma;
805
806extern int ide_vlb_clk; 807extern int ide_vlb_clk;
807extern int ide_pci_clk; 808extern int ide_pci_clk;
808 809
@@ -830,10 +831,6 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
830 831
831ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 832ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
832 833
833ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
834
835extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
836
837extern void ide_fix_driveid(struct hd_driveid *); 834extern void ide_fix_driveid(struct hd_driveid *);
838 835
839extern void ide_fixstring(u8 *, const int, const int); 836extern void ide_fixstring(u8 *, const int, const int);
@@ -842,25 +839,12 @@ int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
842 839
843extern ide_startstop_t ide_do_reset (ide_drive_t *); 840extern ide_startstop_t ide_do_reset (ide_drive_t *);
844 841
845extern void ide_init_drive_cmd (struct request *rq); 842extern void ide_do_drive_cmd(ide_drive_t *, struct request *);
846
847/*
848 * "action" parameter type for ide_do_drive_cmd() below.
849 */
850typedef enum {
851 ide_wait, /* insert rq at end of list, and wait for it */
852 ide_preempt, /* insert rq in front of current request */
853 ide_head_wait, /* insert rq in front of current request and wait for it */
854 ide_end /* insert rq at end of list, but don't wait for it */
855} ide_action_t;
856
857extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
858 843
859extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 844extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
860 845
861enum { 846enum {
862 IDE_TFLAG_LBA48 = (1 << 0), 847 IDE_TFLAG_LBA48 = (1 << 0),
863 IDE_TFLAG_NO_SELECT_MASK = (1 << 1),
864 IDE_TFLAG_FLAGGED = (1 << 2), 848 IDE_TFLAG_FLAGGED = (1 << 2),
865 IDE_TFLAG_OUT_DATA = (1 << 3), 849 IDE_TFLAG_OUT_DATA = (1 << 3),
866 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), 850 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
@@ -965,11 +949,23 @@ typedef struct ide_task_s {
965void ide_tf_dump(const char *, struct ide_taskfile *); 949void ide_tf_dump(const char *, struct ide_taskfile *);
966 950
967extern void SELECT_DRIVE(ide_drive_t *); 951extern void SELECT_DRIVE(ide_drive_t *);
952void SELECT_MASK(ide_drive_t *, int);
968 953
969extern int drive_is_ready(ide_drive_t *); 954extern int drive_is_ready(ide_drive_t *);
970 955
971void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 956void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
972 957
958ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
959 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
960 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
961 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
962 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
963 int));
964ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *,
965 ide_handler_t *, unsigned int, ide_expiry_t *);
966ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
967 ide_handler_t *, unsigned int, ide_expiry_t *);
968
973ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 969ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
974 970
975void task_end_request(ide_drive_t *, struct request *, u8); 971void task_end_request(ide_drive_t *, struct request *, u8);
@@ -981,8 +977,6 @@ int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
981int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); 977int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
982int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); 978int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
983 979
984extern int system_bus_clock(void);
985
986extern int ide_driveid_update(ide_drive_t *); 980extern int ide_driveid_update(ide_drive_t *);
987extern int ide_config_drive_speed(ide_drive_t *, u8); 981extern int ide_config_drive_speed(ide_drive_t *, u8);
988extern u8 eighty_ninty_three (ide_drive_t *); 982extern u8 eighty_ninty_three (ide_drive_t *);
@@ -1264,16 +1258,43 @@ static inline int ide_dev_is_sata(struct hd_driveid *id)
1264u64 ide_get_lba_addr(struct ide_taskfile *, int); 1258u64 ide_get_lba_addr(struct ide_taskfile *, int);
1265u8 ide_dump_status(ide_drive_t *, const char *, u8); 1259u8 ide_dump_status(ide_drive_t *, const char *, u8);
1266 1260
1267typedef struct ide_pio_timings_s { 1261struct ide_timing {
1268 int setup_time; /* Address setup (ns) minimum */ 1262 u8 mode;
1269 int active_time; /* Active pulse (ns) minimum */ 1263 u8 setup; /* t1 */
1270 int cycle_time; /* Cycle time (ns) minimum = */ 1264 u16 act8b; /* t2 for 8-bit io */
1271 /* active + recovery (+ setup for some chips) */ 1265 u16 rec8b; /* t2i for 8-bit io */
1272} ide_pio_timings_t; 1266 u16 cyc8b; /* t0 for 8-bit io */
1267 u16 active; /* t2 or tD */
1268 u16 recover; /* t2i or tK */
1269 u16 cycle; /* t0 */
1270 u16 udma; /* t2CYCTYP/2 */
1271};
1272
1273enum {
1274 IDE_TIMING_SETUP = (1 << 0),
1275 IDE_TIMING_ACT8B = (1 << 1),
1276 IDE_TIMING_REC8B = (1 << 2),
1277 IDE_TIMING_CYC8B = (1 << 3),
1278 IDE_TIMING_8BIT = IDE_TIMING_ACT8B | IDE_TIMING_REC8B |
1279 IDE_TIMING_CYC8B,
1280 IDE_TIMING_ACTIVE = (1 << 4),
1281 IDE_TIMING_RECOVER = (1 << 5),
1282 IDE_TIMING_CYCLE = (1 << 6),
1283 IDE_TIMING_UDMA = (1 << 7),
1284 IDE_TIMING_ALL = IDE_TIMING_SETUP | IDE_TIMING_8BIT |
1285 IDE_TIMING_ACTIVE | IDE_TIMING_RECOVER |
1286 IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
1287};
1288
1289struct ide_timing *ide_timing_find_mode(u8);
1290u16 ide_pio_cycle_time(ide_drive_t *, u8);
1291void ide_timing_merge(struct ide_timing *, struct ide_timing *,
1292 struct ide_timing *, unsigned int);
1293int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1294
1295int ide_scan_pio_blacklist(char *);
1273 1296
1274unsigned int ide_pio_cycle_time(ide_drive_t *, u8);
1275u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8); 1297u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
1276extern const ide_pio_timings_t ide_pio_timings[6];
1277 1298
1278int ide_set_pio_mode(ide_drive_t *, u8); 1299int ide_set_pio_mode(ide_drive_t *, u8);
1279int ide_set_dma_mode(ide_drive_t *, u8); 1300int ide_set_dma_mode(ide_drive_t *, u8);
@@ -1334,7 +1355,8 @@ static inline void ide_set_irq(ide_drive_t *drive, int on)
1334{ 1355{
1335 ide_hwif_t *hwif = drive->hwif; 1356 ide_hwif_t *hwif = drive->hwif;
1336 1357
1337 hwif->OUTB(drive->ctl | (on ? 0 : 2), hwif->io_ports.ctl_addr); 1358 hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | (on ? 0 : 2),
1359 hwif->io_ports.ctl_addr);
1338} 1360}
1339 1361
1340static inline u8 ide_read_status(ide_drive_t *drive) 1362static inline u8 ide_read_status(ide_drive_t *drive)