Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[sfrench/cifs-2.6.git] / include / linux / libata.h
index 745c4f9b4caafab27c1299268cf4eb363d7e7d7f..be5a43928c848fc885625c2e1313b080084cb4d4 100644 (file)
@@ -116,6 +116,7 @@ static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
 enum {
        /* various global constants */
        LIBATA_MAX_PRD          = ATA_MAX_PRD / 2,
+       LIBATA_DUMB_MAX_PRD     = ATA_MAX_PRD / 4,      /* Worst case */
        ATA_MAX_PORTS           = 8,
        ATA_DEF_QUEUE           = 1,
        /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
@@ -136,6 +137,8 @@ enum {
        ATA_DFLAG_CDB_INTR      = (1 << 2), /* device asserts INTRQ when ready for CDB */
        ATA_DFLAG_NCQ           = (1 << 3), /* device supports NCQ */
        ATA_DFLAG_FLUSH_EXT     = (1 << 4), /* do FLUSH_EXT instead of FLUSH */
+       ATA_DFLAG_ACPI_PENDING  = (1 << 5), /* ACPI resume action pending */
+       ATA_DFLAG_ACPI_FAILED   = (1 << 6), /* ACPI on devcfg has failed */
        ATA_DFLAG_CFG_MASK      = (1 << 8) - 1,
 
        ATA_DFLAG_PIO           = (1 << 8), /* device limited to PIO mode */
@@ -193,9 +196,9 @@ enum {
        ATA_PFLAG_SCSI_HOTPLUG  = (1 << 6), /* SCSI hotplug scheduled */
        ATA_PFLAG_INITIALIZING  = (1 << 7), /* being initialized, don't touch */
 
-       ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */
        ATA_PFLAG_SUSPENDED     = (1 << 17), /* port is suspended (power) */
        ATA_PFLAG_PM_PENDING    = (1 << 18), /* PM operation pending */
+       ATA_PFLAG_GTM_VALID     = (1 << 19), /* acpi_gtm data valid */
 
        /* struct ata_queued_cmd flags */
        ATA_QCFLAG_ACTIVE       = (1 << 0), /* cmd not yet ack'd to scsi lyer */
@@ -298,7 +301,6 @@ enum {
        ATA_HORKAGE_NODMA       = (1 << 1),     /* DMA problems */
        ATA_HORKAGE_NONCQ       = (1 << 2),     /* Don't use NCQ */
        ATA_HORKAGE_MAX_SEC_128 = (1 << 3),     /* Limit max sects to 128 */
-       ATA_HORKAGE_DMA_RW_ONLY = (1 << 4),     /* ATAPI DMA for RW only */
 };
 
 enum hsm_task_states {
@@ -321,6 +323,7 @@ enum ata_completion_errors {
        AC_ERR_INVALID          = (1 << 7), /* invalid argument */
        AC_ERR_OTHER            = (1 << 8), /* unknown */
        AC_ERR_NODEV_HINT       = (1 << 9), /* polling device detection hint */
+       AC_ERR_NCQ              = (1 << 10), /* marker for offending NCQ qc */
 };
 
 /* forward declarations */
@@ -364,6 +367,9 @@ struct ata_host {
        void                    *private_data;
        const struct ata_port_operations *ops;
        unsigned long           flags;
+#ifdef CONFIG_ATA_ACPI
+       acpi_handle             acpi_handle;
+#endif
        struct ata_port         *simplex_claimed;       /* channel owning the DMA */
        struct ata_port         *ports[0];
 };
@@ -429,7 +435,11 @@ struct ata_device {
        struct ata_port         *ap;
        unsigned int            devno;          /* 0 or 1 */
        unsigned long           flags;          /* ATA_DFLAG_xxx */
+       unsigned int            horkage;        /* List of broken features */
        struct scsi_device      *sdev;          /* attached SCSI device */
+#ifdef CONFIG_ATA_ACPI
+       acpi_handle             acpi_handle;
+#endif
        /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
        u64                     n_sectors;      /* size of device, if ATA */
        unsigned int            class;          /* ATA_DEV_xxx */
@@ -457,11 +467,6 @@ struct ata_device {
        /* error history */
        struct ata_ering        ering;
        int                     spdn_cnt;
-       unsigned int            horkage;        /* List of broken features */
-#ifdef CONFIG_ATA_ACPI
-       /* ACPI objects info */
-       acpi_handle obj_handle;
-#endif
 };
 
 /* Offset into struct ata_device.  Fields above it are maintained
@@ -490,6 +495,17 @@ struct ata_eh_context {
        unsigned int            did_probe_mask;
 };
 
+struct ata_acpi_drive
+{
+       u32 pio;
+       u32 dma;
+} __packed;
+
+struct ata_acpi_gtm {
+       struct ata_acpi_drive drive[2];
+       u32 flags;
+} __packed;
+
 struct ata_port {
        struct Scsi_Host        *scsi_host; /* our co-allocated scsi host */
        const struct ata_port_operations *ops;
@@ -515,6 +531,7 @@ struct ata_port {
        unsigned int            cbl;    /* cable type; ATA_CBL_xxx */
        unsigned int            hw_sata_spd_limit;
        unsigned int            sata_spd_limit; /* SATA PHY speed limit */
+       unsigned int            sata_spd;       /* current SATA PHY speed */
 
        /* record runtime error info, protected by host lock */
        struct ata_eh_info      eh_info;
@@ -548,8 +565,15 @@ struct ata_port {
        pm_message_t            pm_mesg;
        int                     *pm_result;
 
+       struct timer_list       fastdrain_timer;
+       unsigned long           fastdrain_cnt;
+
        void                    *private_data;
 
+#ifdef CONFIG_ATA_ACPI
+       acpi_handle             acpi_handle;
+       struct ata_acpi_gtm     acpi_gtm;
+#endif
        u8                      sector_buf[ATA_SECT_SIZE]; /* owned by EH */
 };
 
@@ -600,9 +624,8 @@ struct ata_port_operations {
        u8 (*irq_on) (struct ata_port *);
        u8 (*irq_ack) (struct ata_port *ap, unsigned int chk_drq);
 
-       u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
-       void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
-                          u32 val);
+       int (*scr_read) (struct ata_port *ap, unsigned int sc_reg, u32 *val);
+       int (*scr_write) (struct ata_port *ap, unsigned int sc_reg, u32 val);
 
        int (*port_suspend) (struct ata_port *ap, pm_message_t mesg);
        int (*port_resume) (struct ata_port *ap);
@@ -745,7 +768,8 @@ extern unsigned int ata_dev_try_classify(struct ata_port *, unsigned int, u8 *);
  */
 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_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp);
+extern void ata_tf_to_fis(const struct ata_taskfile *tf,
+                         u8 pmp, int is_cmd, u8 *fis);
 extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
 extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device);
 extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
@@ -759,6 +783,7 @@ extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf,
                          unsigned int buflen, int write_data);
 extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
                                unsigned int buflen, int write_data);
+extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
 extern void ata_qc_prep(struct ata_queued_cmd *qc);
 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
 extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
@@ -773,7 +798,6 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
 extern void ata_id_c_string(const u16 *id, unsigned char *s,
                            unsigned int ofs, unsigned int len);
 extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown);
-extern unsigned long ata_device_blacklisted(const struct ata_device *dev);
 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);
