bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1176-ASoC-dwc-Fix-full-duplex-mode.patch
1 From cbc65d9c95088d1437a5a84c7d6628b8d27a86f1 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Tue, 28 Nov 2023 12:14:03 +0000
4 Subject: [PATCH] ASoC: dwc: Fix full-duplex mode
5
6 Configuration of the DMA register was carelessly zeroing bits that may
7 used by a stream in the other direction. Preserve them instead.
8
9 See: https://github.com/raspberrypi/linux/issues/5741
10
11 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
12 ---
13 sound/soc/dwc/dwc-i2s.c | 20 +++++++++++++-------
14 1 file changed, 13 insertions(+), 7 deletions(-)
15
16 --- a/sound/soc/dwc/dwc-i2s.c
17 +++ b/sound/soc/dwc/dwc-i2s.c
18 @@ -189,10 +189,17 @@ static void dw_i2s_config(struct dw_i2s_
19 {
20 struct i2s_clk_config_data *config = &dev->config;
21 u32 ch_reg;
22 - u32 dmacr = 0;
23 + u32 dmacr;
24
25 i2s_disable_channels(dev, stream);
26
27 + dmacr = i2s_read_reg(dev->i2s_base, DMACR);
28 +
29 + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
30 + dmacr &= ~(DMACR_DMAEN_TXCH0 * 0xf);
31 + else
32 + dmacr &= ~(DMACR_DMAEN_RXCH0 * 0xf);
33 +
34 for (ch_reg = 0; ch_reg < (config->chan_nr / 2); ch_reg++) {
35 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
36 i2s_write_reg(dev->i2s_base, TCR(ch_reg),
37 @@ -210,10 +217,6 @@ static void dw_i2s_config(struct dw_i2s_
38 dmacr |= (DMACR_DMAEN_RXCH0 << ch_reg);
39 }
40 }
41 - if (stream == SNDRV_PCM_STREAM_PLAYBACK)
42 - dmacr |= DMACR_DMAEN_TX;
43 - else if (stream == SNDRV_PCM_STREAM_CAPTURE)
44 - dmacr |= DMACR_DMAEN_RX;
45
46 i2s_write_reg(dev->i2s_base, DMACR, dmacr);
47 }
48 @@ -319,10 +322,13 @@ static int dw_i2s_startup(struct snd_pcm
49
50 dw_i2s_config(dev, substream->stream);
51 dmacr = i2s_read_reg(dev->i2s_base, DMACR);
52 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
53 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
54 dma_data = &dev->play_dma_data;
55 - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
56 + dmacr |= DMACR_DMAEN_TX;
57 + } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
58 dma_data = &dev->capture_dma_data;
59 + dmacr |= DMACR_DMAEN_RX;
60 + }
61
62 snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)dma_data);
63 i2s_write_reg(dev->i2s_base, DMACR, dmacr);