From d07049b66cbb224ced2b2c0770c4f6997505069f Mon Sep 17 00:00:00 2001 From: Can Guo Date: Thu, 12 Mar 2020 22:17:02 -0700 Subject: [PATCH] scsi: ufs-qcom: Configure LPM timer settings The timer settings of LPM features such as clock gating, auto hibern8 and RPM auto suspend are hard coded in UFS common driver, make this change to configure these settings in vendor specific driver. Change-Id: Iddf5c5024a168bc6b8ebc8948a5aa9ffbb2e4e1b Signed-off-by: Can Guo --- drivers/scsi/ufs/ufs-qcom.c | 23 +++++++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index bb4f3294a54b..9feb3a9593e8 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1486,8 +1487,19 @@ out: static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba) { + unsigned long flags; int err = 0; + spin_lock_irqsave(hba->host->host_lock, flags); + /* Set the rpm auto suspend delay to 3s */ + hba->host->hostt->rpm_autosuspend_delay = UFS_QCOM_AUTO_SUSPEND_DELAY; + /* Set the default auto-hiberate idle timer value to 1ms */ + hba->ahit = FIELD_PREP(UFSHCI_AHIBERN8_TIMER_MASK, 1) | + FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, 3); + /* Set the clock gating delay to performance mode */ + hba->clk_gating.delay_ms = UFS_QCOM_CLK_GATING_DELAY_MS_PERF; + spin_unlock_irqrestore(hba->host->host_lock, flags); + if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME) err = ufs_qcom_quirk_host_pa_saveconfigtime(hba); @@ -2352,6 +2364,12 @@ out: static int ufs_qcom_clk_scale_up_post_change(struct ufs_hba *hba) { + unsigned long flags; + + spin_lock_irqsave(hba->host->host_lock, flags); + hba->clk_gating.delay_ms = UFS_QCOM_CLK_GATING_DELAY_MS_PERF; + spin_unlock_irqrestore(hba->host->host_lock, flags); + return 0; } @@ -2388,6 +2406,11 @@ static int ufs_qcom_clk_scale_down_post_change(struct ufs_hba *hba) struct ufs_clk_info *clki; struct list_head *head = &hba->clk_list_head; u32 curr_freq = 0; + unsigned long flags; + + spin_lock_irqsave(hba->host->host_lock, flags); + hba->clk_gating.delay_ms = UFS_QCOM_CLK_GATING_DELAY_MS_PWR_SAVE; + spin_unlock_irqrestore(hba->host->host_lock, flags); if (!ufs_qcom_cap_qunipro(host)) return 0; diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h index 5d314251e372..a8f78aed9713 100644 --- a/drivers/scsi/ufs/ufs-qcom.h +++ b/drivers/scsi/ufs/ufs-qcom.h @@ -52,6 +52,11 @@ #define UFS_QCOM_LIMIT_DESIRED_MODE FAST #define UFS_QCOM_LIMIT_PHY_SUBMODE UFS_QCOM_PHY_SUBMODE_G4 +/* default value of auto suspend is 3 seconds */ +#define UFS_QCOM_AUTO_SUSPEND_DELAY 3000 +#define UFS_QCOM_CLK_GATING_DELAY_MS_PWR_SAVE 10 +#define UFS_QCOM_CLK_GATING_DELAY_MS_PERF 50 + /* QCOM UFS host controller vendor specific registers */ enum { REG_UFS_SYS1CLK_1US = 0xC0,