@@ -850,11 +874,11 @@ struct pci_bits {
        unsigned long           val;
 };
 
-extern int ata_pci_init_native_host(struct ata_host *host);
+extern int ata_pci_init_sff_host(struct ata_host *host);
 extern int ata_pci_init_bmdma(struct ata_host *host);
-extern int ata_pci_prepare_native_host(struct pci_dev *pdev,
-                               const struct ata_port_info * const * ppi,
-                               struct ata_host **r_host);
+extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
+                                   const struct ata_port_info * const * ppi,
+                                   struct ata_host **r_host);
 extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
 extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long);
 #endif /* CONFIG_PCI */
@@ -890,27 +914,21 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
 /*
  * ata_eh_info helpers
  */
-#define ata_ehi_push_desc(ehi, fmt, args...) do { \
-       (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \
-                                    ATA_EH_DESC_LEN - (ehi)->desc_len, \
-                                    fmt , ##args); \
-} while (0)
-
-#define ata_ehi_clear_desc(ehi) do { \
-       (ehi)->desc[0] = '\0'; \
-       (ehi)->desc_len = 0; \
-} while (0)
-
-static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi)
+extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...);
+extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...);
+extern void ata_ehi_clear_desc(struct ata_eh_info *ehi);
+
+static inline void ata_ehi_schedule_probe(struct ata_eh_info *ehi)
 {
-       ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK;
+       ehi->flags |= ATA_EHI_RESUME_LINK;
        ehi->action |= ATA_EH_SOFTRESET;
        ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
 }
 
 static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
 {
-       __ata_ehi_hotplugged(ehi);
+       ata_ehi_schedule_probe(ehi);
+       ehi->flags |= ATA_EHI_HOTPLUGGED;
        ehi->err_mask |= AC_ERR_ATA_BUS;
 }
 
@@ -1088,11 +1106,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
 {
        u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
 
-       if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) {
-               if (ata_msg_warn(ap))
-                       printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%p\n",
-                               status, ap->ioaddr.status_addr);
-       }
+       if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
+               DPRINTK("ATA: abnormal status 0x%X on port 0x%p\n",
+                       status, ap->ioaddr.status_addr);
 
        return status;
 }