]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ufs: core: Add quirks for VCC ramp-up delay
authorEd Tsai <ed.tsai@mediatek.com>
Tue, 10 Mar 2026 00:52:28 +0000 (08:52 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 11 Mar 2026 01:34:59 +0000 (21:34 -0400)
On some platforms, the VCC regulator has a slow ramp-up time. Add a delay
after enabling VCC to ensure voltage has fully stabilized before we enable
the clocks.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Ed Tsai <ed.tsai@mediatek.com>
Link: https://patch.msgid.link/20260310005230.4001904-4-ed.tsai@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c
include/ufs/ufshcd.h

index 0eb4f4af231ef7348bfbc1fccf86ec922dc1dacd..cf7f0ae46f753d0a7eaeaf658a5904d92473022f 100644 (file)
@@ -9952,11 +9952,13 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)
 #ifdef CONFIG_PM
 static int ufshcd_vreg_set_hpm(struct ufs_hba *hba)
 {
+       bool vcc_on = false;
        int ret = 0;
 
        if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba) &&
            !hba->dev_info.is_lu_power_on_wp) {
                ret = ufshcd_setup_vreg(hba, true);
+               vcc_on = true;
        } else if (!ufshcd_is_ufs_dev_active(hba)) {
                if (!ufshcd_is_link_active(hba)) {
                        ret = ufshcd_config_vreg_hpm(hba, hba->vreg_info.vccq);
@@ -9967,6 +9969,7 @@ static int ufshcd_vreg_set_hpm(struct ufs_hba *hba)
                                goto vccq_lpm;
                }
                ret = ufshcd_toggle_vreg(hba->dev, hba->vreg_info.vcc, true);
+               vcc_on = true;
        }
        goto out;
 
@@ -9975,6 +9978,15 @@ vccq_lpm:
 vcc_disable:
        ufshcd_toggle_vreg(hba->dev, hba->vreg_info.vcc, false);
 out:
+       /*
+        * On platforms with a slow VCC ramp-up, a delay is needed after
+        * turning on VCC to ensure the voltage is stable before the
+        * reference clock is enabled.
+        */
+       if (hba->quirks & UFSHCD_QUIRK_VCC_ON_DELAY && !ret && vcc_on &&
+           hba->vreg_info.vcc && !hba->vreg_info.vcc->always_on)
+               usleep_range(1000, 1100);
+
        return ret;
 }
 #endif /* CONFIG_PM */
index 182f301c11e7e2b51310c0ab18bc7415a916a429..cb6f1537a3f36668e1360abcb39369d44d7ea749 100644 (file)
@@ -690,6 +690,12 @@ enum ufshcd_quirks {
         * because it causes link startup to become unreliable.
         */
        UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE          = 1 << 26,
+
+       /*
+        * On some platforms, the VCC regulator has a slow ramp-up time. Add a
+        * delay after enabling VCC to ensure it's stable.
+        */
+       UFSHCD_QUIRK_VCC_ON_DELAY                       = 1 << 27,
 };
 
 enum ufshcd_caps {