scsi: ufs: introduce a broken PA_RXHSUNTERMCAP quirk
[platform/kernel/linux-rpi.git] / drivers / scsi / ufs / ufshcd.h
index 4a574aa..8636ec9 100644 (file)
@@ -366,6 +366,7 @@ struct ufs_init_prefetch {
  * @saved_err: sticky error mask
  * @saved_uic_err: sticky UIC error mask
  * @dev_cmd: ufs device management command information
+ * @last_dme_cmd_tstamp: time stamp of the last completed DME command
  * @auto_bkops_enabled: to track whether bkops is enabled in device
  * @vreg_info: UFS device voltage regulator information
  * @clk_list_head: UFS host controller clocks list node head
@@ -416,6 +417,32 @@ struct ufs_hba {
        unsigned int irq;
        bool is_irq_enabled;
 
+       /* Interrupt aggregation support is broken */
+       #define UFSHCD_QUIRK_BROKEN_INTR_AGGR                   UFS_BIT(0)
+
+       /*
+        * delay before each dme command is required as the unipro
+        * layer has shown instabilities
+        */
+       #define UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS              UFS_BIT(1)
+
+       /*
+        * If UFS host controller is having issue in processing LCC (Line
+        * Control Command) coming from device then enable this quirk.
+        * When this quirk is enabled, host controller driver should disable
+        * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE
+        * attribute of device to 0).
+        */
+       #define UFSHCD_QUIRK_BROKEN_LCC                         UFS_BIT(2)
+
+       /*
+        * The attribute PA_RXHSUNTERMCAP specifies whether or not the
+        * inbound Link supports unterminated line in HS mode. Setting this
+        * attribute to 1 fixes moving to HS gear.
+        */
+       #define UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP            UFS_BIT(3)
+
+       unsigned int quirks;    /* Deviations from standard UFSHCI spec. */
 
        wait_queue_head_t tm_wq;
        wait_queue_head_t tm_tag_wq;
@@ -446,6 +473,7 @@ struct ufs_hba {
 
        /* Device management request data */
        struct ufs_dev_cmd dev_cmd;
+       ktime_t last_dme_cmd_tstamp;
 
        /* Keeps information of the UFS device connected to this host */
        struct ufs_dev_info dev_info;
@@ -469,6 +497,12 @@ struct ufs_hba {
 #define UFSHCD_CAP_CLK_SCALING (1 << 2)
        /* Allow auto bkops to enabled during runtime suspend */
 #define UFSHCD_CAP_AUTO_BKOPS_SUSPEND (1 << 3)
+       /*
+        * This capability allows host controller driver to use the UFS HCI's
+        * interrupt aggregation capability.
+        * CAUTION: Enabling this might reduce overall UFS throughput.
+        */
+#define UFSHCD_CAP_INTR_AGGR (1 << 4)
 
        struct devfreq *devfreq;
        struct ufs_clk_scaling clk_scaling;
@@ -493,6 +527,15 @@ static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba)
        return hba->caps & UFSHCD_CAP_AUTO_BKOPS_SUSPEND;
 }
 
+static inline bool ufshcd_is_intr_aggr_allowed(struct ufs_hba *hba)
+{
+       if ((hba->caps & UFSHCD_CAP_INTR_AGGR) &&
+           !(hba->quirks & UFSHCD_QUIRK_BROKEN_INTR_AGGR))
+               return true;
+       else
+               return false;
+}
+
 #define ufshcd_writel(hba, val, reg)   \
        writel((val), (hba)->mmio_base + (reg))
 #define ufshcd_readl(hba, reg) \