]> err.no Git - linux-2.6/blobdiff - include/linux/libata.h
libata: separate PMP support code from core code
[linux-2.6] / include / linux / libata.h
index 53b8db05a1fb478838adea8f8a724b5774ce54b4..eb86d6f396354ce23587a876f81a9c76f5589d3e 100644 (file)
@@ -224,6 +224,7 @@ enum {
        ATA_QCFLAG_RESULT_TF    = (1 << 4), /* result TF requested */
        ATA_QCFLAG_CLEAR_EXCL   = (1 << 5), /* clear excl_link on completion */
        ATA_QCFLAG_QUIET        = (1 << 6), /* don't report device error */
+       ATA_QCFLAG_RETRY        = (1 << 7), /* retry after failure */
 
        ATA_QCFLAG_FAILED       = (1 << 16), /* cmd failed and is owned by EH */
        ATA_QCFLAG_SENSE_VALID  = (1 << 17), /* sense data valid */
@@ -248,6 +249,25 @@ enum {
         */
        ATA_TMOUT_FF_WAIT       = 4 * HZ / 5,
 
+       /* Spec mandates to wait for ">= 2ms" before checking status
+        * after reset.  We wait 150ms, because that was the magic
+        * delay used for ATAPI devices in Hale Landis's ATADRVR, for
+        * the period of time between when the ATA command register is
+        * written, and then status is checked.  Because waiting for
+        * "a while" before checking status is fine, post SRST, we
+        * perform this magic delay here as well.
+        *
+        * Old drivers/ide uses the 2mS rule and then waits for ready.
+        */
+       ATA_WAIT_AFTER_RESET_MSECS = 150,
+
+       /* If PMP is supported, we have to do follow-up SRST.  As some
+        * PMPs don't send D2H Reg FIS after hardreset, LLDs are
+        * advised to wait only for the following duration before
+        * doing SRST.
+        */
+       ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ,
+
        /* ATA bus states */
        BUS_UNKNOWN             = 0,
        BUS_DMA                 = 1,
@@ -425,6 +445,7 @@ enum link_pm {
 };
 extern struct class_device_attribute class_device_attr_link_power_management_policy;
 
+#ifdef CONFIG_ATA_SFF
 struct ata_ioports {
        void __iomem            *cmd_addr;
        void __iomem            *data_addr;
@@ -442,6 +463,7 @@ struct ata_ioports {
        void __iomem            *bmdma_addr;
        void __iomem            *scr_addr;
 };
+#endif /* CONFIG_ATA_SFF */
 
 struct ata_host {
        spinlock_t              lock;
@@ -628,7 +650,9 @@ struct ata_port {
        struct ata_prd          *prd;    /* our SG list */
        dma_addr_t              prd_dma; /* and its DMA mapping */
 
+#ifdef CONFIG_ATA_SFF
        struct ata_ioports      ioaddr; /* ATA cmd/ctl/dma register blocks */
+#endif /* CONFIG_ATA_SFF */
 
        u8                      ctl;    /* cache of ATA control register */
        u8                      last_ctl;       /* Cache last written value */
@@ -695,6 +719,7 @@ struct ata_port_operations {
        int  (*check_atapi_dma)(struct ata_queued_cmd *qc);
        void (*qc_prep)(struct ata_queued_cmd *qc);
        unsigned int (*qc_issue)(struct ata_queued_cmd *qc);
+       bool (*qc_fill_rtf)(struct ata_queued_cmd *qc);
 
        /*
         * Configuration and exception handling
@@ -739,24 +764,27 @@ struct ata_port_operations {
        void (*port_stop)(struct ata_port *ap);
        void (*host_stop)(struct ata_host *host);
 
+#ifdef CONFIG_ATA_SFF
        /*
         * SFF / taskfile oriented ops
         */
-       void (*dev_select)(struct ata_port *ap, unsigned int device);
-       u8   (*check_status)(struct ata_port *ap);
-       u8   (*check_altstatus)(struct ata_port *ap);
-       void (*tf_load)(struct ata_port *ap, const struct ata_taskfile *tf);
-       void (*tf_read)(struct ata_port *ap, struct ata_taskfile *tf);
-       void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf);
-       unsigned int (*data_xfer)(struct ata_device *dev, unsigned char *buf,
-                                 unsigned int buflen, int rw);
-       u8   (*irq_on)(struct ata_port *);
-
-       void (*irq_clear)(struct ata_port *);
+       void (*sff_dev_select)(struct ata_port *ap, unsigned int device);
+       u8   (*sff_check_status)(struct ata_port *ap);
+       u8   (*sff_check_altstatus)(struct ata_port *ap);
+       void (*sff_tf_load)(struct ata_port *ap, const struct ata_taskfile *tf);
+       void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf);
+       void (*sff_exec_command)(struct ata_port *ap,
+                                const struct ata_taskfile *tf);
+       unsigned int (*sff_data_xfer)(struct ata_device *dev,
+                       unsigned char *buf, unsigned int buflen, int rw);
+       u8   (*sff_irq_on)(struct ata_port *);
+       void (*sff_irq_clear)(struct ata_port *);
+
        void (*bmdma_setup)(struct ata_queued_cmd *qc);
        void (*bmdma_start)(struct ata_queued_cmd *qc);
        void (*bmdma_stop)(struct ata_queued_cmd *qc);
        u8   (*bmdma_status)(struct ata_port *ap);
+#endif /* CONFIG_ATA_SFF */
 
        /*
         * Obsolete
@@ -822,12 +850,19 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
 extern void sata_print_link_status(struct ata_link *link);
 extern void ata_port_probe(struct ata_port *);
 extern int sata_set_spd(struct ata_link *link);
+extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
+extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
+                               int (*check_ready)(struct ata_link *link));
 extern int sata_link_debounce(struct ata_link *link,
                        const unsigned long *params, unsigned long deadline);
 extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
                            unsigned long deadline);
 extern int sata_link_hardreset(struct ata_link *link,
-                       const unsigned long *timing, unsigned long deadline);
+                       const unsigned long *timing, unsigned long deadline,
+                       bool *online, int (*check_ready)(struct ata_link *));
+extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
+                             unsigned long deadline);
+extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
 extern void ata_port_disable(struct ata_port *);
 
 extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
@@ -882,7 +917,6 @@ extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
 extern int ata_xfer_mode2shift(unsigned long xfer_mode);
 extern const char *ata_mode_string(unsigned long xfer_mask);
 extern unsigned long ata_id_xfermask(const u16 *id);
-extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
 extern int ata_port_start(struct ata_port *ap);
 extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
@@ -894,10 +928,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
                          unsigned int ofs, unsigned int len);
 extern void ata_id_c_string(const u16 *id, unsigned char *s,
                            unsigned int ofs, unsigned int len);
-extern void ata_noop_irq_clear(struct ata_port *ap);
 extern void ata_qc_complete(struct ata_queued_cmd *qc);
-extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
-                                   void (*finish_qc)(struct ata_queued_cmd *));
+extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
                              void (*done)(struct scsi_cmnd *));
 extern int ata_std_bios_param(struct scsi_device *sdev,
@@ -994,16 +1026,6 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
 }
 #endif
 
-/*
- * PMP - drivers/ata/libata-pmp.c
- */
-extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
-extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline);
-extern int sata_pmp_std_hardreset(struct ata_link *link, unsigned int *class,
-                                 unsigned long deadline);
-extern void sata_pmp_std_postreset(struct ata_link *link, unsigned int *class);
-extern void sata_pmp_error_handler(struct ata_port *ap);
-
 /*
  * EH - drivers/ata/libata-eh.c
  */
@@ -1047,7 +1069,6 @@ extern void ata_std_error_handler(struct ata_port *ap);
  */
 extern const struct ata_port_operations ata_base_port_ops;
 extern const struct ata_port_operations sata_port_ops;
-extern const struct ata_port_operations sata_pmp_port_ops;
 
 #define ATA_BASE_SHT(drv_name)                                 \
        .module                 = THIS_MODULE,                  \
@@ -1120,7 +1141,7 @@ static inline unsigned int ata_tag_valid(unsigned int tag)
 
 static inline unsigned int ata_tag_internal(unsigned int tag)
 {
-       return tag == ATA_MAX_QUEUE - 1;
+       return tag == ATA_TAG_INTERNAL;
 }
 
 /*
@@ -1324,9 +1345,21 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
        return *(struct ata_port **)&host->hostdata[0];
 }
 
+
+/**************************************************************************
+ * PMP - drivers/ata/libata-pmp.c
+ */
+extern const struct ata_port_operations sata_pmp_port_ops;
+
+extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
+extern void sata_pmp_error_handler(struct ata_port *ap);
+
+
 /**************************************************************************
  * SFF - drivers/ata/libata-sff.c
  */
+#ifdef CONFIG_ATA_SFF
+
 extern const struct ata_port_operations ata_sff_port_ops;
 extern const struct ata_port_operations ata_bmdma_port_ops;
 
@@ -1341,45 +1374,49 @@ extern const struct ata_port_operations ata_bmdma_port_ops;
        .sg_tablesize           = LIBATA_MAX_PRD,               \
        .dma_boundary           = ATA_DMA_BOUNDARY
 
-extern void ata_qc_prep(struct ata_queued_cmd *qc);
-extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
-extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
-extern u8 ata_check_status(struct ata_port *ap);
-extern u8 ata_altstatus(struct ata_port *ap);
-extern int ata_busy_sleep(struct ata_port *ap,
-                         unsigned long timeout_pat, unsigned long timeout);
-extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
-extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
-extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
-extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
-extern unsigned int ata_data_xfer(struct ata_device *dev,
+extern void ata_sff_qc_prep(struct ata_queued_cmd *qc);
+extern void ata_sff_dumb_qc_prep(struct ata_queued_cmd *qc);
+extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device);
+extern u8 ata_sff_check_status(struct ata_port *ap);
+extern u8 ata_sff_altstatus(struct ata_port *ap);
+extern int ata_sff_busy_sleep(struct ata_port *ap,
+                             unsigned long timeout_pat, unsigned long timeout);
+extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline);
+extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
+extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
+extern void ata_sff_exec_command(struct ata_port *ap,
+                                const struct ata_taskfile *tf);
+extern unsigned int ata_sff_data_xfer(struct ata_device *dev,
                        unsigned char *buf, unsigned int buflen, int rw);
-extern unsigned int ata_data_xfer_noirq(struct ata_device *dev,
+extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev,
                        unsigned char *buf, unsigned int buflen, int rw);
-extern u8 ata_irq_on(struct ata_port *ap);
-extern void ata_bmdma_irq_clear(struct ata_port *ap);
-extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
-                       u8 status, int in_wq);
-extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
-extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
-extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
-extern void ata_bmdma_freeze(struct ata_port *ap);
-extern void ata_bmdma_thaw(struct ata_port *ap);
-extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
-extern unsigned int ata_dev_try_classify(struct ata_device *dev, int present,
-                                        u8 *r_err);
-extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline);
-extern int ata_std_softreset(struct ata_link *link, unsigned int *classes,
+extern u8 ata_sff_irq_on(struct ata_port *ap);
+extern void ata_sff_irq_clear(struct ata_port *ap);
+extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
+                           u8 status, int in_wq);
+extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
+extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
+extern unsigned int ata_sff_host_intr(struct ata_port *ap,
+                                     struct ata_queued_cmd *qc);
+extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance);
+extern void ata_sff_freeze(struct ata_port *ap);
+extern void ata_sff_thaw(struct ata_port *ap);
+extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline);
+extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
+                                         u8 *r_err);
+extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask,
+                                   unsigned long deadline);
+extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
                             unsigned long deadline);
-extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
-                             unsigned long deadline);
-extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
-extern void ata_bmdma_error_handler(struct ata_port *ap);
-extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
+extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
+                              unsigned long deadline);
+extern void ata_sff_postreset(struct ata_link *link, unsigned int *classes);
+extern void ata_sff_error_handler(struct ata_port *ap);
+extern void ata_sff_post_internal_cmd(struct ata_queued_cmd *qc);
 extern int ata_sff_port_start(struct ata_port *ap);
-extern void ata_std_ports(struct ata_ioports *ioaddr);
-extern unsigned long ata_pci_default_filter(struct ata_device *dev,
-                                           unsigned long xfer_mask);
+extern void ata_sff_std_ports(struct ata_ioports *ioaddr);
+extern unsigned long ata_bmdma_mode_filter(struct ata_device *dev,
+                                          unsigned long xfer_mask);
 extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
 extern void ata_bmdma_start(struct ata_queued_cmd *qc);
 extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
@@ -1387,40 +1424,35 @@ extern u8 ata_bmdma_status(struct ata_port *ap);
 extern void ata_bus_reset(struct ata_port *ap);
 
 #ifdef CONFIG_PCI
-extern int ata_pci_clear_simplex(struct pci_dev *pdev);
-extern int ata_pci_init_bmdma(struct ata_host *host);
-extern int ata_pci_init_sff_host(struct ata_host *host);
-extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
+extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev);
+extern int ata_pci_bmdma_init(struct ata_host *host);
+extern int ata_pci_sff_init_host(struct ata_host *host);
+extern int ata_pci_sff_prepare_host(struct pci_dev *pdev,
                                    const struct ata_port_info * const * ppi,
                                    struct ata_host **r_host);
