The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
@ 2026-06-01  8:02 chancel.liu
  2026-06-01  8:39 ` Charles Keepax
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: chancel.liu @ 2026-06-01  8:02 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, david.rhodes, rf
  Cc: linux-kernel, linux-sound, patches

From: Chancel Liu <chancel.liu@nxp.com>

The existing cs42xx8 driver only supported I2C control interface.
Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/codecs/Kconfig       |   7 +++
 sound/soc/codecs/Makefile      |   2 +
 sound/soc/codecs/cs42xx8-spi.c | 104 +++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100644 sound/soc/codecs/cs42xx8-spi.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a7c61f7c7f4c..ae36f663a5ef 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -93,6 +93,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_CS4271_I2C
 	imply SND_SOC_CS4271_SPI
 	imply SND_SOC_CS42XX8_I2C
+	imply SND_SOC_CS42XX8_SPI
 	imply SND_SOC_CS43130
 	imply SND_SOC_CS4341
 	imply SND_SOC_CS4349
@@ -1077,6 +1078,12 @@ config SND_SOC_CS4271_SPI
 config SND_SOC_CS42XX8
 	tristate
 
+config SND_SOC_CS42XX8_SPI
+	tristate "Cirrus Logic CS42448/CS42888 CODEC (SPI)"
+	depends on SPI_MASTER
+	select SND_SOC_CS42XX8
+	select REGMAP_SPI
+
 config SND_SOC_CS42XX8_I2C
 	tristate "Cirrus Logic CS42448/CS42888 CODEC (I2C)"
 	depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 73315d017c57..aa0396e5b575 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -103,6 +103,7 @@ snd-soc-cs4271-i2c-y := cs4271-i2c.o
 snd-soc-cs4271-spi-y := cs4271-spi.o
 snd-soc-cs42xx8-y := cs42xx8.o
 snd-soc-cs42xx8-i2c-y := cs42xx8-i2c.o
+snd-soc-cs42xx8-spi-y := cs42xx8-spi.o
 snd-soc-cs43130-y := cs43130.o
 snd-soc-cs4341-y := cs4341.o
 snd-soc-cs4349-y := cs4349.o
@@ -543,6 +544,7 @@ obj-$(CONFIG_SND_SOC_CS4271_I2C)	+= snd-soc-cs4271-i2c.o
 obj-$(CONFIG_SND_SOC_CS4271_SPI)	+= snd-soc-cs4271-spi.o
 obj-$(CONFIG_SND_SOC_CS42XX8)	+= snd-soc-cs42xx8.o
 obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
+obj-$(CONFIG_SND_SOC_CS42XX8_SPI) += snd-soc-cs42xx8-spi.o
 obj-$(CONFIG_SND_SOC_CS43130)   += snd-soc-cs43130.o
 obj-$(CONFIG_SND_SOC_CS4341)	+= snd-soc-cs4341.o
 obj-$(CONFIG_SND_SOC_CS4349)	+= snd-soc-cs4349.o
diff --git a/sound/soc/codecs/cs42xx8-spi.c b/sound/soc/codecs/cs42xx8-spi.c
new file mode 100644
index 000000000000..d092cad02b61
--- /dev/null
+++ b/sound/soc/codecs/cs42xx8-spi.c
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Cirrus Logic CS42448/CS42888 Audio CODEC DAI SPI driver
+ *
+ * Copyright 2026 NXP
+ *
+ */
+
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/spi/spi.h>
+#include <sound/soc.h>
+
+#include "cs42xx8.h"
+
+/*
+ * CS42448/CS42888 SPI register access (from datasheet Figure 23):
+ *
+ * The SPI frame is 3 bytes:
+ *   Byte 0: chip address [7:1] = 1001111, bit[0] = R/W (0=write, 1=read)
+ *           Write: 0x9E,  Read: 0x9F
+ *   Byte 1: MAP - Memory Address Pointer
+ *           bit[7] = INCR (auto-increment for burst), bits[6:0] = address
+ *   Byte 2: data byte
+ *
+ * We configure reg_bits=16 so that regmap treats the address field as 2 bytes
+ * (big-endian). The chip address byte (0x9E/0x9F) is placed in the high byte
+ * via write_flag_mask / read_flag_mask, and the MAP register address occupies
+ * the low byte. This produces the correct 3-byte on-wire frame without any
+ * custom bus implementation:
+ *
+ *   write: [0x9E, MAP_addr, data]
+ *   read:  [0x9F, MAP_addr] -> [data]
+ */
+
+static int cs42xx8_spi_probe(struct spi_device *spi)
+{
+	struct cs42xx8_driver_data *drvdata;
+	struct regmap_config config;
+	int ret;
+
+	drvdata = (struct cs42xx8_driver_data *)spi_get_device_match_data(spi);
+	if (!drvdata)
+		return dev_err_probe(&spi->dev, -EINVAL,
+				     "failed to find driver data\n");
+
+	config = cs42xx8_regmap_config;
+	/*
+	 * reg_bits=16 makes regmap send a 2-byte address field (big-endian).
+	 * write_flag_mask/read_flag_mask are OR'd into that address field:
+	 */
+	config.reg_bits           = 16;
+	config.write_flag_mask    = 0x9E;
+	config.read_flag_mask     = 0x9F;
+	config.reg_format_endian  = REGMAP_ENDIAN_BIG;
+
+	ret = cs42xx8_probe(&spi->dev,
+			    devm_regmap_init_spi(spi, &config), drvdata);
+	if (ret)
+		return ret;
+
+	pm_runtime_enable(&spi->dev);
+	pm_request_idle(&spi->dev);
+
+	return 0;
+}
+
+static void cs42xx8_spi_remove(struct spi_device *spi)
+{
+	pm_runtime_disable(&spi->dev);
+}
+
+static const struct of_device_id cs42xx8_of_match[] = {
+	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
+	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
+
+static const struct spi_device_id cs42xx8_spi_id[] = {
+	{ .name = "cs42448", .driver_data = (kernel_ulong_t)&cs42448_data },
+	{ .name = "cs42888", .driver_data = (kernel_ulong_t)&cs42888_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, cs42xx8_spi_id);
+
+static struct spi_driver cs42xx8_spi_driver = {
+	.driver = {
+		.name = "cs42xx8",
+		.pm = pm_ptr(&cs42xx8_pm),
+		.of_match_table = cs42xx8_of_match,
+	},
+	.probe = cs42xx8_spi_probe,
+	.remove = cs42xx8_spi_remove,
+	.id_table = cs42xx8_spi_id,
+};
+
+module_spi_driver(cs42xx8_spi_driver);
+
+MODULE_DESCRIPTION("Cirrus Logic CS42448/CS42888 ALSA SoC Codec SPI Driver");
+MODULE_AUTHOR("Chancel Liu <chancel.liu@nxp.com>");
+MODULE_LICENSE("GPL");
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-01  8:02 [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
@ 2026-06-01  8:39 ` Charles Keepax
  2026-06-02  5:31   ` Chancel Liu (OSS)
  2026-06-01 16:53 ` Mark Brown
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
  2 siblings, 1 reply; 14+ messages in thread
