diff options
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 121 |
1 files changed, 81 insertions, 40 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index b80d2e7fa6d2..d35b1e3bb7e0 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 */ |
| @@ -120,9 +120,11 @@ enum { | |||
| 120 | ATA_SHT_USE_CLUSTERING = 1, | 120 | ATA_SHT_USE_CLUSTERING = 1, |
| 121 | 121 | ||
| 122 | /* struct ata_device stuff */ | 122 | /* struct ata_device stuff */ |
| 123 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ | 123 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ |
| 124 | ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ | 124 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ |
| 125 | ATA_DFLAG_LBA = (1 << 2), /* device supports LBA */ | 125 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, |
| 126 | |||
| 127 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ | ||
| 126 | 128 | ||
| 127 | ATA_DEV_UNKNOWN = 0, /* unknown device */ | 129 | ATA_DEV_UNKNOWN = 0, /* unknown device */ |
| 128 | ATA_DEV_ATA = 1, /* ATA device */ | 130 | ATA_DEV_ATA = 1, /* ATA device */ |
| @@ -132,33 +134,35 @@ enum { | |||
| 132 | ATA_DEV_NONE = 5, /* no device */ | 134 | ATA_DEV_NONE = 5, /* no device */ |
| 133 | 135 | ||
| 134 | /* struct ata_port flags */ | 136 | /* struct ata_port flags */ |
| 135 | ATA_FLAG_SLAVE_POSS = (1 << 1), /* host supports slave dev */ | 137 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ |
| 136 | /* (doesn't imply presence) */ | 138 | /* (doesn't imply presence) */ |
| 137 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ | 139 | ATA_FLAG_SATA = (1 << 1), |
| 138 | ATA_FLAG_SATA = (1 << 3), | 140 | ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */ |
| 139 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ | 141 | ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */ |
| 140 | ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ | 142 | ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */ |
| 141 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ | 143 | ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */ |
| 142 | ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ | 144 | ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */ |
| 143 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 145 | ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ |
| 144 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 146 | ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ |
| 145 | * proper HSM is in place. */ | 147 | ATA_FLAG_IRQ_MASK = (1 << 9), /* Mask IRQ in PIO xfers */ |
| 146 | ATA_FLAG_DEBUGMSG = (1 << 10), | 148 | |
| 147 | ATA_FLAG_NO_ATAPI = (1 << 11), /* No ATAPI support */ | 149 | ATA_FLAG_NOINTR = (1 << 16), /* FIXME: Remove this once |
| 148 | 150 | * proper HSM is in place. */ | |
| 149 | ATA_FLAG_SUSPENDED = (1 << 12), /* port is suspended */ | 151 | ATA_FLAG_DEBUGMSG = (1 << 17), |
| 150 | 152 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 18), /* flush port task */ | |
| 151 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ | 153 | |
| 152 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ | 154 | ATA_FLAG_DISABLED = (1 << 19), /* port is disabled, ignore it */ |
| 153 | 155 | ATA_FLAG_SUSPENDED = (1 << 20), /* port is suspended */ | |
| 154 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */ | 156 | |
| 155 | ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ | 157 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ |
| 156 | 158 | ||
| 157 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 159 | /* struct ata_queued_cmd flags */ |
| 158 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 160 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ |
| 159 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ | 161 | ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */ |
| 162 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ | ||
| 160 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 163 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
| 161 | ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ | 164 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
| 165 | ATA_QCFLAG_EH_SCHEDULED = (1 << 4), /* EH scheduled */ | ||
| 162 | 166 | ||
| 163 | /* host set flags */ | 167 | /* host set flags */ |
| 164 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ | 168 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ |
| @@ -207,10 +211,13 @@ enum { | |||
| 207 | /* size of buffer to pad xfers ending on unaligned boundaries */ | 211 | /* size of buffer to pad xfers ending on unaligned boundaries */ |
| 208 | ATA_DMA_PAD_SZ = 4, | 212 | ATA_DMA_PAD_SZ = 4, |
| 209 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, | 213 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, |
| 210 | 214 | ||
| 211 | /* Masks for port functions */ | 215 | /* masks for port functions */ |
| 212 | ATA_PORT_PRIMARY = (1 << 0), | 216 | ATA_PORT_PRIMARY = (1 << 0), |
| 213 | ATA_PORT_SECONDARY = (1 << 1), | 217 | ATA_PORT_SECONDARY = (1 << 1), |
| 218 | |||
| 219 | /* how hard are we gonna try to probe/recover devices */ | ||
| 220 | ATA_PROBE_MAX_TRIES = 3, | ||
| 214 | }; | 221 | }; |
| 215 | 222 | ||
| 216 | enum hsm_task_states { | 223 | enum hsm_task_states { |
| @@ -245,7 +252,7 @@ struct ata_queued_cmd; | |||
| 245 | /* typedefs */ | 252 | /* typedefs */ |
| 246 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 253 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
| 247 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | 254 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); |
| 248 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | 255 | typedef int (*ata_reset_fn_t)(struct ata_port *, unsigned int *); |
| 249 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | 256 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); |
| 250 | 257 | ||
| 251 | struct ata_ioports { | 258 | struct ata_ioports { |
| @@ -397,6 +404,7 @@ struct ata_port { | |||
| 397 | unsigned int mwdma_mask; | 404 | unsigned int mwdma_mask; |
| 398 | unsigned int udma_mask; | 405 | unsigned int udma_mask; |
| 399 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 406 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
| 407 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | ||
| 400 | 408 | ||
| 401 | struct ata_device device[ATA_MAX_DEVICES]; | 409 | struct ata_device device[ATA_MAX_DEVICES]; |
| 402 | 410 | ||
| @@ -496,15 +504,14 @@ extern void ata_port_probe(struct ata_port *); | |||
| 496 | extern void __sata_phy_reset(struct ata_port *ap); | 504 | extern void __sata_phy_reset(struct ata_port *ap); |
| 497 | extern void sata_phy_reset(struct ata_port *ap); | 505 | extern void sata_phy_reset(struct ata_port *ap); |
| 498 | extern void ata_bus_reset(struct ata_port *ap); | 506 | extern void ata_bus_reset(struct ata_port *ap); |
| 507 | extern int ata_set_sata_spd(struct ata_port *ap); | ||
| 499 | extern int ata_drive_probe_reset(struct ata_port *ap, | 508 | extern int ata_drive_probe_reset(struct ata_port *ap, |
| 500 | ata_probeinit_fn_t probeinit, | 509 | ata_probeinit_fn_t probeinit, |
| 501 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 510 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, |
| 502 | ata_postreset_fn_t postreset, unsigned int *classes); | 511 | ata_postreset_fn_t postreset, unsigned int *classes); |
| 503 | extern void ata_std_probeinit(struct ata_port *ap); | 512 | extern void ata_std_probeinit(struct ata_port *ap); |
| 504 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | 513 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); |
| 505 | unsigned int *classes); | 514 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); |
| 506 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
| 507 | unsigned int *class); | ||
| 508 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 515 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); |
| 509 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 516 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, |
| 510 | int post_reset); | 517 | int post_reset); |
| @@ -537,6 +544,9 @@ extern unsigned int ata_busy_sleep(struct ata_port *ap, | |||
| 537 | unsigned long timeout); | 544 | unsigned long timeout); |
| 538 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), | 545 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), |
| 539 | void *data, unsigned long delay); | 546 | void *data, unsigned long delay); |
| 547 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | ||
| 548 | unsigned long interval_msec, | ||
| 549 | unsigned long timeout_msec); | ||
| 540 | 550 | ||
| 541 | /* | 551 | /* |
| 542 | * Default driver ops implementations | 552 | * Default driver ops implementations |
| @@ -573,7 +583,6 @@ extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | |||
| 573 | extern u8 ata_bmdma_status(struct ata_port *ap); | 583 | extern u8 ata_bmdma_status(struct ata_port *ap); |
| 574 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 584 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
| 575 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 585 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); |
| 576 | extern void ata_eng_timeout(struct ata_port *ap); | ||
| 577 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 586 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, |
| 578 | struct scsi_cmnd *cmd, | 587 | struct scsi_cmnd *cmd, |
| 579 | void (*done)(struct scsi_cmnd *)); | 588 | void (*done)(struct scsi_cmnd *)); |
| @@ -628,6 +637,13 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit | |||
| 628 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); | 637 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); |
| 629 | #endif /* CONFIG_PCI */ | 638 | #endif /* CONFIG_PCI */ |
| 630 | 639 | ||
| 640 | /* | ||
| 641 | * EH | ||
| 642 | */ | ||
| 643 | extern void ata_eng_timeout(struct ata_port *ap); | ||
| 644 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
| 645 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
| 646 | |||
| 631 | 647 | ||
| 632 | static inline int | 648 | static inline int |
| 633 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | 649 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) |
| @@ -671,14 +687,34 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
| 671 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 687 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
| 672 | } | 688 | } |
| 673 | 689 | ||
| 674 | static inline unsigned int ata_class_present(unsigned int class) | 690 | static inline unsigned int ata_class_enabled(unsigned int class) |
| 675 | { | 691 | { |
| 676 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 692 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; |
| 677 | } | 693 | } |
| 678 | 694 | ||
| 679 | static inline unsigned int ata_dev_present(const struct ata_device *dev) | 695 | static inline unsigned int ata_class_disabled(unsigned int class) |
| 696 | { | ||
| 697 | return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP; | ||
| 698 | } | ||
| 699 | |||
| 700 | static inline unsigned int ata_class_absent(unsigned int class) | ||
| 701 | { | ||
| 702 | return !ata_class_enabled(class) && !ata_class_disabled(class); | ||
| 703 | } | ||
| 704 | |||
| 705 | static inline unsigned int ata_dev_enabled(const struct ata_device *dev) | ||
| 706 | { | ||
| 707 | return ata_class_enabled(dev->class); | ||
| 708 | } | ||
| 709 | |||
| 710 | static inline unsigned int ata_dev_disabled(const struct ata_device *dev) | ||
| 680 | { | 711 | { |
| 681 | return ata_class_present(dev->class); | 712 | return ata_class_disabled(dev->class); |
| 713 | } | ||
| 714 | |||
| 715 | static inline unsigned int ata_dev_absent(const struct ata_device *dev) | ||
| 716 | { | ||
| 717 | return ata_class_absent(dev->class); | ||
| 682 | } | 718 | } |
| 683 | 719 | ||
| 684 | static inline u8 ata_chk_status(struct ata_port *ap) | 720 | static inline u8 ata_chk_status(struct ata_port *ap) |
| @@ -944,4 +980,9 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | |||
| 944 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | 980 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); |
| 945 | } | 981 | } |
| 946 | 982 | ||
| 983 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | ||
| 984 | { | ||
| 985 | return (struct ata_port *) &host->hostdata[0]; | ||
| 986 | } | ||
| 987 | |||
| 947 | #endif /* __LINUX_LIBATA_H__ */ | 988 | #endif /* __LINUX_LIBATA_H__ */ |
