Skip to content

Commit cf81b26

Browse files
a3fbroonie
authored andcommitted
ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8
When this driver was first added, it accepted rates of 24.56 MHz and 22.572 MHz for the MCLK when PLL bypass is enabled. These rates seem to have no basis in the datasheets and were thus replaced with 45.1584 MHz and 49.152 MHz, respectively, in commit e7ab858 ("ASoC: cs530x: Correct MCLK reference frequency values"). While the new rates are indeed correct for the CS4xxx ICs[0][1][2][3], they are incorrect for the CS530x ICs the driver was originally written to support as the MCLK frequencies are halved there[4][5][6]. Fix this by checking against the correct type-appropriate rates. While at it, drop the CS530X_SYSCLK_REF_* macros. They arguably confuse more than they help, especially as they are not applicable to the cs5302/4/8. [0]: https://statics.cirrus.com/pubs/proDatasheet/CS4282P_DS1318F1.pdf [1]: https://statics.cirrus.com/pubs/proDatasheet/CS4302P_DS1315F1.pdf [2]: https://statics.cirrus.com/pubs/proDatasheet/CS4304P_DS1316F1.pdf [3]: https://statics.cirrus.com/pubs/proDatasheet/CS4308P_DS1317F1.pdf [4]: https://statics.cirrus.com/pubs/proDatasheet/CS5302P_DS1312F1.pdf [5]: https://statics.cirrus.com/pubs/proDatasheet/CS5304P_DS1313F1.pdf [6]: https://statics.cirrus.com/pubs/proDatasheet/CS5308P_DS1314F1.pdf Fixes: 2884c29 ("ASoC: cs530x: Support for cs530x ADCs") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20260617-cs530x-mclk-v1-1-0215b5f1a0a4@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e6fa716 commit cf81b26

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

sound/soc/codecs/cs530x.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,29 @@ static int cs530x_component_probe(struct snd_soc_component *component)
10931093
return 0;
10941094
}
10951095

1096+
static bool cs530x_mclk_freq_is_valid(struct cs530x_priv *cs530x,
1097+
unsigned int freq)
1098+
{
1099+
/*
1100+
* All these chips support 48 kHz- and 44.1 kHz-related sample rates,
1101+
* but they differ in what MCLK frequency is required for achieving
1102+
* the sample rate.
1103+
*/
1104+
switch (cs530x->devtype) {
1105+
case CS4282:
1106+
case CS4302:
1107+
case CS4304:
1108+
case CS4308:
1109+
return freq == 49152000 || freq == 45158400;
1110+
case CS5302:
1111+
case CS5304:
1112+
case CS5308:
1113+
return freq == 24576000 || freq == 22579200;
1114+
}
1115+
1116+
return false;
1117+
}
1118+
10961119
static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id,
10971120
int source, unsigned int freq, int dir)
10981121
{
@@ -1101,11 +1124,7 @@ static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id,
11011124

11021125
switch (source) {
11031126
case CS530X_SYSCLK_SRC_MCLK:
1104-
switch (freq) {
1105-
case CS530X_SYSCLK_REF_45_1MHZ:
1106-
case CS530X_SYSCLK_REF_49_1MHZ:
1107-
break;
1108-
default:
1127+
if (!cs530x_mclk_freq_is_valid(cs530x, freq)) {
11091128
dev_err(component->dev, "Invalid MCLK source rate %d\n", freq);
11101129
return -EINVAL;
11111130
}

sound/soc/codecs/cs530x.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,6 @@
200200
/* IN_VOL_CTL5 and OUT_VOL_CTL5 */
201201
#define CS530X_INOUT_VU BIT(0)
202202

203-
/* MCLK Reference Source Frequency */
204-
/* 41KHz related */
205-
#define CS530X_SYSCLK_REF_45_1MHZ 45158400
206-
/* 48KHz related */
207-
#define CS530X_SYSCLK_REF_49_1MHZ 49152000
208-
209203
/* System Clock Source */
210204
#define CS530X_SYSCLK_SRC_MCLK 0
211205
#define CS530X_SYSCLK_SRC_PLL 1

0 commit comments

Comments
 (0)