Skip to contentSkip to conversation

ASoC: rt5575: Add the codec driver for the ALC5575

PATCH In review Oder Chiou 3 participants 7 messages Dec 31, 2025 – Jan 7

Subsystems (5)
Device tree bindings Sound ASoC SPI +1 more subsystems
lore
Share & tools
lore

Oder Chiou

author maintainer
#0 lore raw

v11 cover ASoC: rt5575: Add the codec driver for the ALC5575

Hi all,

This patch series adds support for the Realtek ALC5575 audio codec.

Changes in v11:
- Patch 1/4:
- minor fixes
- Patch 2/4:
- change of_find_spi_controller_by_node() gating to CONFIG_OF
- Patch 3/4:
- nothing
- Patch 4/4:
- achieve reverse-christmas-tree notation
- remove formal version check
- revise check whether the firmware boots from SPI or not
- minor fixes

Changes in v10:
- Patch 1/3:
- export of_find_spi_controller_by_node()
- Patch 2/3:
- remove realtek,rt5575-use-spi
- add spi-parent for firmware-loading
- Patch 3/3:
- use of_find_spi_controller_by_node() to get the SPI controller and add the spi device for firmware-loading
- Link to v10: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Patch 1/2:
- modify the comment
- change the compatible name to "realtek,rt5575-use-spi"
- Patch 2/2:
- remove the standalone rt5575_spi_driver module and integrate its functionality into the I2C driver
- move the SPI firmware-loading function to rt5575-spi.c
- use the match data to distinguish between w/wo flash
- minor fixes
- Link to v9: https://lore.kernel.org/all/[email protected]/

Changes in v8:
- Patch 1/2:
- remove the variable rt5575_spi_ready
- use the multiple compatible names to distinguish between w/wo flash
- Patch 2/2:
- add compatible enum "realtek,rt5575-with-spi"
- Link to v8: https://lore.kernel.org/all/[email protected]/

Changes in v7:
- Patch 1/2:
- add a caption for the tristates
- remove the redundant enum of the SPI command
- add the error log in the request firmware failure
- change the function name rt5575_spi_fw_loaded to rt5575_fw_load_by_spi
- minor fixes
- Patch 2/2:
- modify commit message
- Link to v7: https://lore.kernel.org/all/[email protected]/

Changes in v6:
- Patch 1/2:
- modify commit message
- add select SND_SOC_RT5575 to config SND_SOC_RT5575_SPI in the Kconfig
- revise the boiler plate in the head of the file
- sort the include files
- use a structure to transfer the spi data
- use the poll() related function instead the for-loop
- revise the UUID to the private ID
- minor fixes
- Patch 2/2:
- modify description
- Link to v6: https://lore.kernel.org/all/[email protected]/

Changes in v2 to v5:
- Patch 1/2:
- move the firmware to the subdirectory
- remove the empty functions
- remove the cache_type in the regmap_config
- add the error log in the run firmware failure
- Patch 2/2:
- nothing
- Link to v5: https://lore.kernel.org/all/[email protected]/

Oder Chiou (4):
spi: export of_find_spi_controller_by_node()
spi: change of_find_spi_controller_by_node() gating to CONFIG_OF
ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
ASoC: rt5575: Add the codec driver for the ALC5575

 .../bindings/sound/realtek,rt5575.yaml        |  61 +++
 drivers/spi/spi.c                             |  23 +-
 include/linux/spi/spi.h                       |   9 +
 sound/soc/codecs/Kconfig                      |  10 +
 sound/soc/codecs/Makefile                     |   3 +
 sound/soc/codecs/rt5575-spi.c                 | 118 ++++++
 sound/soc/codecs/rt5575-spi.h                 |  27 ++
 sound/soc/codecs/rt5575.c                     | 352 ++++++++++++++++++
 sound/soc/codecs/rt5575.h                     |  58 +++
 9 files changed, 651 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
 create mode 100644 sound/soc/codecs/rt5575-spi.c
 create mode 100644 sound/soc/codecs/rt5575-spi.h
 create mode 100644 sound/soc/codecs/rt5575.c
 create mode 100644 sound/soc/codecs/rt5575.h
