diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-04-12 16:54:16 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-04-12 16:54:16 -0400 |
commit | 875999c5539999f61a45620aae0c3e5fb1d2b035 (patch) | |
tree | 4535032a8a10f5782c0aef6a620b1a624ea9f863 /include/linux/libata.h | |
parent | 79072f38909e3d9883317238887460c39ddcc4cb (diff) | |
parent | 26ec634c31a11a003040e10b4d650495158632fd (diff) |
Merge branch 'upstream'
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 122 |
1 files changed, 81 insertions, 41 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index c2215469a101..11d9febc0078 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <linux/ata.h> | 34 | #include <linux/ata.h> |
35 | #include <linux/workqueue.h> | 35 | #include <linux/workqueue.h> |
36 | #include <scsi/scsi_host.h> | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * compile-time options: to be removed as soon as all the drivers are | 39 | * compile-time options: to be removed as soon as all the drivers are |
@@ -44,7 +45,6 @@ | |||
44 | #undef ATA_NDEBUG /* define to disable quick runtime checks */ | 45 | #undef ATA_NDEBUG /* define to disable quick runtime checks */ |
45 | #undef ATA_ENABLE_PATA /* define to enable PATA support in some | 46 | #undef ATA_ENABLE_PATA /* define to enable PATA support in some |
46 | * low-level drivers */ | 47 | * low-level drivers */ |
47 | #undef ATAPI_ENABLE_DMADIR /* enables ATAPI DMADIR bridge support */ | ||
48 | 48 | ||
49 | 49 | ||
50 | /* note: prints function name for you */ | 50 | /* note: prints function name for you */ |
@@ -121,9 +121,11 @@ enum { | |||
121 | ATA_SHT_USE_CLUSTERING = 1, | 121 | ATA_SHT_USE_CLUSTERING = 1, |
122 | 122 | ||
123 | /* struct ata_device stuff */ | 123 | /* struct ata_device stuff */ |
124 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ | 124 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ |
125 | ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ | 125 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ |
126 | ATA_DFLAG_LBA = (1 << 2), /* device supports LBA */ | 126 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, |
127 | |||
128 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ | ||
127 | 129 | ||
128 | ATA_DEV_UNKNOWN = 0, /* unknown device */ | 130 | ATA_DEV_UNKNOWN = 0, /* unknown device */ |
129 | ATA_DEV_ATA = 1, /* ATA device */ | 131 | ATA_DEV_ATA = 1, /* ATA device */ |
@@ -133,33 +135,35 @@ enum { | |||
133 | ATA_DEV_NONE = 5, /* no device */ | 135 | ATA_DEV_NONE = 5, /* no device */ |
134 | 136 | ||
135 | /* struct ata_port flags */ | 137 | /* struct ata_port flags */ |
136 | ATA_FLAG_SLAVE_POSS = (1 << 1), /* host supports slave dev */ | 138 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ |
137 | /* (doesn't imply presence) */ | 139 | /* (doesn't imply presence) */ |
138 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ | 140 | ATA_FLAG_SATA = (1 << 1), |
139 | ATA_FLAG_SATA = (1 << 3), | 141 | ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */ |
140 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ | 142 | ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */ |
141 | ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ | 143 | ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */ |
142 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ | 144 | ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */ |
143 | ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ | 145 | ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */ |
144 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 146 | ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ |
145 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 147 | ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ |
146 | * proper HSM is in place. */ | 148 | ATA_FLAG_IRQ_MASK = (1 << 9), /* Mask IRQ in PIO xfers */ |
147 | ATA_FLAG_DEBUGMSG = (1 << 10), | 149 | |
148 | ATA_FLAG_NO_ATAPI = (1 << 11), /* No ATAPI support */ | 150 | ATA_FLAG_NOINTR = (1 << 16), /* FIXME: Remove this once |
149 | 151 | * proper HSM is in place. */ | |
150 | ATA_FLAG_SUSPENDED = (1 << 12), /* port is suspended */ | 152 | ATA_FLAG_DEBUGMSG = (1 << 17), |
151 | 153 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 18), /* flush port task */ | |
152 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ | 154 | |
153 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ | 155 | ATA_FLAG_DISABLED = (1 << 19), /* port is disabled, ignore it */ |
154 | 156 | ATA_FLAG_SUSPENDED = (1 << 20), /* port is suspended */ | |
155 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */ | 157 | |
156 | ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ | 158 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ |
157 | 159 | ||
158 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 160 | /* struct ata_queued_cmd flags */ |
159 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 161 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ |
160 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ | 162 | ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */ |
163 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ | ||
161 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 164 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
162 | ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ | 165 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
166 | ATA_QCFLAG_EH_SCHEDULED = (1 << 4), /* EH scheduled */ | ||
163 | 167 | ||
164 | /* host set flags */ | 168 | /* host set flags */ |
165 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ | 169 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ |
@@ -208,10 +212,13 @@ enum { | |||
208 | /* size of buffer to pad xfers ending on unaligned boundaries */ | 212 | /* size of buffer to pad xfers ending on unaligned boundaries */ |
209 | ATA_DMA_PAD_SZ = 4, | 213 | ATA_DMA_PAD_SZ = 4, |
210 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, | 214 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, |
211 | 215 | ||
212 | /* Masks for port functions */ | 216 | /* masks for port functions */ |
213 | ATA_PORT_PRIMARY = (1 << 0), | 217 | ATA_PORT_PRIMARY = (1 << 0), |
214 | ATA_PORT_SECONDARY = (1 << 1), | 218 | ATA_PORT_SECONDARY = (1 << 1), |
219 | |||
220 | /* how hard are we gonna try to probe/recover devices */ | ||
221 | ATA_PROBE_MAX_TRIES = 3, | ||
215 | }; | 222 | }; |
216 | 223 | ||
217 | enum hsm_task_states { | 224 | enum hsm_task_states { |
@@ -246,7 +253,7 @@ struct ata_queued_cmd; | |||
246 | /* typedefs */ | 253 | /* typedefs */ |
247 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 254 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
248 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | 255 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); |
249 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | 256 | typedef int (*ata_reset_fn_t)(struct ata_port *, unsigned int *); |
250 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | 257 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); |
251 | 258 | ||
252 | struct ata_ioports { | 259 | struct ata_ioports { |
@@ -398,6 +405,7 @@ struct ata_port { | |||
398 | unsigned int mwdma_mask; | 405 | unsigned int mwdma_mask; |
399 | unsigned int udma_mask; | 406 | unsigned int udma_mask; |
400 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 407 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
408 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | ||
401 | 409 | ||
402 | struct ata_device device[ATA_MAX_DEVICES]; | 410 | struct ata_device device[ATA_MAX_DEVICES]; |
403 | 411 | ||
@@ -497,15 +505,14 @@ extern void ata_port_probe(struct ata_port *); | |||
497 | extern void __sata_phy_reset(struct ata_port *ap); | 505 | extern void __sata_phy_reset(struct ata_port *ap); |
498 | extern void sata_phy_reset(struct ata_port *ap); | 506 | extern void sata_phy_reset(struct ata_port *ap); |
499 | extern void ata_bus_reset(struct ata_port *ap); | 507 | extern void ata_bus_reset(struct ata_port *ap); |
508 | extern int ata_set_sata_spd(struct ata_port *ap); | ||
500 | extern int ata_drive_probe_reset(struct ata_port *ap, | 509 | extern int ata_drive_probe_reset(struct ata_port *ap, |
501 | ata_probeinit_fn_t probeinit, | 510 | ata_probeinit_fn_t probeinit, |
502 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 511 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, |
503 | ata_postreset_fn_t postreset, unsigned int *classes); | 512 | ata_postreset_fn_t postreset, unsigned int *classes); |
504 | extern void ata_std_probeinit(struct ata_port *ap); | 513 | extern void ata_std_probeinit(struct ata_port *ap); |
505 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | 514 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); |
506 | unsigned int *classes); | 515 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); |
507 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
508 | unsigned int *class); | ||
509 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 516 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); |
510 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 517 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, |
511 | int post_reset); | 518 | int post_reset); |
@@ -524,7 +531,6 @@ extern void ata_host_set_remove(struct ata_host_set *host_set); | |||
524 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 531 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
525 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 532 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
526 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 533 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
527 | extern int ata_scsi_error(struct Scsi_Host *host); | ||
528 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | 534 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); |
529 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | 535 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); |
530 | extern int ata_scsi_release(struct Scsi_Host *host); | 536 | extern int ata_scsi_release(struct Scsi_Host *host); |
@@ -539,6 +545,9 @@ extern unsigned int ata_busy_sleep(struct ata_port *ap, | |||
539 | unsigned long timeout); | 545 | unsigned long timeout); |
540 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), | 546 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), |
541 | void *data, unsigned long delay); | 547 | void *data, unsigned long delay); |
548 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | ||
549 | unsigned long interval_msec, | ||
550 | unsigned long timeout_msec); | ||
542 | 551 | ||
543 | /* | 552 | /* |
544 | * Default driver ops implementations | 553 | * Default driver ops implementations |
@@ -575,7 +584,6 @@ extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | |||
575 | extern u8 ata_bmdma_status(struct ata_port *ap); | 584 | extern u8 ata_bmdma_status(struct ata_port *ap); |
576 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 585 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
577 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 586 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); |
578 | extern void ata_eng_timeout(struct ata_port *ap); | ||
579 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 587 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, |
580 | struct scsi_cmnd *cmd, | 588 | struct scsi_cmnd *cmd, |
581 | void (*done)(struct scsi_cmnd *)); | 589 | void (*done)(struct scsi_cmnd *)); |
@@ -630,6 +638,13 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit | |||
630 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); | 638 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); |
631 | #endif /* CONFIG_PCI */ | 639 | #endif /* CONFIG_PCI */ |
632 | 640 | ||
641 | /* | ||
642 | * EH | ||
643 | */ | ||
644 | extern void ata_eng_timeout(struct ata_port *ap); | ||
645 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
646 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
647 | |||
633 | 648 | ||
634 | static inline int | 649 | static inline int |
635 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | 650 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) |
@@ -673,14 +688,34 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
673 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 688 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
674 | } | 689 | } |
675 | 690 | ||
676 | static inline unsigned int ata_class_present(unsigned int class) | 691 | static inline unsigned int ata_class_enabled(unsigned int class) |
677 | { | 692 | { |
678 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 693 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; |
679 | } | 694 | } |
680 | 695 | ||
681 | static inline unsigned int ata_dev_present(const struct ata_device *dev) | 696 | static inline unsigned int ata_class_disabled(unsigned int class) |
697 | { | ||
698 | return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP; | ||
699 | } | ||
700 | |||
701 | static inline unsigned int ata_class_absent(unsigned int class) | ||
702 | { | ||
703 | return !ata_class_enabled(class) && !ata_class_disabled(class); | ||
704 | } | ||
705 | |||
706 | static inline unsigned int ata_dev_enabled(const struct ata_device *dev) | ||
707 | { | ||
708 | return ata_class_enabled(dev->class); | ||
709 | } | ||
710 | |||
711 | static inline unsigned int ata_dev_disabled(const struct ata_device *dev) | ||
682 | { | 712 | { |
683 | return ata_class_present(dev->class); | 713 | return ata_class_disabled(dev->class); |
714 | } | ||
715 | |||
716 | static inline unsigned int ata_dev_absent(const struct ata_device *dev) | ||
717 | { | ||
718 | return ata_class_absent(dev->class); | ||
684 | } | 719 | } |
685 | 720 | ||
686 | static inline u8 ata_chk_status(struct ata_port *ap) | 721 | static inline u8 ata_chk_status(struct ata_port *ap) |
@@ -946,4 +981,9 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | |||
946 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | 981 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); |
947 | } | 982 | } |
948 | 983 | ||
984 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | ||
985 | { | ||
986 | return (struct ata_port *) &host->hostdata[0]; | ||
987 | } | ||
988 | |||
949 | #endif /* __LINUX_LIBATA_H__ */ | 989 | #endif /* __LINUX_LIBATA_H__ */ |