Skip to contentSkip to conversation

Add support for Cirrus Logic CS530x DAC and CODEC variants.

PATCH Superseded Vitaly Rodionov 2 participants 17 messages Oct 22, 2025

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for Cirrus Logic CS530x DAC and CODEC variants.

This patch series introduces DAC, CODEC, and SPI control bus support for Cirrus Logic CS530x variants, along with general code cleanup and resolution of checkpatch.pl warnings.

Changes since v1,v2,v3:

- Signed off all patches
- Splitted "tidy up" pach in 3 separate simple patches
- Fixed commit subject to much preferred subject prefix for binding patches.
- Moved dt-bindings related patch down the chain
- Added all relevant maintainers to CC list

Changes since v4:
- Sorted dt-binding properties list
- Re-worked removal of unused defenitions and structures
- Move renaming of CS530X_IN_VU to CS530X_INOUT_VU into separate patch
- Added dt-bindings SPI propery patch

Simon Trimmer (3):
ASoC: cs530x: Add CODEC and DAC support
ASoC: cs530x: Check the DEVID matches the devtype
ASoC: cs530x: Rename i2c related structures

Vitaly Rodionov (9):
ASoC: cs530x: Update the copyright headers
ASoC: cs530x: Sort #include directives and tydy up whitespaces
ASoC: cs530x: Remove unused struct members and constants
ASoC: cs530x: Correct constant naming
ASoC: dt-bindings: sound: cirrus: cs530x: Add cs530x
ASoC: cs530x: Rename bitfield to reflect common use for ADC and DAC
ASoC: cs530x: Correct MCLK reference frequency values
ASoC: dt-bindings: sound: cirrus: cs530x: add spi bus properties
ASoC: cs530x: Add SPI bus support for cs530x parts

 .../bindings/sound/cirrus,cs530x.yaml         |   7 +
 sound/soc/codecs/Kconfig                      |  10 +
 sound/soc/codecs/Makefile                     |   2 +
 sound/soc/codecs/cs530x-i2c.c                 |  24 +-
 sound/soc/codecs/cs530x-spi.c                 |  92 ++++
 sound/soc/codecs/cs530x.c                     | 516 +++++++++++++++---
 sound/soc/codecs/cs530x.h                     |  90 ++-
 7 files changed, 635 insertions(+), 106 deletions(-)
 create mode 100644 sound/soc/codecs/cs530x-spi.c
Signature · 1 line
2.43.0
#1 lore raw

PATCH v5 1/12 ASoC: cs530x: Update the copyright headers

---
 sound/soc/codecs/cs530x-i2c.c | 4 ++--
 sound/soc/codecs/cs530x.c     | 4 ++--
 sound/soc/codecs/cs530x.h     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/cs530x-i2c.c +2 -2
index 22b1a4d6b61c..be80dcad3647 100644
@@ -2,8 +2,8 @@
 //
 // CS530x CODEC driver
 //
-// Copyright (C) 2024 Cirrus Logic, Inc. and
-//                    Cirrus Logic International Semiconductor Ltd.
+// Copyright (C) 2024-2025 Cirrus Logic, Inc. and
+//                         Cirrus Logic International Semiconductor Ltd.
 
 #include <linux/device.h>
 #include <linux/module.h>
sound/soc/codecs/cs530x.c +2 -2
index 0dbc5fb92290..88084e7d6447 100644
@@ -2,8 +2,8 @@
 //
 // CS530x CODEC driver
 //
-// Copyright (C) 2024 Cirrus Logic, Inc. and
-//                    Cirrus Logic International Semiconductor Ltd.
+// Copyright (C) 2024-2025 Cirrus Logic, Inc. and
+//                         Cirrus Logic International Semiconductor Ltd.
 
 #include <sound/core.h>
 #include <linux/delay.h>
sound/soc/codecs/cs530x.h +1 -1
index f473e33eb835..b325847036e9 100644
@@ -2,7 +2,7 @@
 /*
  * CS530x CODEC driver internal data
  *
- * Copyright (C) 2023-2024 Cirrus Logic, Inc. and
+ * Copyright (C) 2023-2025 Cirrus Logic, Inc. and
  *                         Cirrus Logic International Semiconductor Ltd.
  */
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v5 2/12 ASoC: cs530x: Sort #include directives and tydy up whitespaces

