mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
ASoC: rockchip: i2s: Simplify FIFO clear routine
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Change-Id: I4ecfe4978d7646a99b205772515ae1c4f2d4607f
This commit is contained in:
@@ -93,11 +93,24 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai)
|
||||
return snd_soc_dai_get_drvdata(dai);
|
||||
}
|
||||
|
||||
static int rockchip_i2s_clear(struct rk_i2s_dev *i2s)
|
||||
{
|
||||
unsigned int clr = I2S_CLR_TXC | I2S_CLR_RXC;
|
||||
unsigned int val = 0;
|
||||
int ret;
|
||||
|
||||
regmap_update_bits(i2s->regmap, I2S_CLR, clr, clr);
|
||||
|
||||
ret = regmap_read_poll_timeout_atomic(i2s->regmap, I2S_CLR, val,
|
||||
!(val & clr), 10, 100);
|
||||
if (ret < 0)
|
||||
dev_warn(i2s->dev, "fail to clear\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
int retry = 10;
|
||||
|
||||
spin_lock(&i2s->lock);
|
||||
if (on) {
|
||||
regmap_update_bits(i2s->regmap, I2S_DMACR,
|
||||
@@ -122,21 +135,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
|
||||
I2S_XFER_RXS_STOP);
|
||||
|
||||
udelay(150);
|
||||
regmap_update_bits(i2s->regmap, I2S_CLR,
|
||||
I2S_CLR_TXC | I2S_CLR_RXC,
|
||||
I2S_CLR_TXC | I2S_CLR_RXC);
|
||||
|
||||
regmap_read(i2s->regmap, I2S_CLR, &val);
|
||||
|
||||
/* Should wait for clear operation to finish */
|
||||
while (val) {
|
||||
regmap_read(i2s->regmap, I2S_CLR, &val);
|
||||
retry--;
|
||||
if (!retry) {
|
||||
dev_warn(i2s->dev, "fail to clear\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
rockchip_i2s_clear(i2s);
|
||||
}
|
||||
}
|
||||
spin_unlock(&i2s->lock);
|
||||
@@ -144,9 +143,6 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
|
||||
|
||||
static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
int retry = 10;
|
||||
|
||||
spin_lock(&i2s->lock);
|
||||
if (on) {
|
||||
regmap_update_bits(i2s->regmap, I2S_DMACR,
|
||||
@@ -171,21 +167,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
|
||||
I2S_XFER_RXS_STOP);
|
||||
|
||||
udelay(150);
|
||||
regmap_update_bits(i2s->regmap, I2S_CLR,
|
||||
I2S_CLR_TXC | I2S_CLR_RXC,
|
||||
I2S_CLR_TXC | I2S_CLR_RXC);
|
||||
|
||||
regmap_read(i2s->regmap, I2S_CLR, &val);
|
||||
|
||||
/* Should wait for clear operation to finish */
|
||||
while (val) {
|
||||
regmap_read(i2s->regmap, I2S_CLR, &val);
|
||||
retry--;
|
||||
if (!retry) {
|
||||
dev_warn(i2s->dev, "fail to clear\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
rockchip_i2s_clear(i2s);
|
||||
}
|
||||
}
|
||||
spin_unlock(&i2s->lock);
|
||||
|
||||
Reference in New Issue
Block a user