mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhe Wang <zhewang116@gmail.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com,
	alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	beanhuo@micron.com, stanley.chu@mediatek.com,
	adrian.hunter@intel.com, zhe.wang1@unisoc.com,
	zhenxiong.lai@unisoc.com, yuelin.tang@unisoc.com
Subject: [PATCH V2] scsi: ufs: core: Let delay value after LPM can be modified by vendor
Date: Fri, 21 Oct 2022 09:52:17 +0800	[thread overview]
Message-ID: <20221021015217.20272-1-zhewang116@gmail.com> (raw)

From: Zhe Wang <zhe.wang1@unisoc.com>

Some UFS devices require that the VCC should drop below 0.1V after
turning off, otherwise device may not resume successfully. And
because the power-off rate is different on different SOC platforms.
Therefore, we hope that the delay can be modified by vendor to
adjust the most appropriate delay value.

Signed-off-by: Zhe Wang <zhe.wang1@unisoc.com>
---
V1 -> V2
- move turnoff_delay_us to struct ufs_vreg instead
- replace usleep_range with ufshcd_delay_us

 drivers/ufs/core/ufshcd.c | 9 ++++++++-
 include/ufs/ufs.h         | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 7256e6c43ca6..386ff6ed2f20 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -89,6 +89,9 @@
 /* Polling time to wait for fDeviceInit */
 #define FDEVICEINIT_COMPL_TIMEOUT 1500 /* millisecs */
 
+/* Default value of turn off VCC rail: 5000us */
+#define UFS_VCC_TURNOFF_DELAY_US 5000
+
 #define ufshcd_toggle_vreg(_dev, _vreg, _on)				\
 	({                                                              \
 		int _ret;                                               \
@@ -7784,6 +7787,10 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
 
 	ufs_fixup_device_setup(hba);
 
+	if (hba->dev_quirks & UFS_DEVICE_QUIRK_DELAY_AFTER_LPM &&
+	    !hba->vreg_info.vcc->turnoff_delay_us)
+		hba->vreg_info.vcc->turnoff_delay_us = UFS_VCC_TURNOFF_DELAY_US;
+
 	ufshcd_wb_probe(hba, desc_buf);
 
 	ufshcd_temp_notif_probe(hba, desc_buf);
@@ -8918,7 +8925,7 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)
 	 */
 	if (vcc_off && hba->vreg_info.vcc &&
 		hba->dev_quirks & UFS_DEVICE_QUIRK_DELAY_AFTER_LPM)
-		usleep_range(5000, 5100);
+		ufshcd_delay_us(hba->vreg_info.vcc->turnoff_delay_us, 100);
 }
 
 #ifdef CONFIG_PM
diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h
index 1bba3fead2ce..792335dfd70b 100644
--- a/include/ufs/ufs.h
+++ b/include/ufs/ufs.h
@@ -569,6 +569,7 @@ struct ufs_vreg {
 	bool always_on;
 	bool enabled;
 	int max_uA;
+	u32 turnoff_delay_us;
 };
 
 struct ufs_vreg_info {
-- 
2.17.1


             reply	other threads:[~2022-10-21  1:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21  1:52 Zhe Wang [this message]
2022-10-21  7:46 ` Avri Altman
2022-10-23 10:18   ` Zhe Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221021015217.20272-1-zhewang116@gmail.com \
    --to=zhewang116@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stanley.chu@mediatek.com \
    --cc=yuelin.tang@unisoc.com \
    --cc=zhe.wang1@unisoc.com \
    --cc=zhenxiong.lai@unisoc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®