lkml.org 
[lkml]   [2020]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 5/8] scsi: ufs-mediatek: replace all delay places by common delay function
Date
A common delay function is introduced in UFS core driver, thus
ufs-mediatek can use it to replace all delay codes.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 3b0e575d7460..0ff6781654fd 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -100,17 +100,6 @@ static int ufs_mtk_bind_mphy(struct ufs_hba *hba)
return err;
}

-static void ufs_mtk_udelay(unsigned long us)
-{
- if (!us)
- return;
-
- if (us < 10)
- udelay(us);
- else
- usleep_range(us, us + 10);
-}
-
static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
@@ -123,7 +112,7 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)

if (on) {
ufs_mtk_ref_clk_notify(on, res);
- ufs_mtk_udelay(host->ref_clk_ungating_wait_us);
+ ufshcd_wait_us(host->ref_clk_ungating_wait_us, 10, true);
ufshcd_writel(hba, REFCLK_REQUEST, REG_UFS_REFCLK_CTRL);
} else {
ufshcd_writel(hba, REFCLK_RELEASE, REG_UFS_REFCLK_CTRL);
@@ -138,7 +127,7 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
if (((value & REFCLK_ACK) >> 1) == (value & REFCLK_REQUEST))
goto out;

- usleep_range(100, 200);
+ ufshcd_wait_us(100, 100, true);
} while (time_before(jiffies, timeout));

dev_err(hba->dev, "missing ack of refclk req, reg: 0x%x\n", value);
@@ -150,7 +139,7 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
out:
host->ref_clk_enabled = on;
if (!on) {
- ufs_mtk_udelay(host->ref_clk_gating_wait_us);
+ ufshcd_wait_us(host->ref_clk_gating_wait_us, 10, true);
ufs_mtk_ref_clk_notify(on, res);
}

@@ -430,12 +419,12 @@ static void ufs_mtk_device_reset(struct ufs_hba *hba)
*
* To be on safe side, keep the reset low for at least 10us.
*/
- usleep_range(10, 15);
+ ufshcd_wait_us(10, 5, true);

ufs_mtk_device_reset_ctrl(1, res);

/* Some devices may need time to respond to rst_n */
- usleep_range(10000, 15000);
+ ufshcd_wait_us(10000, 5000, true);

dev_info(hba->dev, "device reset done\n");
}
--
2.18.0
\
 
 \ /
  Last update: 2020-03-12 14:25    [W:0.060 / U:0.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site