bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-0892-ASoC-dwc-Support-set_bclk_ratio.patch
1 From 06f794e8cb227249e03893e4b4923ff58556eb60 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Thu, 4 Mar 2021 14:49:23 +0000
4 Subject: [PATCH] ASoC: dwc: Support set_bclk_ratio
5
6 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
7 ---
8 sound/soc/dwc/dwc-i2s.c | 35 +++++++++++++++++++++++++++++++++++
9 1 file changed, 35 insertions(+)
10
11 --- a/sound/soc/dwc/dwc-i2s.c
12 +++ b/sound/soc/dwc/dwc-i2s.c
13 @@ -351,11 +351,46 @@ static int dw_i2s_set_fmt(struct snd_soc
14 return ret;
15 }
16
17 +static int dw_i2s_set_bclk_ratio(struct snd_soc_dai *cpu_dai,
18 + unsigned int ratio)
19 +{
20 + struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
21 + struct i2s_clk_config_data *config = &dev->config;
22 +
23 + dev_err(dev->dev, "%s(%d)\n", __func__, ratio);
24 + switch (ratio) {
25 + case 32:
26 + config->data_width = 16;
27 + dev->ccr = 0x00;
28 + dev->xfer_resolution = 0x02;
29 + break;
30 +
31 + case 48:
32 + config->data_width = 24;
33 + dev->ccr = 0x08;
34 + dev->xfer_resolution = 0x04;
35 + break;
36 +
37 + case 64:
38 + config->data_width = 32;
39 + dev->ccr = 0x10;
40 + dev->xfer_resolution = 0x05;
41 + break;
42 + default:
43 + return -EINVAL;
44 + }
45 +
46 + i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
47 +
48 + return 0;
49 +}
50 +
51 static const struct snd_soc_dai_ops dw_i2s_dai_ops = {
52 .hw_params = dw_i2s_hw_params,
53 .prepare = dw_i2s_prepare,
54 .trigger = dw_i2s_trigger,
55 .set_fmt = dw_i2s_set_fmt,
56 + .set_bclk_ratio = dw_i2s_set_bclk_ratio,
57 };
58
59 #ifdef CONFIG_PM