]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/libata.h
libata: misc updates to prepare for slave link
[linux-2.6-omap-h63xx.git] / include / linux / libata.h
index 06b80337303b805bffcc2920b0d8796004f902ef..0c7e6f3c28eb7057c1e2a9b31d1696031bcf3570 100644 (file)
@@ -163,6 +163,7 @@ enum {
        ATA_DEV_NONE            = 9,    /* no device */
 
        /* struct ata_link flags */
+       ATA_LFLAG_NO_HRST       = (1 << 1), /* avoid hardreset */
        ATA_LFLAG_NO_SRST       = (1 << 2), /* avoid softreset */
        ATA_LFLAG_ASSUME_ATA    = (1 << 3), /* assume ATA class */
        ATA_LFLAG_ASSUME_SEMB   = (1 << 4), /* assume SEMB class */
@@ -320,6 +321,8 @@ enum {
        ATA_EH_LPM              = (1 << 4),  /* link power management action */
 
        ATA_EH_PERDEV_MASK      = ATA_EH_REVALIDATE,
+       ATA_EH_ALL_ACTIONS      = ATA_EH_REVALIDATE | ATA_EH_RESET |
+                                 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
 
        /* ata_eh_info->flags */
        ATA_EHI_HOTPLUGGED      = (1 << 0),  /* could have been hotplugged */
@@ -646,6 +649,7 @@ struct ata_link {
 
        unsigned int            flags;          /* ATA_LFLAG_xxx */
 
+       u32                     saved_scontrol; /* SControl on probe */
        unsigned int            hw_sata_spd_limit;
        unsigned int            sata_spd_limit;
        unsigned int            sata_spd;       /* current SATA PHY speed */
@@ -770,8 +774,8 @@ struct ata_port_operations {
        /*
         * Optional features
         */
-       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  (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val);
+       int  (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
        void (*pmp_attach)(struct ata_port *ap);
        void (*pmp_detach)(struct ata_port *ap);
        int  (*enable_pm)(struct ata_port *ap, enum link_pm policy);
@@ -918,8 +922,8 @@ extern int sata_scr_valid(struct ata_link *link);
 extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
 extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
 extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
-extern int ata_link_online(struct ata_link *link);
-extern int ata_link_offline(struct ata_link *link);
+extern bool ata_link_online(struct ata_link *link);
+extern bool ata_link_offline(struct ata_link *link);
 #ifdef CONFIG_PM
 extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
 extern void ata_host_resume(struct ata_host *host);
@@ -1263,34 +1267,17 @@ static inline int ata_link_active(struct ata_link *link)
        return ata_tag_valid(link->active_tag) || link->sactive;
 }
 
-static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
-{
-       if (sata_pmp_attached(ap))
-               return ap->pmp_link;
-       return &ap->link;
-}
-
-static inline struct ata_link *ata_port_next_link(struct ata_link *link)
-{
-       struct ata_port *ap = link->ap;
+extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
+                                            struct ata_link *link,
+                                            bool dev_only);
 
-       if (ata_is_host_link(link)) {
-               if (!sata_pmp_attached(ap))
-                       return NULL;
-               return ap->pmp_link;
-       }
-
-       if (++link < ap->nr_pmp_links + ap->pmp_link)
-               return link;
-       return NULL;
-}
-
-#define __ata_port_for_each_link(lk, ap) \
-       for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk))
+#define __ata_port_for_each_link(link, ap) \
+       for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
+            (link) = __ata_port_next_link((ap), (link), false))
 
 #define ata_port_for_each_link(link, ap) \
-       for ((link) = ata_port_first_link(ap); (link); \
-            (link) = ata_port_next_link(link))
+       for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
+            (link) = __ata_port_next_link((ap), (link), true))
 
 #define ata_link_for_each_dev(dev, link) \
        for ((dev) = (link)->device; \
@@ -1427,6 +1414,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies,
        return from_jiffies + msecs_to_jiffies(timeout_msecs);
 }
 
+/* Don't open code these in drivers as there are traps. Firstly the range may
+   change in future hardware and specs, secondly 0xFF means 'no DMA' but is
+   > UDMA_0. Dyma ddreigiau */
+
+static inline int ata_using_mwdma(struct ata_device *adev)
+{
+       if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
+               return 1;
+       return 0;
+}
+
+static inline int ata_using_udma(struct ata_device *adev)
+{
+       if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
+               return 1;
+       return 0;
+}
+
+static inline int ata_dma_enabled(struct ata_device *adev)
+{
+       return (adev->dma_mode == 0xFF ? 0 : 1);
+}
 
 /**************************************************************************
  * PMP - drivers/ata/libata-pmp.c