* [PATCH] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8
@ 2026-06-17 14:47 Ahmad Fatoum
2026-06-20 10:27 ` Charles Keepax
2026-06-22 17:29 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-06-17 14:47 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Paul Handrigan
Cc: linux-sound, patches, linux-kernel, kernel, Ahmad Fatoum,
Vitaly Rodionov
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 e7ab858390f2
("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: 2884c29152c0 ("ASoC: cs530x: Support for cs530x ADCs")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Cc: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
---
sound/soc/codecs/cs530x.c | 29 ++++++++++++++++++++++++-----
sound/soc/codecs/cs530x.h | 6 ------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/cs530x.c b/sound/soc/codecs/cs530x.c
index 18b5ff75feec..2c7e33135911 100644
--- a/sound/soc/codecs/cs530x.c
+++ b/sound/soc/codecs/cs530x.c
@@ -1093,6 +1093,29 @@ static int cs530x_component_probe(struct snd_soc_component *component)
return 0;
}
+static bool cs530x_mclk_freq_is_valid(struct cs530x_priv *cs530x,
+ unsigned int freq)
+{
+ /*
+ * All these chips support 48 kHz- and 44.1 kHz-related sample rates,
+ * but they differ in what MCLK frequency is required for achieving
+ * the sample rate.
+ */
+ switch (cs530x->devtype) {
+ case CS4282:
+ case CS4302:
+ case CS4304:
+ case CS4308:
+ return freq == 49152000 || freq == 45158400;
+ case CS5302:
+ case CS5304:
+ case CS5308:
+ return freq == 24576000 || freq == 22579200;
+ }
+
+ return false;
+}
+
static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id,
int source, unsigned int freq, int dir)
{
@@ -1101,11 +1124,7 @@ static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id,
switch (source) {
case CS530X_SYSCLK_SRC_MCLK:
- switch (freq) {
- case CS530X_SYSCLK_REF_45_1MHZ:
- case CS530X_SYSCLK_REF_49_1MHZ:
- break;
- default:
+ if (!cs530x_mclk_freq_is_valid(cs530x, freq)) {
dev_err(component->dev, "Invalid MCLK source rate %d\n", freq);
return -EINVAL;
}
diff --git a/sound/soc/codecs/cs530x.h b/sound/soc/codecs/cs530x.h
index 1e2f6a7a589c..18aa4dfd0c86 100644
--- a/sound/soc/codecs/cs530x.h
+++ b/sound/soc/codecs/cs530x.h
@@ -200,12 +200,6 @@
/* IN_VOL_CTL5 and OUT_VOL_CTL5 */
#define CS530X_INOUT_VU BIT(0)
-/* MCLK Reference Source Frequency */
-/* 41KHz related */
-#define CS530X_SYSCLK_REF_45_1MHZ 45158400
-/* 48KHz related */
-#define CS530X_SYSCLK_REF_49_1MHZ 49152000
-
/* System Clock Source */
#define CS530X_SYSCLK_SRC_MCLK 0
#define CS530X_SYSCLK_SRC_PLL 1
---
base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
change-id: 20260617-cs530x-mclk-14d424295d79
Best regards,
--
Ahmad Fatoum <a.fatoum@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8
2026-06-17 14:47 [PATCH] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8 Ahmad Fatoum
@ 2026-06-20 10:27 ` Charles Keepax
2026-06-22 17:29 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2026-06-20 10:27 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Paul Handrigan, linux-sound,
patches, linux-kernel, kernel, Vitaly Rodionov
On Wed, Jun 17, 2026 at 04:47:53PM +0200, Ahmad Fatoum wrote:
> 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 e7ab858390f2
> ("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: 2884c29152c0 ("ASoC: cs530x: Support for cs530x ADCs")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8
2026-06-17 14:47 [PATCH] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8 Ahmad Fatoum
2026-06-20 10:27 ` Charles Keepax
@ 2026-06-22 17:29 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-06-22 17:29 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, Paul Handrigan, Ahmad Fatoum
Cc: linux-sound, patches, linux-kernel, kernel, Vitaly Rodionov
On Wed, 17 Jun 2026 16:47:53 +0200, Ahmad Fatoum wrote:
> ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8
https://git.kernel.org/broonie/sound/c/cf81b260916c
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-22 18:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 14:47 [PATCH] ASoC: cs530x: Fix expected MCLK rates for CS5302/4/8 Ahmad Fatoum
2026-06-20 10:27 ` Charles Keepax
2026-06-22 17:29 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox