]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: ufs: ufs-mediatek: Add stage information for ref-clk control
authorPeter Wang <peter.wang@mediatek.com>
Thu, 23 Jun 2022 03:50:48 +0000 (11:50 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 28 Jun 2022 03:17:36 +0000 (23:17 -0400)
Add "PRE_CHANGE" and "POST_CHANGE" information for ref-clk control to
precisely configure the low-power state of the parent of ref-clk.

Link: https://lore.kernel.org/r/20220623035052.18802-5-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/host/ufs-mediatek.c
drivers/ufs/host/ufs-mediatek.h

index b15351c2235bf80d6c37ad227287d86b26d272d0..0cc7d4faccec4e02422cd3563adc2daec2780af7 100644 (file)
@@ -244,8 +244,9 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
        if (host->ref_clk_enabled == on)
                return 0;
 
+       ufs_mtk_ref_clk_notify(on, PRE_CHANGE, res);
+
        if (on) {
-               ufs_mtk_ref_clk_notify(on, res);
                ufshcd_writel(hba, REFCLK_REQUEST, REG_UFS_REFCLK_CTRL);
        } else {
                ufshcd_delay_us(host->ref_clk_gating_wait_us, 10);
@@ -267,7 +268,7 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
 
        dev_err(hba->dev, "missing ack of refclk req, reg: 0x%x\n", value);
 
-       ufs_mtk_ref_clk_notify(host->ref_clk_enabled, res);
+       ufs_mtk_ref_clk_notify(host->ref_clk_enabled, POST_CHANGE, res);
 
        return -ETIMEDOUT;
 
@@ -275,8 +276,8 @@ out:
        host->ref_clk_enabled = on;
        if (on)
                ufshcd_delay_us(host->ref_clk_ungating_wait_us, 10);
-       else
-               ufs_mtk_ref_clk_notify(on, res);
+
+       ufs_mtk_ref_clk_notify(on, POST_CHANGE, res);
 
        return 0;
 }
index f5c1c643dd52a8192e04c6dfe8e0d287b99752d9..c12ceb4d941fb8d312de8de534b26ea537d5ed27 100644 (file)
@@ -189,8 +189,8 @@ static void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
 #define ufs_mtk_crypto_ctrl(res, enable) \
        ufs_mtk_smc(UFS_MTK_SIP_CRYPTO_CTRL, &(res), enable)
 
-#define ufs_mtk_ref_clk_notify(on, res) \
-       ufs_mtk_smc(UFS_MTK_SIP_REF_CLK_NOTIFICATION, &(res), on)
+#define ufs_mtk_ref_clk_notify(on, stage, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_REF_CLK_NOTIFICATION, &(res), on, stage)
 
 #define ufs_mtk_device_reset_ctrl(high, res) \
        ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, &(res), high)