bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1180-ASoC-Adds-support-for-TAS575x-to-the-pcm512x-driver.patch
1 From a535dd07aff73f3a6eb40174ab5dc413d05f36a1 Mon Sep 17 00:00:00 2001
2 From: Joerg Schambacher <joerg.hifiberry@gmail.com>
3 Date: Fri, 29 Sep 2023 17:07:20 +0200
4 Subject: [PATCH] ASoC: Adds support for TAS575x to the pcm512x driver
5
6 commit 1f817805262c2c34142291da376d4932d3c493bc upstream.
7
8 Enables the existing pcm512x driver to control the almost
9 compatible TAS5754 and -76 amplifers. Both amplifiers support
10 only an I2C interface and the internal PLL must be always
11 on to provide necessary clocks to the amplifier section.
12 Tested on TAS5756 with support from Andreas Arbesser-Krasser
13 from Texas Instruments <a-krasser@ti.com>
14
15 Signed-off-by: Joerg Schambacher <joerg.hifiberry@gmail.com>
16 Link: https://lore.kernel.org/r/20230929150722.405415-1-joerg.hifiberry@gmail.com
17 Signed-off-by: Mark Brown <broonie@kernel.org>
18 ---
19 sound/soc/codecs/pcm512x-i2c.c | 4 ++++
20 sound/soc/codecs/pcm512x.c | 36 +++++++++++++++++++++++++++++++---
21 2 files changed, 37 insertions(+), 3 deletions(-)
22
23 --- a/sound/soc/codecs/pcm512x-i2c.c
24 +++ b/sound/soc/codecs/pcm512x-i2c.c
25 @@ -39,6 +39,8 @@ static const struct i2c_device_id pcm512
26 { "pcm5122", },
27 { "pcm5141", },
28 { "pcm5142", },
29 + { "tas5754", },
30 + { "tas5756", },
31 { }
32 };
33 MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
34 @@ -49,6 +51,8 @@ static const struct of_device_id pcm512x
35 { .compatible = "ti,pcm5122", },
36 { .compatible = "ti,pcm5141", },
37 { .compatible = "ti,pcm5142", },
38 + { .compatible = "ti,tas5754", },
39 + { .compatible = "ti,tas5756", },
40 { }
41 };
42 MODULE_DEVICE_TABLE(of, pcm512x_of_match);
43 --- a/sound/soc/codecs/pcm512x.c
44 +++ b/sound/soc/codecs/pcm512x.c
45 @@ -48,6 +48,7 @@ struct pcm512x_priv {
46 int mute;
47 struct mutex mutex;
48 unsigned int bclk_ratio;
49 + int force_pll_on;
50 };
51
52 /*
53 @@ -1258,10 +1259,34 @@ static int pcm512x_hw_params(struct snd_
54 return ret;
55 }
56
57 - ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN,
58 - PCM512x_PLLE, 0);
59 + if (!pcm512x->force_pll_on) {
60 + ret = regmap_update_bits(pcm512x->regmap,
61 + PCM512x_PLL_EN, PCM512x_PLLE, 0);
62 + } else {
63 + /* provide minimum PLL config for TAS575x clocking
64 + * and leave PLL enabled
65 + */
66 + ret = regmap_write(pcm512x->regmap,
67 + PCM512x_PLL_COEFF_0, 0x01);
68 + if (ret != 0) {
69 + dev_err(component->dev,
70 + "Failed to set pll coefficient: %d\n", ret);
71 + return ret;
72 + }
73 + ret = regmap_write(pcm512x->regmap,
74 + PCM512x_PLL_COEFF_1, 0x04);
75 + if (ret != 0) {
76 + dev_err(component->dev,
77 + "Failed to set pll coefficient: %d\n", ret);
78 + return ret;
79 + }
80 + ret = regmap_write(pcm512x->regmap,
81 + PCM512x_PLL_EN, 0x01);
82 + dev_dbg(component->dev, "Enabling PLL for TAS575x\n");
83 + }
84 +
85 if (ret != 0) {
86 - dev_err(component->dev, "Failed to disable pll: %d\n", ret);
87 + dev_err(component->dev, "Failed to set pll mode: %d\n", ret);
88 return ret;
89 }
90 }
91 @@ -1659,6 +1684,11 @@ int pcm512x_probe(struct device *dev, st
92 ret = -EINVAL;
93 goto err_pm;
94 }
95 +
96 + if (!strcmp(np->name, "tas5756") ||
97 + !strcmp(np->name, "tas5754"))
98 + pcm512x->force_pll_on = 1;
99 + dev_dbg(dev, "Device ID: %s\n", np->name);
100 }
101 #endif
102