mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
ASoC: rockchip: i2s: Add reset mechanism
This patch brings i2s back to normal by resetting i2s m/h logic if i2s' clear operation is failed. Change-Id: I2fd47039b522ac89499b4a2912d5ffb7a469e75e Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/dmaengine_pcm.h>
|
||||
@@ -43,6 +44,8 @@ struct rk_i2s_dev {
|
||||
|
||||
struct regmap *regmap;
|
||||
struct regmap *grf;
|
||||
struct reset_control *reset_m;
|
||||
struct reset_control *reset_h;
|
||||
|
||||
/*
|
||||
* Used to indicate the tx/rx status.
|
||||
@@ -96,6 +99,21 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai)
|
||||
return snd_soc_dai_get_drvdata(dai);
|
||||
}
|
||||
|
||||
static void rockchip_i2s_reset(struct rk_i2s_dev *i2s)
|
||||
{
|
||||
if (!IS_ERR(i2s->reset_m))
|
||||
reset_control_assert(i2s->reset_m);
|
||||
if (!IS_ERR(i2s->reset_h))
|
||||
reset_control_assert(i2s->reset_h);
|
||||
udelay(1);
|
||||
if (!IS_ERR(i2s->reset_m))
|
||||
reset_control_deassert(i2s->reset_m);
|
||||
if (!IS_ERR(i2s->reset_h))
|
||||
reset_control_deassert(i2s->reset_h);
|
||||
regcache_mark_dirty(i2s->regmap);
|
||||
regcache_sync(i2s->regmap);
|
||||
}
|
||||
|
||||
static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
@@ -136,7 +154,8 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
|
||||
regmap_read(i2s->regmap, I2S_CLR, &val);
|
||||
retry--;
|
||||
if (!retry) {
|
||||
dev_warn(i2s->dev, "fail to clear\n");
|
||||
dev_warn(i2s->dev, "reset\n");
|
||||
rockchip_i2s_reset(i2s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -185,7 +204,8 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
|
||||
regmap_read(i2s->regmap, I2S_CLR, &val);
|
||||
retry--;
|
||||
if (!retry) {
|
||||
dev_warn(i2s->dev, "fail to clear\n");
|
||||
dev_warn(i2s->dev, "reset\n");
|
||||
rockchip_i2s_reset(i2s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -618,6 +638,9 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
|
||||
i2s->pins = of_id->data;
|
||||
}
|
||||
|
||||
i2s->reset_m = devm_reset_control_get(&pdev->dev, "reset-m");
|
||||
i2s->reset_h = devm_reset_control_get(&pdev->dev, "reset-h");
|
||||
|
||||
/* try to prepare related clocks */
|
||||
i2s->hclk = devm_clk_get(&pdev->dev, "i2s_hclk");
|
||||
if (IS_ERR(i2s->hclk)) {
|
||||
|
||||
Reference in New Issue
Block a user