-extern int ata_pci_activate_sff_host(struct ata_host *host,
+extern int ata_pci_sff_activate_host(struct ata_host *host,
                                     irq_handler_t irq_handler,
                                     struct scsi_host_template *sht);
-extern int ata_pci_init_one(struct pci_dev *pdev,
-                           const struct ata_port_info * const * ppi,
-                           struct scsi_host_template *sht, void *host_priv);
+extern int ata_pci_sff_init_one(struct pci_dev *pdev,
+                               const struct ata_port_info * const * ppi,
+                               struct scsi_host_template *sht, void *host_priv);
 #endif /* CONFIG_PCI */
 
-static inline u8 ata_chk_status(struct ata_port *ap)
-{
-       return ap->ops->check_status(ap);
-}
-
 /**
- *     ata_pause - Flush writes and pause 400 nanoseconds.
+ *     ata_sff_pause - Flush writes and pause 400 nanoseconds.
  *     @ap: Port to wait for.
  *
  *     LOCKING:
  *     Inherited from caller.
  */
-static inline void ata_pause(struct ata_port *ap)
+static inline void ata_sff_pause(struct ata_port *ap)
 {
-       ata_altstatus(ap);
+       ata_sff_altstatus(ap);
        ndelay(400);
 }
 
 /**
- *     ata_busy_wait - Wait for a port status register
+ *     ata_sff_busy_wait - Wait for a port status register
  *     @ap: Port to wait for.
  *     @bits: bits that must be clear
  *     @max: number of 10uS waits to perform
@@ -1432,14 +1464,14 @@ static inline void ata_pause(struct ata_port *ap)
  *     LOCKING:
  *     Inherited from caller.
  */
-static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
-                              unsigned int max)
+static inline u8 ata_sff_busy_wait(struct ata_port *ap, unsigned int bits,
+                                  unsigned int max)
 {
        u8 status;
 
        do {
                udelay(10);
-               status = ata_chk_status(ap);
+               status = ap->ops->sff_check_status(ap);
                max--;
        } while (status != 0xff && (status & bits) && (max > 0));
 
@@ -1458,7 +1490,7 @@ static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
  */
 static inline u8 ata_wait_idle(struct ata_port *ap)
 {
-       u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
+       u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
 
 #ifdef ATA_DEBUG
        if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
@@ -1468,5 +1500,6 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
 
        return status;
 }
+#endif /* CONFIG_ATA_SFF */
 
 #endif /* __LINUX_LIBATA_H__ */