Signature · 1 line
2.52.0
author maintainer
#1 lore raw

PATCH v11 1/4 spi: export of_find_spi_controller_by_node()

Some devices are primarily described on another bus (e.g. I2C) but also have an additional SPI connection that serves as a transport for firmware loading. Export of_find_spi_controller_by_node() so drivers can obtain the SPI controller referenced by a DT phandle.

---
 drivers/spi/spi.c       | 3 ++-
 include/linux/spi/spi.h | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/spi/spi.c +2 -1
index e25df9990f82..ecb5281b04a2 100644
@@ -4771,7 +4771,7 @@ static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
 }
 
 /* The spi controllers are not using spi_bus, so we find it with another way */
-static struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
+struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
 {
 	struct device *dev;
 
@@ -4784,6 +4784,7 @@ static struct spi_controller *of_find_spi_controller_by_node(struct device_node
 	/* Reference got in class_find_device */
 	return container_of(dev, struct spi_controller, dev);
 }
+EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node);
 
 static int of_spi_notify(struct notifier_block *nb, unsigned long action,
 			 void *arg)
include/linux/spi/spi.h +9 -0
index cb2c2df31089..e6fdaf02386c 100644
@@ -882,6 +882,15 @@ extern int devm_spi_register_controller(struct device *dev,
 					struct spi_controller *ctlr);
 extern void spi_unregister_controller(struct spi_controller *ctlr);
 
+#if IS_ENABLED(CONFIG_OF_DYNAMIC)
+extern struct spi_controller *of_find_spi_controller_by_node(struct device_node *node);
+#else
+static inline struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
+{
+	return NULL;
+}
+#endif
+
 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SPI_MASTER)
 extern struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev);
 extern struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,
Signature · 1 line
2.52.0
author maintainer
#2 lore raw

PATCH v11 2/4 spi: change of_find_spi_controller_by_node() gating to CONFIG_OF

In reply to Oder Chiou

Currently, the helper of_find_spi_controller_by_node() is gated under CONFIG_OF_DYNAMIC. This prevents drivers from using it in all CONFIG_OF configurations.

This patch moves the gating to CONFIG_OF, keeping the inline fallback returning NULL when Device Tree support is disabled.

---
 drivers/spi/spi.c       | 20 +++++++++++---------
 include/linux/spi/spi.h |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)
drivers/spi/spi.c +11 -9
index ecb5281b04a2..2badacc7a91c 100644
@@ -4761,15 +4761,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
 
 /*-------------------------------------------------------------------------*/
 
-#if IS_ENABLED(CONFIG_OF_DYNAMIC)
-/* Must call put_device() when done with returned spi_device device */
-static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
-{
-	struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node);
-
-	return dev ? to_spi_device(dev) : NULL;
-}
-
+#if IS_ENABLED(CONFIG_OF)
 /* The spi controllers are not using spi_bus, so we find it with another way */
 struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
 {
@@ -4785,6 +4777,16 @@ struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
 	return container_of(dev, struct spi_controller, dev);
 }
 EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node);
+#endif
+
+#if IS_ENABLED(CONFIG_OF_DYNAMIC)
+/* Must call put_device() when done with returned spi_device device */
+static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
+{
+	struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node);
+
+	return dev ? to_spi_device(dev) : NULL;
+}
 
 static int of_spi_notify(struct notifier_block *nb, unsigned long action,
 			 void *arg)
include/linux/spi/spi.h +1 -1
index e6fdaf02386c..8bc616b00343 100644
@@ -882,7 +882,7 @@ extern int devm_spi_register_controller(struct device *dev,
 					struct spi_controller *ctlr);
 extern void spi_unregister_controller(struct spi_controller *ctlr);
 
-#if IS_ENABLED(CONFIG_OF_DYNAMIC)
+#if IS_ENABLED(CONFIG_OF)
 extern struct spi_controller *of_find_spi_controller_by_node(struct device_node *node);
 #else
 static inline struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
Signature · 1 line
2.52.0
author maintainer
#3 lore raw

PATCH v11 3/4 ASoC: dt-bindings: realtek,rt5575: add support for ALC5575

In reply to Oder Chiou

Audio codec with I2S, I2C and SPI.

---
 .../bindings/sound/realtek,rt5575.yaml        | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
Documentation/devicetree/bindings/sound/realtek,rt5575.yaml new file +61 -0
new file mode 100644
index 000000000000..981ebc39b195
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/realtek,rt5575.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ALC5575 audio CODEC
+
+maintainers:
+  - Oder Chiou <[email protected]>
+
+description:
+  The device supports both I2C and SPI. I2C is mandatory, while SPI is
+  optional depending on the hardware configuration. SPI is used for
+  firmware loading if present.
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: realtek,rt5575
+
+  reg:
+    maxItems: 1
+
+  spi-parent:
+    description:
+      Optional phandle reference to the SPI controller used for firmware
+      loading. The argument specifies the chip select.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  # I2C-only node
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        codec@57 {
+            compatible = "realtek,rt5575";
+            reg = <0x57>;
+        };
+    };
+
+  # I2C + optional SPI node
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        codec@57 {
+            compatible = "realtek,rt5575";
+            reg = <0x57>;
+            spi-parent = <&spi0 0>; /* chip-select 0 */
+        };
+    };
Signature · 1 line
2.52.0
author maintainer
#4 lore raw

PATCH v11 4/4 ASoC: rt5575: Add the codec driver for the ALC5575

In reply to Oder Chiou

The ALC5575 integrates an audio DSP that typically loads its firmware from an external flash via its own SPI host interface. In certain hardware configurations, the firmware can alternatively be loaded through the SPI client interface. The driver provides basic mute and volume control functions. When the SPI client interface is enabled, firmware loading is handled by the SPI driver.

---
 sound/soc/codecs/Kconfig      |  10 +
 sound/soc/codecs/Makefile     |   3 +
 sound/soc/codecs/rt5575-spi.c | 118 ++++++++++++
 sound/soc/codecs/rt5575-spi.h |  27 +++
 sound/soc/codecs/rt5575.c     | 352 ++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt5575.h     |  58 ++++++
 6 files changed, 568 insertions(+)
 create mode 100644 sound/soc/codecs/rt5575-spi.c
 create mode 100644 sound/soc/codecs/rt5575-spi.h
 create mode 100644 sound/soc/codecs/rt5575.c
 create mode 100644 sound/soc/codecs/rt5575.h
sound/soc/codecs/Kconfig +10 -0
index 93a266a12a3b..90f09d4bdf8e 100644
@@ -212,6 +212,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT1305
 	imply SND_SOC_RT1308
 	imply SND_SOC_RT5514
+	imply SND_SOC_RT5575
 	imply SND_SOC_RT5616
 	imply SND_SOC_RT5631
 	imply SND_SOC_RT5640
@@ -1783,6 +1784,15 @@ config SND_SOC_RT5514_SPI_BUILTIN
 	bool # force RT5514_SPI to be built-in to avoid link errors
 	default SND_SOC_RT5514=y && SND_SOC_RT5514_SPI=m
 
+config SND_SOC_RT5575
+	tristate "Realtek ALC5575 Codec - I2C"
+	depends on I2C
+
+config SND_SOC_RT5575_SPI
+	tristate "Realtek ALC5575 Codec - SPI"
+	depends on SPI_MASTER && I2C
+	depends on SND_SOC_RT5575
+
 config SND_SOC_RT5616
 	tristate "Realtek RT5616 CODEC"
 	depends on I2C
sound/soc/codecs/Makefile +3 -0
index d687d4f74363..a6406bc907a9 100644
@@ -253,6 +253,8 @@ snd-soc-rt286-y := rt286.o
 snd-soc-rt298-y := rt298.o
 snd-soc-rt5514-y := rt5514.o
 snd-soc-rt5514-spi-y := rt5514-spi.o
+snd-soc-rt5575-y := rt5575.o
+snd-soc-rt5575-$(CONFIG_SND_SOC_RT5575_SPI) += rt5575-spi.o
 snd-soc-rt5616-y := rt5616.o
 snd-soc-rt5631-y := rt5631.o
 snd-soc-rt5640-y := rt5640.o
@@ -686,6 +688,7 @@ obj-$(CONFIG_SND_SOC_RT298)	+= snd-soc-rt298.o
 obj-$(CONFIG_SND_SOC_RT5514)	+= snd-soc-rt5514.o
 obj-$(CONFIG_SND_SOC_RT5514_SPI)	+= snd-soc-rt5514-spi.o
 obj-$(CONFIG_SND_SOC_RT5514_SPI_BUILTIN)	+= snd-soc-rt5514-spi.o
+obj-$(CONFIG_SND_SOC_RT5575)	+= snd-soc-rt5575.o
 obj-$(CONFIG_SND_SOC_RT5616)	+= snd-soc-rt5616.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_RT5640)	+= snd-soc-rt5640.o
sound/soc/codecs/rt5575-spi.c new file +118 -0

118 lines not on this page · raw message

sound/soc/codecs/rt5575-spi.h new file +27 -0
new file mode 100644
index 000000000000..084638820b6f
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * rt5575-spi.h  --  ALC5575 SPI driver
+ *
+ * Copyright(c) 2025 Realtek Semiconductor Corp.
+ *
+ */
+
+#ifndef __RT5575_SPI_H__
+#define __RT5575_SPI_H__
+
+#if IS_ENABLED(CONFIG_SND_SOC_RT5575_SPI)
+struct spi_device *rt5575_spi_get_device(struct device *dev);
+int rt5575_spi_fw_load(struct spi_device *spi);
+#else
+static inline struct spi_device *rt5575_spi_get_device(struct device *dev)
+{
+	return NULL;
+}
+
+static inline int rt5575_spi_fw_load(struct spi_device *spi)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif /* __RT5575_SPI_H__ */
sound/soc/codecs/rt5575.c new file +352 -0

352 lines not on this page · raw message

sound/soc/codecs/rt5575.h new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.52.0
maintainer
#5 lore raw
In reply to Oder Chiou
Quoted 15 lines · Oder Chiou

This patch series adds support for the Realtek ALC5575 audio codec.

Changes in v11:
- Patch 1/4:
- minor fixes
- Patch 2/4:
- change of_find_spi_controller_by_node() gating to CONFIG_OF
- Patch 3/4:
- nothing
- Patch 4/4:
- achieve reverse-christmas-tree notation
- remove formal version check
- revise check whether the firmware boots from SPI or not
- minor fixes

Quoted 1 line

[...]

Applied to

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

Thanks!

[1/4] spi: export of_find_spi_controller_by_node()

      commit: ee69f55eb183efb43da14cdad72910b1b1cc2932
[2/4] spi: change of_find_spi_controller_by_node() gating to CONFIG_OF
      commit: 037f8d896688bf3384eb6bf34e24e8fbc9f6e02d
[3/4] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
      commit: af4c0b951b18a8af73fa8541fabf1bf2484bba9b
[4/4] ASoC: rt5575: Add the codec driver for the ALC5575
      commit: c7ac7499ac5bb50ab3e00add121822c5c904bc91

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

Reviewed-by
#6 lore raw
Quoted 21 lines · Mark Brown
Quoted 15 lines · Oder Chiou

This patch series adds support for the Realtek ALC5575 audio codec.

Changes in v11:
- Patch 1/4:
- minor fixes
- Patch 2/4:
- change of_find_spi_controller_by_node() gating to CONFIG_OF
- Patch 3/4:
- nothing
- Patch 4/4:
- achieve reverse-christmas-tree notation
- remove formal version check
- revise check whether the firmware boots from SPI or not
- minor fixes

Quoted 1 line

[...]

Applied to

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

...

Quoted 2 lines

[4/4] ASoC: rt5575: Add the codec driver for the ALC5575

       commit: c7ac7499ac5bb50ab3e00add121822c5c904bc91

Due to Christmas break I wasn't able to continue the review during that time, back at work today :) To be honest, I believe there are still some comments (not related to nitpicks) left uncovered. However, the code in v11 (more like v12) is still a large improvement when compared to v1. For that reason, if it is still feasible you can add my tag: