summaryrefslogtreecommitdiffstats
path: root/drivers/soundwire
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2020-03-17 11:33:20 -0500
committerVinod Koul <vkoul@kernel.org>2020-03-19 12:43:04 +0530
commit12632459f11a3e082207d48dca53555dfcf95585 (patch)
tree5a81ba0e76ee054dd850d668111e145e644af27a /drivers/soundwire
parentaf4cc917826fd1fb5c84a2a0f675777920db9074 (diff)
downloadlinux-12632459f11a3e082207d48dca53555dfcf95585.tar.bz2
soundwire: cadence: merge routines to clear/set bits
Use a single loop to wait for hardware to set/clear fields. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200317163329.25501-9-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire')
-rw-r--r--drivers/soundwire/cadence_master.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index 613c63359413..7d9fc2c645e3 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -211,26 +211,6 @@ static inline void cdns_updatel(struct sdw_cdns *cdns,
cdns_writel(cdns, offset, tmp);
}
-static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value)
-{
- int timeout = 10;
- u32 reg_read;
-
- writel(value, cdns->registers + offset);
-
- /* Wait for bit to be self cleared */
- do {
- reg_read = readl(cdns->registers + offset);
- if ((reg_read & value) == 0)
- return 0;
-
- timeout--;
- udelay(50);
- } while (timeout != 0);
-
- return -EAGAIN;
-}
-
static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
{
int timeout = 10;
@@ -249,6 +229,14 @@ static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
return -ETIMEDOUT;
}
+static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value)
+{
+ writel(value, cdns->registers + offset);
+
+ /* Wait for bit to be self cleared */
+ return cdns_set_wait(cdns, offset, value, 0);
+}
+
/*
* all changes to the MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL
* need to be confirmed with a write to MCP_CONFIG_UPDATE