Commit 713d1369789f2a2336c3431b15276c968862bdb7

Authored by Stephen Warren
Committed by Mark Brown
1 parent e999dc5040

ASoC: Tegra: I2S: Ensure clock is enabled when writing regs

The I2S controller needs a clock to respond to register writes. Without
this, register writes will at worst hang the CPU. In practice, I've only
observed writes being dropped.

Luckily, the dropped register writes historically had no effect:

TEGRA_I2S_TIMING: The value we wrote was the reset default.

TEGRA_I2S_FIFO_SCR: The default was for the FIFOs to request more data
when one slot was empty. The requested value was for the FIFOs to request
when four slots were empty. The DMA controller in the mainline kernel is
configured to burst a single entry at a time into the FIFO, hence there
was no issue. The only negative effect was on bus efficiency losses due
to an increased number of arbitration attempts.

However, in various non-upstream changes, the DMA controller now bursts
four entries at a time into the FIFO. If there is only space for one
entry, the data is simply dropped. In practice, this resulted in 3/4 of
samples being dropped, and playback at 4x the expected rate and pitch.
By fixing the clocking issue, this is solved.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff

sound/soc/tegra/tegra_i2s.c
... ... @@ -222,11 +222,17 @@
222 222 if (i2sclock % (2 * srate))
223 223 reg |= TEGRA_I2S_TIMING_NON_SYM_ENABLE;
224 224  
  225 + if (!i2s->clk_refs)
  226 + clk_enable(i2s->clk_i2s);
  227 +
225 228 tegra_i2s_write(i2s, TEGRA_I2S_TIMING, reg);
226 229  
227 230 tegra_i2s_write(i2s, TEGRA_I2S_FIFO_SCR,
228 231 TEGRA_I2S_FIFO_SCR_FIFO2_ATN_LVL_FOUR_SLOTS |
229 232 TEGRA_I2S_FIFO_SCR_FIFO1_ATN_LVL_FOUR_SLOTS);
  233 +
  234 + if (!i2s->clk_refs)
  235 + clk_disable(i2s->clk_i2s);
230 236  
231 237 return 0;
232 238 }