Skip to content

Commit

Permalink
ASoC: tegra20: i2s: Add reset control
Browse files Browse the repository at this point in the history
The I2S reset may be asserted at a boot time, in particular this is the
case on Tegra20 AC100 netbook. Tegra20 I2S driver doesn't manage the
reset control and currently it happens to work because reset is implicitly
deasserted by the tegra-clk driver when I2S clock is enabled. The I2S
permanently stays in a reset once tegra-clk is fixed to not touch the
resets, which it shouldn't be doing. Add reset control to the Tegra20
I2S driver.

Note that I2S reset was always specified in Tegra20 device-tree, hence
DTB ABI changes aren't required.

Tested-by: Paul Fertser <fercerpav@gmail.com> # T20 AC100
Reported-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210314154459.15375-3-digetx@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Dmitry Osipenko authored and Mark Brown committed Mar 18, 2021
1 parent a46b782 commit 9c648ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions sound/soc/tegra/tegra20_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
Expand All @@ -37,6 +38,8 @@ static int tegra20_i2s_runtime_suspend(struct device *dev)
{
struct tegra20_i2s *i2s = dev_get_drvdata(dev);

regcache_cache_only(i2s->regmap, true);

clk_disable_unprepare(i2s->clk_i2s);

return 0;
Expand All @@ -47,13 +50,35 @@ static int tegra20_i2s_runtime_resume(struct device *dev)
struct tegra20_i2s *i2s = dev_get_drvdata(dev);
int ret;

ret = reset_control_assert(i2s->reset);
if (ret)
return ret;

ret = clk_prepare_enable(i2s->clk_i2s);
if (ret) {
dev_err(dev, "clk_enable failed: %d\n", ret);
return ret;
}

usleep_range(10, 100);

ret = reset_control_deassert(i2s->reset);
if (ret)
goto disable_clocks;

regcache_cache_only(i2s->regmap, false);
regcache_mark_dirty(i2s->regmap);

ret = regcache_sync(i2s->regmap);
if (ret)
goto disable_clocks;

return 0;

disable_clocks:
clk_disable_unprepare(i2s->clk_i2s);

return ret;
}

static int tegra20_i2s_set_fmt(struct snd_soc_dai *dai,
Expand Down Expand Up @@ -339,6 +364,12 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev)
i2s->dai = tegra20_i2s_dai_template;
i2s->dai.name = dev_name(&pdev->dev);

i2s->reset = devm_reset_control_get_exclusive(&pdev->dev, "i2s");
if (IS_ERR(i2s->reset)) {
dev_err(&pdev->dev, "Can't retrieve i2s reset\n");
return PTR_ERR(i2s->reset);
}

i2s->clk_i2s = clk_get(&pdev->dev, NULL);
if (IS_ERR(i2s->clk_i2s)) {
dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
Expand Down
1 change: 1 addition & 0 deletions sound/soc/tegra/tegra20_i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ struct tegra20_i2s {
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
struct regmap *regmap;
struct reset_control *reset;
};

#endif

0 comments on commit 9c648ef

Please sign in to comment.