libata: reimplement link power management
[pandora-kernel.git] / include / linux / libata.h
index 45fb296..bc4ee21 100644 (file)
@@ -172,6 +172,7 @@ enum {
        ATA_LFLAG_NO_RETRY      = (1 << 5), /* don't retry this link */
        ATA_LFLAG_DISABLED      = (1 << 6), /* link is disabled */
        ATA_LFLAG_SW_ACTIVITY   = (1 << 7), /* keep activity stats */
+       ATA_LFLAG_NO_LPM        = (1 << 8), /* disable LPM on this link */
 
        /* struct ata_port flags */
        ATA_FLAG_SLAVE_POSS     = (1 << 0), /* host supports slave dev */
@@ -196,7 +197,7 @@ enum {
        ATA_FLAG_ACPI_SATA      = (1 << 17), /* need native SATA ACPI layout */
        ATA_FLAG_AN             = (1 << 18), /* controller supports AN */
        ATA_FLAG_PMP            = (1 << 19), /* controller supports PMP */
-       ATA_FLAG_IPM            = (1 << 20), /* driver can handle IPM */
+       ATA_FLAG_LPM            = (1 << 20), /* driver can handle LPM */
        ATA_FLAG_EM             = (1 << 21), /* driver supports enclosure
                                              * management */
        ATA_FLAG_SW_ACTIVITY    = (1 << 22), /* driver supports sw activity
@@ -324,12 +325,11 @@ enum {
        ATA_EH_HARDRESET        = (1 << 2), /* meaningful only in ->prereset */
        ATA_EH_RESET            = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
        ATA_EH_ENABLE_LINK      = (1 << 3),
-       ATA_EH_LPM              = (1 << 4),  /* link power management action */
        ATA_EH_PARK             = (1 << 5), /* unload heads and stop I/O */
 
        ATA_EH_PERDEV_MASK      = ATA_EH_REVALIDATE | ATA_EH_PARK,
        ATA_EH_ALL_ACTIONS      = ATA_EH_REVALIDATE | ATA_EH_RESET |
-                                 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
+                                 ATA_EH_ENABLE_LINK,
 
        /* ata_eh_info->flags */
        ATA_EHI_HOTPLUGGED      = (1 << 0),  /* could have been hotplugged */
@@ -377,7 +377,6 @@ enum {
        ATA_HORKAGE_BROKEN_HPA  = (1 << 4),     /* Broken HPA */
        ATA_HORKAGE_DISABLE     = (1 << 5),     /* Disable it */
        ATA_HORKAGE_HPA_SIZE    = (1 << 6),     /* native size off by one */
-       ATA_HORKAGE_IPM         = (1 << 7),     /* Link PM problems */
        ATA_HORKAGE_IVB         = (1 << 8),     /* cbl det validity bit bugs */
        ATA_HORKAGE_STUCK_ERR   = (1 << 9),     /* stuck ERR on next PACKET */
        ATA_HORKAGE_BRIDGE_OK   = (1 << 10),    /* no bridge limits */
@@ -464,6 +463,22 @@ enum ata_completion_errors {
        AC_ERR_NCQ              = (1 << 10), /* marker for offending NCQ qc */
 };
 
+/*
+ * Link power management policy: If you alter this, you also need to
+ * alter libata-scsi.c (for the ascii descriptions)
+ */
+enum ata_lpm_policy {
+       ATA_LPM_UNKNOWN,
+       ATA_LPM_MAX_POWER,
+       ATA_LPM_MED_POWER,
+       ATA_LPM_MIN_POWER,
+};
+
+enum ata_lpm_hints {
+       ATA_LPM_EMPTY           = (1 << 0), /* port empty/probing */
+       ATA_LPM_HIPM            = (1 << 1), /* may use HIPM */
+};
+
 /* forward declarations */
 struct scsi_device;
 struct ata_port_operations;
@@ -478,16 +493,6 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes,
                              unsigned long deadline);
 typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes);
 
-/*
- * host pm policy: If you alter this, you also need to alter libata-scsi.c
- * (for the ascii descriptions)
- */
-enum link_pm {
-       NOT_AVAILABLE,
-       MIN_POWER,
-       MAX_PERFORMANCE,
-       MEDIUM_POWER,
-};
 extern struct device_attribute dev_attr_link_power_management_policy;
 extern struct device_attribute dev_attr_unload_heads;
 extern struct device_attribute dev_attr_em_message_type;
@@ -604,6 +609,7 @@ struct ata_device {
        union acpi_object       *gtf_cache;
        unsigned int            gtf_filter;
 #endif
+       struct device           tdev;
        /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
        u64                     n_sectors;      /* size of device, if ATA */
        u64                     n_native_sectors; /* native size, if ATA */
@@ -690,6 +696,7 @@ struct ata_link {
        struct ata_port         *ap;
        int                     pmp;            /* port multiplier port # */
 
+       struct device           tdev;
        unsigned int            active_tag;     /* active tag on this link */
        u32                     sactive;        /* active NCQ commands */
 
@@ -699,6 +706,7 @@ struct ata_link {
        unsigned int            hw_sata_spd_limit;
        unsigned int            sata_spd_limit;
        unsigned int            sata_spd;       /* current SATA PHY speed */
+       enum ata_lpm_policy     lpm_policy;
 
        /* record runtime error info, protected by host_set lock */
        struct ata_eh_info      eh_info;
@@ -707,6 +715,8 @@ struct ata_link {
 
        struct ata_device       device[ATA_MAX_DEVICES];
 };
+#define ATA_LINK_CLEAR_BEGIN           offsetof(struct ata_link, active_tag)
+#define ATA_LINK_CLEAR_END             offsetof(struct ata_link, device[0])
 
 struct ata_port {
        struct Scsi_Host        *scsi_host; /* our co-allocated scsi host */
@@ -752,6 +762,7 @@ struct ata_port {
        struct ata_port_stats   stats;
        struct ata_host         *host;
        struct device           *dev;
+       struct device           tdev;
 
        struct mutex            scsi_scan_mutex;
        struct delayed_work     hotplug_task;
@@ -767,7 +778,7 @@ struct ata_port {
 
        pm_message_t            pm_mesg;
        int                     *pm_result;
-       enum link_pm            pm_policy;
+       enum ata_lpm_policy     target_lpm_policy;
 
        struct timer_list       fastdrain_timer;
        unsigned long           fastdrain_cnt;
@@ -833,8 +844,8 @@ struct ata_port_operations {
        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);
-       void (*disable_pm)(struct ata_port *ap);
+       int  (*set_lpm)(struct ata_link *link, enum ata_lpm_policy policy,
+                       unsigned hints);
 
        /*
         * Start, stop, suspend and resume
@@ -946,6 +957,8 @@ 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_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
+                            bool spm_wakeup);
 extern int sata_link_hardreset(struct ata_link *link,
                        const unsigned long *timing, unsigned long deadline,
                        bool *online, int (*check_ready)(struct ata_link *));