From: Charles Keepax @ 2026-06-01  8:39 UTC (permalink / raw)
  To: chancel.liu
  Cc: lgirdwood, broonie, perex, tiwai, david.rhodes, rf, linux-kernel,
	linux-sound, patches

On Mon, Jun 01, 2026 at 05:02:24PM +0900, chancel.liu@oss.nxp.com wrote:
> From: Chancel Liu <chancel.liu@nxp.com>
> 
> The existing cs42xx8 driver only supported I2C control interface.
> Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> 
> Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> +static int cs42xx8_spi_probe(struct spi_device *spi)
> +{
> +	struct cs42xx8_driver_data *drvdata;
> +	struct regmap_config config;
> +	int ret;
> +
> +	drvdata = (struct cs42xx8_driver_data *)spi_get_device_match_data(spi);
> +	if (!drvdata)
> +		return dev_err_probe(&spi->dev, -EINVAL,
> +				     "failed to find driver data\n");
> +
> +	config = cs42xx8_regmap_config;
> +	/*
> +	 * reg_bits=16 makes regmap send a 2-byte address field (big-endian).
> +	 * write_flag_mask/read_flag_mask are OR'd into that address field:
> +	 */
> +	config.reg_bits           = 16;
> +	config.write_flag_mask    = 0x9E;
> +	config.read_flag_mask     = 0x9F;
> +	config.reg_format_endian  = REGMAP_ENDIAN_BIG;

Probably nicer to just update cs42xx8_regmap_config for the
endian, I believe this part is the same on both buses?

Otherwise looks fine to me.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-01  8:02 [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
  2026-06-01  8:39 ` Charles Keepax
@ 2026-06-01 16:53 ` Mark Brown
  2026-06-02  6:25   ` Chancel Liu (OSS)
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
  2 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2026-06-01 16:53 UTC (permalink / raw)
  To: chancel.liu
  Cc: lgirdwood, perex, tiwai, david.rhodes, rf, linux-kernel,
	linux-sound, patches

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]

On Mon, Jun 01, 2026 at 05:02:24PM +0900, chancel.liu@oss.nxp.com wrote:

> The existing cs42xx8 driver only supported I2C control interface.
> Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.

> + * The SPI frame is 3 bytes:
> + *   Byte 0: chip address [7:1] = 1001111, bit[0] = R/W (0=write, 1=read)
> + *           Write: 0x9E,  Read: 0x9F
> + *   Byte 1: MAP - Memory Address Pointer
> + *           bit[7] = INCR (auto-increment for burst), bits[6:0] = address

> + * We configure reg_bits=16 so that regmap treats the address field as 2 bytes
> + * (big-endian). The chip address byte (0x9E/0x9F) is placed in the high byte
> + * via write_flag_mask / read_flag_mask, and the MAP register address occupies
> + * the low byte. This produces the correct 3-byte on-wire frame without any
> + * custom bus implementation:
> + *
> + *   write: [0x9E, MAP_addr, data]
> + *   read:  [0x9F, MAP_addr] -> [data]

What about INCR?

> +static const struct of_device_id cs42xx8_of_match[] = {
> +	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
> +	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, cs42xx8_of_match);

This should have an update to the bindings as well.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-01  8:39 ` Charles Keepax
@ 2026-06-02  5:31   ` Chancel Liu (OSS)
  0 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu (OSS) @ 2026-06-02  5:31 UTC (permalink / raw)
  To: Charles Keepax, Chancel Liu (OSS)
  Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, david.rhodes@cirrus.com, rf@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	patches@opensource.cirrus.com

> > From: Chancel Liu <chancel.liu@nxp.com>
> >
> > The existing cs42xx8 driver only supported I2C control interface.
> > Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> >
> > Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> > +static int cs42xx8_spi_probe(struct spi_device *spi) {
> > +     struct cs42xx8_driver_data *drvdata;
> > +     struct regmap_config config;
> > +     int ret;
> > +
> > +     drvdata = (struct cs42xx8_driver_data
> *)spi_get_device_match_data(spi);
> > +     if (!drvdata)
> > +             return dev_err_probe(&spi->dev, -EINVAL,
> > +                                  "failed to find driver data\n");
> > +
> > +     config = cs42xx8_regmap_config;
> > +     /*
> > +      * reg_bits=16 makes regmap send a 2-byte address field (big-
> endian).
> > +      * write_flag_mask/read_flag_mask are OR'd into that address
> field:
> > +      */
> > +     config.reg_bits           = 16;
> > +     config.write_flag_mask    = 0x9E;
> > +     config.read_flag_mask     = 0x9F;
> > +     config.reg_format_endian  = REGMAP_ENDIAN_BIG;
> 
> Probably nicer to just update cs42xx8_regmap_config for the endian, I
> believe this part is the same on both buses?
> 
> Otherwise looks fine to me.
> 
> Thanks,
> Charles

Okay. I'll move format endian into common regmap config.

Regards,
Chancel Liu

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-01 16:53 ` Mark Brown
@ 2026-06-02  6:25   ` Chancel Liu (OSS)
  2026-06-02  8:44     ` Charles Keepax
  0 siblings, 1 reply; 14+ messages in thread
From: Chancel Liu (OSS) @ 2026-06-02  6:25 UTC (permalink / raw)
  To: Mark Brown, Chancel Liu (OSS)
  Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	david.rhodes@cirrus.com, rf@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	patches@opensource.cirrus.com

> > The existing cs42xx8 driver only supported I2C control interface.
> > Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> 
> > + * The SPI frame is 3 bytes:
> > + *   Byte 0: chip address [7:1] = 1001111, bit[0] = R/W (0=write,
> 1=read)
> > + *           Write: 0x9E,  Read: 0x9F
> > + *   Byte 1: MAP - Memory Address Pointer
> > + *           bit[7] = INCR (auto-increment for burst), bits[6:0] =
> address
> 
> > + * We configure reg_bits=16 so that regmap treats the address field as
> 2 bytes
> > + * (big-endian). The chip address byte (0x9E/0x9F) is placed in the
> high byte
> > + * via write_flag_mask / read_flag_mask, and the MAP register address
> occupies
> > + * the low byte. This produces the correct 3-byte on-wire frame without
> any
> > + * custom bus implementation:
> > + *
> > + *   write: [0x9E, MAP_addr, data]
> > + *   read:  [0x9F, MAP_addr] -> [data]
> 
> What about INCR?
> 

Indeed. This patch doesn't handle INCR. I'll enable INCR after reworking
on write_flag_mask/read_flag_mask.

> > +static const struct of_device_id cs42xx8_of_match[] = {
> > +	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
> > +	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
> 
> This should have an update to the bindings as well.

OK. I'll also update bindings in next revision.

Regards, 
Chancel Liu

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-02  6:25   ` Chancel Liu (OSS)
@ 2026-06-02  8:44     ` Charles Keepax
  2026-06-02  9:56       ` Chancel Liu (OSS)
  0 siblings, 1 reply; 14+ messages in thread
From: Charles Keepax @ 2026-06-02  8:44 UTC (permalink / raw)
  To: Chancel Liu (OSS)
  Cc: Mark Brown, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	david.rhodes@cirrus.com, rf@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	patches@opensource.cirrus.com

On Tue, Jun 02, 2026 at 06:25:33AM +0000, Chancel Liu (OSS) wrote:
> > > The existing cs42xx8 driver only supported I2C control interface.
> > > Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> > 
> > > + * The SPI frame is 3 bytes:
> > > + *   Byte 0: chip address [7:1] = 1001111, bit[0] = R/W (0=write,
> > 1=read)
> > > + *           Write: 0x9E,  Read: 0x9F
> > > + *   Byte 1: MAP - Memory Address Pointer
> > > + *           bit[7] = INCR (auto-increment for burst), bits[6:0] =
> > address
> > 
> > > + * We configure reg_bits=16 so that regmap treats the address field as
> > 2 bytes
> > > + * (big-endian). The chip address byte (0x9E/0x9F) is placed in the
> > high byte
> > > + * via write_flag_mask / read_flag_mask, and the MAP register address
> > occupies
> > > + * the low byte. This produces the correct 3-byte on-wire frame without
> > any
> > > + * custom bus implementation:
> > > + *
> > > + *   write: [0x9E, MAP_addr, data]
> > > + *   read:  [0x9F, MAP_addr] -> [data]
> > 
> > What about INCR?
> > 
> 
> Indeed. This patch doesn't handle INCR. I'll enable INCR after reworking
> on write_flag_mask/read_flag_mask.
> 

I don't think the driver does anything that reads/writes more
than a single register, so one could probably just set
use_single_read/write and punt on handling INCR for now.

> > > +static const struct of_device_id cs42xx8_of_match[] = {
> > > +	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
> > > +	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
> > > +	{ /* sentinel */ }
> > > +};
> > > +MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
> > 
> > This should have an update to the bindings as well.

Thanks sorry missed that.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-02  8:44     ` Charles Keepax
@ 2026-06-02  9:56       ` Chancel Liu (OSS)
  0 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu (OSS) @ 2026-06-02  9:56 UTC (permalink / raw)
  To: Charles Keepax, Chancel Liu (OSS)
  Cc: Mark Brown, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	david.rhodes@cirrus.com, rf@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	patches@opensource.cirrus.com

> > > > The existing cs42xx8 driver only supported I2C control interface.
> > > > Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio
> CODEC.
> > >
> > > > + * The SPI frame is 3 bytes:
> > > > + *   Byte 0: chip address [7:1] = 1001111, bit[0] = R/W (0=write,
> > > 1=read)
> > > > + *           Write: 0x9E,  Read: 0x9F
> > > > + *   Byte 1: MAP - Memory Address Pointer
> > > > + *           bit[7] = INCR (auto-increment for burst), bits[6:0] =
> > > address
> > >
> > > > + * We configure reg_bits=16 so that regmap treats the address
> > > > + field as
> > > 2 bytes
> > > > + * (big-endian). The chip address byte (0x9E/0x9F) is placed in
> > > > + the
> > > high byte
> > > > + * via write_flag_mask / read_flag_mask, and the MAP register
> > > > + address
> > > occupies
> > > > + * the low byte. This produces the correct 3-byte on-wire frame
> > > > + without
> > > any
> > > > + * custom bus implementation:
> > > > + *
> > > > + *   write: [0x9E, MAP_addr, data]
> > > > + *   read:  [0x9F, MAP_addr] -> [data]
> > >
> > > What about INCR?
> > >
> >
> > Indeed. This patch doesn't handle INCR. I'll enable INCR after
> > reworking on write_flag_mask/read_flag_mask.
> >
> 
> I don't think the driver does anything that reads/writes more than a
> single register, so one could probably just set use_single_read/write and
> punt on handling INCR for now.
>

Even after enabling INCR, I found in my testing that the current
configuration still issues single-register writes during
regcache_sync(). So for this case, INCR is not actually exercised by
the current sync path.

Given that, I agree that it's better to keep this series focused on
single read/write accesses for now. If a path that performs true
bulk/raw multi-register accesses is added later, INCR support can be
introduced as a separate follow-up.

Regards, 
Chancel Liu

> > > > +static const struct of_device_id cs42xx8_of_match[] = {  {
> > > > +.compatible = "cirrus,cs42448", .data = &cs42448_data, },  {
> > > > +.compatible = "cirrus,cs42888", .data = &cs42888_data, },  { /*
> > > > +sentinel */ } }; MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
> > >
> > > This should have an update to the bindings as well.
> 
> Thanks sorry missed that.
> 
> Thanks,
> Charles

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 0/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-01  8:02 [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
  2026-06-01  8:39 ` Charles Keepax
  2026-06-01 16:53 ` Mark Brown
@ 2026-06-03  9:50 ` chancel.liu
  2026-06-03  9:50   ` [PATCH v2 1/2] ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support chancel.liu
                     ` (4 more replies)
  2 siblings, 5 replies; 14+ messages in thread
From: chancel.liu @ 2026-06-03  9:50 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, david.rhodes, rf, robh, krzk+dt,
	conor+dt
  Cc: devicetree, linux-kernel, linux-sound, patches

From: Chancel Liu <chancel.liu@nxp.com>

The existing cs42xx8 driver only supported I2C control interface.
Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.

Changes in v2:
- Add SPI bus support in codec binding
- Move format endian into common regmap config
- Enable use_single_read/write for common regmap config

Chancel Liu (2):
  ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support
  ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec

 .../bindings/sound/cirrus,cs42xx8.yaml        |  23 ++++
 sound/soc/codecs/Kconfig                      |   7 ++
 sound/soc/codecs/Makefile                     |   2 +
 sound/soc/codecs/cs42xx8-spi.c                | 104 ++++++++++++++++++
 sound/soc/codecs/cs42xx8.c                    |   3 +
 5 files changed, 139 insertions(+)
 create mode 100644 sound/soc/codecs/cs42xx8-spi.c

--
2.50.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/2] ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
@ 2026-06-03  9:50   ` chancel.liu
  2026-06-03  9:50   ` [PATCH v2 2/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: chancel.liu @ 2026-06-03  9:50 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, david.rhodes, rf, robh, krzk+dt,
	conor+dt
  Cc: devicetree, linux-kernel, linux-sound, patches

From: Chancel Liu <chancel.liu@nxp.com>

Codec CS42448/CS42888 supports multiple control interfaces. At present,
only the I2C interface is implemented. Adding support for the SPI
control interface, operating at up to 6MHz.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 .../bindings/sound/cirrus,cs42xx8.yaml        | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/cirrus,cs42xx8.yaml b/Documentation/devicetree/bindings/sound/cirrus,cs42xx8.yaml
index 7ae72bd901f4..a1ae548c4b7b 100644
--- a/Documentation/devicetree/bindings/sound/cirrus,cs42xx8.yaml
+++ b/Documentation/devicetree/bindings/sound/cirrus,cs42xx8.yaml
@@ -11,6 +11,7 @@ maintainers:
 
 allOf:
   - $ref: dai-common.yaml#
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
 
 properties:
   compatible:
@@ -21,6 +22,9 @@ properties:
   reg:
     maxItems: 1
 
+  spi-max-frequency:
+    maximum: 6000000
+
   clocks:
     minItems: 1
     maxItems: 2
@@ -86,3 +90,22 @@ examples:
           reset-gpios = <&gpio 1>;
       };
     };
+
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      cs-gpios = <&gpio 8 0>;
+
+      codec@0 {
+          compatible = "cirrus,cs42888";
+          reg = <0>;
+          spi-max-frequency = <6000000>;
+          clocks = <&codec_mclk 0>;
+          clock-names = "mclk";
+          VA-supply = <&reg_audio>;
+          VD-supply = <&reg_audio>;
+          VLS-supply = <&reg_audio>;
+          VLC-supply = <&reg_audio>;
+          reset-gpios = <&gpio 1>;
+      };
+    };
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
  2026-06-03  9:50   ` [PATCH v2 1/2] ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support chancel.liu
@ 2026-06-03  9:50   ` chancel.liu
  2026-06-03 11:46   ` [PATCH v2 0/2] " Charles Keepax
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: chancel.liu @ 2026-06-03  9:50 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, david.rhodes, rf, robh, krzk+dt,
	conor+dt
  Cc: devicetree, linux-kernel, linux-sound, patches

From: Chancel Liu <chancel.liu@nxp.com>

The existing cs42xx8 driver only supported I2C control interface.
Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/codecs/Kconfig       |   7 +++
 sound/soc/codecs/Makefile      |   2 +
 sound/soc/codecs/cs42xx8-spi.c | 104 +++++++++++++++++++++++++++++++++
 sound/soc/codecs/cs42xx8.c     |   3 +
 4 files changed, 116 insertions(+)
 create mode 100644 sound/soc/codecs/cs42xx8-spi.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a7c61f7c7f4c..ae36f663a5ef 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -93,6 +93,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_CS4271_I2C
 	imply SND_SOC_CS4271_SPI
 	imply SND_SOC_CS42XX8_I2C
+	imply SND_SOC_CS42XX8_SPI
 	imply SND_SOC_CS43130
 	imply SND_SOC_CS4341
 	imply SND_SOC_CS4349
@@ -1077,6 +1078,12 @@ config SND_SOC_CS4271_SPI
 config SND_SOC_CS42XX8
 	tristate
 
+config SND_SOC_CS42XX8_SPI
+	tristate "Cirrus Logic CS42448/CS42888 CODEC (SPI)"
+	depends on SPI_MASTER
+	select SND_SOC_CS42XX8
+	select REGMAP_SPI
+
 config SND_SOC_CS42XX8_I2C
 	tristate "Cirrus Logic CS42448/CS42888 CODEC (I2C)"
 	depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 73315d017c57..aa0396e5b575 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -103,6 +103,7 @@ snd-soc-cs4271-i2c-y := cs4271-i2c.o
 snd-soc-cs4271-spi-y := cs4271-spi.o
 snd-soc-cs42xx8-y := cs42xx8.o
 snd-soc-cs42xx8-i2c-y := cs42xx8-i2c.o
+snd-soc-cs42xx8-spi-y := cs42xx8-spi.o
 snd-soc-cs43130-y := cs43130.o
 snd-soc-cs4341-y := cs4341.o
 snd-soc-cs4349-y := cs4349.o
@@ -543,6 +544,7 @@ obj-$(CONFIG_SND_SOC_CS4271_I2C)	+= snd-soc-cs4271-i2c.o
 obj-$(CONFIG_SND_SOC_CS4271_SPI)	+= snd-soc-cs4271-spi.o
 obj-$(CONFIG_SND_SOC_CS42XX8)	+= snd-soc-cs42xx8.o
 obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
+obj-$(CONFIG_SND_SOC_CS42XX8_SPI) += snd-soc-cs42xx8-spi.o
 obj-$(CONFIG_SND_SOC_CS43130)   += snd-soc-cs43130.o
 obj-$(CONFIG_SND_SOC_CS4341)	+= snd-soc-cs4341.o
 obj-$(CONFIG_SND_SOC_CS4349)	+= snd-soc-cs4349.o
diff --git a/sound/soc/codecs/cs42xx8-spi.c b/sound/soc/codecs/cs42xx8-spi.c
new file mode 100644
index 000000000000..b86fe2fe771e
--- /dev/null
+++ b/sound/soc/codecs/cs42xx8-spi.c
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Cirrus Logic CS42448/CS42888 Audio CODEC DAI SPI driver
+ *
+ * Copyright 2026 NXP
+ *
+ */
+
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/spi/spi.h>
+#include <sound/soc.h>
+
+#include "cs42xx8.h"
+
+/*
+ * CS42448/CS42888 SPI register access (from datasheet Figure 23):
+ *
+ * The SPI frame is 3 bytes:
+ *   Byte 0: chip address [7:1] = 1001111, bit[0] = R/W (0=write, 1=read)
+ *           Write: 0x9E,  Read: 0x9F
+ *   Byte 1: MAP - Memory Address Pointer
+ *           bit[7] = INCR (auto-increment for burst), bits[6:0] = address
+ *   Byte 2: data byte
+ *
+ * We configure reg_bits=16 so that regmap treats the address field as 2 bytes
+ * (big-endian). The chip address byte (0x9E/0x9F) is placed in the high byte
+ * via write_flag_mask / read_flag_mask, and the MAP register address occupies
+ * the low byte. Currently INCR (MAP bit[7]) is not set and use_single_read/write
+ * are enabled. This produces the correct 3-byte on-wire frame without any
+ * custom bus implementation:
+ *
+ *   write: [0x9E, MAP_addr, data]
+ *   read:  [0x9F, MAP_addr] -> [data]
+ */
+
+static int cs42xx8_spi_probe(struct spi_device *spi)
+{
+	struct cs42xx8_driver_data *drvdata;
+	struct regmap_config config;
+	int ret;
+
+	drvdata = (struct cs42xx8_driver_data *)spi_get_device_match_data(spi);
+	if (!drvdata)
+		return dev_err_probe(&spi->dev, -EINVAL,
+				     "failed to find driver data\n");
+
+	config = cs42xx8_regmap_config;
+	/*
+	 * reg_bits=16 makes regmap send a 2-byte address field (big-endian).
+	 * write_flag_mask/read_flag_mask are OR'd into that address field:
+	 */
+	config.reg_bits           = 16;
+	config.write_flag_mask    = 0x9E;
+	config.read_flag_mask     = 0x9F;
+
+	ret = cs42xx8_probe(&spi->dev,
+			    devm_regmap_init_spi(spi, &config), drvdata);
+	if (ret)
+		return ret;
+
+	pm_runtime_enable(&spi->dev);
+	pm_request_idle(&spi->dev);
+
+	return 0;
+}
+
+static void cs42xx8_spi_remove(struct spi_device *spi)
+{
+	pm_runtime_disable(&spi->dev);
+}
+
+static const struct of_device_id cs42xx8_of_match[] = {
+	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
+	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
+
+static const struct spi_device_id cs42xx8_spi_id[] = {
+	{ .name = "cs42448", .driver_data = (kernel_ulong_t)&cs42448_data },
+	{ .name = "cs42888", .driver_data = (kernel_ulong_t)&cs42888_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, cs42xx8_spi_id);
+
+static struct spi_driver cs42xx8_spi_driver = {
+	.driver = {
+		.name = "cs42xx8",
+		.pm = pm_ptr(&cs42xx8_pm),
+		.of_match_table = cs42xx8_of_match,
+	},
+	.probe = cs42xx8_spi_probe,
+	.remove = cs42xx8_spi_remove,
+	.id_table = cs42xx8_spi_id,
+};
+
+module_spi_driver(cs42xx8_spi_driver);
+
+MODULE_DESCRIPTION("Cirrus Logic CS42448/CS42888 ALSA SoC Codec SPI Driver");
+MODULE_AUTHOR("Chancel Liu <chancel.liu@nxp.com>");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
index 12fe9b3e2525..5b689549c74e 100644
--- a/sound/soc/codecs/cs42xx8.c
+++ b/sound/soc/codecs/cs42xx8.c
@@ -478,6 +478,9 @@ const struct regmap_config cs42xx8_regmap_config = {
 	.volatile_reg = cs42xx8_volatile_register,
 	.writeable_reg = cs42xx8_writeable_register,
 	.cache_type = REGCACHE_MAPLE,
+	.reg_format_endian  = REGMAP_ENDIAN_BIG,
+	.use_single_read = true,
+	.use_single_write = true,
 };
 EXPORT_SYMBOL_GPL(cs42xx8_regmap_config);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 0/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
  2026-06-03  9:50   ` [PATCH v2 1/2] ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support chancel.liu
  2026-06-03  9:50   ` [PATCH v2 2/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
@ 2026-06-03 11:46   ` Charles Keepax
  2026-06-03 11:57   ` Mark Brown
  2026-06-03 11:57   ` Mark Brown
  4 siblings, 0 replies; 14+ messages in thread
From: Charles Keepax @ 2026-06-03 11:46 UTC (permalink / raw)
  To: chancel.liu
  Cc: lgirdwood, broonie, perex, tiwai, david.rhodes, rf, robh, krzk+dt,
	conor+dt, devicetree, linux-kernel, linux-sound, patches

On Wed, Jun 03, 2026 at 06:50:39PM +0900, chancel.liu@oss.nxp.com wrote:
> From: Chancel Liu <chancel.liu@nxp.com>
> 
> The existing cs42xx8 driver only supported I2C control interface.
> Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> 
> Changes in v2:
> - Add SPI bus support in codec binding
> - Move format endian into common regmap config
> - Enable use_single_read/write for common regmap config
> 
> Chancel Liu (2):
>   ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support
>   ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
> 

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 0/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
                     ` (2 preceding siblings ...)
  2026-06-03 11:46   ` [PATCH v2 0/2] " Charles Keepax
@ 2026-06-03 11:57   ` Mark Brown
  2026-06-03 12:14     ` Chancel Liu (OSS)
  2026-06-03 11:57   ` Mark Brown
  4 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2026-06-03 11:57 UTC (permalink / raw)
  To: chancel.liu
  Cc: lgirdwood, perex, tiwai, david.rhodes, rf, robh, krzk+dt,
	conor+dt, devicetree, linux-kernel, linux-sound, patches

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

On Wed, Jun 03, 2026 at 06:50:39PM +0900, chancel.liu@oss.nxp.com wrote:
> From: Chancel Liu <chancel.liu@nxp.com>
> 
> The existing cs42xx8 driver only supported I2C control interface.
> Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.

Please don't send new patches in reply to old patches or serieses, this
makes it harder for both people and tools to understand what is going
on - it can bury things in mailboxes and make it difficult to keep track
of what current patches are, both for the new patches and the old ones.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 0/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
                     ` (3 preceding siblings ...)
  2026-06-03 11:57   ` Mark Brown
@ 2026-06-03 11:57   ` Mark Brown
  4 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2026-06-03 11:57 UTC (permalink / raw)
  To: lgirdwood, perex, tiwai, david.rhodes, rf, robh, krzk+dt,
	conor+dt, chancel.liu
  Cc: devicetree, linux-kernel, linux-sound, patches