In reply to Vitaly Rodionov
---
 sound/soc/codecs/cs530x-i2c.c |  2 +-
 sound/soc/codecs/cs530x.c     | 49 ++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 28 deletions(-)
sound/soc/codecs/cs530x-i2c.c +1 -1
index be80dcad3647..d6b7883ba7b9 100644
@@ -48,7 +48,7 @@ static int cs530x_i2c_probe(struct i2c_client *client)
 	cs530x->regmap = devm_regmap_init_i2c(client, &cs530x_regmap);
 	if (IS_ERR(cs530x->regmap))
 		return dev_err_probe(&client->dev, PTR_ERR(cs530x->regmap),
-			      "Failed to allocate register map\n");
+				     "Failed to allocate register map\n");
 
 	cs530x->devtype = (uintptr_t)i2c_get_match_data(client);
 	cs530x->dev = &client->dev;
sound/soc/codecs/cs530x.c +22 -27

162 lines not on this page · raw message

Signature · 1 line
2.43.0
#3 lore raw

PATCH v5 3/12 ASoC: cs530x: Remove unused struct members and constants

In reply to Vitaly Rodionov
---
 sound/soc/codecs/cs530x.c | 6 ------
 sound/soc/codecs/cs530x.h | 5 +----
 2 files changed, 1 insertion(+), 10 deletions(-)
sound/soc/codecs/cs530x.c +0 -6
index 3a59eeba5e55..3de748fa5255 100644
@@ -21,9 +21,6 @@
 
 #include "cs530x.h"
 
-#define CS530X_MAX_ADC_CH	8
-#define CS530X_MIN_ADC_CH	2
-
 static const char *cs530x_supply_names[CS530X_NUM_SUPPLIES] = {
 	"vdd-a",
 	"vdd-io",
@@ -517,7 +514,6 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	cs530x->fs = fs;
 	regmap_update_bits(regmap, CS530X_CLK_CFG_1,
 			   CS530X_SAMPLE_RATE_MASK, fs_val);
 
@@ -781,8 +777,6 @@ static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id,
 				freq);
 			return -EINVAL;
 		}
-
-		cs530x->mclk_rate = freq;
 		break;
 	case CS530X_SYSCLK_SRC_PLL:
 		break;
sound/soc/codecs/cs530x.h +1 -4
index b325847036e9..5b47c1ae2a09 100644
@@ -99,7 +99,7 @@
 #define CS530X_TDM_EN_MASK		BIT(2)
 #define CS530X_ASP_FMT_I2S		0
 #define CS530X_ASP_FMT_LJ		1
-#define CS530X_ASP_FMT_DSP_A		0x6
+#define CS530X_ASP_FMT_DSP_A		6
 
 /* TDM Slots */
 #define CS530X_0_1_TDM_SLOT_MASK	GENMASK(1, 0)
@@ -207,11 +207,8 @@ struct cs530x_priv {
 
 	struct regulator_bulk_data supplies[CS530X_NUM_SUPPLIES];
 
-	unsigned int mclk_rate;
-
 	int tdm_width;
 	int tdm_slots;
-	int fs;
 	int adc_pairs_count;
 
 	struct gpio_desc *reset_gpio;
Signature · 1 line
2.43.0
#4 lore raw

PATCH v5 4/12 ASoC: cs530x: Correct constant naming

In reply to Vitaly Rodionov
---
 sound/soc/codecs/cs530x.c | 10 +++++-----
 sound/soc/codecs/cs530x.h | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)
sound/soc/codecs/cs530x.c +5 -5
index 3de748fa5255..42b9e087f28d 100644
@@ -491,23 +491,23 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream,
 		break;
 	case 44100:
 	case 48000:
-		fs_val = CS530X_FS_48K_44P1K;
+		fs_val = CS530X_FS_44P1K_48K;
 		break;
 	case 88200:
 	case 96000:
-		fs_val = CS530X_FS_96K_88P2K;
+		fs_val = CS530X_FS_88P2K_96K;
 		break;
 	case 176400:
 	case 192000:
-		fs_val = CS530X_FS_192K_176P4K;
+		fs_val = CS530X_FS_176P4K_192K;
 		break;
 	case 356800:
 	case 384000:
-		fs_val = CS530X_FS_384K_356P8K;
+		fs_val = CS530X_FS_356P8K_384K;
 		break;
 	case 705600:
 	case 768000:
-		fs_val = CS530X_FS_768K_705P6K;
+		fs_val = CS530X_FS_705P6K_768K;
 		break;
 	default:
 		dev_err(component->dev, "Invalid sample rate %d\n", fs);
sound/soc/codecs/cs530x.h +5 -5
index 5b47c1ae2a09..f7640161c77f 100644
@@ -73,11 +73,11 @@
 /* CLK_CFG_1 */
 #define CS530X_SAMPLE_RATE_MASK		GENMASK(2, 0)
 #define CS530X_FS_32K			0
-#define CS530X_FS_48K_44P1K		1
-#define CS530X_FS_96K_88P2K		2
-#define CS530X_FS_192K_176P4K		3
-#define CS530X_FS_384K_356P8K		4
-#define CS530X_FS_768K_705P6K		5
+#define CS530X_FS_44P1K_48K		1
+#define CS530X_FS_88P2K_96K		2
+#define CS530X_FS_176P4K_192K		3
+#define CS530X_FS_356P8K_384K		4
+#define CS530X_FS_705P6K_768K		5
 
 /* CHIP_ENABLE */
 #define CS530X_GLOBAL_EN		BIT(0)
Signature · 1 line
2.43.0
#5 lore raw

PATCH v5 5/12 ASoC: dt-bindings: sound: cirrus: cs530x: Add cs530x

In reply to Vitaly Rodionov

This patch adds additional cs530x family variants.

cirrus,cs4282 - high-performance, 32-bit resolution, stereo CODEC cirrus,cs4302 - high performance stereo DAC, 2 channels cirrus,cs4304 - high performance stereo DAC, 4 channels cirrus,cs4308 - high performance stereo DAC, 8 channels

---
 Documentation/devicetree/bindings/sound/cirrus,cs530x.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs530x.yaml +4 -0
index 9582eb8eb418..04ed197f91eb 100644
@@ -19,6 +19,10 @@ allOf:
 properties:
   compatible:
     enum:
+      - cirrus,cs4282
+      - cirrus,cs4302
+      - cirrus,cs4304
+      - cirrus,cs4308
       - cirrus,cs5302
       - cirrus,cs5304
       - cirrus,cs5308
Signature · 1 line
2.43.0
Acked-by on v5 5/12
#6 lore raw

Re: [PATCH v5 05/12] ASoC: dt-bindings: sound: cirrus: cs530x: Add cs530x

Quoted 7 lines · Vitaly Rodionov

This patch adds additional cs530x family variants.

cirrus,cs4282 - high-performance, 32-bit resolution, stereo CODEC cirrus,cs4302 - high performance stereo DAC, 2 channels cirrus,cs4304 - high performance stereo DAC, 4 channels cirrus,cs4308 - high performance stereo DAC, 8 channels

Quoted 5 lines
---
 Documentation/devicetree/bindings/sound/cirrus,cs530x.yaml | 4 ++++
 1 file changed, 4 insertions(+)

Best regards,
Krzysztof

#7 lore raw

PATCH v5 6/12 ASoC: cs530x: Add CODEC and DAC support

In reply to Vitaly Rodionov

From: Simon Trimmer <[email protected]>

- Added DAC register address constants
- Add the new registers to the regmap config
- Renamed constants that are shared between the DACs and ADCs
- Add the device IDs and device names of the CODEC and DACs along with their different capabilities
- Add DAPM widgets, ALSA controls and event handling for the DAC functionality
- Add Playback DAI support

---
 sound/soc/codecs/cs530x-i2c.c |  16 ++
 sound/soc/codecs/cs530x.c     | 411 +++++++++++++++++++++++++++++++---
 sound/soc/codecs/cs530x.h     |  58 +++--
 3 files changed, 440 insertions(+), 45 deletions(-)
sound/soc/codecs/cs530x-i2c.c +16 -0
index d6b7883ba7b9..ab410826f777 100644
@@ -14,6 +14,18 @@
 
 static const struct of_device_id cs530x_of_match[] = {
 	{
+		.compatible = "cirrus,cs4282",
+		.data = (void *)CS4282,
+	}, {
+		.compatible = "cirrus,cs4302",
+		.data = (void *)CS4302,
+	}, {
+		.compatible = "cirrus,cs4304",
+		.data = (void *)CS4304,
+	}, {
+		.compatible = "cirrus,cs4308",
+		.data = (void *)CS4308,
+	}, {
 		.compatible = "cirrus,cs5302",
 		.data = (void *)CS5302,
 	}, {
@@ -28,6 +40,10 @@ static const struct of_device_id cs530x_of_match[] = {
 MODULE_DEVICE_TABLE(of, cs530x_of_match);
 
 static const struct i2c_device_id cs530x_i2c_id[] = {
+	{ "cs4282", CS4282 },
+	{ "cs4302", CS4302 },
+	{ "cs4304", CS4304 },
+	{ "cs4308", CS4308 },
 	{ "cs5302", CS5302 },
 	{ "cs5304", CS5304 },
 	{ "cs5308", CS5308 },
sound/soc/codecs/cs530x.c +382 -29

557 lines not on this page · raw message

sound/soc/codecs/cs530x.h +42 -16

104 lines not on this page · raw message

Signature · 1 line
2.43.0
#8 lore raw

PATCH v5 7/12 ASoC: cs530x: Rename bitfield to reflect common use for ADC and DAC

In reply to Vitaly Rodionov
---
 sound/soc/codecs/cs530x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/cs530x.c +2 -2
index 4b0bf1c3b985..193d7af5cfd5 100644
@@ -141,8 +141,8 @@ static int cs530x_put_volsw_vu(struct snd_kcontrol *kcontrol,
 	if (ret)
 		goto volsw_err;
 
-	/* Write IN_VU bit for the volume change to take effect */
-	regmap_write(regmap, CS530X_IN_VOL_CTRL5, CS530X_IN_VU);
+	/* Write INOUT_VU bit for the volume change to take effect */
+	regmap_write(regmap, CS530X_IN_VOL_CTRL5, CS530X_INOUT_VU);
 
 volsw_err:
 	snd_soc_dapm_mutex_unlock(dapm);
Signature · 1 line
2.43.0
#9 lore raw

PATCH v5 8/12 ASoC: cs530x: Check the DEVID matches the devtype

In reply to Vitaly Rodionov

From: Simon Trimmer <[email protected]>

If the read device ID is not the expected devtype derived from the compatible device match then fail the probe as other configuration details may be incorrect.

---
 sound/soc/codecs/cs530x.c |  6 ++++++
 sound/soc/codecs/cs530x.h | 14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
sound/soc/codecs/cs530x.c +6 -0
index 193d7af5cfd5..7dd9e5d19336 100644
@@ -1181,6 +1181,12 @@ static int cs530x_check_device_id(struct cs530x_priv *cs530x)
 				     dev_id);
 	}
 
+	if (cs530x->devtype != dev_id) {
+		dev_err(dev, "Read device ID 0x%x is not the expected devtype 0x%x\n",
+			dev_id, cs530x->devtype);
+		return -EINVAL;
+	}
+
 	dev_dbg(dev, "Device ID 0x%x Rev ID 0x%x (%d in %d out)\n", dev_id, rev,
 		cs530x->num_adcs, cs530x->num_dacs);
 
sound/soc/codecs/cs530x.h +7 -7
index 52fb148df36a..d11711715ba8 100644
@@ -211,13 +211,13 @@
 #define CS530X_NUM_SUPPLIES		2
 
 enum cs530x_type {
-	CS4282,
-	CS4302,
-	CS4304,
-	CS4308,
-	CS5302,
-	CS5304,
-	CS5308,
+	CS4282 = CS530X_2CH_CODEC_DEV_ID,
+	CS4302 = CS530X_2CH_DAC_DEV_ID,
+	CS4304 = CS530X_4CH_DAC_DEV_ID,
+	CS4308 = CS530X_8CH_DAC_DEV_ID,
+	CS5302 = CS530X_2CH_ADC_DEV_ID,
+	CS5304 = CS530X_4CH_ADC_DEV_ID,
+	CS5308 = CS530X_8CH_ADC_DEV_ID,
 };
 
 /* codec private data */
Signature · 1 line
2.43.0
#10 lore raw

PATCH v5 9/12 ASoC: cs530x: Correct MCLK reference frequency values

In reply to Vitaly Rodionov

The MCLK frequency must be 49.152 MHz (for 48 kHz-related sample rates) or 45.1584 MHz (for 44.1 kHz-related sample rates).

---
 sound/soc/codecs/cs530x.c | 9 ++++++---
 sound/soc/codecs/cs530x.h | 6 ++++++
 2 files changed, 12 insertions(+), 3 deletions(-)
sound/soc/codecs/cs530x.c +6 -3
index 7dd9e5d19336..19fac4a90368 100644
@@ -1100,9 +1100,12 @@ static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id,
 
 	switch (source) {
 	case CS530X_SYSCLK_SRC_MCLK:
-		if (freq != 24560000 && freq != 22572000) {
-			dev_err(component->dev, "Invalid MCLK source rate %d\n",
-				freq);
+		switch (freq) {
+		case CS530X_SYSCLK_REF_45_1MHZ:
+		case CS530X_SYSCLK_REF_49_1MHZ:
+			break;
+		default:
+			dev_err(component->dev, "Invalid MCLK source rate %d\n", freq);
 			return -EINVAL;
 		}
 		break;
sound/soc/codecs/cs530x.h +6 -0
index d11711715ba8..2c773c4b6b92 100644
@@ -200,6 +200,12 @@
 /* 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
Signature · 1 line
2.43.0
#11 lore raw

PATCH v5 10/12 ASoC: cs530x: Rename i2c related structures

In reply to Vitaly Rodionov

From: Simon Trimmer <[email protected]>

In preparation for SPI support these structures should be renamed to reflect that they are for i2c.

---
 sound/soc/codecs/cs530x-i2c.c | 2 +-
 sound/soc/codecs/cs530x.c     | 4 ++--
 sound/soc/codecs/cs530x.h     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/cs530x-i2c.c +1 -1
index ab410826f777..52b02ceaa7e3 100644
@@ -61,7 +61,7 @@ static int cs530x_i2c_probe(struct i2c_client *client)
 
 	i2c_set_clientdata(client, cs530x);
 
-	cs530x->regmap = devm_regmap_init_i2c(client, &cs530x_regmap);
+	cs530x->regmap = devm_regmap_init_i2c(client, &cs530x_regmap_i2c);
 	if (IS_ERR(cs530x->regmap))
 		return dev_err_probe(&client->dev, PTR_ERR(cs530x->regmap),
 				     "Failed to allocate register map\n");
sound/soc/codecs/cs530x.c +2 -2
index 19fac4a90368..9fcae9b85a45 100644
@@ -1128,7 +1128,7 @@ static const struct snd_soc_component_driver soc_component_dev_cs530x = {
 	.endianness		= 1,
 };
 
-const struct regmap_config cs530x_regmap = {
+const struct regmap_config cs530x_regmap_i2c = {
 	.reg_bits = 16,
 	.val_bits = 16,
 
@@ -1140,7 +1140,7 @@ const struct regmap_config cs530x_regmap = {
 	.reg_defaults = cs530x_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(cs530x_reg_defaults),
 };
-EXPORT_SYMBOL_NS_GPL(cs530x_regmap, "SND_SOC_CS530X");
+EXPORT_SYMBOL_NS_GPL(cs530x_regmap_i2c, "SND_SOC_CS530X");
 
 static int cs530x_check_device_id(struct cs530x_priv *cs530x)
 {
sound/soc/codecs/cs530x.h +1 -1
index 2c773c4b6b92..2a7b7d01ecfb 100644
@@ -246,7 +246,7 @@ struct cs530x_priv {
 	struct gpio_desc *reset_gpio;
 };
 
-extern const struct regmap_config cs530x_regmap;
+extern const struct regmap_config cs530x_regmap_i2c;
 int cs530x_probe(struct cs530x_priv *cs530x);
 
 #endif
Signature · 1 line
2.43.0
#12 lore raw

PATCH v5 11/12 ASoC: dt-bindings: sound: cirrus: cs530x: add spi bus properties

In reply to Vitaly Rodionov

This patch adds property for cs530x SPI control bus with max frequency 24MHz.

---
 Documentation/devicetree/bindings/sound/cirrus,cs530x.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs530x.yaml +3 -0
index 04ed197f91eb..b233bcd18d49 100644
@@ -30,6 +30,9 @@ properties:
   reg:
     maxItems: 1
 
+  spi-max-frequency:
+    maximum: 24000000
+
   '#sound-dai-cells':
     const: 1
 
Signature · 1 line
2.43.0
#13 lore raw

Re: [PATCH v5 11/12] ASoC: dt-bindings: sound: cirrus: cs530x: add spi bus properties

Quoted 2 lines · Vitaly Rodionov

This patch adds property for cs530x SPI control bus with max frequency 24MHz.

Why?

You described what you did, we see that from the diff. Explain why you are doing this, e.g. hardware is like that? Old hardware? New hardware? Both? If only new, then why this is a separate patch?

Also, since I expect new version:
Please do not use "This commit/patch/change", but imperative mood. See longer explanation here:
https://elixir.bootlin.com/linux/v6.16/source/Documentation/process/submitting-patches.rst#L94

Best regards,
Krzysztof

#14 lore raw

Re: [PATCH v5 11/12] ASoC: dt-bindings: sound: cirrus: cs530x: add spi bus properties

Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Vitaly Rodionov

This patch adds property for cs530x SPI control bus with max frequency 24MHz.

Why?

Quoted 9 lines

You described what you did, we see that from the diff. Explain why you are doing this, e.g. hardware is like that? Old hardware? New hardware? Both? If only new, then why this is a separate patch?

Also, since I expect new version:
Please do not use "This commit/patch/change", but imperative mood. See longer explanation here:
https://elixir.bootlin.com/linux/v6.16/source/Documentation/process/submitting-patches.rst#L94

And after looking at next patch I understand why - you add SPI which was not there, so this patch is not correct alone anyway. You need a ref to spi-peripheral-props (see any other SPI device). My previous questions still stay valid though - how this relates to existing devices and to earlier patch.

Best regards,
Krzysztof

#15 lore raw

Re: [PATCH v5 11/12] ASoC: dt-bindings: sound: cirrus: cs530x: add spi bus properties

Quoted 17 lines · Krzysztof Kozlowski
Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Vitaly Rodionov

This patch adds property for cs530x SPI control bus with max frequency 24MHz.

Why?

Quoted 9 lines

You described what you did, we see that from the diff. Explain why you are doing this, e.g. hardware is like that? Old hardware? New hardware? Both? If only new, then why this is a separate patch?

Also, since I expect new version:
Please do not use "This commit/patch/change", but imperative mood. See longer explanation here:
https://elixir.bootlin.com/linux/v6.16/source/Documentation/process/submitting-patches.rst#L94

Quoted 8 lines

And after looking at next patch I understand why - you add SPI which was not there, so this patch is not correct alone anyway. You need a ref to spi-peripheral-props (see any other SPI device). My previous questions still stay valid though - how this relates to existing devices and to earlier patch.

Best regards,
Krzysztof

Hi Krzysztof,

Thanks for pointing that out. You’re correct — the SPI part is added in the next patch, so this one isn’t fully correct on its own. I’ll fix it by adding a reference to spi-peripheral-props and will address your previous questions about its relation to existing devices and the earlier patch.

Thanks,
Vitaly

#16 lore raw

PATCH v5 12/12 ASoC: cs530x: Add SPI bus support for cs530x parts

In reply to Vitaly Rodionov

Cirrus Logic cs530x device family has 2 control buses I2C and SPI. This patch adds SPI support.

---
 sound/soc/codecs/Kconfig      | 10 ++++
 sound/soc/codecs/Makefile     |  2 +
 sound/soc/codecs/cs530x-spi.c | 92 +++++++++++++++++++++++++++++++++++
 sound/soc/codecs/cs530x.c     | 21 ++++++++
 sound/soc/codecs/cs530x.h     |  1 +
 5 files changed, 126 insertions(+)
 create mode 100644 sound/soc/codecs/cs530x-spi.c
sound/soc/codecs/Kconfig +10 -0
index 160c07699a8b..ef49f71e8b34 100644
@@ -106,6 +106,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_CS48L32
 	imply SND_SOC_CS53L30
 	imply SND_SOC_CS530X_I2C
+	imply SND_SOC_CS530X_SPI
 	imply SND_SOC_CX20442
 	imply SND_SOC_CX2072X
 	imply SND_SOC_DA7210
@@ -1082,6 +1083,15 @@ config SND_SOC_CS530X_I2C
 	  Enable support for Cirrus Logic CS530X ADCs
 	  with I2C control.
 
+config SND_SOC_CS530X_SPI
+	tristate "Cirrus Logic CS530x ADCs (SPI)"
+	depends on SPI_MASTER
+	select REGMAP_SPI
+	select SND_SOC_CS530X
+	help
+	  Enable support for Cirrus Logic CS530X ADCs
+	  with SPI control.
+
 config SND_SOC_CX20442
 	tristate
 	depends on TTY
sound/soc/codecs/Makefile +2 -0
index bd95a7c911d5..39138d96a720 100644
@@ -115,6 +115,7 @@ snd-soc-cs48l32-y := cs48l32.o cs48l32-tables.o
 snd-soc-cs53l30-y := cs53l30.o
 snd-soc-cs530x-y := cs530x.o
 snd-soc-cs530x-i2c-y := cs530x-i2c.o
+snd-soc-cs530x-spi-y := cs530x-spi.o
 snd-soc-cx20442-y := cx20442.o
 snd-soc-cx2072x-y := cx2072x.o
 snd-soc-da7210-y := da7210.o
@@ -546,6 +547,7 @@ obj-$(CONFIG_SND_SOC_CS48L32)	+= snd-soc-cs48l32.o
 obj-$(CONFIG_SND_SOC_CS53L30)	+= snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CS530X)	+= snd-soc-cs530x.o
 obj-$(CONFIG_SND_SOC_CS530X_I2C)	+= snd-soc-cs530x-i2c.o
+obj-$(CONFIG_SND_SOC_CS530X_SPI)	+= snd-soc-cs530x-spi.o
 obj-$(CONFIG_SND_SOC_CX20442)	+= snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_CX2072X)	+= snd-soc-cx2072x.o
 obj-$(CONFIG_SND_SOC_DA7210)	+= snd-soc-da7210.o
sound/soc/codecs/cs530x-spi.c new file +92 -0

92 lines not on this page · raw message

sound/soc/codecs/cs530x.c +21 -0
index 9fcae9b85a45..f8f409d0b035 100644
@@ -12,6 +12,7 @@
 #include <linux/pm.h>
 #include <linux/property.h>
 #include <linux/slab.h>
+#include <linux/spi/spi.h>
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/pcm.h>
@@ -1142,6 +1143,26 @@ const struct regmap_config cs530x_regmap_i2c = {
 };
 EXPORT_SYMBOL_NS_GPL(cs530x_regmap_i2c, "SND_SOC_CS530X");
 
+const struct regmap_config cs530x_regmap_spi = {
+	.reg_bits = 16,
+	.pad_bits = 16,
+	.val_bits = 16,
+
+	.reg_stride = 2,
+
+	.reg_format_endian = REGMAP_ENDIAN_BIG,
+	.val_format_endian = REGMAP_ENDIAN_BIG,
+
+	.max_register = CS530X_MAX_REGISTER,
+	.writeable_reg = cs530x_writeable_register,
+	.readable_reg = cs530x_readable_register,
+
+	.cache_type = REGCACHE_MAPLE,
+	.reg_defaults = cs530x_reg_defaults,
+	.num_reg_defaults = ARRAY_SIZE(cs530x_reg_defaults),
+};
+EXPORT_SYMBOL_NS_GPL(cs530x_regmap_spi, "SND_SOC_CS530X");
+
 static int cs530x_check_device_id(struct cs530x_priv *cs530x)
 {
 	struct device *dev = cs530x->dev;
sound/soc/codecs/cs530x.h +1 -0
index 2a7b7d01ecfb..1e2f6a7a589c 100644
@@ -247,6 +247,7 @@ struct cs530x_priv {
 };
 
 extern const struct regmap_config cs530x_regmap_i2c;
+extern const struct regmap_config cs530x_regmap_spi;
 int cs530x_probe(struct cs530x_priv *cs530x);
 
 #endif
Signature · 1 line
2.43.0