Commit fbb0ec65 authored by Judy Hsiao's avatar Judy Hsiao Committed by Mark Brown

ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR

Use regmap_read_poll_timeout to poll I2S_CLR.
It also fixes the 'rockchip-i2s ff070000.i2s; fail to clear' when
the read of I2S_CLR exceeds the retry limit.

Fixes: 0ff9f8b9 ("ASoC: rockchip: i2s: Fix error code when fail to read I2S_CLR")
Signed-off-by: default avatarJudy Hsiao <judyhsiao@chromium.org>
Reviewed-by: default avatarBrian Norris <briannorris@chromium.org>
Link: https://lore.kernel.org/r/20220914031234.2250298-1-judyhsiao@chromium.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3e9a8386
...@@ -126,7 +126,6 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai) ...@@ -126,7 +126,6 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai)
static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
{ {
unsigned int val = 0; unsigned int val = 0;
int retry = 10;
int ret = 0; int ret = 0;
spin_lock(&i2s->lock); spin_lock(&i2s->lock);
...@@ -163,18 +162,14 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) ...@@ -163,18 +162,14 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
I2S_CLR_TXC | I2S_CLR_RXC); I2S_CLR_TXC | I2S_CLR_RXC);
if (ret < 0) if (ret < 0)
goto end; goto end;
regmap_read(i2s->regmap, I2S_CLR, &val); ret = regmap_read_poll_timeout(i2s->regmap,
I2S_CLR,
/* Should wait for clear operation to finish */ val,
while (val) { val != 0,
regmap_read(i2s->regmap, I2S_CLR, &val); 20,
retry--; 200);
if (!retry) { if (ret < 0)
dev_warn(i2s->dev, "fail to clear\n"); dev_warn(i2s->dev, "fail to clear: %d\n", ret);
ret = -EBUSY;
break;
}
}
} }
} }
end: end:
...@@ -188,7 +183,6 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) ...@@ -188,7 +183,6 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
{ {
unsigned int val = 0; unsigned int val = 0;
int retry = 10;
int ret = 0; int ret = 0;
spin_lock(&i2s->lock); spin_lock(&i2s->lock);
...@@ -226,17 +220,14 @@ static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) ...@@ -226,17 +220,14 @@ static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
I2S_CLR_TXC | I2S_CLR_RXC); I2S_CLR_TXC | I2S_CLR_RXC);
if (ret < 0) if (ret < 0)
goto end; goto end;
regmap_read(i2s->regmap, I2S_CLR, &val); ret = regmap_read_poll_timeout(i2s->regmap,
/* Should wait for clear operation to finish */ I2S_CLR,
while (val) { val,
regmap_read(i2s->regmap, I2S_CLR, &val); val != 0,
retry--; 20,
if (!retry) { 200);
dev_warn(i2s->dev, "fail to clear\n"); if (ret < 0)
ret = -EBUSY; dev_warn(i2s->dev, "fail to clear: %d\n", ret);
break;
}
}
} }
} }
end: end:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment