All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 0/2] ASoC: rt5575: Add the codec driver for the ALC5575
@ 2025-12-11 11:01 Oder Chiou
  2025-12-11 11:01 ` [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575 Oder Chiou
  2025-12-11 11:01 ` [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
  0 siblings, 2 replies; 10+ messages in thread
From: Oder Chiou @ 2025-12-11 11:01 UTC (permalink / raw)
  To: cezary.rojewski, broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: perex, linux-sound, devicetree, alsa-devel, flove, shumingf,
	jack.yu, derek.fang, Oder Chiou

Hi all,

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

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

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/20251201105926.1714341-1-oder_chiou@realtek.com/

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/20251121084112.743518-1-oder_chiou@realtek.com/

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/20251031073245.3629060-1-oder_chiou@realtek.com/

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/20251015103404.3075684-1-oder_chiou@realtek.com/

Oder Chiou (2):
  ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
  ASoC: rt5575: Add the codec driver for the ALC5575

 .../bindings/sound/realtek,rt5575.yaml        |  44 +++
 sound/soc/codecs/Kconfig                      |  10 +
 sound/soc/codecs/Makefile                     |   3 +
 sound/soc/codecs/rt5575-spi.c                 | 102 +++++
 sound/soc/codecs/rt5575-spi.h                 |  26 ++
 sound/soc/codecs/rt5575.c                     | 363 ++++++++++++++++++
 sound/soc/codecs/rt5575.h                     |  59 +++
 7 files changed, 607 insertions(+)
 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

-- 
2.52.0


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

* [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
  2025-12-11 11:01 [PATCH v9 0/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
@ 2025-12-11 11:01 ` Oder Chiou
  2025-12-11 15:38   ` Rob Herring
  2025-12-11 11:01 ` [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
  1 sibling, 1 reply; 10+ messages in thread
From: Oder Chiou @ 2025-12-11 11:01 UTC (permalink / raw)
  To: cezary.rojewski, broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: perex, linux-sound, devicetree, alsa-devel, flove, shumingf,
	jack.yu, derek.fang, Oder Chiou

Audio codec with I2S, I2C and SPI.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 .../bindings/sound/realtek,rt5575.yaml        | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/realtek,rt5575.yaml

diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
new file mode 100644
index 000000000000..60f9af399dd2
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
@@ -0,0 +1,44 @@
+# 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 <oder_chiou@realtek.com>
+
+description:
+  The device supports both I2C and SPI. I2C is mandatory, while SPI is
+  optional depending on the hardware configuration.
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rt5575
+      - realtek,rt5575-use-spi
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        codec@57 {
+            compatible = "realtek,rt5575";
+            reg = <0x57>;
+        };
+    };
-- 
2.52.0


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

* [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
  2025-12-11 11:01 [PATCH v9 0/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
  2025-12-11 11:01 ` [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575 Oder Chiou
@ 2025-12-11 11:01 ` Oder Chiou
  2025-12-12  1:31   ` kernel test robot
  2025-12-14 23:00   ` kernel test robot
  1 sibling, 2 replies; 10+ messages in thread
From: Oder Chiou @ 2025-12-11 11:01 UTC (permalink / raw)
  To: cezary.rojewski, broonie, lgirdwood, robh, krzk+dt, conor+dt
  Cc: perex, linux-sound, devicetree, alsa-devel, flove, shumingf,
	jack.yu, derek.fang, 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.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 sound/soc/codecs/Kconfig      |  10 +
 sound/soc/codecs/Makefile     |   3 +
 sound/soc/codecs/rt5575-spi.c | 102 ++++++++++
 sound/soc/codecs/rt5575-spi.h |  26 +++
 sound/soc/codecs/rt5575.c     | 363 ++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt5575.h     |  59 ++++++
 6 files changed, 563 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

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 061791e61907..4286e7c480d8 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -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
+	select SND_SOC_RT5575
+
 config SND_SOC_RT5616
 	tristate "Realtek RT5616 CODEC"
 	depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index d687d4f74363..a6406bc907a9 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -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
diff --git a/sound/soc/codecs/rt5575-spi.c b/sound/soc/codecs/rt5575-spi.c
new file mode 100644
index 000000000000..39879ee52366
--- /dev/null
+++ b/sound/soc/codecs/rt5575-spi.c
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * rt5575-spi.c  --  ALC5575 SPI driver
+ *
+ * Copyright(c) 2025 Realtek Semiconductor Corp.
+ *
+ */
+
+#include <linux/firmware.h>
+#include <linux/spi/spi.h>
+
+#include "rt5575-spi.h"
+
+#define RT5575_SPI_CMD_BURST_WRITE	5
+#define RT5575_SPI_BUF_LEN		240
+
+struct rt5575_spi_burst_write {
+	u8 cmd;
+	u32 addr;
+	u8 data[RT5575_SPI_BUF_LEN];
+	u8 dummy;
+} __packed;
+
+static int rt5575_spi_device_match(struct device *dev, const void *data)
+{
+	struct spi_device *spi = container_of(dev, struct spi_device, dev);
+
+	if (!strcmp("rt5575", spi->modalias))
+		return 1;
+
+	return 0;
+}
+
+struct spi_device *rt5575_spi_find_device(void)
+{
+	struct device *dev;
+
+	dev = bus_find_device(&spi_bus_type, NULL, NULL, rt5575_spi_device_match);
+	if (dev)
+		return container_of(dev, struct spi_device, dev);
+	else
+		return NULL;
+}
+
+/**
+ * rt5575_spi_burst_write - Write data to SPI by rt5575 address.
+ * @spi: SPI device.
+ * @addr: Start address.
+ * @txbuf: Data buffer for writing.
+ * @len: Data length.
+ *
+ */
+static int rt5575_spi_burst_write(struct spi_device *spi, u32 addr, const u8 *txbuf,
+						size_t len)
+{
+	struct rt5575_spi_burst_write buf = {
+		.cmd = RT5575_SPI_CMD_BURST_WRITE
+	};
+	unsigned int end, offset = 0;
+
+	while (offset < len) {
+		if (offset + RT5575_SPI_BUF_LEN <= len)
+			end = RT5575_SPI_BUF_LEN;
+		else
+			end = len % RT5575_SPI_BUF_LEN;
+
+		buf.addr = cpu_to_le32(addr + offset);
+		memcpy(&buf.data, &txbuf[offset], end);
+		spi_write(spi, &buf, sizeof(buf));
+
+		offset += RT5575_SPI_BUF_LEN;
+	}
+
+	return 0;
+}
+
+int rt5575_spi_fw_load(struct spi_device *spi)
+{
+	const struct firmware *firmware;
+	struct device *dev = &spi->dev;
+	static const char * const fw_path[] = {
+		"realtek/rt5575/rt5575_fw1.bin",
+		"realtek/rt5575/rt5575_fw2.bin",
+		"realtek/rt5575/rt5575_fw3.bin",
+		"realtek/rt5575/rt5575_fw4.bin"
+	};
+	static const u32 fw_addr[] = { 0x5f400000, 0x5f600000, 0x5f7fe000, 0x5f7ff000 };
+	int i, ret;
+
+	for (i = 0; i < ARRAY_SIZE(fw_addr); i++) {
+		ret = request_firmware(&firmware, fw_path[i], dev);
+		if (!ret) {
+			rt5575_spi_burst_write(spi, fw_addr[i], firmware->data, firmware->size);
+			release_firmware(firmware);
+		} else {
+			dev_err(dev, "Request firmware failure: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/codecs/rt5575-spi.h b/sound/soc/codecs/rt5575-spi.h
new file mode 100644
index 000000000000..08f793044865
--- /dev/null
+++ b/sound/soc/codecs/rt5575-spi.h
@@ -0,0 +1,26 @@
+/* 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_find_device(void);
+int rt5575_spi_fw_load(struct spi_device *spi);
+#else
+static inline struct spi_device *rt5575_spi_find_device(void)
+{
+	return NULL;
+}
+static inline int rt5575_spi_fw_load(struct spi_device *spi)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif /* __RT5575_SPI_H__ */
diff --git a/sound/soc/codecs/rt5575.c b/sound/soc/codecs/rt5575.c
new file mode 100644
index 000000000000..64bb3296e0a0
--- /dev/null
+++ b/sound/soc/codecs/rt5575.c
@@ -0,0 +1,363 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * rt5575.c  --  ALC5575 ALSA SoC audio component driver
+ *
+ * Copyright(c) 2025 Realtek Semiconductor Corp.
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/spi/spi.h>
+#include <sound/soc.h>
+#include <sound/tlv.h>
+
+#include "rt5575.h"
+#include "rt5575-spi.h"
+
+static bool rt5575_readable_register(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case RT5575_ID:
+	case RT5575_ID_1:
+	case RT5575_MIXL_VOL:
+	case RT5575_MIXR_VOL:
+	case RT5575_PROMPT_VOL:
+	case RT5575_SPK01_VOL:
+	case RT5575_SPK23_VOL:
+	case RT5575_MIC1_VOL:
+	case RT5575_MIC2_VOL:
+	case RT5575_WNC_CTRL:
+	case RT5575_MODE_CTRL:
+	case RT5575_I2S_RATE_CTRL:
+	case RT5575_SLEEP_CTRL:
+	case RT5575_ALG_BYPASS_CTRL:
+	case RT5575_PINMUX_CTRL_2:
+	case RT5575_GPIO_CTRL_1:
+	case RT5575_DSP_BUS_CTRL:
+	case RT5575_SW_INT:
+	case RT5575_DSP_BOOT_ERR:
+	case RT5575_DSP_READY:
+	case RT5575_DSP_CMD_ADDR:
+	case RT5575_EFUSE_DATA_2:
+	case RT5575_EFUSE_DATA_3:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static const DECLARE_TLV_DB_SCALE(ob_tlv, -9525, 75, 0);
+
+static const struct snd_kcontrol_new rt5575_snd_controls[] = {
+	SOC_DOUBLE("Speaker CH-01 Playback Switch", RT5575_SPK01_VOL, 31, 15, 1, 1),
+	SOC_DOUBLE_TLV("Speaker CH-01 Playback Volume", RT5575_SPK01_VOL, 17, 1, 167, 0, ob_tlv),
+	SOC_DOUBLE("Speaker CH-23 Playback Switch", RT5575_SPK23_VOL, 31, 15, 1, 1),
+	SOC_DOUBLE_TLV("Speaker CH-23 Playback Volume", RT5575_SPK23_VOL, 17, 1, 167, 0, ob_tlv),
+	SOC_DOUBLE("Mic1 Capture Switch", RT5575_MIC1_VOL, 31, 15, 1, 1),
+	SOC_DOUBLE_TLV("Mic1 Capture Volume", RT5575_MIC1_VOL, 17, 1, 167, 0, ob_tlv),
+	SOC_DOUBLE("Mic2 Capture Switch", RT5575_MIC2_VOL, 31, 15, 1, 1),
+	SOC_DOUBLE_TLV("Mic2 Capture Volume", RT5575_MIC2_VOL, 17, 1, 167, 0, ob_tlv),
+	SOC_DOUBLE_R("Mix Playback Switch", RT5575_MIXL_VOL, RT5575_MIXR_VOL, 31, 1, 1),
+	SOC_DOUBLE_R_TLV("Mix Playback Volume", RT5575_MIXL_VOL, RT5575_MIXR_VOL, 1, 127, 0,
+		ob_tlv),
+	SOC_DOUBLE("Prompt Playback Switch", RT5575_PROMPT_VOL, 31, 15, 1, 1),
+	SOC_DOUBLE_TLV("Prompt Playback Volume", RT5575_PROMPT_VOL, 17, 1, 167, 0, ob_tlv),
+};
+
+static const struct snd_soc_dapm_widget rt5575_dapm_widgets[] = {
+	SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0),
+
+	SND_SOC_DAPM_INPUT("INPUT"),
+	SND_SOC_DAPM_OUTPUT("OUTPUT"),
+};
+
+static const struct snd_soc_dapm_route rt5575_dapm_routes[] = {
+	{ "AIF1TX", NULL, "INPUT" },
+	{ "AIF2TX", NULL, "INPUT" },
+	{ "AIF3TX", NULL, "INPUT" },
+	{ "AIF4TX", NULL, "INPUT" },
+	{ "OUTPUT", NULL, "AIF1RX" },
+	{ "OUTPUT", NULL, "AIF2RX" },
+	{ "OUTPUT", NULL, "AIF3RX" },
+	{ "OUTPUT", NULL, "AIF4RX" },
+};
+
+static long long rt5575_get_priv_id(struct rt5575_priv *rt5575)
+{
+	int priv_id_low, priv_id_high;
+
+	regmap_write(rt5575->regmap, RT5575_EFUSE_PID, 0xa0000000);
+	regmap_read(rt5575->regmap, RT5575_EFUSE_DATA_2, &priv_id_low);
+	regmap_read(rt5575->regmap, RT5575_EFUSE_DATA_3, &priv_id_high);
+	regmap_write(rt5575->regmap, RT5575_EFUSE_PID, 0);
+
+	return ((long long)priv_id_high << 32) | (long long)priv_id_low;
+}
+
+static int rt5575_probe(struct snd_soc_component *component)
+{
+	struct rt5575_priv *rt5575 = snd_soc_component_get_drvdata(component);
+	struct device *dev = component->dev;
+
+	rt5575->component = component;
+
+	dev_info(dev, "Private ID: %llx\n", rt5575_get_priv_id(rt5575));
+
+	return 0;
+}
+
+#define RT5575_STEREO_RATES SNDRV_PCM_RATE_8000_192000
+#define RT5575_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
+			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8 | \
+			SNDRV_PCM_FMTBIT_S32_LE)
+
+static struct snd_soc_dai_driver rt5575_dai[] = {
+	{
+		.name = "rt5575-aif1",
+		.id = RT5575_AIF1,
+		.playback = {
+			.stream_name = "AIF1 Playback",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+		.capture = {
+			.stream_name = "AIF1 Capture",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+	},
+	{
+		.name = "rt5575-aif2",
+		.id = RT5575_AIF2,
+		.playback = {
+			.stream_name = "AIF2 Playback",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+		.capture = {
+			.stream_name = "AIF2 Capture",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+	},
+	{
+		.name = "rt5575-aif3",
+		.id = RT5575_AIF3,
+		.playback = {
+			.stream_name = "AIF3 Playback",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+		.capture = {
+			.stream_name = "AIF3 Capture",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+	},
+	{
+		.name = "rt5575-aif4",
+		.id = RT5575_AIF4,
+		.playback = {
+			.stream_name = "AIF4 Playback",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+		.capture = {
+			.stream_name = "AIF4 Capture",
+			.channels_min = 1,
+			.channels_max = 8,
+			.rates = RT5575_STEREO_RATES,
+			.formats = RT5575_FORMATS,
+		},
+	},
+};
+
+static const struct snd_soc_component_driver rt5575_soc_component_dev = {
+	.probe = rt5575_probe,
+	.controls = rt5575_snd_controls,
+	.num_controls = ARRAY_SIZE(rt5575_snd_controls),
+	.dapm_widgets = rt5575_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(rt5575_dapm_widgets),
+	.dapm_routes = rt5575_dapm_routes,
+	.num_dapm_routes = ARRAY_SIZE(rt5575_dapm_routes),
+	.use_pmdown_time = 1,
+	.endianness = 1,
+};
+
+static const struct regmap_config rt5575_dsp_regmap = {
+	.name = "dsp",
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 2,
+};
+
+static int rt5575_i2c_read(void *context, unsigned int reg, unsigned int *val)
+{
+	struct i2c_client *client = context;
+	struct rt5575_priv *rt5575 = i2c_get_clientdata(client);
+
+	regmap_read(rt5575->dsp_regmap, reg | RT5575_DSP_MAPPING, val);
+
+	return 0;
+}
+
+static int rt5575_i2c_write(void *context, unsigned int reg, unsigned int val)
+{
+	struct i2c_client *client = context;
+	struct rt5575_priv *rt5575 = i2c_get_clientdata(client);
+
+	regmap_write(rt5575->dsp_regmap, reg | RT5575_DSP_MAPPING, val);
+
+	return 0;
+}
+
+static const struct regmap_config rt5575_regmap = {
+	.reg_bits = 16,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.max_register = 0xfffc,
+	.readable_reg = rt5575_readable_register,
+	.reg_read = rt5575_i2c_read,
+	.reg_write = rt5575_i2c_write,
+	.use_single_read = true,
+	.use_single_write = true,
+};
+
+static int rt5575_fw_load_by_spi(struct rt5575_priv *rt5575)
+{
+	struct i2c_client *i2c = rt5575->i2c;
+	struct spi_device *spi;
+	struct device *dev = &i2c->dev;
+	int ret;
+
+	spi = rt5575_spi_find_device();
+	if (!spi) {
+		dev_err(dev, "Get SPI device failure: %d\n", ret);
+		return -ENODEV;
+	}
+
+	regmap_write(rt5575->dsp_regmap, 0xfafafafa, 0x00000004);
+	regmap_write(rt5575->dsp_regmap, 0x18008064, 0x00000000);
+	regmap_write(rt5575->dsp_regmap, 0x18008068, 0x0002ffff);
+
+	ret = rt5575_spi_fw_load(spi);
+	if (ret) {
+		dev_err(dev, "Load firmware failure: %d\n", ret);
+		return -ENODEV;
+	}
+
+	regmap_write(rt5575->dsp_regmap, 0x18000000, 0x00000000);
+	regmap_update_bits(rt5575->regmap, RT5575_SW_INT, 1, 1);
+
+	regmap_read_poll_timeout(rt5575->regmap, RT5575_SW_INT, ret, !ret, 100000, 10000000);
+	if (ret) {
+		dev_err(dev, "Run firmware failure: %d\n", ret);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int rt5575_i2c_probe(struct i2c_client *i2c)
+{
+	struct rt5575_priv *rt5575;
+	struct device *dev = &i2c->dev;
+	int dev_type = (uintptr_t)i2c_get_match_data(i2c);
+	int ret, val;
+
+	rt5575 = devm_kzalloc(dev, sizeof(struct rt5575_priv), GFP_KERNEL);
+	if (!rt5575)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, rt5575);
+
+	rt5575->i2c = i2c;
+
+	rt5575->dsp_regmap = devm_regmap_init_i2c(i2c, &rt5575_dsp_regmap);
+	if (IS_ERR(rt5575->dsp_regmap)) {
+		ret = PTR_ERR(rt5575->dsp_regmap);
+		dev_err(dev, "Failed to allocate DSP register map: %d\n", ret);
+		return ret;
+	}
+
+	rt5575->regmap = devm_regmap_init(dev, NULL, i2c, &rt5575_regmap);
+	if (IS_ERR(rt5575->regmap)) {
+		ret = PTR_ERR(rt5575->regmap);
+		dev_err(dev, "Failed to allocate register map: %d\n", ret);
+		return ret;
+	}
+
+	regmap_read(rt5575->regmap, RT5575_ID, &val);
+	if (val != RT5575_DEVICE_ID) {
+		dev_err(dev, "Device with ID register %08x is not rt5575\n", val);
+		return -ENODEV;
+	}
+
+	regmap_read(rt5575->regmap, RT5575_ID_1, &val);
+	if (!val) {
+		dev_err(dev, "This is not formal version\n");
+		return -ENODEV;
+	}
+
+	if (dev_type == RT5575_WITHOUT_FLASH) {
+		if (IS_ENABLED(CONFIG_SND_SOC_RT5575_SPI)) {
+			if (rt5575_fw_load_by_spi(rt5575))
+				return -ENODEV;
+		} else {
+			dev_err(dev, "This dev type should enable CONFIG_SND_SOC_RT5575_SPI\n");
+			return -ENODEV;
+		}
+	}
+
+	return devm_snd_soc_register_component(dev, &rt5575_soc_component_dev, rt5575_dai,
+						ARRAY_SIZE(rt5575_dai));
+}
+
+static const struct i2c_device_id rt5575_i2c_id[] = {
+	{ "rt5575" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, rt5575_i2c_id);
+
+static const struct of_device_id rt5575_of_match[] = {
+	{ .compatible = "realtek,rt5575", .data = (void *)RT5575_WITH_FLASH },
+	{ .compatible = "realtek,rt5575-use-spi", .data = (void *)RT5575_WITHOUT_FLASH },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rt5575_of_match);
+
+static struct i2c_driver rt5575_i2c_driver = {
+	.driver = {
+		.name = "rt5575",
+		.owner = THIS_MODULE,
+		.of_match_table = rt5575_of_match,
+	},
+	.probe = rt5575_i2c_probe,
+	.id_table = rt5575_i2c_id,
+};
+module_i2c_driver(rt5575_i2c_driver);
+
+MODULE_DESCRIPTION("ASoC ALC5575 driver");
+MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/rt5575.h b/sound/soc/codecs/rt5575.h
new file mode 100644
index 000000000000..6e19050f0b09
--- /dev/null
+++ b/sound/soc/codecs/rt5575.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * rt5575.h  --  ALC5575 ALSA SoC audio driver
+ *
+ * Copyright(c) 2025 Realtek Semiconductor Corp.
+ *
+ */
+
+#ifndef __RT5575_H__
+#define __RT5575_H__
+
+#define RT5575_DEVICE_ID	0x10ec5575
+#define RT5575_DSP_MAPPING	0x18000000
+
+#define RT5575_ID		0x8008
+#define RT5575_ID_1		0x800c
+#define RT5575_MIXL_VOL		0x8a14
+#define RT5575_MIXR_VOL		0x8a18
+#define RT5575_PROMPT_VOL	0x8a84
+#define RT5575_SPK01_VOL	0x8a88
+#define RT5575_SPK23_VOL	0x8a8c
+#define RT5575_MIC1_VOL		0x8a98
+#define RT5575_MIC2_VOL		0x8a9c
+#define RT5575_WNC_CTRL		0x80ec
+#define RT5575_MODE_CTRL	0x80f0
+#define RT5575_I2S_RATE_CTRL	0x80f4
+#define RT5575_SLEEP_CTRL	0x80f8
+#define RT5575_ALG_BYPASS_CTRL	0x80fc
+#define RT5575_PINMUX_CTRL_2	0x81a4
+#define RT5575_GPIO_CTRL_1	0x8208
+#define RT5575_DSP_BUS_CTRL	0x880c
+#define RT5575_SW_INT		0x0018
+#define RT5575_DSP_BOOT_ERR	0x8e14
+#define RT5575_DSP_READY	0x8e24
+#define RT5575_DSP_CMD_ADDR	0x8e28
+#define RT5575_EFUSE_DATA_2	0xc638
+#define RT5575_EFUSE_DATA_3	0xc63c
+#define RT5575_EFUSE_PID	0xc660
+
+enum {
+	RT5575_AIF1,
+	RT5575_AIF2,
+	RT5575_AIF3,
+	RT5575_AIF4,
+	RT5575_AIFS,
+};
+
+enum {
+	RT5575_WITH_FLASH,
+	RT5575_WITHOUT_FLASH,
+};
+
+struct rt5575_priv {
+	struct i2c_client *i2c;
+	struct snd_soc_component *component;
+	struct regmap *dsp_regmap, *regmap;
+};
+
+#endif /* __RT5575_H__ */
-- 
2.52.0


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

* Re: [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
  2025-12-11 11:01 ` [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575 Oder Chiou
@ 2025-12-11 15:38   ` Rob Herring
  2025-12-12  8:59     ` Oder Chiou
  0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2025-12-11 15:38 UTC (permalink / raw)
  To: Oder Chiou
  Cc: cezary.rojewski, broonie, lgirdwood, krzk+dt, conor+dt, perex,
	linux-sound, devicetree, alsa-devel, flove, shumingf, jack.yu,
	derek.fang

On Thu, Dec 11, 2025 at 07:01:29PM +0800, Oder Chiou wrote:
> Audio codec with I2S, I2C and SPI.
> 
> Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
> ---
>  .../bindings/sound/realtek,rt5575.yaml        | 44 +++++++++++++++++++
>  1 file changed, 44 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> 
> diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> new file mode 100644
> index 000000000000..60f9af399dd2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> @@ -0,0 +1,44 @@
> +# 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 <oder_chiou@realtek.com>
> +
> +description:
> +  The device supports both I2C and SPI. I2C is mandatory, while SPI is
> +  optional depending on the hardware configuration.
> +
> +allOf:
> +  - $ref: /schemas/spi/spi-peripheral-props.yaml#
> +  - $ref: dai-common.yaml#
> +
> +properties:
> +  compatible:
> +    enum:
> +      - realtek,rt5575
> +      - realtek,rt5575-use-spi
> +
> +  reg:
> +    maxItems: 1
> +
> +required:
> +  - compatible
> +  - reg
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +        codec@57 {
> +            compatible = "realtek,rt5575";
> +            reg = <0x57>;
> +        };
> +    };

It is completely unclear what you are doing in the SPI case. I 
deciphered it studying the driver. I shouldn't have to do that, your 
binding should make that clear. 

So your DT must look like this:

i2c {
	codec@57 {
		compatible = "realtek,rt5575-use-spi";
		reg = <0x57>;
	};
};

spi {
	codec@1 {
		compatible = "realtek,rt5575";
		reg = <0x1>;
	};
};

First, there's no need for "-use-spi" because you can just check if 
there is a rt5575 SPI device and use it if there is. Why would you have 
the SPI device and not use it?

But really it is not ideal having 2 device nodes for a single device. It 
would be much simpler to just have something like this in the i2c node:

spi-parent = <&spi0 1>;

Where the cell is the chip-select #.

We have an 'i2c-parent' already for similar reasons when there are 2 
bus connections.

Rob

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

* Re: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
  2025-12-11 11:01 ` [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
@ 2025-12-12  1:31   ` kernel test robot
  2025-12-14 23:00   ` kernel test robot
  1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-12-12  1:31 UTC (permalink / raw)
  To: Oder Chiou; +Cc: llvm, oe-kbuild-all

Hi Oder,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.18 next-20251211]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Oder-Chiou/ASoC-dt-bindings-realtek-rt5575-add-support-for-ALC5575/20251211-190355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20251211110130.2925541-3-oder_chiou%40realtek.com
patch subject: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20251212/202512120943.V0TRmEDs-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251212/202512120943.V0TRmEDs-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512120943.V0TRmEDs-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/rt5575.c:256:48: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
     256 |                 dev_err(dev, "Get SPI device failure: %d\n", ret);
         |                                                              ^~~
   include/linux/dev_printk.h:154:65: note: expanded from macro 'dev_err'
     154 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                                        ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                                     ^~~~~~~~~~~
   sound/soc/codecs/rt5575.c:252:9: note: initialize the variable 'ret' to silence this warning
     252 |         int ret;
         |                ^
         |                 = 0
   1 warning generated.


vim +/ret +256 sound/soc/codecs/rt5575.c

   246	
   247	static int rt5575_fw_load_by_spi(struct rt5575_priv *rt5575)
   248	{
   249		struct i2c_client *i2c = rt5575->i2c;
   250		struct spi_device *spi;
   251		struct device *dev = &i2c->dev;
   252		int ret;
   253	
   254		spi = rt5575_spi_find_device();
   255		if (!spi) {
 > 256			dev_err(dev, "Get SPI device failure: %d\n", ret);
   257			return -ENODEV;
   258		}
   259	
   260		regmap_write(rt5575->dsp_regmap, 0xfafafafa, 0x00000004);
   261		regmap_write(rt5575->dsp_regmap, 0x18008064, 0x00000000);
   262		regmap_write(rt5575->dsp_regmap, 0x18008068, 0x0002ffff);
   263	
   264		ret = rt5575_spi_fw_load(spi);
   265		if (ret) {
   266			dev_err(dev, "Load firmware failure: %d\n", ret);
   267			return -ENODEV;
   268		}
   269	
   270		regmap_write(rt5575->dsp_regmap, 0x18000000, 0x00000000);
   271		regmap_update_bits(rt5575->regmap, RT5575_SW_INT, 1, 1);
   272	
   273		regmap_read_poll_timeout(rt5575->regmap, RT5575_SW_INT, ret, !ret, 100000, 10000000);
   274		if (ret) {
   275			dev_err(dev, "Run firmware failure: %d\n", ret);
   276			return -ENODEV;
   277		}
   278	
   279		return 0;
   280	}
   281	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* RE: [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
  2025-12-11 15:38   ` Rob Herring
@ 2025-12-12  8:59     ` Oder Chiou
  2025-12-12 13:09       ` Rob Herring
  0 siblings, 1 reply; 10+ messages in thread
From: Oder Chiou @ 2025-12-12  8:59 UTC (permalink / raw)
  To: 'Rob Herring'
  Cc: cezary.rojewski@intel.com, broonie@kernel.org,
	lgirdwood@gmail.com, krzk+dt@kernel.org, conor+dt@kernel.org,
	perex@perex.cz, linux-sound@vger.kernel.org,
	devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Flove(HsinFu), Shuming [范書銘], Jack Yu,
	Derek [方德義]

> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Thursday, December 11, 2025 11:39 PM
> To: Oder Chiou <oder_chiou@realtek.com>
> Cc: cezary.rojewski@intel.com; broonie@kernel.org; lgirdwood@gmail.com;
> krzk+dt@kernel.org; conor+dt@kernel.org; perex@perex.cz;
> linux-sound@vger.kernel.org; devicetree@vger.kernel.org;
> alsa-devel@alsa-project.org; Flove(HsinFu) <flove@realtek.com>; Shuming [范
> 書銘] <shumingf@realtek.com>; Jack Yu <jack.yu@realtek.com>; Derek [方德
> 義] <derek.fang@realtek.com>
> Subject: Re: [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for
> ALC5575
> 
> 
> External mail : This email originated from outside the organization. Do not
> reply, click links, or open attachments unless you recognize the sender and
> know the content is safe.
> 
> 
> 
> On Thu, Dec 11, 2025 at 07:01:29PM +0800, Oder Chiou wrote:
> > Audio codec with I2S, I2C and SPI.
> >
> > Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
> > ---
> >  .../bindings/sound/realtek,rt5575.yaml        | 44
> +++++++++++++++++++
> >  1 file changed, 44 insertions(+)
> >  create mode 100644
> Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> > new file mode 100644
> > index 000000000000..60f9af399dd2
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> > @@ -0,0 +1,44 @@
> > +# 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 <oder_chiou@realtek.com>
> > +
> > +description:
> > +  The device supports both I2C and SPI. I2C is mandatory, while SPI is
> > +  optional depending on the hardware configuration.
> > +
> > +allOf:
> > +  - $ref: /schemas/spi/spi-peripheral-props.yaml#
> > +  - $ref: dai-common.yaml#
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - realtek,rt5575
> > +      - realtek,rt5575-use-spi
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    i2c {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +        codec@57 {
> > +            compatible = "realtek,rt5575";
> > +            reg = <0x57>;
> > +        };
> > +    };
> 
> It is completely unclear what you are doing in the SPI case. I
> deciphered it studying the driver. I shouldn't have to do that, your
> binding should make that clear.
> 
> So your DT must look like this:
> 
> i2c {
>         codec@57 {
>                 compatible = "realtek,rt5575-use-spi";
>                 reg = <0x57>;
>         };
> };
> 
> spi {
>         codec@1 {
>                 compatible = "realtek,rt5575";
>                 reg = <0x1>;
>         };
> };
> 
> First, there's no need for "-use-spi" because you can just check if
> there is a rt5575 SPI device and use it if there is. Why would you have
> the SPI device and not use it?

The compatible realtek,rt5575-use-spi will be removed, and if there is no
SPI device in the DTS, the warning message will be shown as "The hardware
configuration should be with built-in flash".

> But really it is not ideal having 2 device nodes for a single device. It
> would be much simpler to just have something like this in the i2c node:
> 
> spi-parent = <&spi0 1>;
> 
> Where the cell is the chip-select #.
> 
> We have an 'i2c-parent' already for similar reasons when there are 2
> bus connections.

In the current kernel, I cannot find any function to obtain a
struct spi_controller when no SPI device is defined in the DTS. This was
possible in older kernels using the legacy spi_busnum_to_master(), but
that function is no longer available in upstream.

Thanks,
Oder

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

* Re: [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575
  2025-12-12  8:59     ` Oder Chiou
@ 2025-12-12 13:09       ` Rob Herring
  0 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2025-12-12 13:09 UTC (permalink / raw)
  To: Oder Chiou
  Cc: cezary.rojewski@intel.com, broonie@kernel.org,
	lgirdwood@gmail.com, krzk+dt@kernel.org, conor+dt@kernel.org,
	perex@perex.cz, linux-sound@vger.kernel.org,
	devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Flove(HsinFu), Shuming [范書銘], Jack Yu,
	Derek [方德義]

On Fri, Dec 12, 2025 at 2:59 AM Oder Chiou <oder_chiou@realtek.com> wrote:
>
> > -----Original Message-----
> > From: Rob Herring <robh@kernel.org>
> > Sent: Thursday, December 11, 2025 11:39 PM
> > To: Oder Chiou <oder_chiou@realtek.com>
> > Cc: cezary.rojewski@intel.com; broonie@kernel.org; lgirdwood@gmail.com;
> > krzk+dt@kernel.org; conor+dt@kernel.org; perex@perex.cz;
> > linux-sound@vger.kernel.org; devicetree@vger.kernel.org;
> > alsa-devel@alsa-project.org; Flove(HsinFu) <flove@realtek.com>; Shuming [范
> > 書銘] <shumingf@realtek.com>; Jack Yu <jack.yu@realtek.com>; Derek [方德
> > 義] <derek.fang@realtek.com>
> > Subject: Re: [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for
> > ALC5575
> >
> >
> > External mail : This email originated from outside the organization. Do not
> > reply, click links, or open attachments unless you recognize the sender and
> > know the content is safe.
> >
> >
> >
> > On Thu, Dec 11, 2025 at 07:01:29PM +0800, Oder Chiou wrote:
> > > Audio codec with I2S, I2C and SPI.
> > >
> > > Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
> > > ---
> > >  .../bindings/sound/realtek,rt5575.yaml        | 44
> > +++++++++++++++++++
> > >  1 file changed, 44 insertions(+)
> > >  create mode 100644
> > Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> > >
> > > diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> > b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> > > new file mode 100644
> > > index 000000000000..60f9af399dd2
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/sound/realtek,rt5575.yaml
> > > @@ -0,0 +1,44 @@
> > > +# 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 <oder_chiou@realtek.com>
> > > +
> > > +description:
> > > +  The device supports both I2C and SPI. I2C is mandatory, while SPI is
> > > +  optional depending on the hardware configuration.
> > > +
> > > +allOf:
> > > +  - $ref: /schemas/spi/spi-peripheral-props.yaml#
> > > +  - $ref: dai-common.yaml#
> > > +
> > > +properties:
> > > +  compatible:
> > > +    enum:
> > > +      - realtek,rt5575
> > > +      - realtek,rt5575-use-spi
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +
> > > +unevaluatedProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +    i2c {
> > > +        #address-cells = <1>;
> > > +        #size-cells = <0>;
> > > +        codec@57 {
> > > +            compatible = "realtek,rt5575";
> > > +            reg = <0x57>;
> > > +        };
> > > +    };
> >
> > It is completely unclear what you are doing in the SPI case. I
> > deciphered it studying the driver. I shouldn't have to do that, your
> > binding should make that clear.
> >
> > So your DT must look like this:
> >
> > i2c {
> >         codec@57 {
> >                 compatible = "realtek,rt5575-use-spi";
> >                 reg = <0x57>;
> >         };
> > };
> >
> > spi {
> >         codec@1 {
> >                 compatible = "realtek,rt5575";
> >                 reg = <0x1>;
> >         };
> > };
> >
> > First, there's no need for "-use-spi" because you can just check if
> > there is a rt5575 SPI device and use it if there is. Why would you have
> > the SPI device and not use it?
>
> The compatible realtek,rt5575-use-spi will be removed, and if there is no
> SPI device in the DTS, the warning message will be shown as "The hardware
> configuration should be with built-in flash".
>
> > But really it is not ideal having 2 device nodes for a single device. It
> > would be much simpler to just have something like this in the i2c node:
> >
> > spi-parent = <&spi0 1>;
> >
> > Where the cell is the chip-select #.
> >
> > We have an 'i2c-parent' already for similar reasons when there are 2
> > bus connections.
>
> In the current kernel, I cannot find any function to obtain a
> struct spi_controller when no SPI device is defined in the DTS. This was
> possible in older kernels using the legacy spi_busnum_to_master(), but
> that function is no longer available in upstream.

Yeah, you may have to add something given 'spi-parent' doesn't exist
yet. I don't think spi_busnum_to_master() would be quite right either.
In any case, what the kernel supports or doesn't support doesn't
matter from a binding perspective.

Rob

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

* Re: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
@ 2025-12-17 16:06 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-12-14  2:11 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251211110130.2925541-3-oder_chiou@realtek.com>
References: <20251211110130.2925541-3-oder_chiou@realtek.com>
TO: Oder Chiou <oder_chiou@realtek.com>

Hi Oder,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.18 next-20251212]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Oder-Chiou/ASoC-dt-bindings-realtek-rt5575-add-support-for-ALC5575/20251211-190355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20251211110130.2925541-3-oder_chiou%40realtek.com
patch subject: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: parisc-randconfig-r072-20251214 (https://download.01.org/0day-ci/archive/20251214/202512140909.a0ok9gVy-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.3.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202512140909.a0ok9gVy-lkp@intel.com/

smatch warnings:
sound/soc/codecs/rt5575.c:256 rt5575_fw_load_by_spi() error: uninitialized symbol 'ret'.

vim +/ret +256 sound/soc/codecs/rt5575.c

56f073d89eb8e0 Oder Chiou 2025-12-11  246  
56f073d89eb8e0 Oder Chiou 2025-12-11  247  static int rt5575_fw_load_by_spi(struct rt5575_priv *rt5575)
56f073d89eb8e0 Oder Chiou 2025-12-11  248  {
56f073d89eb8e0 Oder Chiou 2025-12-11  249  	struct i2c_client *i2c = rt5575->i2c;
56f073d89eb8e0 Oder Chiou 2025-12-11  250  	struct spi_device *spi;
56f073d89eb8e0 Oder Chiou 2025-12-11  251  	struct device *dev = &i2c->dev;
56f073d89eb8e0 Oder Chiou 2025-12-11  252  	int ret;
56f073d89eb8e0 Oder Chiou 2025-12-11  253  
56f073d89eb8e0 Oder Chiou 2025-12-11  254  	spi = rt5575_spi_find_device();
56f073d89eb8e0 Oder Chiou 2025-12-11  255  	if (!spi) {
56f073d89eb8e0 Oder Chiou 2025-12-11 @256  		dev_err(dev, "Get SPI device failure: %d\n", ret);
56f073d89eb8e0 Oder Chiou 2025-12-11  257  		return -ENODEV;
56f073d89eb8e0 Oder Chiou 2025-12-11  258  	}
56f073d89eb8e0 Oder Chiou 2025-12-11  259  
56f073d89eb8e0 Oder Chiou 2025-12-11  260  	regmap_write(rt5575->dsp_regmap, 0xfafafafa, 0x00000004);
56f073d89eb8e0 Oder Chiou 2025-12-11  261  	regmap_write(rt5575->dsp_regmap, 0x18008064, 0x00000000);
56f073d89eb8e0 Oder Chiou 2025-12-11  262  	regmap_write(rt5575->dsp_regmap, 0x18008068, 0x0002ffff);
56f073d89eb8e0 Oder Chiou 2025-12-11  263  
56f073d89eb8e0 Oder Chiou 2025-12-11  264  	ret = rt5575_spi_fw_load(spi);
56f073d89eb8e0 Oder Chiou 2025-12-11  265  	if (ret) {
56f073d89eb8e0 Oder Chiou 2025-12-11  266  		dev_err(dev, "Load firmware failure: %d\n", ret);
56f073d89eb8e0 Oder Chiou 2025-12-11  267  		return -ENODEV;
56f073d89eb8e0 Oder Chiou 2025-12-11  268  	}
56f073d89eb8e0 Oder Chiou 2025-12-11  269  
56f073d89eb8e0 Oder Chiou 2025-12-11  270  	regmap_write(rt5575->dsp_regmap, 0x18000000, 0x00000000);
56f073d89eb8e0 Oder Chiou 2025-12-11  271  	regmap_update_bits(rt5575->regmap, RT5575_SW_INT, 1, 1);
56f073d89eb8e0 Oder Chiou 2025-12-11  272  
56f073d89eb8e0 Oder Chiou 2025-12-11  273  	regmap_read_poll_timeout(rt5575->regmap, RT5575_SW_INT, ret, !ret, 100000, 10000000);
56f073d89eb8e0 Oder Chiou 2025-12-11  274  	if (ret) {
56f073d89eb8e0 Oder Chiou 2025-12-11  275  		dev_err(dev, "Run firmware failure: %d\n", ret);
56f073d89eb8e0 Oder Chiou 2025-12-11  276  		return -ENODEV;
56f073d89eb8e0 Oder Chiou 2025-12-11  277  	}
56f073d89eb8e0 Oder Chiou 2025-12-11  278  
56f073d89eb8e0 Oder Chiou 2025-12-11  279  	return 0;
56f073d89eb8e0 Oder Chiou 2025-12-11  280  }
56f073d89eb8e0 Oder Chiou 2025-12-11  281  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
  2025-12-11 11:01 ` [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
  2025-12-12  1:31   ` kernel test robot
@ 2025-12-14 23:00   ` kernel test robot
  1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-12-14 23:00 UTC (permalink / raw)
  To: Oder Chiou; +Cc: Paul Gazzillo, Necip Fazil Yildiran, oe-kbuild-all

Hi Oder,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.16-rc1 next-20251212]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Oder-Chiou/ASoC-dt-bindings-realtek-rt5575-add-support-for-ALC5575/20251211-190355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20251211110130.2925541-3-oder_chiou%40realtek.com
patch subject: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
config: arc-kismet-CONFIG_SND_SOC_RT5575-CONFIG_SND_SOC_RT5575_SPI-0-0 (https://download.01.org/0day-ci/archive/20251215/202512150010.v3tY6v3H-lkp@intel.com/config)
reproduce: (https://download.01.org/0day-ci/archive/20251215/202512150010.v3tY6v3H-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512150010.v3tY6v3H-lkp@intel.com/

kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for SND_SOC_RT5575 when selected by SND_SOC_RT5575_SPI
   WARNING: unmet direct dependencies detected for SND_SOC_RT5575
     Depends on [n]: SOUND [=y] && SND [=y] && SND_SOC [=y] && I2C [=n]
     Selected by [y]:
     - SND_SOC_RT5575_SPI [=y] && SOUND [=y] && SND [=y] && SND_SOC [=y] && SPI_MASTER [=y]

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
@ 2025-12-17 16:06 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2025-12-17 16:06 UTC (permalink / raw)
  To: oe-kbuild, Oder Chiou; +Cc: lkp, oe-kbuild-all

Hi Oder,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Oder-Chiou/ASoC-dt-bindings-realtek-rt5575-add-support-for-ALC5575/20251211-190355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20251211110130.2925541-3-oder_chiou%40realtek.com
patch subject: [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575
config: parisc-randconfig-r072-20251214 (https://download.01.org/0day-ci/archive/20251214/202512140909.a0ok9gVy-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.3.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202512140909.a0ok9gVy-lkp@intel.com/

smatch warnings:
sound/soc/codecs/rt5575.c:256 rt5575_fw_load_by_spi() error: uninitialized symbol 'ret'.

vim +/ret +256 sound/soc/codecs/rt5575.c

56f073d89eb8e0 Oder Chiou 2025-12-11  247  static int rt5575_fw_load_by_spi(struct rt5575_priv *rt5575)
56f073d89eb8e0 Oder Chiou 2025-12-11  248  {
56f073d89eb8e0 Oder Chiou 2025-12-11  249  	struct i2c_client *i2c = rt5575->i2c;
56f073d89eb8e0 Oder Chiou 2025-12-11  250  	struct spi_device *spi;
56f073d89eb8e0 Oder Chiou 2025-12-11  251  	struct device *dev = &i2c->dev;
56f073d89eb8e0 Oder Chiou 2025-12-11  252  	int ret;
56f073d89eb8e0 Oder Chiou 2025-12-11  253  
56f073d89eb8e0 Oder Chiou 2025-12-11  254  	spi = rt5575_spi_find_device();
56f073d89eb8e0 Oder Chiou 2025-12-11  255  	if (!spi) {
56f073d89eb8e0 Oder Chiou 2025-12-11 @256  		dev_err(dev, "Get SPI device failure: %d\n", ret);
                                                                                                     ^^^
ret isn't initialized.

56f073d89eb8e0 Oder Chiou 2025-12-11  257  		return -ENODEV;
56f073d89eb8e0 Oder Chiou 2025-12-11  258  	}
56f073d89eb8e0 Oder Chiou 2025-12-11  259  
56f073d89eb8e0 Oder Chiou 2025-12-11  260  	regmap_write(rt5575->dsp_regmap, 0xfafafafa, 0x00000004);
56f073d89eb8e0 Oder Chiou 2025-12-11  261  	regmap_write(rt5575->dsp_regmap, 0x18008064, 0x00000000);
56f073d89eb8e0 Oder Chiou 2025-12-11  262  	regmap_write(rt5575->dsp_regmap, 0x18008068, 0x0002ffff);
56f073d89eb8e0 Oder Chiou 2025-12-11  263  
56f073d89eb8e0 Oder Chiou 2025-12-11  264  	ret = rt5575_spi_fw_load(spi);
56f073d89eb8e0 Oder Chiou 2025-12-11  265  	if (ret) {
56f073d89eb8e0 Oder Chiou 2025-12-11  266  		dev_err(dev, "Load firmware failure: %d\n", ret);
56f073d89eb8e0 Oder Chiou 2025-12-11  267  		return -ENODEV;

s/-ENODEV/ret/

56f073d89eb8e0 Oder Chiou 2025-12-11  268  	}
56f073d89eb8e0 Oder Chiou 2025-12-11  269  
56f073d89eb8e0 Oder Chiou 2025-12-11  270  	regmap_write(rt5575->dsp_regmap, 0x18000000, 0x00000000);
56f073d89eb8e0 Oder Chiou 2025-12-11  271  	regmap_update_bits(rt5575->regmap, RT5575_SW_INT, 1, 1);
56f073d89eb8e0 Oder Chiou 2025-12-11  272  
56f073d89eb8e0 Oder Chiou 2025-12-11  273  	regmap_read_poll_timeout(rt5575->regmap, RT5575_SW_INT, ret, !ret, 100000, 10000000);
56f073d89eb8e0 Oder Chiou 2025-12-11  274  	if (ret) {
56f073d89eb8e0 Oder Chiou 2025-12-11  275  		dev_err(dev, "Run firmware failure: %d\n", ret);
56f073d89eb8e0 Oder Chiou 2025-12-11  276  		return -ENODEV;
56f073d89eb8e0 Oder Chiou 2025-12-11  277  	}
56f073d89eb8e0 Oder Chiou 2025-12-11  278  
56f073d89eb8e0 Oder Chiou 2025-12-11  279  	return 0;
56f073d89eb8e0 Oder Chiou 2025-12-11  280  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


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

end of thread, other threads:[~2025-12-17 16:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 11:01 [PATCH v9 0/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
2025-12-11 11:01 ` [PATCH v9 1/2] ASoC: dt-bindings: realtek,rt5575: add support for ALC5575 Oder Chiou
2025-12-11 15:38   ` Rob Herring
2025-12-12  8:59     ` Oder Chiou
2025-12-12 13:09       ` Rob Herring
2025-12-11 11:01 ` [PATCH v9 2/2] ASoC: rt5575: Add the codec driver for the ALC5575 Oder Chiou
2025-12-12  1:31   ` kernel test robot
2025-12-14 23:00   ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2025-12-14  2:11 kernel test robot
2025-12-17 16:06 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.