On Wed, 03 Jun 2026 18:50:39 +0900, chancel.liu@oss.nxp.com wrote:
> ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
> 
> From: Chancel Liu <chancel.liu@nxp.com>
> 
> The existing cs42xx8 driver only supported I2C control interface.
> Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/2] ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support
      https://git.kernel.org/broonie/sound/c/596f8d649444
[2/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
      https://git.kernel.org/broonie/sound/c/3158f585f4f2

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] 14+ messages in thread

* RE: [PATCH v2 0/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec
  2026-06-03 11:57   ` Mark Brown
@ 2026-06-03 12:14     ` Chancel Liu (OSS)
  0 siblings, 0 replies; 14+ messages in thread
From: Chancel Liu (OSS) @ 2026-06-03 12:14 UTC (permalink / raw)
  To: Mark Brown, Chancel Liu (OSS)
  Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	david.rhodes@cirrus.com, rf@opensource.cirrus.com,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com

> > The existing cs42xx8 driver only supported I2C control interface.
> > Add SPI bus support for the Cirrus Logic CS42448/CS42888 Audio CODEC.
> 
> Please don't send new patches in reply to old patches or serieses, this
> makes it harder for both people and tools to understand what is going
> on - it can bury things in mailboxes and make it difficult to keep track
> of what current patches are, both for the new patches and the old ones.

Thanks for the reminder. Sorry about that. Understood, I won't do that
again.

Regards, 
Chancel Liu

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-06-03 13:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01  8:02 [PATCH] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
2026-06-01  8:39 ` Charles Keepax
2026-06-02  5:31   ` Chancel Liu (OSS)
2026-06-01 16:53 ` Mark Brown
2026-06-02  6:25   ` Chancel Liu (OSS)
2026-06-02  8:44     ` Charles Keepax
2026-06-02  9:56       ` Chancel Liu (OSS)
2026-06-03  9:50 ` [PATCH v2 0/2] " chancel.liu
2026-06-03  9:50   ` [PATCH v2 1/2] ASoC: dt-bindings: cirrus,cs42xx8: Add SPI bus support chancel.liu
2026-06-03  9:50   ` [PATCH v2 2/2] ASoC: cs42xx8: Add SPI bus support for CS42448/CS42888 codec chancel.liu
2026-06-03 11:46   ` [PATCH v2 0/2] " Charles Keepax
2026-06-03 11:57   ` Mark Brown
2026-06-03 12:14     ` Chancel Liu (OSS)
2026-06-03 11:57   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox