Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ASoC: add Senary SN622x SDCA SoundWire support
@ 2026-12-01  2:56 Qianghua Wang
  2026-12-01  2:56 ` [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support Qianghua Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Qianghua Wang @ 2026-12-01  2:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-sound, alsa-devel, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Cezary Rojewski, Peter Ujfalusi, Kai Vehmanen,
	Pierre-Louis Bossart, bo liu, Qianghua Wang

Resend of the SN622x series (same 3-patch split: codec, sdw_utils, ACPI).

The SN6220/SN6224 codec driver is trimmed and aligned with the in-tree
SN624x SDCA pattern: PDE via sdca_asoc/DAPM, no debug mixer controls or
hw_params attach polling, DisCo function init tables with a small OEM
fallback, and devm_regmap_init_sdw_mbq_cfg().  Speaker + DMIC only; no
codec jack detect (board HP mux unchanged).

Patches 2–3 are unchanged in scope from v1 (machine/DAPM hooks and
Panther Lake / Nova Lake ACPI entries).

Build-tested: x86_64, make M=sound/soc/codecs sn622x-sdca-sdw.o
(CONFIG_SND_SOC_SN622X_SDCA_SDW=m in local .config)

No hardware testing on SN6220/SN6224 yet for this v2; Tested-on will
follow when EVK is available.

Signed-off-by: Qianghua Wang <qianghua.wang@senarytech.com>

Qianghua Wang (3):
  ASoC: codecs: add SN622x SDCA SoundWire codec support
  ASoC: sdw_utils: add SN622x codec_info and DAPM hooks
  ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines

 MAINTAINERS                                   |    1 +
 sound/soc/codecs/Kconfig                      |   12 +
 sound/soc/codecs/Makefile                     |    2 +
 sound/soc/codecs/sn622x-sdca-sdw.c            | 1873 +++++++++++++++++
 sound/soc/codecs/sn622x-sdca.h                |  104 +
 .../intel/common/soc-acpi-intel-nvl-match.c   |   79 +
 .../intel/common/soc-acpi-intel-ptl-match.c   |  120 ++
 sound/soc/sdw_utils/soc_sdw_senary_dmic.c     |   19 +-
 sound/soc/sdw_utils/soc_sdw_senary_sdca.c     |    9 +-
 sound/soc/sdw_utils/soc_sdw_utils.c           |  205 +-
 10 files changed, 2394 insertions(+), 30 deletions(-)
 create mode 100644 sound/soc/codecs/sn622x-sdca-sdw.c
 create mode 100644 sound/soc/codecs/sn622x-sdca.h

-- 
2.43.0


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

* [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support
  2026-12-01  2:56 [PATCH v2 0/3] ASoC: add Senary SN622x SDCA SoundWire support Qianghua Wang
@ 2026-12-01  2:56 ` Qianghua Wang
  2026-12-01  3:23   ` sashiko-bot
  2026-12-01  2:56 ` [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks Qianghua Wang
  2026-12-01  2:56 ` [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines Qianghua Wang
  2 siblings, 1 reply; 7+ messages in thread
From: Qianghua Wang @ 2026-12-01  2:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-sound, alsa-devel, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Cezary Rojewski, Peter Ujfalusi, Kai Vehmanen,
	Pierre-Louis Bossart, bo liu, Qianghua Wang

Add the snd-soc-sn622x-sdca SoundWire codec driver for Senary SN6220 and
SN6224 SDCA devices (speaker SmartAmp + internal DMIC; no headset jack on
the codec; HP/SPK analog mux is board-level).

PDE and FU paths follow the SN624x SDCA pattern (sdca_asoc, DAPM widgets).
Bring-up only registers stay as small OEM fallbacks when ACPI init tables
are absent; there are no debug mixer controls.

Signed-off-by: Qianghua Wang <qianghua.wang@senarytech.com>
---
 MAINTAINERS                        |    1 +
 sound/soc/codecs/Kconfig           |   12 +
 sound/soc/codecs/Makefile          |    2 +
 sound/soc/codecs/sn622x-sdca-sdw.c | 1873 ++++++++++++++++++++++++++++
 sound/soc/codecs/sn622x-sdca.h     |  104 ++
 5 files changed, 1992 insertions(+)
 create mode 100644 sound/soc/codecs/sn622x-sdca-sdw.c
 create mode 100644 sound/soc/codecs/sn622x-sdca.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315..4bdb99ce8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -30952,6 +30952,7 @@ M:	qianghua.wang <qianghua.wang@senarytech.com>
 S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
 F:	sound/hda/codecs/senarytech.c
+F:	sound/soc/codecs/sn622x*
 F:	sound/soc/codecs/sn624x*
 F:	sound/soc/sdw_utils/soc_sdw_senary*
 
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index ba59dabee..6664011bf 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -257,6 +257,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_SIMPLE_MUX
 	imply SND_SOC_SMA1303
 	imply SND_SOC_SMA1307
+	imply SND_SOC_SN622X_SDCA_SDW
 	imply SND_SOC_SN624X_SDCA_SDW
 	imply SND_SOC_SPDIF
 	imply SND_SOC_SRC4XXX_I2C
@@ -2113,6 +2114,17 @@ config SND_SOC_SMA1307
 	  If you are using a system with an SMA1307 amplifier connected
 	  via I2C, enable this option.
 
+config SND_SOC_SN622X_SDCA_SDW
+	tristate "Senary SN622X SDCA Codec - SDW"
+	depends on SND_SOC_SDCA
+	depends on SOUNDWIRE
+	select REGMAP_SOUNDWIRE
+	select REGMAP_SOUNDWIRE_MBQ
+	help
+	  SoundWire SDCA driver for Senary SN622X (e.g. SN6220, SN6224).
+	  Speaker playback and DMIC capture only. Headphone plug and the
+	  analog switch between speaker and headphone are done in hardware.
+
 config SND_SOC_SN624X_SDCA_SDW
 	tristate "Senary SN624x SDCA Codec - SDW"
 	depends on SND_SOC_SDCA
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 3826f9e4f..6bbce032c 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -303,6 +303,7 @@ snd-soc-sigmadsp-regmap-y := sigmadsp-regmap.o
 snd-soc-si476x-y := si476x.o
 snd-soc-sma1303-y := sma1303.o
 snd-soc-sma1307-y := sma1307.o
+snd-soc-sn622x-sdca-y := sn622x-sdca-sdw.o
 snd-soc-sn624x-sdca-y := sn624x-sdca-sdw.o
 snd-soc-spdif-tx-y := spdif_transmitter.o
 snd-soc-spdif-rx-y := spdif_receiver.o
@@ -748,6 +749,7 @@ obj-$(CONFIG_SND_SOC_SIGMADSP_REGMAP)	+= snd-soc-sigmadsp-regmap.o
 obj-$(CONFIG_SND_SOC_SI476X)	+= snd-soc-si476x.o
 obj-$(CONFIG_SND_SOC_SMA1303)	+= snd-soc-sma1303.o
 obj-$(CONFIG_SND_SOC_SMA1307)	+= snd-soc-sma1307.o
+obj-$(CONFIG_SND_SOC_SN622X_SDCA_SDW)    += snd-soc-sn622x-sdca.o
 obj-$(CONFIG_SND_SOC_SN624X_SDCA_SDW)    += snd-soc-sn624x-sdca.o
 obj-$(CONFIG_SND_SOC_SPDIF)	+= snd-soc-spdif-rx.o snd-soc-spdif-tx.o
 obj-$(CONFIG_SND_SOC_SRC4XXX)	+= snd-soc-src4xxx.o
diff --git a/sound/soc/codecs/sn622x-sdca-sdw.c b/sound/soc/codecs/sn622x-sdca-sdw.c
new file mode 100644
index 000000000..b492fda63
--- /dev/null
+++ b/sound/soc/codecs/sn622x-sdca-sdw.c
@@ -0,0 +1,1873 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// sn622x-sdw-sdca.c -- Senary SN622X SDCA ALSA SoC SoundWire audio driver
+//
+// Copyright(c) 2025 Senary Semiconductor Corp.
+//
+
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/find.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/soundwire/sdw.h>
+#include <linux/soundwire/sdw_registers.h>
+#include <linux/soundwire/sdw_type.h>
+
+#include <sound/jack.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/sdca.h>
+#include <sound/sdca_asoc.h>
+#include <sound/sdca_function.h>
+#include <sound/sdca_regmap.h>
+#include <sound/sdw.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include "sn622x-sdca.h"
+
+/* Resume wait after bus re-enumeration (sn624x / rt722-style) */
+#define SN622X_PROBE_TIMEOUT_MS			5000U
+#define SN622X_PWR_D0				SDCA_PDE_PS0
+#define SN622X_PWR_D3				SDCA_PDE_PS3
+#define SN622X_MUTE_ON				1
+#define SN622X_PDE_PS_POLL_BUDGET_US		2000000U
+#define SN622X_FUN_NEEDS_INIT			BIT(5)
+#define SN622X_FUN_HAS_BEEN_RESET		BIT(6)
+
+struct sn622x_sdca_priv;
+
+static void sn622x_sdca_sdca_irq_mask_all(struct sn622x_sdca_priv *sn622x);
+#define SN622X_DBG(dev, fmt, ...) dev_dbg(dev, "sn622x: " fmt, ##__VA_ARGS__)
+
+/*
+ * SDCA control addresses via SDW_SDCA_CTL(fun, ent, ctl, ch) / SDW_SDCA_MBQ_CTL.
+ * Q7.8 speaker volume: PRIM = SCP, SECOND = MBQ on the same FU control.
+ * DPN channel enable (SoundWire port SCP) is programmed by the bus/stream core.
+ */
+#define SN622X_SDCA_U32(r)			((u32)(r))
+
+/* Speaker (function 1) — PDE, CS, FU10 mute/vol */
+#define SN622X_REG_RATE_SEL \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_CS01, \
+				     SN622X_SDCA_CTL_SAMPLE_FREQ_INDEX, 0))
+#define SN622X_REG_MUTE \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_USER_FU10, \
+				     SN622X_SDCA_CTL_FU_MUTE, SN622X_SDCA_CH_L))
+#define SN622X_REG_RIGHT_MUTE \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_USER_FU10, \
+				     SN622X_SDCA_CTL_FU_MUTE, SN622X_SDCA_CH_R))
+#define SN622X_REG_VOL_PRIM \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_USER_FU10, \
+				     SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_L))
+#define SN622X_REG_VOL_SECOND \
+	SN622X_SDCA_U32(SDW_SDCA_MBQ_CTL(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, \
+				      SN622X_SDCA_ENT_USER_FU10, \
+				      SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_L)))
+#define SN622X_REG_CHR_VOL_PRIM \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_USER_FU10, \
+				     SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_R))
+#define SN622X_REG_CHR_VOL_SECOND \
+	SN622X_SDCA_U32(SDW_SDCA_MBQ_CTL(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, \
+				      SN622X_SDCA_ENT_USER_FU10, \
+				      SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_R)))
+/*
+ * FU10 channel volume is Q7.8 over PRIM (SCP) + SECOND (MBQ) per channel.
+ * Defaults programmed in DAPM FU POST_PMU; unmute follows TRIGGER_START.
+ */
+#define SN622X_SPK_VOL_PRIM_DEFAULT		0x00u
+#define SN622X_SPK_VOL_SECOND_DEFAULT		0xfau
+#define SN622X_SPK_CHR_VOL_PRIM_DEFAULT		0x00u
+#define SN622X_SPK_CHR_VOL_SECOND_DEFAULT	0xfau
+#define SN622X_REG_SPEAKER_FUN_STATUS_CTL \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_ENTITY0, \
+				     SN622X_SDCA_CTL_FUNCTION_STATUS, 0))
+
+/* Speaker vendor SCP (not SDCA): charge-pump enable value per SN6220 map */
+#define SN622X_VENDOR_REG_CHARGE_PUMP	0x00002086u
+#define SN622X_CHARGE_PUMP_ENABLE	0x0bu
+
+/* DMIC capture (function 2) */
+#define SN622X_REG_DMIC_CAP_MUTE \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
+				     SN622X_SDCA_CTL_FU_MUTE, SN622X_SDCA_CH_L))
+#define SN622X_REG_DMIC_CAP_CHR_MUTE \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
+				     SN622X_SDCA_CTL_FU_MUTE, SN622X_SDCA_CH_R))
+#define SN622X_REG_DMIC_CAP_VOL_FRAC \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
+				     SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_L))
+#define SN622X_REG_DMIC_CAP_VOL_INT \
+	SN622X_SDCA_U32(SDW_SDCA_MBQ_CTL(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, \
+				      SN622X_SDCA_ENT_USER_FU20, \
+				      SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_L)))
+#define SN622X_REG_DMIC_CAP_CHR_VOL_FRAC \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
+				     SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_R))
+#define SN622X_REG_DMIC_CAP_CHR_VOL_INT \
+	SN622X_SDCA_U32(SDW_SDCA_MBQ_CTL(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, \
+				      SN622X_SDCA_ENT_USER_FU20, \
+				      SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_R)))
+#define SN622X_REG_DMIC_CAP_RATE_SEL \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_CS02, \
+				     SN622X_SDCA_CTL_SAMPLE_FREQ_INDEX, 0))
+#define SN622X_REG_DMIC_MFPU_BYPASS \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_MFPU08, \
+				     SN622X_SDCA_CTL_FU_MUTE, 0))
+#define SN622X_REG_DMIC_MFPU_ALGO_ENABLE \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_MFPU08, \
+				     SN622X_SDCA_CTL_FU_VOLUME, 0))
+#define SN622X_REG_DMIC_FUN_STATUS_CTL \
+	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_ENTITY0, \
+				     SN622X_SDCA_CTL_FUNCTION_STATUS, 0))
+
+/* Gate PCM path entry on ATTACHED; enumerate/attach are SoundWire core. */
+static bool sn622x_slave_attached(struct sdw_slave *slave)
+{
+	return slave && slave->status == SDW_SLAVE_ATTACHED;
+}
+
+static int sn622x_pde_request_ps(struct device *dev, struct regmap *regmap,
+				 unsigned int fun, unsigned int ent,
+				 unsigned int ps)
+{
+	static const struct sdca_pde_delay delays[] = {
+		{ .from_ps = SDCA_PDE_PS0, .to_ps = SDCA_PDE_PS3,
+		  .us = SN622X_PDE_PS_POLL_BUDGET_US },
+		{ .from_ps = SDCA_PDE_PS3, .to_ps = SDCA_PDE_PS0,
+		  .us = SN622X_PDE_PS_POLL_BUDGET_US },
+		{ .from_ps = SDCA_PDE_PS1, .to_ps = SDCA_PDE_PS0,
+		  .us = SN622X_PDE_PS_POLL_BUDGET_US },
+		{ .from_ps = SDCA_PDE_PS2, .to_ps = SDCA_PDE_PS0,
+		  .us = SN622X_PDE_PS_POLL_BUDGET_US },
+		{ .from_ps = SDCA_PDE_PS0, .to_ps = SDCA_PDE_PS0,
+		  .us = SN622X_PDE_PS_POLL_BUDGET_US },
+		{ .from_ps = SDCA_PDE_PS3, .to_ps = SDCA_PDE_PS3,
+		  .us = SN622X_PDE_PS_POLL_BUDGET_US },
+	};
+	unsigned int req = SDW_SDCA_CTL(fun, ent, SDCA_CTL_PDE_REQUESTED_PS, 0);
+	unsigned int act = SDW_SDCA_CTL(fun, ent, SDCA_CTL_PDE_ACTUAL_PS, 0);
+	unsigned int from_ps = SDCA_PDE_PS3;
+	int ret;
+
+	ret = regmap_read(regmap, act, &from_ps);
+	if (ret < 0) {
+		dev_warn(dev,
+			 "sn622x: PDE fun=%u ent=0x%x ACTUAL_PS read failed (%d)\n",
+			 fun, ent, ret);
+		from_ps = (ps == SN622X_PWR_D0) ? SN622X_PWR_D3 : SN622X_PWR_D0;
+	} else {
+		from_ps &= 0xffu;
+	}
+
+	if (from_ps == ps)
+		return 0;
+
+	ret = regmap_write(regmap, req, ps);
+	if (ret < 0) {
+		dev_warn(dev,
+			 "sn622x: PDE fun=%u ent=0x%x REQUESTED_PS=%u write failed (%d)\n",
+			 fun, ent, ps, ret);
+		return ret;
+	}
+
+	ret = sdca_asoc_pde_poll_actual_ps(regmap, fun, ent,
+					   from_ps, ps,
+					   delays, ARRAY_SIZE(delays));
+	if (ret < 0)
+		dev_warn(dev,
+			 "sn622x: PDE fun=%u ent=0x%x ACTUAL_PS poll failed (%d; want %u)\n",
+			 fun, ent, ret, ps);
+	return ret;
+}
+
+static int sn622x_dapm_pde_event(struct snd_soc_dapm_widget *w,
+				 struct snd_kcontrol *kcontrol, int event,
+				 unsigned int fun, unsigned int ent)
+{
+	struct snd_soc_component *component =
+		snd_soc_dapm_to_component(w->dapm);
+	struct sn622x_sdca_priv *sn622x =
+		snd_soc_component_get_drvdata(component);
+	struct device *dev = component->dev;
+	int ret;
+
+	if (!sn622x || !sn622x->regmap)
+		return -ENODEV;
+
+	switch (event) {
+	case SND_SOC_DAPM_POST_PMU:
+		ret = sn622x_pde_request_ps(dev, sn622x->regmap, fun, ent,
+					    SN622X_PWR_D0);
+		if (ret < 0)
+			dev_warn(dev,
+				 "sn622x: DAPM %s PDE fun=%u ent=0x%x -> PS0 failed (%d)\n",
+				 w->name, fun, ent, ret);
+		break;
+	case SND_SOC_DAPM_PRE_PMD:
+		ret = sn622x_pde_request_ps(dev, sn622x->regmap, fun, ent,
+					    SN622X_PWR_D3);
+		if (ret < 0)
+			dev_warn(dev,
+				 "sn622x: DAPM %s PDE fun=%u ent=0x%x -> PS3 failed (%d)\n",
+				 w->name, fun, ent, ret);
+		break;
+	default:
+		return 0;
+	}
+	return ret;
+}
+
+static int sn622x_pde_spk_event(struct snd_soc_dapm_widget *w,
+				struct snd_kcontrol *kcontrol, int event)
+{
+	return sn622x_dapm_pde_event(w, kcontrol, event,
+				     SN622X_FUNC_NUM_SPEAKER,
+				     SN622X_SDCA_ENT_PDE03);
+}
+
+static int sn622x_pde_dmic_event(struct snd_soc_dapm_widget *w,
+				 struct snd_kcontrol *kcontrol, int event)
+{
+	return sn622x_dapm_pde_event(w, kcontrol, event,
+				     SN622X_FUNC_NUM_MIC_ARRAY,
+				     SN622X_SDCA_ENT_PDE03);
+}
+
+static int sn622x_fu_mute_event(struct snd_soc_dapm_widget *w,
+				struct snd_kcontrol *kcontrol, int event,
+				unsigned int mute_l, unsigned int mute_r,
+				unsigned int vol_l_prim, unsigned int vol_l_sec,
+				unsigned int vol_r_prim, unsigned int vol_r_sec,
+				unsigned int prim, unsigned int sec_l,
+				unsigned int sec_r, bool unmute_on_pmu)
+{
+	struct snd_soc_component *component =
+		snd_soc_dapm_to_component(w->dapm);
+	struct sn622x_sdca_priv *sn622x =
+		snd_soc_component_get_drvdata(component);
+	struct device *dev = component->dev;
+	int ret;
+
+	if (!sn622x || !sn622x->regmap)
+		return -ENODEV;
+
+	switch (event) {
+	case SND_SOC_DAPM_POST_PMU:
+		ret = regmap_write(sn622x->regmap, vol_l_prim, prim);
+		if (ret < 0)
+			dev_warn(dev, "sn622x: DAPM %s vol(L) prim failed (%d)\n",
+				 w->name, ret);
+		ret = regmap_write(sn622x->regmap, vol_l_sec, sec_l);
+		if (ret < 0)
+			dev_warn(dev, "sn622x: DAPM %s vol(L) sec failed (%d)\n",
+				 w->name, ret);
+		if (vol_r_prim) {
+			ret = regmap_write(sn622x->regmap, vol_r_prim, prim);
+			if (ret < 0)
+				dev_warn(dev,
+					 "sn622x: DAPM %s vol(R) prim failed (%d)\n",
+					 w->name, ret);
+			ret = regmap_write(sn622x->regmap, vol_r_sec, sec_r);
+			if (ret < 0)
+				dev_warn(dev,
+					 "sn622x: DAPM %s vol(R) sec failed (%d)\n",
+					 w->name, ret);
+		}
+		if (unmute_on_pmu) {
+			ret = regmap_write(sn622x->regmap, mute_l, 0);
+			if (ret < 0)
+				dev_warn(dev,
+					 "sn622x: DAPM %s unmute(L) failed (%d)\n",
+					 w->name, ret);
+			if (mute_r) {
+				ret = regmap_write(sn622x->regmap, mute_r, 0);
+				if (ret < 0)
+					dev_warn(dev,
+						 "sn622x: DAPM %s unmute(R) failed (%d)\n",
+						 w->name, ret);
+			}
+		}
+		break;
+	case SND_SOC_DAPM_PRE_PMD:
+		ret = regmap_write(sn622x->regmap, mute_l, SN622X_MUTE_ON);
+		if (ret < 0)
+			dev_warn(dev, "sn622x: DAPM %s mute(L) failed (%d)\n",
+				 w->name, ret);
+		if (mute_r) {
+			ret = regmap_write(sn622x->regmap, mute_r, SN622X_MUTE_ON);
+			if (ret < 0)
+				dev_warn(dev, "sn622x: DAPM %s mute(R) failed (%d)\n",
+					 w->name, ret);
+		}
+		usleep_range(SN622X_ROUTE_AFTER_MUTE_US_MIN,
+			     SN622X_ROUTE_AFTER_MUTE_US_MAX);
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
+static int sn622x_fu_spk_event(struct snd_soc_dapm_widget *w,
+			       struct snd_kcontrol *kcontrol, int event)
+{
+	return sn622x_fu_mute_event(w, kcontrol, event,
+				    SN622X_REG_MUTE, SN622X_REG_RIGHT_MUTE,
+				    SN622X_REG_VOL_PRIM, SN622X_REG_VOL_SECOND,
+				    SN622X_REG_CHR_VOL_PRIM,
+				    SN622X_REG_CHR_VOL_SECOND,
+				    SN622X_SPK_VOL_PRIM_DEFAULT,
+				    SN622X_SPK_VOL_SECOND_DEFAULT,
+				    SN622X_SPK_CHR_VOL_SECOND_DEFAULT,
+				    false);
+}
+
+#define SN622X_DMIC_VOL_FRAC_DEFAULT	0x4du
+#define SN622X_DMIC_VOL_INT_DEFAULT	0xfbu
+
+static int sn622x_fu_dmic_event(struct snd_soc_dapm_widget *w,
+				struct snd_kcontrol *kcontrol, int event)
+{
+	return sn622x_fu_mute_event(w, kcontrol, event,
+				    SN622X_REG_DMIC_CAP_MUTE,
+				    SN622X_REG_DMIC_CAP_CHR_MUTE,
+				    SN622X_REG_DMIC_CAP_VOL_FRAC,
+				    SN622X_REG_DMIC_CAP_VOL_INT,
+				    SN622X_REG_DMIC_CAP_CHR_VOL_FRAC,
+				    SN622X_REG_DMIC_CAP_CHR_VOL_INT,
+				    SN622X_DMIC_VOL_FRAC_DEFAULT,
+				    SN622X_DMIC_VOL_INT_DEFAULT,
+				    SN622X_DMIC_VOL_INT_DEFAULT,
+				    false);
+}
+
+/* FU unmute after SDW transport is running (see .trigger START). */
+static void sn622x_speaker_fu_unmute(struct device *dev,
+				     struct sn622x_sdca_priv *sn622x)
+{
+	int ret;
+
+	if (!sn622x || !sn622x->regmap || !sn622x_slave_attached(sn622x->slave))
+		return;
+
+	ret = regmap_write(sn622x->regmap, SN622X_REG_MUTE, 0);
+	if (ret < 0)
+		dev_warn(dev, "sn622x: speaker unmute(L) failed (%d)\n", ret);
+	ret = regmap_write(sn622x->regmap, SN622X_REG_RIGHT_MUTE, 0);
+	if (ret < 0)
+		dev_warn(dev, "sn622x: speaker unmute(R) failed (%d)\n", ret);
+}
+
+static void sn622x_dmic_fu_unmute(struct device *dev,
+				  struct sn622x_sdca_priv *sn622x)
+{
+	int ret;
+
+	if (!sn622x || !sn622x->regmap || !sn622x_slave_attached(sn622x->slave))
+		return;
+
+	ret = regmap_write(sn622x->regmap, SN622X_REG_DMIC_CAP_MUTE, 0);
+	if (ret < 0)
+		dev_warn(dev, "sn622x: dmic unmute(L) failed (%d)\n", ret);
+	ret = regmap_write(sn622x->regmap, SN622X_REG_DMIC_CAP_CHR_MUTE, 0);
+	if (ret < 0)
+		dev_warn(dev, "sn622x: dmic unmute(R) failed (%d)\n", ret);
+}
+
+/* Clear SPEAKER Function Status needs-init / been-reset (write 0x61). Returns 1 if ACKed. */
+static int sn622x_speaker_fun_ack_if_needed(struct device *dev,
+					    struct sn622x_sdca_priv *sn622x)
+{
+	struct reg_sequence clear_status =
+		REG_SEQ0(SN622X_REG_SPEAKER_FUN_STATUS_CTL, 0x61);
+	unsigned int st = 0;
+	int ret;
+
+	if (!sn622x || !sn622x->regmap || !sn622x->slave)
+		return 0;
+	if (sn622x->slave->status != SDW_SLAVE_ATTACHED)
+		return 0;
+
+	ret = regmap_read_bypassed(sn622x->regmap,
+				   SN622X_REG_SPEAKER_FUN_STATUS_CTL, &st);
+	if (ret < 0)
+		return 0;
+	if (!(st & (SN622X_FUN_NEEDS_INIT | SN622X_FUN_HAS_BEEN_RESET)))
+		return 0;
+
+	ret = regmap_multi_reg_write_bypassed(sn622x->regmap, &clear_status, 1);
+	if (ret < 0) {
+		dev_warn(dev, "sn622x: speaker FUN ACK failed (%d)\n", ret);
+		return 0;
+	}
+	usleep_range(1000, 1500);
+	return 1;
+}
+
+/*
+ * Speaker path setup before streaming: FUN ACK + vendor analog (charge pump).
+ * PDE and FU mute/volume are DAPM widgets (sn624x-style).
+ */
+static void sn622x_speaker_playback_prepare(struct device *dev,
+					    struct sn622x_sdca_priv *sn622x)
+{
+	if (!sn622x || !sn622x->regmap || !sn622x->slave)
+		return;
+
+	mutex_lock(&sn622x->path_lock);
+
+	if (!sn622x_slave_attached(sn622x->slave)) {
+		dev_dbg(dev, "sn622x: speaker prepare: skip (not ATTACHED)\n");
+		goto out_unlock;
+	}
+
+	sn622x_speaker_fun_ack_if_needed(dev, sn622x);
+
+	/*
+	 * Enable the speaker charge pump (vendor 0x2086 = 0x0b). FU unmute/volume
+	 * is applied later when the DAPM speaker path powers up.
+	 */
+	{
+		unsigned int pump = 0xff;
+		struct reg_sequence pump_on =
+			REG_SEQ0(SN622X_VENDOR_REG_CHARGE_PUMP, SN622X_CHARGE_PUMP_ENABLE);
+
+		if (regmap_read_bypassed(sn622x->regmap, SN622X_VENDOR_REG_CHARGE_PUMP,
+					 &pump) == 0 &&
+		    (pump & 0xffu) != SN622X_CHARGE_PUMP_ENABLE) {
+			if (regmap_multi_reg_write_bypassed(sn622x->regmap,
+							    &pump_on, 1) == 0)
+				usleep_range(1000, 1500);
+		}
+	}
+
+out_unlock:
+	mutex_unlock(&sn622x->path_lock);
+}
+
+static int sn622x_hw_params_port(struct snd_soc_dai *dai,
+				 struct snd_pcm_substream *substream)
+{
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (dai->id == SN622X_DAI_SPEAKER)
+			return SN622X_PORT_SPEAKER_PLAYBACK;
+	} else {
+		if (dai->id == SN622X_DAI_DMIC)
+			return SN622X_PORT_DMIC_CAPTURE;
+	}
+	return -EINVAL;
+}
+
+static int sn622x_dmic_apply_defaults(struct device *dev,
+				      struct sn622x_sdca_priv *sn622x);
+
+/* DMIC vendor init table; run when analog not yet restored for this attach. */
+static void sn622x_restore_dmic_analog(struct device *dev,
+				       struct sn622x_sdca_priv *sn622x,
+				       const char *why)
+{
+	struct reg_sequence clear_dmic =
+		REG_SEQ0(SN622X_REG_DMIC_FUN_STATUS_CTL, 0x61);
+	int ret;
+
+	if (!sn622x || !sn622x->regmap || !sn622x->slave)
+		return;
+	if (!sn622x_slave_attached(sn622x->slave)) {
+		dev_dbg(dev, "sn622x: restore dmic skip (%s): not ATTACHED\n",
+			why ? why : "?");
+		return;
+	}
+	if (sn622x->dmic_analog_restored) {
+		dev_dbg(dev, "sn622x: restore dmic skip (%s): already done\n",
+			why ? why : "?");
+		return;
+	}
+
+	dev_dbg(dev, "sn622x: restore dmic analog (%s)\n", why ? why : "?");
+
+	ret = sn622x_dmic_apply_defaults(dev, sn622x);
+	if (ret < 0) {
+		dev_warn(dev, "sn622x: restore dmic: init table failed (%d)\n",
+			 ret);
+		return;
+	}
+
+	ret = regmap_multi_reg_write_bypassed(sn622x->regmap, &clear_dmic, 1);
+	if (ret < 0) {
+		dev_warn(dev, "sn622x: restore dmic: FUN STATUS clear failed (%d)\n",
+			 ret);
+		return;
+	}
+	usleep_range(1000, 1500);
+	sn622x->dmic_analog_restored = true;
+}
+
+/* DMIC vendor/analog after sdw_stream_add_slave; PDE/FU via DAPM. */
+static void sn622x_dmic_capture_prepare(struct device *dev,
+					struct sn622x_sdca_priv *sn622x,
+					unsigned int pcm_rate,
+					bool bringup)
+{
+	unsigned int st = 0;
+	struct reg_sequence clear_dmic =
+		REG_SEQ0(SN622X_REG_DMIC_FUN_STATUS_CTL, 0x61);
+	int r;
+
+	if (!sn622x || !sn622x->regmap || !sn622x->slave)
+		return;
+
+	mutex_lock(&sn622x->path_lock);
+
+	if (!sn622x_slave_attached(sn622x->slave)) {
+		dev_dbg(dev, "sn622x: dmic prepare: skip (not ATTACHED)\n");
+		goto out_unlock;
+	}
+
+	if (regmap_read_bypassed(sn622x->regmap, SN622X_REG_DMIC_FUN_STATUS_CTL,
+				 &st) == 0 &&
+	    (st & (SN622X_FUN_NEEDS_INIT | SN622X_FUN_HAS_BEEN_RESET))) {
+		regmap_multi_reg_write_bypassed(sn622x->regmap, &clear_dmic, 1);
+		usleep_range(1000, 1500);
+	}
+
+	if (bringup || !sn622x->dmic_analog_restored)
+		sn622x_restore_dmic_analog(dev, sn622x,
+					   bringup ? "dmic_pmu" : "dmic_recover");
+
+	if (!sn622x->dmic_cap_cfg_done) {
+		static const struct reg_sequence cap_cfg[] = {
+			REG_SEQ0(0x00002126u, 0x18),
+			REG_SEQ0(0x00002127u, 0x01),
+			REG_SEQ0(0x000020f3u, 0x30),
+		};
+
+		r = regmap_multi_reg_write_bypassed(sn622x->regmap, cap_cfg,
+						    ARRAY_SIZE(cap_cfg));
+		if (r < 0)
+			dev_warn(dev,
+				 "sn622x: dmic prepare: cap vendor cfg failed (%d)\n",
+				 r);
+		else
+			sn622x->dmic_cap_cfg_done = true;
+	}
+
+	sn622x->dmic_route_latched = true;
+	(void)pcm_rate;
+
+out_unlock:
+	mutex_unlock(&sn622x->path_lock);
+}
+
+static const char *sn622x_status_str(enum sdw_slave_status status)
+{
+	switch (status) {
+	case SDW_SLAVE_UNATTACHED:
+		return "UNATTACHED";
+	case SDW_SLAVE_ATTACHED:
+		return "ATTACHED";
+	case SDW_SLAVE_ALERT:
+		return "ALERT";
+	case SDW_SLAVE_RESERVED:
+		return "RESERVED";
+	default:
+		return "UNKNOWN";
+	}
+}
+
+static int sn622x_sdca_mbq_size(struct device *dev, unsigned int reg)
+{
+	if (!SDW_SDCA_VALID_CTL(reg))
+		return 1;
+
+	switch (reg) {
+	case SN622X_REG_VOL_SECOND:
+	case SN622X_REG_CHR_VOL_SECOND:
+	case SN622X_REG_DMIC_CAP_VOL_INT:
+	case SN622X_REG_DMIC_CAP_VOL_FRAC:
+	case SN622X_REG_DMIC_CAP_CHR_VOL_INT:
+	case SN622X_REG_DMIC_CAP_CHR_VOL_FRAC:
+		return 2;
+	default:
+		return 1;
+	}
+}
+
+static bool sn622x_sdca_volatile_register(struct device *dev, unsigned int reg)
+{
+	if (!SDW_SDCA_VALID_CTL(reg))
+		return true;
+
+	if (SDW_SDCA_CTL_CSEL(reg) == SDCA_CTL_PDE_ACTUAL_PS)
+		return true;
+
+	return false;
+}
+
+static const struct regmap_sdw_mbq_cfg sn622x_sdca_mbq_cfg = {
+	.mbq_size = sn622x_sdca_mbq_size,
+};
+
+static const struct regmap_config sn622x_sdca_regmap = {
+	.reg_bits = 32,
+	.val_bits = 16,
+	.volatile_reg = sn622x_sdca_volatile_register,
+	.max_register = 0xffffffff,
+	.cache_type = REGCACHE_MAPLE,
+	.use_single_read = true,
+	.use_single_write = true,
+};
+
+static int sn622x_write_sdca_init_table(struct device *dev,
+					struct sn622x_sdca_priv *sn622x,
+					struct sdca_function_data *fn,
+					const char *label)
+{
+	int ret;
+
+	if (!fn || !fn->num_init_table)
+		return -ENOENT;
+
+	ret = sdca_regmap_write_init(dev, sn622x->regmap, fn);
+	if (ret < 0) {
+		dev_warn(dev,
+			 "sn622x: %s function-initialization-table write failed (%d)\n",
+			 label, ret);
+		return ret;
+	}
+
+	dev_dbg(dev, "sn622x: applied %s function-initialization-table (%d writes)\n",
+		label, fn->num_init_table);
+	return 0;
+}
+
+static int sn622x_parse_sdca_functions(struct sn622x_sdca_priv *sn622x)
+{
+	struct sdw_slave *slave = sn622x->slave;
+	struct device *dev = &slave->dev;
+	int i, ret;
+
+	if (!slave->sdca_data.num_functions) {
+		dev_dbg(dev, "sn622x: no SDCA function descriptors from DisCo\n");
+		return 0;
+	}
+
+	for (i = 0; i < slave->sdca_data.num_functions; i++) {
+		struct sdca_function_desc *desc = &slave->sdca_data.function[i];
+		struct sdca_function_data *fn;
+		bool is_mic = false, is_speaker = false;
+
+		switch (desc->type) {
+		case SDCA_FUNCTION_TYPE_SMART_MIC:
+		case SDCA_FUNCTION_TYPE_SIMPLE_MIC:
+			is_mic = true;
+			break;
+		case SDCA_FUNCTION_TYPE_SMART_AMP:
+		case SDCA_FUNCTION_TYPE_SIMPLE_AMP:
+		case SDCA_FUNCTION_TYPE_SPEAKER_MIC:
+			is_speaker = true;
+			break;
+		default:
+			break;
+		}
+
+		if (desc->adr == SN622X_FUNC_NUM_MIC_ARRAY)
+			is_mic = true;
+		else if (desc->adr == SN622X_FUNC_NUM_SPEAKER)
+			is_speaker = true;
+
+		if (!is_mic && !is_speaker)
+			continue;
+
+		fn = devm_kzalloc(dev, sizeof(*fn), GFP_KERNEL);
+		if (!fn)
+			return -ENOMEM;
+
+		fn->desc = desc;
+		ret = sdca_parse_function(dev, fn);
+		if (ret) {
+			dev_warn(dev,
+				 "sn622x: sdca_parse_function(%s adr=%u) failed (%d)%s\n",
+				 desc->name ? desc->name : "?", desc->adr, ret,
+				 fn->num_init_table ?
+				 ", keeping ACPI init table" : "");
+			if (!fn->num_init_table)
+				continue;
+		} else {
+			dev_dbg(dev,
+				"sn622x: parsed SDCA function %s type=%u adr=%u init_writes=%d\n",
+				desc->name ? desc->name : "?", desc->type,
+				desc->adr, fn->num_init_table);
+		}
+
+		if (is_speaker && !sn622x->speaker_func)
+			sn622x->speaker_func = fn;
+		else if (is_mic && !sn622x->mic_func)
+			sn622x->mic_func = fn;
+	}
+
+	return 0;
+}
+
+static bool sn622x_sdca_disco_omits_mic(const struct sdw_slave *slave)
+{
+	int i;
+
+	if (!slave->sdca_data.interface_revision || !slave->sdca_data.num_functions)
+		return false;
+
+	for (i = 0; i < slave->sdca_data.num_functions; i++) {
+		const struct sdca_function_desc *desc = &slave->sdca_data.function[i];
+
+		if (desc->adr == SN622X_FUNC_NUM_MIC_ARRAY)
+			return false;
+		switch (desc->type) {
+		case SDCA_FUNCTION_TYPE_SMART_MIC:
+		case SDCA_FUNCTION_TYPE_SIMPLE_MIC:
+			return false;
+		default:
+			break;
+		}
+	}
+	return true;
+}
+
+static int sn622x_dmic_oem_fallback_init(struct device *dev,
+					 struct sn622x_sdca_priv *sn622x)
+{
+	int ret;
+	const struct reg_sequence dmic_oem_table[] = {
+		REG_SEQ0(0x00002041, 0x00),
+		/* Omit PPU11 0x40880380 (NACK on SN6220). */
+		REG_SEQ0(0x00002105, 0x66),
+		REG_SEQ0(0x00002107, 0x26),
+		REG_SEQ0(0x00002109, 0x62),
+		REG_SEQ0(SN622X_REG_DMIC_CAP_MUTE, 0x00),
+		REG_SEQ0(SN622X_REG_DMIC_CAP_CHR_MUTE, 0x00),
+		REG_SEQ0(SN622X_REG_DMIC_CAP_VOL_INT, 0x00),
+		REG_SEQ0(SN622X_REG_DMIC_CAP_VOL_FRAC, 0x00),
+		REG_SEQ0(SN622X_REG_DMIC_CAP_CHR_VOL_INT, 0x00),
+		REG_SEQ0(SN622X_REG_DMIC_CAP_CHR_VOL_FRAC, 0x00),
+		REG_SEQ0(0x408029d8, 0x0c),
+		REG_SEQ0(0x408009d8, 0x00),
+		REG_SEQ0(0x408029d9, 0x0c),
+		REG_SEQ0(0x408009d9, 0x00),
+		REG_SEQ0(0x00002140, 0x18),
+		REG_SEQ0(0x00002045, 0x01),
+	};
+
+	if (!sn622x || !sn622x->regmap || !sn622x->slave)
+		return -ENODEV;
+
+	dev_warn_once(dev,
+		      "sn622x: using DMIC OEM init fallback (no ACPI init table)\n");
+	ret = regmap_multi_reg_write_bypassed(sn622x->regmap, dmic_oem_table,
+					      ARRAY_SIZE(dmic_oem_table));
+	if (ret < 0) {
+		dev_warn(dev, "sn622x: DMIC OEM fallback failed (%d)\n", ret);
+		return ret;
+	}
+
+	usleep_range(1000, 1500);
+	return 0;
+}
+
+static int sn622x_dmic_apply_defaults(struct device *dev,
+				      struct sn622x_sdca_priv *sn622x)
+{
+	int ret;
+
+	if (!sn622x || !sn622x->regmap || !sn622x->slave)
+		return -ENODEV;
+
+	if (sn622x_sdca_disco_omits_mic(sn622x->slave))
+		return 0;
+
+	ret = sn622x_write_sdca_init_table(dev, sn622x, sn622x->mic_func, "dmic");
+	if (ret == 0) {
+		usleep_range(1000, 1500);
+		return 0;
+	}
+
+	return sn622x_dmic_oem_fallback_init(dev, sn622x);
+}
+
+static int sn622x_speaker_apply_defaults(struct device *dev,
+					 struct sn622x_sdca_priv *sn622x)
+{
+	int ret;
+
+	ret = sn622x_write_sdca_init_table(dev, sn622x, sn622x->speaker_func,
+					   "speaker");
+	if (ret == 0) {
+		usleep_range(1000, 1500);
+		return 0;
+	}
+	return ret == -ENOENT ? 0 : ret;
+}
+
+static void sn622x_sdca_sdca_irq_mask_all(struct sn622x_sdca_priv *sn622x)
+{
+	if (!sn622x->slave)
+		return;
+
+	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK1, 0);
+	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK2, 0);
+	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK3, 0);
+	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK4, 0);
+	SN622X_DBG(&sn622x->slave->dev,
+		   "SDCA INTMASK1-4 = 0 (all SDCA sources masked)\n");
+}
+
+static int sn622x_sdca_io_init(struct device *dev, struct sdw_slave *slave)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
+	int ret;
+	unsigned int dmic_func_status;
+	if (sn622x->hw_init) {
+		SN622X_DBG(dev, "io_init: skip (hw_init already true)\n");
+		return 0;
+	}
+
+	mutex_lock(&sn622x->path_lock);
+	if (sn622x->hw_init) {
+		mutex_unlock(&sn622x->path_lock);
+		return 0;
+	}
+	/* PCM open: defer full io_init until streams close (same bus, no extra SCP). */
+	if (sn622x->first_hw_init &&
+	    (sn622x->playback_active || sn622x->dmic_active)) {
+		dev_dbg(dev, "sn622x: io_init: stream open — skip bus access\n");
+		sn622x->hw_init = true;
+		mutex_unlock(&sn622x->path_lock);
+		return 0;
+	}
+	/* Capture still active: minimal cache/PM + DMIC FUN ACK; route in prepare. */
+	if (sn622x->dmic_active) {
+		dev_dbg(dev, "sn622x: io_init: capture active, DMIC FUN ACK\n");
+		sn622x->disable_irq = false;
+		sn622x_sdca_sdca_irq_mask_all(sn622x);
+		regcache_cache_only(sn622x->regmap, false);
+		pm_runtime_get_noresume(dev);
+
+		ret = regmap_read_bypassed(sn622x->regmap,
+					   SN622X_REG_DMIC_FUN_STATUS_CTL,
+					   &dmic_func_status);
+		if (ret == 0) {
+			dev_dbg(dev,
+				 "sn622x: io_init: DMIC FUN[0x%x]=0x%x\n",
+				 SN622X_REG_DMIC_FUN_STATUS_CTL,
+				 dmic_func_status);
+			if (dmic_func_status &
+			    (SN622X_FUN_NEEDS_INIT |
+			     SN622X_FUN_HAS_BEEN_RESET)) {
+				struct reg_sequence clear_dmic =
+					REG_SEQ0(SN622X_REG_DMIC_FUN_STATUS_CTL,
+						 0x61);
+
+				ret = regmap_multi_reg_write_bypassed(
+					sn622x->regmap, &clear_dmic, 1);
+				if (ret < 0)
+					dev_warn(dev,
+						 "sn622x: io_init: DMIC FUN ACK failed (%d)\n",
+						 ret);
+				else
+					usleep_range(1000, 1500);
+			}
+		}
+
+		pm_runtime_set_active(dev);
+		sn622x->hw_init = true;
+		sn622x->first_hw_init = true;
+		pm_runtime_put_autosuspend(dev);
+		mutex_unlock(&sn622x->path_lock);
+		return 0;
+	}
+
+	sn622x->disable_irq = false;
+
+	sn622x_sdca_sdca_irq_mask_all(sn622x);
+
+	regcache_cache_only(sn622x->regmap, false);
+
+	pm_runtime_get_noresume(dev);
+
+	{
+		unsigned int spk_func_status;
+
+		ret = regmap_read_bypassed(sn622x->regmap,
+					   SN622X_REG_SPEAKER_FUN_STATUS_CTL,
+					   &spk_func_status);
+		if (ret < 0) {
+			dev_dbg(dev,
+				"sn622x: io_init: SPEAKER FUN STATUS read failed (%d)\n",
+				ret);
+		} else if (spk_func_status & (SN622X_FUN_NEEDS_INIT |
+					      SN622X_FUN_HAS_BEEN_RESET)) {
+			ret = sn622x_speaker_apply_defaults(dev, sn622x);
+			if (ret < 0)
+				dev_warn(dev,
+					 "sn622x: io_init: speaker init table failed (%d)\n",
+					 ret);
+			usleep_range(5000, 8000);
+			if (sn622x->slave->status == SDW_SLAVE_ATTACHED)
+				sn622x_speaker_fun_ack_if_needed(dev, sn622x);
+		}
+
+		ret = regmap_read_bypassed(sn622x->regmap,
+					   SN622X_REG_DMIC_FUN_STATUS_CTL,
+					   &dmic_func_status);
+		if (ret < 0) {
+			dev_dbg(dev,
+				"sn622x: io_init: DMIC FUN STATUS read failed (%d)\n",
+				ret);
+		} else if (dmic_func_status & (SN622X_FUN_NEEDS_INIT |
+					       SN622X_FUN_HAS_BEEN_RESET) &&
+			   sn622x->slave->status == SDW_SLAVE_ATTACHED) {
+			struct reg_sequence clear_dmic =
+				REG_SEQ0(SN622X_REG_DMIC_FUN_STATUS_CTL, 0x61);
+
+			ret = regmap_multi_reg_write_bypassed(sn622x->regmap,
+							      &clear_dmic, 1);
+			if (ret < 0)
+				dev_warn(dev,
+					 "sn622x: io_init: DMIC FUN ACK failed (%d)\n",
+					 ret);
+			else
+				usleep_range(1000, 1500);
+		}
+	}
+
+	pm_runtime_set_active(dev);
+
+	sn622x->hw_init = true;
+	sn622x->first_hw_init = true;
+
+	pm_runtime_put_autosuspend(dev);
+
+	SN622X_DBG(dev, "io_init: complete (hw_init set)\n");
+	mutex_unlock(&sn622x->path_lock);
+	return 0;
+}
+
+/* Defer register access after rapid ATTACH/UNATTACH transitions (external HP mux). */
+static void sn622x_pm_recover(struct device *dev)
+{
+	int err = dev->power.runtime_error;
+
+	if (!err)
+		return;
+
+	dev_dbg(dev, "sn622x: clear sticky runtime PM error %d\n", err);
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
+	pm_runtime_enable(dev);
+}
+
+static void sn622x_schedule_bus_recover(struct sn622x_sdca_priv *sn622x,
+					unsigned int delay_ms)
+{
+	mod_delayed_work(system_wq, &sn622x->bus_recover_work,
+			 msecs_to_jiffies(delay_ms));
+}
+
+static bool sn622x_dmic_needs_recover(const struct sn622x_sdca_priv *sn622x)
+{
+	if (!sn622x->dmic_active)
+		return false;
+	if (!sn622x->dmic_route_latched)
+		return true;
+	if (sn622x->dmic_recover_until &&
+	    time_before(jiffies, sn622x->dmic_recover_until))
+		return true;
+	return false;
+}
+
+/*
+ * Deferred bring-up after UNATTACH (external HP mux): runtime PM cleanup,
+ * io_init when re-attached, DMIC vendor prepare retries while capture is open.
+ */
+static void sn622x_bus_recover_work(struct work_struct *work)
+{
+	struct sn622x_sdca_priv *sn622x =
+		container_of(work, struct sn622x_sdca_priv, bus_recover_work.work);
+	struct device *dev;
+	bool got_pm = false;
+	int ret;
+
+	if (!sn622x->slave)
+		return;
+
+	dev = &sn622x->slave->dev;
+
+	if (!sn622x_slave_attached(sn622x->slave)) {
+		if (sn622x_dmic_needs_recover(sn622x))
+			sn622x_schedule_bus_recover(sn622x,
+						    SN622X_BUS_RECOVER_DMIC_MS);
+		return;
+	}
+
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0 && ret != -EACCES)
+		return;
+	if (ret == 0)
+		got_pm = true;
+
+	sn622x_pm_recover(dev);
+
+	if (!sn622x->hw_init)
+		sn622x_sdca_io_init(dev, sn622x->slave);
+
+	if (sn622x_dmic_needs_recover(sn622x) &&
+	    (!sn622x->playback_active || !sn622x->dmic_route_latched)) {
+		dev_dbg(dev, "sn622x: bus_recover: DMIC capture prepare\n");
+		sn622x_dmic_capture_prepare(dev, sn622x, sn622x->dmic_rate, false);
+		if (sn622x_dmic_needs_recover(sn622x))
+			sn622x_schedule_bus_recover(sn622x,
+						    SN622X_BUS_RECOVER_DMIC_MS);
+	}
+
+	if (got_pm) {
+		pm_runtime_mark_last_busy(dev);
+		pm_runtime_put_autosuspend(dev);
+	}
+}
+
+static int sn622x_sdca_update_status(struct sdw_slave *slave,
+				     enum sdw_slave_status status)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
+
+	SN622X_DBG(&slave->dev, "update_status: %s hw_init=%d dev_num=%u\n",
+		   sn622x_status_str(status), sn622x->hw_init, slave->dev_num);
+
+	if (status == SDW_SLAVE_UNATTACHED) {
+		unsigned long prev_unattach = sn622x->last_unattach_jiffies;
+
+		sn622x->hw_init = false;
+		sn622x->last_unattach_jiffies = jiffies;
+		/* After ATTACH, capture prepare re-latches route; keep dmic_analog_restored. */
+		sn622x->dmic_route_latched = false;
+		if (prev_unattach &&
+		    time_before(jiffies, prev_unattach +
+				msecs_to_jiffies(SN622X_UNATTACH_STORM_WINDOW_MS)))
+			sn622x->unattach_storm++;
+		else
+			sn622x->unattach_storm = 1;
+		if (sn622x->dmic_active &&
+		    sn622x->unattach_storm >= SN622X_UNATTACH_STORM_MAX) {
+			dev_warn(&slave->dev,
+				 "sn622x: rapid UNATTACH — stop DMIC recover\n");
+			sn622x->dmic_active = false;
+			sn622x->dmic_recover_until = 0;
+			cancel_delayed_work(&sn622x->bus_recover_work);
+		} else if (sn622x->dmic_active) {
+			sn622x->dmic_recover_until = jiffies + 2 * HZ;
+		}
+		sn622x_schedule_bus_recover(sn622x, SN622X_BUS_RECOVER_SETTLE_MS);
+	}
+
+	if (status == SDW_SLAVE_ATTACHED) {
+		if (sn622x->unattach_storm &&
+		    time_after(jiffies, sn622x->last_unattach_jiffies +
+			       msecs_to_jiffies(3000)))
+			sn622x->unattach_storm = 0;
+		sn622x_sdca_sdca_irq_mask_all(sn622x);
+	}
+
+	if (status != SDW_SLAVE_ATTACHED)
+		return 0;
+
+	if (sn622x->hw_init) {
+		dev_dbg(&slave->dev,
+			"sn622x: update_status ATTACHED: io_init already done\n");
+		return 0;
+	}
+
+	if (sn622x->first_hw_init &&
+	    time_before(jiffies, sn622x->last_unattach_jiffies +
+			msecs_to_jiffies(SN622X_ATTACH_DEBOUNCE_MS))) {
+		dev_dbg(&slave->dev,
+			"sn622x: defer io_init %u ms after UNATTACH\n",
+			SN622X_ATTACH_DEBOUNCE_MS);
+		sn622x_schedule_bus_recover(sn622x, SN622X_BUS_RECOVER_SETTLE_MS);
+		return 0;
+	}
+
+	sn622x_pm_recover(&slave->dev);
+	return sn622x_sdca_io_init(&slave->dev, slave);
+}
+
+static int sn622x_sdca_read_prop(struct sdw_slave *slave)
+{
+	struct sdw_slave_prop *prop = &slave->prop;
+	struct sdw_dpn_prop *dpn;
+	unsigned long addr;
+	unsigned int bit;
+	int nval;
+	int i, j;
+
+	sdw_slave_read_lane_mapping(slave);
+	prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY;
+	prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
+	prop->paging_support = true;
+	prop->use_domain_irq = true;
+	/* dev_num 1 on this link: wake_capable is unsupported on Intel hosts. */
+	prop->wake_capable = false;
+
+	/* SN6220: speaker playback (port1) + DMIC capture (port3) only */
+	prop->source_ports = BIT(SN622X_PORT_DMIC_CAPTURE);
+	prop->sink_ports = BIT(SN622X_PORT_SPEAKER_PLAYBACK);
+
+	nval = hweight32(prop->source_ports);
+	prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval,
+					   sizeof(*prop->src_dpn_prop), GFP_KERNEL);
+	if (!prop->src_dpn_prop)
+		return -ENOMEM;
+	i = 0;
+	dpn = prop->src_dpn_prop;
+	addr = prop->source_ports;
+	for_each_set_bit(bit, &addr, 32) {
+		dpn[i].num = bit;
+		dpn[i].type = SDW_DPN_FULL;
+		dpn[i].simple_ch_prep_sm = true;
+		dpn[i].ch_prep_timeout = 10;
+		i++;
+	}
+	nval = hweight32(prop->sink_ports);
+	prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval,
+					   sizeof(*prop->sink_dpn_prop), GFP_KERNEL);
+	if (!prop->sink_dpn_prop)
+		return -ENOMEM;
+	j = 0;
+	dpn = prop->sink_dpn_prop;
+	addr = prop->sink_ports;
+	for_each_set_bit(bit, &addr, 32) {
+		dpn[j].num = bit;
+		dpn[j].type = SDW_DPN_FULL;
+		dpn[j].simple_ch_prep_sm = true;
+		dpn[j].ch_prep_timeout = 10;
+		j++;
+	}
+	prop->clk_stop_timeout = 900;
+	/*
+	 * Use MIPI simple clock-stop: avoids sdw_bus_wait_for_clk_prep_deprep()
+	 * on SDW_BROADCAST_DEV_NUM (15). Kernel logs "slave:15" for that wait,
+	 * not a second physical device — SN622X is typically dev_num 6 on LNL.
+	 */
+	prop->simple_clk_stop_capable = true;
+	/*
+	 * SN6224: DPN_LaneCtrl writes return -ENODATA
+	 * (Command Ignored) and block prepare. Skip lane programming until
+	 * DisCo/ACPI provides a valid lane map for this silicon.
+	 */
+	prop->lane_control_support = false;
+	SN622X_DBG(&slave->dev,
+		   "read_prop: src_ports=0x%x sink_ports=0x%x lane irq paging\n",
+		   prop->source_ports, prop->sink_ports);
+
+	return 0;
+}
+
+/* PoC: clear DP0 sticky bits so bus alert handler can finish (DevNum assign). */
+static int sn622x_clear_dp0_int(struct sdw_slave *slave)
+{
+	int status, status2, ret, count = 0;
+	u8 clear, impl_int_mask;
+
+	status = sdw_read_no_pm(slave, SDW_DP0_INT);
+	if (status < 0)
+		return status;
+
+	do {
+		clear = status & ~(SDW_DP0_INTERRUPTS | SDW_DP0_SDCA_CASCADE);
+
+		if (status & SDW_DP0_INT_TEST_FAIL)
+			clear |= SDW_DP0_INT_TEST_FAIL;
+
+		if (status & SDW_DP0_INT_PORT_READY) {
+			complete(&slave->port_ready[0]);
+			clear |= SDW_DP0_INT_PORT_READY;
+		}
+
+		if (status & SDW_DP0_INT_BRA_FAILURE)
+			clear |= SDW_DP0_INT_BRA_FAILURE;
+
+		impl_int_mask = SDW_DP0_INT_IMPDEF1 | SDW_DP0_INT_IMPDEF2 |
+				SDW_DP0_INT_IMPDEF3;
+		if (status & impl_int_mask)
+			clear |= impl_int_mask;
+
+		ret = sdw_write_no_pm(slave, SDW_DP0_INT, clear);
+		if (ret < 0)
+			return ret;
+
+		status2 = sdw_read_no_pm(slave, SDW_DP0_INT);
+		if (status2 < 0)
+			return status2;
+		status &= status2;
+		count++;
+	} while ((status & SDW_DP0_INTERRUPTS) && count < 8);
+
+	return 0;
+}
+
+/*
+ * Clear SDCA INT1/2 and DP0 cascade. Pending IRQs block clock-stop prepare
+ * (SDW_SCP_STAT CLK_STP_NF never clears -> -ETIMEDOUT on slave:15).
+ */
+static int sn622x_sdca_flush_pending_irqs(struct sn622x_sdca_priv *sn622x,
+					  struct device *dev)
+{
+	int ret, stat = 0;
+	int count = 0;
+	const int retry = 3;
+	unsigned int sdca_cascade, scp_sdca_stat1, scp_sdca_stat2 = 0;
+
+	if (!sn622x || !sn622x->slave)
+		return 0;
+
+	ret = sdw_read_no_pm(sn622x->slave, SDW_SCP_SDCA_INT1);
+	if (ret < 0)
+		return ret;
+	sn622x->scp_sdca_stat1 = ret;
+
+	ret = sdw_read_no_pm(sn622x->slave, SDW_SCP_SDCA_INT2);
+	if (ret < 0)
+		return ret;
+	sn622x->scp_sdca_stat2 = ret;
+
+	do {
+		ret = sdw_read_no_pm(sn622x->slave, SDW_SCP_SDCA_INT1);
+		if (ret < 0)
+			return ret;
+		if (ret & SDW_SCP_SDCA_INTMASK_SDCA_0) {
+			ret = sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INT1,
+					      SDW_SCP_SDCA_INTMASK_SDCA_0);
+			if (ret < 0)
+				return ret;
+		}
+
+		ret = sdw_read_no_pm(sn622x->slave, SDW_SCP_SDCA_INT2);
+		if (ret < 0)
+			return ret;
+		if (ret & SDW_SCP_SDCA_INTMASK_SDCA_8) {
+			ret = sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INT2,
+					      SDW_SCP_SDCA_INTMASK_SDCA_8);
+			if (ret < 0)
+				return ret;
+		}
+
+		ret = sn622x_clear_dp0_int(sn622x->slave);
+		if (ret < 0)
+			return ret;
+
+		ret = sdw_read_no_pm(sn622x->slave, SDW_DP0_INT);
+		if (ret < 0)
+			return ret;
+		sdca_cascade = ret & SDW_DP0_SDCA_CASCADE;
+
+		ret = sdw_read_no_pm(sn622x->slave, SDW_SCP_SDCA_INT1);
+		if (ret < 0)
+			return ret;
+		scp_sdca_stat1 = ret & SDW_SCP_SDCA_INTMASK_SDCA_0;
+
+		ret = sdw_read_no_pm(sn622x->slave, SDW_SCP_SDCA_INT2);
+		if (ret < 0)
+			return ret;
+		scp_sdca_stat2 = ret & SDW_SCP_SDCA_INTMASK_SDCA_8;
+
+		stat = scp_sdca_stat1 || scp_sdca_stat2 || sdca_cascade;
+		count++;
+	} while (stat != 0 && count < retry);
+
+	if (stat && dev)
+		dev_warn(dev,
+			 "sn622x: SDCA IRQ flush incomplete (stat=%u)\n", stat);
+
+	return stat ? -EBUSY : 0;
+}
+
+static int sn622x_sdca_clk_stop(struct sdw_slave *slave,
+				enum sdw_clk_stop_mode mode,
+				enum sdw_clk_stop_type type)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
+
+	if (!sn622x)
+		return 0;
+
+	switch (type) {
+	case SDW_CLK_PRE_PREPARE:
+		mutex_lock(&sn622x->disable_irq_lock);
+		sn622x_sdca_flush_pending_irqs(sn622x, &slave->dev);
+		mutex_unlock(&sn622x->disable_irq_lock);
+		dev_dbg(&slave->dev, "sn622x: clk_stop PRE_PREPARE\n");
+		break;
+	case SDW_CLK_POST_DEPREPARE:
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int sn622x_sdca_interrupt_callback(struct sdw_slave *slave,
+					  struct sdw_slave_intr_status *status)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
+	int ret;
+
+	if (!sn622x)
+		return 0;
+
+	/*
+	 * bus.c sdw_handle_slave_alerts() expects the codec to clear SDCA INT1/2
+	 * when DP0 SDCA_CASCADE is set. Skipping INT clear leaves stat!=0 ->
+	 * "Reached MAX_RETRY on alert read" and dev_num never assigned.
+	 */
+
+	SN622X_DBG(&slave->dev,
+		   "irq: control_port=%#x sdca_cascade=%u disable_irq=%d\n",
+		   status->control_port, status->sdca_cascade, sn622x->disable_irq);
+
+	mutex_lock(&sn622x->disable_irq_lock);
+
+	ret = sn622x_sdca_flush_pending_irqs(sn622x, &slave->dev);
+	if (ret < 0 && ret != -EBUSY)
+		goto io_error;
+
+	SN622X_DBG(&slave->dev, "irq: INT1=0x%x INT2=0x%x\n",
+		   sn622x->scp_sdca_stat1, sn622x->scp_sdca_stat2);
+
+	mutex_unlock(&sn622x->disable_irq_lock);
+	return 0;
+
+io_error:
+	mutex_unlock(&sn622x->disable_irq_lock);
+	dev_err_ratelimited(&slave->dev, "%s: IO error (%d)\n", __func__, ret);
+	return ret;
+}
+
+static const struct sdw_slave_ops sn622x_sdca_slave_ops = {
+	.read_prop = sn622x_sdca_read_prop,
+	.interrupt_callback = sn622x_sdca_interrupt_callback,
+	.update_status = sn622x_sdca_update_status,
+	.clk_stop = sn622x_sdca_clk_stop,
+};
+
+static int sn622x_sdca_probe(struct snd_soc_component *component)
+{
+	struct sn622x_sdca_priv *sn622x = snd_soc_component_get_drvdata(component);
+	int ret;
+
+	sn622x->component = component;
+
+	if (!sn622x->first_hw_init)
+		return 0;
+
+	ret = pm_runtime_resume(component->dev);
+	if (ret < 0 && ret != -EACCES)
+		return ret;
+
+	return 0;
+}
+
+static int sn622x_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
+				     struct snd_pcm_hw_params *params,
+				     struct snd_soc_dai *dai)
+{
+	struct snd_soc_component *component = dai->component;
+	struct sn622x_sdca_priv *sn622x = snd_soc_component_get_drvdata(component);
+	struct sdw_stream_config stream_config = {};
+	struct sdw_port_config port_config = {};
+	struct sdw_stream_runtime *sdw_stream;
+	int port;
+	int ret;
+	bool got_pm = false;
+
+	sdw_stream = snd_soc_dai_get_dma_data(dai, substream);
+	if (!sdw_stream) {
+		dev_warn(dai->dev,
+			 "sn622x: hw_params: no SDW stream (set_stream not run yet?)\n");
+		return -EINVAL;
+	}
+	if (!sn622x->slave) {
+		dev_warn(dai->dev, "sn622x: hw_params: slave NULL\n");
+		return -EINVAL;
+	}
+	/* No stream programming while slave is not ATTACHED (-ENODEV, no bus poll). */
+	if (!sn622x_slave_attached(sn622x->slave)) {
+		dev_err_ratelimited(dai->dev,
+				    "sn622x: hw_params: slave not ATTACHED\n");
+		return -ENODEV;
+	}
+
+	dev_dbg(dai->dev, "sn622x: hw_params: dai=%s id=%d stream=%s\n",
+		dai->name, dai->id, snd_pcm_stream_str(substream));
+
+	ret = pm_runtime_resume_and_get(component->dev);
+	if (ret < 0 && ret != -EACCES) {
+		dev_err(dai->dev,
+			"sn622x: hw_params: pm_runtime_resume_and_get failed (%d)\n",
+			ret);
+		return ret;
+	}
+	if (ret == 0)
+		got_pm = true;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (dai->id == SN622X_DAI_SPEAKER)
+			port = SN622X_PORT_SPEAKER_PLAYBACK;
+		else {
+			ret = -EINVAL;
+			goto out;
+		}
+	} else {
+		if (dai->id == SN622X_DAI_DMIC)
+			port = SN622X_PORT_DMIC_CAPTURE;
+		else {
+			ret = -EINVAL;
+			goto out;
+		}
+	}
+
+	/* Fixed 48 kHz; accept S24_LE opens but use 16-bit SDW frames when asked. */
+	if (params_rate(params) != 48000) {
+		dev_err(dai->dev, "%s: Rate %d is not supported\n",
+			__func__, params_rate(params));
+		ret = -EINVAL;
+		goto out;
+	}
+
+	snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
+	stream_config.frame_rate = 48000;
+	if (stream_config.bps > 16 &&
+	    params_format(params) == SNDRV_PCM_FORMAT_S16_LE)
+		stream_config.bps = 16;
+	port_config.num = port;
+
+	ret = sdw_stream_add_slave(sn622x->slave, &stream_config,
+				   &port_config, 1, sdw_stream);
+
+	if (ret) {
+		dev_err(dai->dev, "%s: sdw_stream_add_slave port %d failed: %d\n",
+			__func__, port, ret);
+		goto out;
+	}
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+	    dai->id == SN622X_DAI_SPEAKER) {
+		sn622x->playback_active |= SN622X_PB_ACTIVE_SPK;
+		ret = regmap_write(sn622x->regmap, SN622X_REG_RATE_SEL, 0x01);
+		if (ret < 0)
+			dev_warn(dai->dev,
+				 "sn622x: hw_params: speaker rate_sel failed (%d)\n",
+				 ret);
+		sn622x_speaker_playback_prepare(dai->dev, sn622x);
+	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
+		   dai->id == SN622X_DAI_DMIC) {
+		sn622x->dmic_route_latched = false;
+		sn622x->dmic_rate = params_rate(params);
+		ret = regmap_write(sn622x->regmap, SN622X_REG_DMIC_CAP_RATE_SEL,
+				   0x01);
+		if (ret < 0)
+			dev_warn(dai->dev,
+				 "sn622x: hw_params: dmic rate_sel failed (%d)\n",
+				 ret);
+		sn622x_dmic_capture_prepare(dai->dev, sn622x, sn622x->dmic_rate,
+					    true);
+	}
+out:
+	if (got_pm) {
+		pm_runtime_mark_last_busy(component->dev);
+		pm_runtime_put_autosuspend(component->dev);
+	}
+	return ret;
+}
+
+static int sn622x_sdca_pcm_hw_free(struct snd_pcm_substream *substream,
+				   struct snd_soc_dai *dai)
+{
+	struct snd_soc_component *component = dai->component;
+	struct sn622x_sdca_priv *sn622x = snd_soc_component_get_drvdata(component);
+	struct sdw_stream_runtime *sdw_stream =
+		snd_soc_dai_get_dma_data(dai, substream);
+	int port;
+	bool got_pm = false;
+	int ret;
+
+	if (!sn622x->slave)
+		return -EINVAL;
+
+	port = sn622x_hw_params_port(dai, substream);
+	if (port < 0)
+		return port;
+
+	ret = pm_runtime_resume_and_get(component->dev);
+	if (ret < 0 && ret != -EACCES)
+		return ret;
+	if (ret == 0)
+		got_pm = true;
+
+
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
+	    dai->id == SN622X_DAI_DMIC) {
+		sn622x->dmic_active = false;
+		sn622x->dmic_route_latched = false;
+		sn622x->dmic_recover_until = 0;
+		cancel_delayed_work_sync(&sn622x->bus_recover_work);
+	}
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+	    dai->id == SN622X_DAI_SPEAKER) {
+		sn622x->playback_active &= ~SN622X_PB_ACTIVE_SPK;
+	}
+
+	sdw_stream_remove_slave(sn622x->slave, sdw_stream);
+
+	if (got_pm) {
+		pm_runtime_mark_last_busy(component->dev);
+		pm_runtime_put_autosuspend(component->dev);
+	}
+	return 0;
+}
+
+static int sn622x_sdca_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
+				      int direction)
+{
+	snd_soc_dai_dma_data_set(dai, direction, sdw_stream);
+	return 0;
+}
+
+static void sn622x_sdca_shutdown(struct snd_pcm_substream *substream,
+				 struct snd_soc_dai *dai)
+{
+	snd_soc_dai_set_dma_data(dai, substream, NULL);
+}
+
+/*
+ * Speaker (SDCA function 1) and DMIC (function 2): one PDE SUPPLY per function.
+ * Duplex is two DAPM paths; each stream powers only its own PDE/FU (sn624x-style).
+ * HP/speaker mux is outside this driver.
+ */
+static const struct snd_soc_dapm_widget sn622x_sdca_dapm_widgets[] = {
+	SND_SOC_DAPM_AIF_IN("SPK RX", "Speaker Playback", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("DMIC TX", "DMic Capture", 0, SND_SOC_NOPM, 0, 0),
+
+	SND_SOC_DAPM_SUPPLY("PDE SPK", SND_SOC_NOPM, 0, 0,
+			    sn622x_pde_spk_event,
+			    SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+	SND_SOC_DAPM_SUPPLY("PDE DMIC", SND_SOC_NOPM, 0, 0,
+			    sn622x_pde_dmic_event,
+			    SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+
+	SND_SOC_DAPM_DAC_E("FU SPK", NULL, SND_SOC_NOPM, 0, 0,
+			   sn622x_fu_spk_event,
+			   SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+	SND_SOC_DAPM_ADC_E("FU DMIC", NULL, SND_SOC_NOPM, 0, 0,
+			   sn622x_fu_dmic_event,
+			   SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+
+	SND_SOC_DAPM_OUTPUT("SPK"),
+	SND_SOC_DAPM_INPUT("DMIC"),
+};
+
+static const struct snd_soc_dapm_route sn622x_sdca_audio_map[] = {
+	{ "FU SPK", NULL, "SPK RX" },
+	{ "FU SPK", NULL, "PDE SPK" },
+	{ "SPK", NULL, "FU SPK" },
+
+	{ "FU DMIC", NULL, "DMIC" },
+	{ "FU DMIC", NULL, "PDE DMIC" },
+	{ "DMIC TX", NULL, "FU DMIC" },
+};
+
+static int sn622x_sdca_trigger(struct snd_pcm_substream *substream, int cmd,
+			      struct snd_soc_dai *dai)
+{
+	struct snd_soc_component *component = dai->component;
+	struct sn622x_sdca_priv *sn622x = snd_soc_component_get_drvdata(component);
+	bool got_pm = false;
+	int ret;
+
+	if (cmd != SNDRV_PCM_TRIGGER_START &&
+	    cmd != SNDRV_PCM_TRIGGER_RESUME &&
+	    cmd != SNDRV_PCM_TRIGGER_PAUSE_RELEASE)
+		return 0;
+
+	ret = pm_runtime_resume_and_get(component->dev);
+	if (ret < 0 && ret != -EACCES)
+		return ret;
+	if (ret == 0)
+		got_pm = true;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+	    dai->id == SN622X_DAI_SPEAKER)
+		sn622x_speaker_fu_unmute(dai->dev, sn622x);
+	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
+		 dai->id == SN622X_DAI_DMIC) {
+		sn622x->dmic_rate = substream->runtime->rate;
+		sn622x->dmic_active = true;
+		if (!sn622x->dmic_route_latched)
+			sn622x_dmic_capture_prepare(dai->dev, sn622x,
+						    sn622x->dmic_rate, false);
+		sn622x_dmic_fu_unmute(dai->dev, sn622x);
+	}
+
+	if (got_pm) {
+		pm_runtime_mark_last_busy(component->dev);
+		pm_runtime_put_autosuspend(component->dev);
+	}
+	return 0;
+}
+
+static const struct snd_soc_dai_ops sn622x_sdca_ops = {
+	.hw_params	= sn622x_sdca_pcm_hw_params,
+	.hw_free	= sn622x_sdca_pcm_hw_free,
+	.trigger	= sn622x_sdca_trigger,
+	.set_stream	= sn622x_sdca_set_sdw_stream,
+	.shutdown	= sn622x_sdca_shutdown,
+};
+
+static struct snd_soc_dai_driver sn622x_sdca_dai[] = {
+	{
+		.name = "sn622x-sdca-aif",
+		.id = SN622X_DAI_SPEAKER,
+		.playback = {
+			.stream_name = "Speaker Playback",
+			.channels_min = 1,
+			.channels_max = 2,
+			.rates = SN622X_STEREO_RATES,
+			.formats = SN622X_FORMATS,
+		},
+		.ops = &sn622x_sdca_ops,
+	},
+	{
+		.name = "sn622x-sdca-aif2",
+		.id = SN622X_DAI_DMIC,
+		.capture = {
+			.stream_name = "DMic Capture",
+			.channels_min = 1,
+			.channels_max = 2,
+			.rates = SN622X_STEREO_RATES,
+			.formats = SN622X_FORMATS,
+		},
+		.ops = &sn622x_sdca_ops,
+	},
+};
+
+static const struct snd_soc_component_driver soc_sdca_dev_sn622x = {
+	.probe = sn622x_sdca_probe,
+	.dapm_widgets = sn622x_sdca_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(sn622x_sdca_dapm_widgets),
+	.dapm_routes = sn622x_sdca_audio_map,
+	.num_dapm_routes = ARRAY_SIZE(sn622x_sdca_audio_map),
+	/* SN6220: no jack detect — HP path switched externally */
+	.set_jack = NULL,
+	.endianness = 1,
+};
+
+int sn622x_sdca_init(struct device *dev, struct regmap *regmap,
+		     struct sdw_slave *slave)
+{
+	struct sn622x_sdca_priv *sn622x;
+	int ret;
+
+	sn622x = devm_kzalloc(dev, sizeof(*sn622x), GFP_KERNEL);
+	if (!sn622x)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, sn622x);
+	sn622x->slave = slave;
+	sn622x->regmap = regmap;
+
+	ret = sn622x_parse_sdca_functions(sn622x);
+	if (ret < 0)
+		return ret;
+
+	mutex_init(&sn622x->disable_irq_lock);
+	mutex_init(&sn622x->path_lock);
+	INIT_DELAYED_WORK(&sn622x->bus_recover_work, sn622x_bus_recover_work);
+
+	regcache_cache_only(sn622x->regmap, true);
+
+	ret = devm_snd_soc_register_component(dev,
+					      &soc_sdca_dev_sn622x, sn622x_sdca_dai,
+					      ARRAY_SIZE(sn622x_sdca_dai));
+	if (ret < 0)
+		return ret;
+
+	pm_runtime_set_autosuspend_delay(dev, 3000);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_mark_last_busy(dev);
+	/*
+	 * Fresh probe: disable_depth is already 1. Only disable when a previous
+	 * instance left runtime_error set, then enable exactly once.
+	 */
+	if (dev->power.runtime_error)
+		pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
+	pm_runtime_enable(dev);
+
+	return 0;
+}
+
+static int sn622x_sdca_sdw_probe(struct sdw_slave *slave,
+				 const struct sdw_device_id *id)
+{
+	struct regmap *regmap;
+	int ret;
+
+	SN622X_DBG(&slave->dev, "sdw_probe: dev_num=%u status=%s\n",
+		   slave->dev_num, sn622x_status_str(slave->status));
+
+	/*
+	 * read_prop runs once at slave add; force again on driver bind so a
+	 * module reload picks up lane_control_support=false without reboot.
+	 */
+	slave->prop.lane_control_support = false;
+
+	regmap = devm_regmap_init_sdw_mbq_cfg(&slave->dev, slave,
+					      &sn622x_sdca_regmap,
+					      &sn622x_sdca_mbq_cfg);
+	if (IS_ERR(regmap)) {
+		dev_err(&slave->dev,
+			"sn622x: devm_regmap_init_sdw_mbq_cfg failed (%ld)\n",
+			PTR_ERR(regmap));
+		return PTR_ERR(regmap);
+	}
+
+	ret = sn622x_sdca_init(&slave->dev, regmap, slave);
+	if (ret < 0)
+		dev_err(&slave->dev, "sn622x: sn622x_sdca_init failed (%d)\n", ret);
+	else {
+		struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
+
+		if (sn622x)
+			sn622x_sdca_sdca_irq_mask_all(sn622x);
+		SN622X_DBG(&slave->dev, "SoundWire probe finished OK\n");
+	}
+
+	return ret;
+}
+
+static void sn622x_sdca_sdw_remove(struct sdw_slave *slave)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
+
+	SN622X_DBG(&slave->dev, "SoundWire driver remove\n");
+	sn622x->dmic_active = false;
+	cancel_delayed_work_sync(&sn622x->bus_recover_work);
+	if (sn622x->first_hw_init)
+		pm_runtime_disable(&slave->dev);
+	mutex_destroy(&sn622x->disable_irq_lock);
+}
+
+static const struct sdw_device_id sn622x_sdca_id[] = {
+	/*
+	 * SN6220: 0x184c and 0x6220. SN6224: 0x1850 and 0x6224.
+	 * 0x6220/0x6224 follow SN624x (0x6244) part_id naming; not 0x1864 (SN624x).
+	 */
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x184c, 0x3, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x184c, 0x0, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x6220, 0x3, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x6220, 0x0, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x1850, 0x3, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x1850, 0x0, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x6224, 0x3, 0x1, 0),
+	SDW_SLAVE_ENTRY_EXT(0x0496, 0x6224, 0x0, 0x1, 0),
+	{ }
+};
+MODULE_DEVICE_TABLE(sdw, sn622x_sdca_id);
+
+static int sn622x_sdca_dev_suspend(struct device *dev)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
+
+	if (!sn622x->first_hw_init)
+		return 0;
+
+	SN622X_DBG(dev, "runtime suspend\n");
+
+	regcache_cache_only(sn622x->regmap, true);
+
+	return 0;
+}
+
+static int sn622x_sdca_dev_system_suspend(struct device *dev)
+{
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
+
+	if (!sn622x->first_hw_init)
+		return 0;
+
+	SN622X_DBG(dev, "system suspend: mask SDCA IRQs\n");
+	mutex_lock(&sn622x->disable_irq_lock);
+	sn622x->disable_irq = true;
+	sn622x_sdca_sdca_irq_mask_all(sn622x);
+	mutex_unlock(&sn622x->disable_irq_lock);
+
+	return sn622x_sdca_dev_suspend(dev);
+}
+
+static int sn622x_sdca_dev_resume(struct device *dev)
+{
+	struct sdw_slave *slave = dev_to_sdw_dev(dev);
+	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
+	int ret;
+
+	if (!sn622x->first_hw_init)
+		return 0;
+
+	SN622X_DBG(dev, "resume: unattach_request=%u status=%s\n",
+		   slave->unattach_request, sn622x_status_str(slave->status));
+
+	if (slave->unattach_request) {
+		ret = sdw_slave_wait_for_init(slave, SN622X_PROBE_TIMEOUT_MS);
+		if (ret)
+			dev_dbg(dev, "sn622x: resume: init wait failed (%d)\n", ret);
+	}
+
+	mutex_lock(&sn622x->disable_irq_lock);
+	sn622x->disable_irq = false;
+	mutex_unlock(&sn622x->disable_irq_lock);
+
+	slave->unattach_request = 0;
+	if (!sn622x_slave_attached(slave))
+		return 0;
+
+	/* Resume: enable regmap I/O; avoid regcache_sync (stale cache vs live device). */
+	regcache_cache_only(sn622x->regmap, false);
+
+	return 0;
+}
+
+static const struct dev_pm_ops sn622x_sdca_pm = {
+	SYSTEM_SLEEP_PM_OPS(sn622x_sdca_dev_system_suspend, sn622x_sdca_dev_resume)
+	RUNTIME_PM_OPS(sn622x_sdca_dev_suspend, sn622x_sdca_dev_resume, NULL)
+};
+
+static struct sdw_driver sn622x_sdca_sdw_driver = {
+	.driver = {
+		.name = "sn622x-sdca",
+		.pm = pm_ptr(&sn622x_sdca_pm),
+	},
+	.probe = sn622x_sdca_sdw_probe,
+	.remove = sn622x_sdca_sdw_remove,
+	.ops = &sn622x_sdca_slave_ops,
+	.id_table = sn622x_sdca_id,
+};
+module_sdw_driver(sn622x_sdca_sdw_driver);
+
+MODULE_DESCRIPTION("ASoC SN622X SDCA SoundWire driver speaker+DMIC (no jack detect; HP mux external)");
+MODULE_AUTHOR("Senary Semiconductor Corp.");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("SND_SOC_SDCA");
+MODULE_SOFTDEP("pre: snd-soc-sdca");
diff --git a/sound/soc/codecs/sn622x-sdca.h b/sound/soc/codecs/sn622x-sdca.h
new file mode 100644
index 000000000..9b8105272
--- /dev/null
+++ b/sound/soc/codecs/sn622x-sdca.h
@@ -0,0 +1,104 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * sn622x-sdca.h -- SN622X (SN6220) SDCA ALSA SoC audio driver header
+ * SN6220: speaker + SoftMic/DMIC only. No jack detect; HP mux is external.
+ *
+ * Copyright(c) 2025 Senary Semiconductor Corp.
+ */
+
+#ifndef __SN622X_SDCA_H__
+#define __SN622X_SDCA_H__
+
+#include <linux/bits.h>
+#include <linux/mutex.h>
+#include <linux/soundwire/sdw.h>
+#include <linux/workqueue.h>
+#include <sound/sdca_function.h>
+#include <sound/soc.h>
+
+/*
+ * SDCA function numbers (SN6220 DisCo / ACPI topology — speaker + mic only).
+ */
+#define SN622X_FUNC_NUM_SPEAKER		0x01
+#define SN622X_FUNC_NUM_MIC_ARRAY	0x02
+
+/* Entity instance IDs */
+#define SN622X_SDCA_ENT_ENTITY0		0x00
+#define SN622X_SDCA_ENT_CS01		0x01
+#define SN622X_SDCA_ENT_CS02		0x02
+#define SN622X_SDCA_ENT_PDE03		0x03
+#define SN622X_SDCA_ENT_MFPU08		0x08
+#define SN622X_SDCA_ENT_USER_FU10	0x10
+#define SN622X_SDCA_ENT_USER_FU20	0x20
+
+#define SN622X_SDCA_CTL_FU_MUTE			SDCA_CTL_FU_MUTE
+#define SN622X_SDCA_CTL_FU_VOLUME		SDCA_CTL_FU_CHANNEL_VOLUME
+#define SN622X_SDCA_CTL_SAMPLE_FREQ_INDEX	SDCA_CTL_CS_SAMPLERATEINDEX
+#define SN622X_SDCA_CTL_FUNCTION_STATUS		SDCA_CTL_ENTITY_0_FUNCTION_STATUS
+#define SN622X_SDCA_CH_L		0x01
+#define SN622X_SDCA_CH_R		0x02
+
+struct sn622x_sdca_priv {
+	struct regmap *regmap;
+	struct snd_soc_component *component;
+	struct sdw_slave *slave;
+	bool hw_init;
+	bool first_hw_init;
+	struct delayed_work bus_recover_work; /* io_init + DMIC retry after UNATTACH */
+	struct sdca_function_data *speaker_func;
+	struct sdca_function_data *mic_func;
+	unsigned long last_unattach_jiffies;
+	unsigned int dmic_rate;
+	bool dmic_active;
+	bool dmic_route_latched; /* capture vendor prepare done this stream */
+	bool dmic_cap_cfg_done; /* DMIC vendor cfg latched since last ATTACH */
+	bool dmic_analog_restored; /* DMIC init table done (retain across UNATTACH) */
+	unsigned long dmic_recover_until; /* jiffies: capture prepare retries */
+	unsigned int unattach_storm; /* UNATTACH count in 2s window */
+	struct mutex path_lock;	   /* serialize capture/speaker prepare vs io_init */
+	struct mutex disable_irq_lock;
+	bool disable_irq;
+	unsigned int playback_active;	/* SN622X_PB_ACTIVE_* while PCM open */
+	unsigned int scp_sdca_stat1;
+	unsigned int scp_sdca_stat2;
+};
+
+/*
+ * SoundWire data port numbers (SN6220: speaker port 1, DMIC port 3).
+ */
+#define SN622X_PORT_SPEAKER_PLAYBACK		1
+#define SN622X_PORT_DMIC_CAPTURE		3
+
+/* Order matches sn622x_sdca_dai[] .id — speaker + dmic only */
+enum sn622x_dai_id {
+	SN622X_DAI_SPEAKER = 0,
+	SN622X_DAI_DMIC = 1,
+};
+
+/* playback_active bits (set in hw_params, cleared in hw_free) */
+#define SN622X_PB_ACTIVE_SPK			BIT(0)
+
+/* µs settle times for path prepare */
+#define SN622X_ROUTE_AFTER_MUTE_US_MIN		5000
+#define SN622X_ROUTE_AFTER_MUTE_US_MAX		8000
+#define SN622X_ROUTE_AFTER_D3_US_MIN		10000
+#define SN622X_ROUTE_AFTER_D3_US_MAX		15000
+#define SN622X_ROUTE_BEFORE_ACTIVE_US_MIN	10000
+#define SN622X_ROUTE_BEFORE_ACTIVE_US_MAX	15000
+#define SN622X_UAJ_DMIC_PPU11			0x40880380
+
+#define SN622X_BUS_RECOVER_SETTLE_MS		400
+#define SN622X_BUS_RECOVER_DMIC_MS		150
+#define SN622X_UNATTACH_STORM_MAX		5
+#define SN622X_UNATTACH_STORM_WINDOW_MS		2000
+#define SN622X_ATTACH_DEBOUNCE_MS		400
+
+/* 48 kHz only; advertise S24_LE for SOF, use 16-bit SDW frames when host uses S16. */
+#define SN622X_STEREO_RATES	SNDRV_PCM_RATE_48000
+#define SN622X_FORMATS		(SNDRV_PCM_FMTBIT_S16_LE | \
+				 SNDRV_PCM_FMTBIT_S24_LE)
+
+int sn622x_sdca_init(struct device *dev, struct regmap *regmap,
+		     struct sdw_slave *slave);
+
+#endif /* __SN622X_SDCA_H__ */
-- 
2.43.0


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

* [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks
  2026-12-01  2:56 [PATCH v2 0/3] ASoC: add Senary SN622x SDCA SoundWire support Qianghua Wang
  2026-12-01  2:56 ` [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support Qianghua Wang
@ 2026-12-01  2:56 ` Qianghua Wang
  2026-12-01  3:08   ` sashiko-bot
  2026-12-01  2:56 ` [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines Qianghua Wang
  2 siblings, 1 reply; 7+ messages in thread
From: Qianghua Wang @ 2026-12-01  2:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-sound, alsa-devel, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Cezary Rojewski, Peter Ujfalusi, Kai Vehmanen,
	Pierre-Louis Bossart, bo liu, Qianghua Wang

Register SN6220/SN6224 part_id entries (0x184c/0x6220 and 0x1850/0x6224) in
codec_info_list, add sn622x speaker DAPM routes, and use dynamic name_prefix
for Senary DMIC card routing (senary_dmic widgets/controls shared with SN624x).

Signed-off-by: Qianghua Wang <qianghua.wang@senarytech.com>
---
 sound/soc/sdw_utils/soc_sdw_senary_dmic.c |  19 +-
 sound/soc/sdw_utils/soc_sdw_senary_sdca.c |   9 +-
 sound/soc/sdw_utils/soc_sdw_utils.c       | 205 ++++++++++++++++++++--
 3 files changed, 203 insertions(+), 30 deletions(-)

diff --git a/sound/soc/sdw_utils/soc_sdw_senary_dmic.c b/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
index 725f4658e..ab351a5c1 100644
--- a/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
+++ b/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
@@ -10,11 +10,6 @@
 #include <sound/soc-dapm.h>
 #include <sound/soc_sdw_utils.h>
 
-/* Card pin "Dmic" → codec input (name_prefix + " DMIC") */
-static const struct snd_soc_dapm_route senary_dmic_map[] = {
-	{ "sn624x DMIC", NULL, "Dmic" },
-};
-
 static const struct snd_soc_dapm_route senary_dmic_map_bare[] = {
 	{ "DMIC", NULL, "Dmic" },
 };
@@ -24,17 +19,23 @@ int asoc_sdw_senary_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
 	struct snd_soc_card *card = rtd->card;
 	struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
 	struct snd_soc_component *component;
+	struct snd_soc_dapm_route route;
+	char *codec_dmic;
 	char *mic_name;
 	int ret;
 
 	component = dai->component;
 
 	if (component->name_prefix) {
-		ret = snd_soc_dapm_add_routes(dapm, senary_dmic_map,
-					      ARRAY_SIZE(senary_dmic_map));
+		codec_dmic = devm_kasprintf(card->dev, GFP_KERNEL, "%s DMIC",
+					    component->name_prefix);
+		if (!codec_dmic)
+			return -ENOMEM;
+		route = (struct snd_soc_dapm_route){ codec_dmic, NULL, "Dmic" };
+		ret = snd_soc_dapm_add_routes(dapm, &route, 1);
 		mic_name = devm_kstrdup(card->dev, component->name_prefix, GFP_KERNEL);
 	} else {
-		dev_warn(card->dev, "sn624x dmic: component %s has no name_prefix\n",
+		dev_warn(card->dev, "senary dmic: component %s has no name_prefix\n",
 			 component->name);
 		ret = snd_soc_dapm_add_routes(dapm, senary_dmic_map_bare,
 					      ARRAY_SIZE(senary_dmic_map_bare));
@@ -57,4 +58,4 @@ int asoc_sdw_senary_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
 
 	return 0;
 }
-EXPORT_SYMBOL_NS(asoc_sdw_senary_dmic_rtd_init, "SND_SOC_SDW_UTILS");
+EXPORT_SYMBOL_NS(asoc_sdw_senary_dmic_rtd_init, "SND_SOC_SDW_UTILS");
\ No newline at end of file
diff --git a/sound/soc/sdw_utils/soc_sdw_senary_sdca.c b/sound/soc/sdw_utils/soc_sdw_senary_sdca.c
index 0adde845a..9c51d8588 100644
--- a/sound/soc/sdw_utils/soc_sdw_senary_sdca.c
+++ b/sound/soc/sdw_utils/soc_sdw_senary_sdca.c
@@ -22,6 +22,10 @@ static const struct snd_soc_dapm_route sn624x_spk_map_bare[] = {
 	{ "Speaker", NULL, "SPK" },
 };
 
+static const struct snd_soc_dapm_route sn622x_spk_map[] = {
+	{ "Speaker", NULL, "sn622x SPK" },
+};
+
 /* Structure to map codec names to respective route arrays and sizes */
 struct codec_route_map {
 	const char *codec_name;
@@ -31,6 +35,7 @@ struct codec_route_map {
 
 /* Codec route maps array */
 static const struct codec_route_map codec_routes[] = {
+	{ "sn622x", sn622x_spk_map, ARRAY_SIZE(sn622x_spk_map) },
 	{ "sn624x", sn624x_spk_map, ARRAY_SIZE(sn624x_spk_map) },
 };
 
@@ -60,10 +65,10 @@ int asoc_sdw_senary_sdca_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct sn
 
 	/*
 	 * No name_prefix means the codec widgets were created as "SPK",
-	 * not "sn624x SPK". DAI name is still sn624x-sdca-aif2.
+	 * not "<prefix> SPK" (e.g. sn624x SPK / sn622x SPK).
 	 */
 	if (!dai->component->name_prefix) {
-		dev_warn(rtd->dev, "sn624x spk: component %s has no name_prefix\n",
+		dev_warn(rtd->dev, "senary spk: component %s has no name_prefix\n",
 			 dai->component->name);
 		routes = sn624x_spk_map_bare;
 		nroutes = ARRAY_SIZE(sn624x_spk_map_bare);
diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
index fefc4d7f5..f454fe4d9 100644
--- a/sound/soc/sdw_utils/soc_sdw_utils.c
+++ b/sound/soc/sdw_utils/soc_sdw_utils.c
@@ -17,12 +17,12 @@ static const struct snd_soc_dapm_widget generic_dmic_widgets[] = {
 	SND_SOC_DAPM_MIC("DMIC", NULL),
 };
 
-/* Senary SN624x UCM uses CaptureMixerElem "Dmic"; keep separate from generic DMIC. */
-static const struct snd_soc_dapm_widget sn624x_dmic_widgets[] = {
+/* Senary SN622x/SN624x: UCM "Dmic" + Dmic Switch (not generic "DMIC"). */
+static const struct snd_soc_dapm_widget senary_dmic_widgets[] = {
 	SND_SOC_DAPM_MIC("Dmic", NULL),
 };
 
-static const struct snd_kcontrol_new sn624x_dmic_controls[] = {
+static const struct snd_kcontrol_new senary_dmic_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Dmic"),
 };
 
@@ -1537,10 +1537,10 @@ struct asoc_sdw_codec_info codec_info_list[] = {
 				.dai_type = SOC_SDW_DAI_TYPE_MIC,
 				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
 				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
-				.widgets = sn624x_dmic_widgets,
-				.num_widgets = ARRAY_SIZE(sn624x_dmic_widgets),
-				.controls = sn624x_dmic_controls,
-				.num_controls = ARRAY_SIZE(sn624x_dmic_controls),
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
 				.quirk = SOC_SDW_CODEC_MIC,
 				.quirk_exclude = true,
 			},
@@ -1588,10 +1588,10 @@ struct asoc_sdw_codec_info codec_info_list[] = {
 				.dai_type = SOC_SDW_DAI_TYPE_MIC,
 				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
 				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
-				.widgets = sn624x_dmic_widgets,
-				.num_widgets = ARRAY_SIZE(sn624x_dmic_widgets),
-				.controls = sn624x_dmic_controls,
-				.num_controls = ARRAY_SIZE(sn624x_dmic_controls),
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
 				.quirk = SOC_SDW_CODEC_MIC,
 				.quirk_exclude = true,
 			},
@@ -1639,10 +1639,10 @@ struct asoc_sdw_codec_info codec_info_list[] = {
 				.dai_type = SOC_SDW_DAI_TYPE_MIC,
 				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
 				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
-				.widgets = sn624x_dmic_widgets,
-				.num_widgets = ARRAY_SIZE(sn624x_dmic_widgets),
-				.controls = sn624x_dmic_controls,
-				.num_controls = ARRAY_SIZE(sn624x_dmic_controls),
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
 				.quirk = SOC_SDW_CODEC_MIC,
 				.quirk_exclude = true,
 			},
@@ -1690,16 +1690,183 @@ struct asoc_sdw_codec_info codec_info_list[] = {
 				.dai_type = SOC_SDW_DAI_TYPE_MIC,
 				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
 				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
-				.widgets = sn624x_dmic_widgets,
-				.num_widgets = ARRAY_SIZE(sn624x_dmic_widgets),
-				.controls = sn624x_dmic_controls,
-				.num_controls = ARRAY_SIZE(sn624x_dmic_controls),
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
 				.quirk = SOC_SDW_CODEC_MIC,
 				.quirk_exclude = true,
 			},
 		},
 		.dai_num = 3,
 	},
+	/*
+	 * Senary SN622x: speaker amp + DMIC only (no UAJ jack).
+	 * SN6220 and SN6224 share topology; only SoundWire part_id differs.
+	 *
+	 * Silicone/ACPI may report either encoding (both observed in the field):
+	 *   SN624x-style part digits: SN6220 -> 0x6220, SN6224 -> 0x6224
+	 *     (same rule as SN6244 part_id 0x6244 in the table above).
+	 *   Decimal-as-value: SN6220 -> 0x184c (6220), SN6224 -> 0x1850 (6224).
+	 * One row per (vendor_id, part_id) pair — asoc_sdw_find_codec_info_part()
+	 * matches exactly. Do not use 0x1864 (6244 decimal, SN624x).
+	 */
+	/* SN6220, part_id 0x184c */
+	{
+		.vendor_id = 0x0496,
+		.part_id = 0x184c,
+		.name_prefix = "sn622x",
+		.ignore_internal_dmic = true,
+		.dais = {
+			{
+				.direction = {true, false},
+				.dai_name = "sn622x-sdca-aif",
+				.component_name = "sn622x",
+				.dai_type = SOC_SDW_DAI_TYPE_AMP,
+				.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
+				.init = asoc_sdw_senary_amp_init,
+				.exit = asoc_sdw_senary_amp_exit,
+				.rtd_init = asoc_sdw_senary_sdca_spk_rtd_init,
+				.controls = generic_spk_controls,
+				.num_controls = ARRAY_SIZE(generic_spk_controls),
+				.widgets = generic_spk_widgets,
+				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
+				.quirk = SOC_SDW_CODEC_SPKR,
+				.quirk_exclude = true,
+			},
+			{
+				.direction = {false, true},
+				.dai_name = "sn622x-sdca-aif2",
+				.dai_type = SOC_SDW_DAI_TYPE_MIC,
+				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
+				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
+				.quirk = SOC_SDW_CODEC_MIC,
+				.quirk_exclude = true,
+			},
+		},
+		.dai_num = 2,
+	},
+	/* SN6220, part_id 0x6220 */
+	{
+		.vendor_id = 0x0496,
+		.part_id = 0x6220,
+		.name_prefix = "sn622x",
+		.ignore_internal_dmic = true,
+		.dais = {
+			{
+				.direction = {true, false},
+				.dai_name = "sn622x-sdca-aif",
+				.component_name = "sn622x",
+				.dai_type = SOC_SDW_DAI_TYPE_AMP,
+				.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
+				.init = asoc_sdw_senary_amp_init,
+				.exit = asoc_sdw_senary_amp_exit,
+				.rtd_init = asoc_sdw_senary_sdca_spk_rtd_init,
+				.controls = generic_spk_controls,
+				.num_controls = ARRAY_SIZE(generic_spk_controls),
+				.widgets = generic_spk_widgets,
+				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
+				.quirk = SOC_SDW_CODEC_SPKR,
+				.quirk_exclude = true,
+			},
+			{
+				.direction = {false, true},
+				.dai_name = "sn622x-sdca-aif2",
+				.dai_type = SOC_SDW_DAI_TYPE_MIC,
+				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
+				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
+				.quirk = SOC_SDW_CODEC_MIC,
+				.quirk_exclude = true,
+			},
+		},
+		.dai_num = 2,
+	},
+	/* SN6224, part_id 0x1850 */
+	{
+		.vendor_id = 0x0496,
+		.part_id = 0x1850,
+		.name_prefix = "sn622x",
+		.ignore_internal_dmic = true,
+		.dais = {
+			{
+				.direction = {true, false},
+				.dai_name = "sn622x-sdca-aif",
+				.component_name = "sn622x",
+				.dai_type = SOC_SDW_DAI_TYPE_AMP,
+				.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
+				.init = asoc_sdw_senary_amp_init,
+				.exit = asoc_sdw_senary_amp_exit,
+				.rtd_init = asoc_sdw_senary_sdca_spk_rtd_init,
+				.controls = generic_spk_controls,
+				.num_controls = ARRAY_SIZE(generic_spk_controls),
+				.widgets = generic_spk_widgets,
+				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
+				.quirk = SOC_SDW_CODEC_SPKR,
+				.quirk_exclude = true,
+			},
+			{
+				.direction = {false, true},
+				.dai_name = "sn622x-sdca-aif2",
+				.dai_type = SOC_SDW_DAI_TYPE_MIC,
+				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
+				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
+				.quirk = SOC_SDW_CODEC_MIC,
+				.quirk_exclude = true,
+			},
+		},
+		.dai_num = 2,
+	},
+	/* SN6224, part_id 0x6224 */
+	{
+		.vendor_id = 0x0496,
+		.part_id = 0x6224,
+		.name_prefix = "sn622x",
+		.ignore_internal_dmic = true,
+		.dais = {
+			{
+				.direction = {true, false},
+				.dai_name = "sn622x-sdca-aif",
+				.component_name = "sn622x",
+				.dai_type = SOC_SDW_DAI_TYPE_AMP,
+				.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
+				.init = asoc_sdw_senary_amp_init,
+				.exit = asoc_sdw_senary_amp_exit,
+				.rtd_init = asoc_sdw_senary_sdca_spk_rtd_init,
+				.controls = generic_spk_controls,
+				.num_controls = ARRAY_SIZE(generic_spk_controls),
+				.widgets = generic_spk_widgets,
+				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
+				.quirk = SOC_SDW_CODEC_SPKR,
+				.quirk_exclude = true,
+			},
+			{
+				.direction = {false, true},
+				.dai_name = "sn622x-sdca-aif2",
+				.dai_type = SOC_SDW_DAI_TYPE_MIC,
+				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
+				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
+				.widgets = senary_dmic_widgets,
+				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
+				.controls = senary_dmic_controls,
+				.num_controls = ARRAY_SIZE(senary_dmic_controls),
+				.quirk = SOC_SDW_CODEC_MIC,
+				.quirk_exclude = true,
+			},
+		},
+		.dai_num = 2,
+	},
 };
 EXPORT_SYMBOL_NS(codec_info_list, "SND_SOC_SDW_UTILS");
 
-- 
2.43.0


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

* [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines
  2026-12-01  2:56 [PATCH v2 0/3] ASoC: add Senary SN622x SDCA SoundWire support Qianghua Wang
  2026-12-01  2:56 ` [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support Qianghua Wang
  2026-12-01  2:56 ` [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks Qianghua Wang
@ 2026-12-01  2:56 ` Qianghua Wang
  2026-12-01  3:06   ` sashiko-bot
  2 siblings, 1 reply; 7+ messages in thread
From: Qianghua Wang @ 2026-12-01  2:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-sound, alsa-devel, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Cezary Rojewski, Peter Ujfalusi, Kai Vehmanen,
	Pierre-Louis Bossart, bo liu, Qianghua Wang

Add Panther Lake and Nova Lake ACPI tables for Senary SN622x (speaker + DMIC)
using sof-*-dummy.tplg and function topologies, aligned with SN624x bring-up.

Signed-off-by: Qianghua Wang <qianghua.wang@senarytech.com>
---
 .../intel/common/soc-acpi-intel-nvl-match.c   |  79 ++++++++++++
 .../intel/common/soc-acpi-intel-ptl-match.c   | 120 ++++++++++++++++++
 2 files changed, 199 insertions(+)

diff --git a/sound/soc/intel/common/soc-acpi-intel-nvl-match.c b/sound/soc/intel/common/soc-acpi-intel-nvl-match.c
index 4a67f6b72..4f0b4aa5d 100644
--- a/sound/soc/intel/common/soc-acpi-intel-nvl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-nvl-match.c
@@ -9,6 +9,7 @@
 #include <sound/soc-acpi.h>
 #include <sound/soc-acpi-intel-match.h>
 #include <sound/soc-acpi-intel-ssp-common.h>
+#include "sof-function-topology-lib.h"
 #include "soc-acpi-intel-sdw-mockup-match.h"
 
 static const struct snd_soc_acpi_codecs nvl_essx_83x6 = {
@@ -66,6 +67,56 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_nvl_machines[] = {
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_nvl_machines);
 
+/*
+ * Senary SN622x on NVL: speaker + DMIC (headphone mux external).
+ * Same SDW part_id rules as PTL/codec_info (0x184c/0x6220, 0x1850/0x6224).
+ * Codec on SoundWire link 0, _ADR version nibble 0x3 (like SN624x on MTL).
+ */
+static const struct snd_soc_acpi_endpoint sn622x_endpoints[] = {
+	{
+		.num = 0,
+		.aggregated = 0,
+		.group_position = 0,
+		.group_id = 0,
+	},
+	{
+		.num = 1,
+		.aggregated = 0,
+		.group_position = 0,
+		.group_id = 0,
+	},
+};
+
+#define NVL_SN622X_SINGLE_ADR(_sym, _adr)				\
+static const struct snd_soc_acpi_adr_device _sym[] = {			\
+	{								\
+		.adr = (_adr),						\
+		.num_endpoints = ARRAY_SIZE(sn622x_endpoints),		\
+		.endpoints = sn622x_endpoints,				\
+		.name_prefix = "sn622x",				\
+	},								\
+}
+
+#define NVL_SN622X_LINK(_sym, _adr_arr)				\
+static const struct snd_soc_acpi_link_adr _sym[] = {			\
+	{								\
+		.mask = BIT(0),						\
+		.num_adr = ARRAY_SIZE(_adr_arr),			\
+		.adr_d = _adr_arr,					\
+	},								\
+	{}								\
+}
+
+NVL_SN622X_SINGLE_ADR(nvl_sn6220_184c_adr, 0x0000300496184c01ull);
+NVL_SN622X_SINGLE_ADR(nvl_sn6220_6220_adr, 0x0000300496622001ull);
+NVL_SN622X_SINGLE_ADR(nvl_sn6224_1850_adr, 0x0000300496185001ull);
+NVL_SN622X_SINGLE_ADR(nvl_sn6224_6224_adr, 0x0000300496622401ull);
+
+NVL_SN622X_LINK(nvl_link_sn6220_184c, nvl_sn6220_184c_adr);
+NVL_SN622X_LINK(nvl_link_sn6220_6220, nvl_sn6220_6220_adr);
+NVL_SN622X_LINK(nvl_link_sn6224_1850, nvl_sn6224_1850_adr);
+NVL_SN622X_LINK(nvl_link_sn6224_6224, nvl_sn6224_6224_adr);
+
 /* this table is used when there is no I2S codec present */
 struct snd_soc_acpi_mach snd_soc_acpi_intel_nvl_sdw_machines[] = {
 	/* mockup tests need to be first */
@@ -87,6 +138,34 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_nvl_sdw_machines[] = {
 		.drv_name = "sof_sdw",
 		.sof_tplg_filename = "sof-nvl-rt715-rt711-rt1308-mono.tplg",
 	},
+	{
+		.link_mask = BIT(0),
+		.links = nvl_link_sn6220_184c,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-nvl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
+	{
+		.link_mask = BIT(0),
+		.links = nvl_link_sn6220_6220,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-nvl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
+	{
+		.link_mask = BIT(0),
+		.links = nvl_link_sn6224_1850,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-nvl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
+	{
+		.link_mask = BIT(0),
+		.links = nvl_link_sn6224_6224,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-nvl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_nvl_sdw_machines);
diff --git a/sound/soc/intel/common/soc-acpi-intel-ptl-match.c b/sound/soc/intel/common/soc-acpi-intel-ptl-match.c
index 467709def..5276e46ac 100644
--- a/sound/soc/intel/common/soc-acpi-intel-ptl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-ptl-match.c
@@ -503,6 +503,98 @@ SN624X_PTL_LINK(ptl_link_sn6244, sn6244_single_adr);
 SN624X_PTL_LINK(ptl_link_sn6245, sn6245_single_adr);
 SN624X_PTL_LINK(ptl_link_sn6247, sn6247_single_adr);
 
+/* Senary SN622x: speaker + DMIC. Headphone mux is external. */
+static const struct snd_soc_acpi_endpoint sn622x_endpoints[] = {
+	{
+		.num = 0,
+		.aggregated = 0,
+		.group_position = 0,
+		.group_id = 0,
+	},
+	{
+		.num = 1,
+		.aggregated = 0,
+		.group_position = 0,
+		.group_id = 0,
+	},
+};
+
+/* SN6220, part_id 0x184c, link 3 */
+static const struct snd_soc_acpi_adr_device sn622x_l3_184c_adr[] = {
+	{
+		.adr = 0x0003300496184c01ull,
+		.num_endpoints = ARRAY_SIZE(sn622x_endpoints),
+		.endpoints = sn622x_endpoints,
+		.name_prefix = "sn622x",
+	},
+};
+
+static const struct snd_soc_acpi_link_adr link_sn622x_l3_184c[] = {
+	{
+		.mask = BIT(3),
+		.num_adr = ARRAY_SIZE(sn622x_l3_184c_adr),
+		.adr_d = sn622x_l3_184c_adr,
+	},
+	{}
+};
+
+/* SN6220, part_id 0x6220 (SN624x-style), link 3 */
+static const struct snd_soc_acpi_adr_device sn622x_l3_6220_adr[] = {
+	{
+		.adr = 0x0003300496622001ull,
+		.num_endpoints = ARRAY_SIZE(sn622x_endpoints),
+		.endpoints = sn622x_endpoints,
+		.name_prefix = "sn622x",
+	},
+};
+
+static const struct snd_soc_acpi_link_adr link_sn622x_l3_6220[] = {
+	{
+		.mask = BIT(3),
+		.num_adr = ARRAY_SIZE(sn622x_l3_6220_adr),
+		.adr_d = sn622x_l3_6220_adr,
+	},
+	{}
+};
+
+/* SN6224, part_id 0x1850, link 2 */
+static const struct snd_soc_acpi_adr_device sn622x_l2_1850_adr[] = {
+	{
+		.adr = 0x0002300496185001ull,
+		.num_endpoints = ARRAY_SIZE(sn622x_endpoints),
+		.endpoints = sn622x_endpoints,
+		.name_prefix = "sn622x",
+	},
+};
+
+static const struct snd_soc_acpi_link_adr link_sn622x_l2_1850[] = {
+	{
+		.mask = BIT(2),
+		.num_adr = ARRAY_SIZE(sn622x_l2_1850_adr),
+		.adr_d = sn622x_l2_1850_adr,
+	},
+	{}
+};
+
+/* SN6224, part_id 0x6224, link 3 */
+static const struct snd_soc_acpi_adr_device sn622x_l3_6224_adr[] = {
+	{
+		.adr = 0x0003300496622401ull,
+		.num_endpoints = ARRAY_SIZE(sn622x_endpoints),
+		.endpoints = sn622x_endpoints,
+		.name_prefix = "sn622x",
+	},
+};
+
+static const struct snd_soc_acpi_link_adr link_sn622x_l3_6224[] = {
+	{
+		.mask = BIT(3),
+		.num_adr = ARRAY_SIZE(sn622x_l3_6224_adr),
+		.adr_d = sn622x_l3_6224_adr,
+	},
+	{}
+};
+
 struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_sdw_machines[] = {
 /* Order Priority: mockup > most links > most bit link-mask > alphabetical */
 	{
@@ -597,6 +689,34 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_sdw_machines[] = {
 		.sof_tplg_filename = "sof-ptl-rt712-l3-rt1320-l3.tplg",
 	},
 
+	{
+		.link_mask = BIT(2),
+		.links = link_sn622x_l2_1850,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-ptl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
+	{
+		.link_mask = BIT(3),
+		.links = link_sn622x_l3_184c,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-ptl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
+	{
+		.link_mask = BIT(3),
+		.links = link_sn622x_l3_6220,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-ptl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
+	{
+		.link_mask = BIT(3),
+		.links = link_sn622x_l3_6224,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-ptl-dummy.tplg",
+		.get_function_tplg_files = sof_sdw_get_tplg_files,
+	},
 	{
 		.link_mask = BIT(3),
 		.links = ptl_link_sn6242,
-- 
2.43.0


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

* Re: [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines
  2026-12-01  2:56 ` [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines Qianghua Wang
@ 2026-12-01  3:06   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-01  3:06 UTC (permalink / raw)
  To: Qianghua Wang; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: Intel: SND_SOC_INTEL_SOUNDWIRE_SOF_MACH omits
  SND_SOC_SN622X_SDCA_SDW
--

commit 99f0bc9c69539964512c4e7f7d2e4ca6d4cc3a7a
Author: Qianghua Wang <qianghua.wang@senarytech.com>

ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines

This commit adds ACPI SoundWire match entries for Senary SN622x codecs on
Panther Lake and Nova Lake platforms using the sof_sdw machine driver.

> diff --git a/sound/soc/intel/common/soc-acpi-intel-nvl-match.c b/sound/soc/intel/common/soc-acpi-intel-nvl-match.c
> index 4a67f6b72fa58..4f0b4aa5d90cf 100644
> --- a/sound/soc/intel/common/soc-acpi-intel-nvl-match.c
> +++ b/sound/soc/intel/common/soc-acpi-intel-nvl-match.c

[ ... ]

> @@ -87,6 +138,34 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_nvl_sdw_machines[] = {
>  		.drv_name = "sof_sdw",
>  		.sof_tplg_filename = "sof-nvl-rt715-rt711-rt1308-mono.tplg",
>  	},
> +	{
> +		.link_mask = BIT(0),
> +		.links = nvl_link_sn6220_184c,
> +		.drv_name = "sof_sdw",
> +		.sof_tplg_filename = "sof-nvl-dummy.tplg",
> +		.get_function_tplg_files = sof_sdw_get_tplg_files,
> +	},

[Severity: Medium]
Should SND_SOC_INTEL_SOUNDWIRE_SOF_MACH in sound/soc/intel/boards/Kconfig
also select SND_SOC_SN622X_SDCA_SDW?

These new PTL and NVL entries bind SN622x devices to the sof_sdw machine
driver (controlled by SND_SOC_INTEL_SOUNDWIRE_SOF_MACH), which explicitly
selects the codec drivers it supports, including SND_SOC_SN624X_SDCA_SDW
added in 32f9c551a91a ("ASoC: Intel: soc-acpi: add SN624x entries for
ARL/LNL/MTL/PTL").  Without selecting SND_SOC_SN622X_SDCA_SDW, enabling
SND_SOC_INTEL_SOUNDWIRE_SOF_MACH will not build the snd-soc-sn622x-sdca
codec driver unless SND_SOC_SN622X_SDCA_SDW or SND_SOC_ALL_CODECS is
enabled separately, leaving sof_sdw unable to bind the codec on matched
systems.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201025636.60506-1-qianghua.wang@senarytech.com?part=3

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

* Re: [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks
  2026-12-01  2:56 ` [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks Qianghua Wang
@ 2026-12-01  3:08   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-01  3:08 UTC (permalink / raw)
  To: Qianghua Wang; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ASoC: sdw_utils: amp_exit refcount underflow and skipped
  rtd_init_done reset
- [Medium] ASoC: sdw_utils: hardcoded sn624x fallback in
  asoc_sdw_senary_dmic_rtd_init()
--

commit d30e9f295b29e6f872bab08cdf9991bdd8b978e4
Author: Qianghua Wang <qianghua.wang@senarytech.com>

ASoC: sdw_utils: add SN622x codec_info and DAPM hooks

This commit registers SoundWire codec_info_list entries and speaker DAPM
routes for Senary SN6220 and SN6224, and shares the Senary DMIC widgets,
controls, and routing helper across SN622x and SN624x.

> diff --git a/sound/soc/sdw_utils/soc_sdw_senary_dmic.c b/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
> index 725f4658ec9c7..ab351a5c1ec9e 100644
> --- a/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
> +++ b/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
> @@ -24,17 +19,23 @@ int asoc_sdw_senary_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
>  	struct snd_soc_card *card = rtd->card;
>  	struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
>  	struct snd_soc_component *component;
> +	struct snd_soc_dapm_route route;
> +	char *codec_dmic;
>  	char *mic_name;
>  	int ret;
>  
>  	component = dai->component;
>  
>  	if (component->name_prefix) {
> -		ret = snd_soc_dapm_add_routes(dapm, senary_dmic_map,
> -					      ARRAY_SIZE(senary_dmic_map));
> +		codec_dmic = devm_kasprintf(card->dev, GFP_KERNEL, "%s DMIC",
> +					    component->name_prefix);
> +		if (!codec_dmic)
> +			return -ENOMEM;
> +		route = (struct snd_soc_dapm_route){ codec_dmic, NULL, "Dmic" };
> +		ret = snd_soc_dapm_add_routes(dapm, &route, 1);
>  		mic_name = devm_kstrdup(card->dev, component->name_prefix, GFP_KERNEL);
>  	} else {
> -		dev_warn(card->dev, "sn624x dmic: component %s has no name_prefix\n",
> +		dev_warn(card->dev, "senary dmic: component %s has no name_prefix\n",
>  			 component->name);
>  		ret = snd_soc_dapm_add_routes(dapm, senary_dmic_map_bare,
>  					      ARRAY_SIZE(senary_dmic_map_bare));

[Severity: Medium]
Should the fallback branch below this derive mic_name from dai->name
instead of hardcoding "sn624x"?  When component->name_prefix is NULL on an
SN6220 or SN6224 system, this still sets mic_name to "sn624x" and appends
"mic:sn624x-dmic" to card->components, breaking UCM microphone matching.

> diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
> index b6acf7616d147..b048e9e115abb 100644
> --- a/sound/soc/sdw_utils/soc_sdw_utils.c
> +++ b/sound/soc/sdw_utils/soc_sdw_utils.c
[ ... ]
> @@ -1690,16 +1690,183 @@ struct asoc_sdw_codec_info codec_info_list[] = {
[ ... ]
> +	/* SN6220, part_id 0x184c */
> +	{
> +		.vendor_id = 0x0496,
> +		.part_id = 0x184c,
> +		.name_prefix = "sn622x",
> +		.ignore_internal_dmic = true,
> +		.dais = {
> +			{
> +				.direction = {true, false},
> +				.dai_name = "sn622x-sdca-aif",
> +				.component_name = "sn622x",
> +				.dai_type = SOC_SDW_DAI_TYPE_AMP,
> +				.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
> +				.init = asoc_sdw_senary_amp_init,
> +				.exit = asoc_sdw_senary_amp_exit,
> +				.rtd_init = asoc_sdw_senary_sdca_spk_rtd_init,
> +				.controls = generic_spk_controls,
> +				.num_controls = ARRAY_SIZE(generic_spk_controls),
> +				.widgets = generic_spk_widgets,
> +				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
> +				.quirk = SOC_SDW_CODEC_SPKR,
> +				.quirk_exclude = true,
> +			},
> +			{
> +				.direction = {false, true},
> +				.dai_name = "sn622x-sdca-aif2",
> +				.dai_type = SOC_SDW_DAI_TYPE_MIC,
> +				.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
> +				.rtd_init = asoc_sdw_senary_dmic_rtd_init,
> +				.widgets = senary_dmic_widgets,
> +				.num_widgets = ARRAY_SIZE(senary_dmic_widgets),
> +				.controls = senary_dmic_controls,
> +				.num_controls = ARRAY_SIZE(senary_dmic_controls),
> +				.quirk = SOC_SDW_CODEC_MIC,
> +				.quirk_exclude = true,
> +			},
> +		},
> +		.dai_num = 2,
> +	},

[Severity: High]
Does wiring .exit = asoc_sdw_senary_amp_exit on dais[0] across all four
SN622x codec_info_list entries underflow ctx->amp_dev1 and ctx->amp_dev2
and skip resetting dais[1].rtd_init_done on card teardown?

asoc_sdw_mc_dailink_exit_loop() matches used DAIs by dai_name:

sound/soc/sdw_utils/soc_sdw_utils.c:asoc_sdw_mc_dailink_exit_loop() {
    ...
	for (i = 0; i < ctx->codec_info_list_count; i++) {
		for (j = 0; j < codec_info_list[i].dai_num; j++) {
			codec_info_list[i].dais[j].rtd_init_done = false;
			/* Check each dai in codec_info_lis to see if it is used in the link */
			if (!codec_info_list[i].dais[j].exit)
				continue;

			dai_link = asoc_sdw_mc_find_codec_dai_used(card,
							  codec_info_list[i].dais[j].dai_name);
			if (dai_link) {
				/* Do the .exit function if the codec dai is used in the link */
				ret = codec_info_list[i].dais[j].exit(card, dai_link);
				if (ret)
					dev_warn(card->dev,
						 "codec exit failed %d\n",
						 ret);
				break;
			}
		}
	}
}

Because all four SN622x entries share dais[0].dai_name = "sn622x-sdca-aif",
teardown matches dais[0] on every entry and calls asoc_sdw_senary_amp_exit()
four times.  Unlike asoc_sdw_rt_amp_exit(), asoc_sdw_senary_amp_exit() does
not clear ctx->amp_dev1 or ctx->amp_dev2 to NULL after calling
device_remove_software_node() and put_device(), so on systems with two
aggregated amplifiers it drops each device reference four times, causing a
refcount underflow and use-after-free.

In addition, hitting break at j = 0 on every SN622x entry skips j = 1
("sn622x-sdca-aif2"), leaving dais[1].rtd_init_done set to true so a
subsequent card probe skips DMIC widget, control, and route initialization.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201025636.60506-1-qianghua.wang@senarytech.com?part=2

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

* Re: [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support
  2026-12-01  2:56 ` [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support Qianghua Wang
@ 2026-12-01  3:23   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-01  3:23 UTC (permalink / raw)
  To: Qianghua Wang; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 16 potential
issues to consider:
- [High] ASoC: sn622x: broken MBQ sizing in sn622x_sdca_mbq_size() and
  volume write order
- [High] ASoC: sn622x: unreachable dmic_active branch and skipped init
  in sn622x_sdca_io_init()
- [High] ASoC: sn622x: dmic_analog_restored and dmic_cap_cfg_done never
  cleared on reset
- [High] ASoC: sn622x: broken runtime PM lifecycle in sn622x_sdca_init()
  and io_init()
- [High] ASoC: sn622x: sn622x_sdca_dev_resume() leaves regmap in
  cache-only mode
- [High] ASoC: sn622x: unguarded sdw_write_no_pm() in probe and system
  suspend
- [Medium] ASoC: sn622x: sn622x_clear_dp0_int() duplicates bus core DP0
  interrupt handling
- [Medium] ASoC: sn622x: missing stream rollback on error in
  sn622x_sdca_pcm_hw_params()
- [Medium] ASoC: sn622x: skipped cleanup on runtime PM error in
  sn622x_sdca_pcm_hw_free()
- [Medium] ASoC: sn622x: missing sn622x_sdca_disco_omits_mic() guards in
  prop and init
- [Medium] ASoC: sn622x: broken bus_recover_work cancellation and state
  sync on unattach
- [Medium] ASoC: sn622x: uncanceled bus_recover_work races with system
  suspend
- [Medium] ASoC: sn622x: sn622x_sdca_dev_resume() returns 0 with regmap
  left cache-only
- [Medium] ASoC: sn622x: repeated and unbounded polling in
  sn622x_dmic_needs_recover()
- [Medium] ASoC: sn622x: missing cleanup on regmap_write() error in
  hw_params
- [Low] ASoC: sn622x: dead S16_LE bps check in
  sn622x_sdca_pcm_hw_params() and unused definitions
--

commit 460bd275ece026483bbb20b3f6335f1bd2ea73c2
Author: Qianghua Wang <qianghua.wang@senarytech.com>

ASoC: codecs: add SN622x SDCA SoundWire codec support

This commit adds the snd-soc-sn622x-sdca SoundWire codec driver for Senary
SN6220 and SN6224 SDCA devices supporting speaker playback and internal
DMIC capture.

> diff --git a/sound/soc/codecs/sn622x-sdca-sdw.c b/sound/soc/codecs/sn622x-sdca-sdw.c
> new file mode 100644
> index 0000000000000..b492fda63e37f
> --- /dev/null
> +++ b/sound/soc/codecs/sn622x-sdca-sdw.c

[ ... ]

> +#define SN622X_SPK_VOL_PRIM_DEFAULT		0x00u
> +#define SN622X_SPK_VOL_SECOND_DEFAULT		0xfau
> +#define SN622X_SPK_CHR_VOL_PRIM_DEFAULT		0x00u
> +#define SN622X_SPK_CHR_VOL_SECOND_DEFAULT	0xfau
> +#define SN622X_REG_SPEAKER_FUN_STATUS_CTL \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_SPEAKER, SN622X_SDCA_ENT_ENTITY0, \
> +				     SN622X_SDCA_CTL_FUNCTION_STATUS, 0))
> +
> +/* Speaker vendor SCP (not SDCA): charge-pump enable value per SN6220 map */
> +#define SN622X_VENDOR_REG_CHARGE_PUMP	0x00002086u
> +#define SN622X_CHARGE_PUMP_ENABLE	0x0bu
> +
> +/* DMIC capture (function 2) */
> +#define SN622X_REG_DMIC_CAP_MUTE \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
> +				     SN622X_SDCA_CTL_FU_MUTE, SN622X_SDCA_CH_L))
> +#define SN622X_REG_DMIC_CAP_CHR_MUTE \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
> +				     SN622X_SDCA_CTL_FU_MUTE, SN622X_SDCA_CH_R))
> +#define SN622X_REG_DMIC_CAP_VOL_FRAC \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
> +				     SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_L))
> +#define SN622X_REG_DMIC_CAP_VOL_INT \
> +	SN622X_SDCA_U32(SDW_SDCA_MBQ_CTL(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, \
> +				      SN622X_SDCA_ENT_USER_FU20, \
> +				      SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_L)))
> +#define SN622X_REG_DMIC_CAP_CHR_VOL_FRAC \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_USER_FU20, \
> +				     SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_R))
> +#define SN622X_REG_DMIC_CAP_CHR_VOL_INT \
> +	SN622X_SDCA_U32(SDW_SDCA_MBQ_CTL(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, \
> +				      SN622X_SDCA_ENT_USER_FU20, \
> +				      SN622X_SDCA_CTL_FU_VOLUME, SN622X_SDCA_CH_R)))
> +#define SN622X_REG_DMIC_CAP_RATE_SEL \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_CS02, \
> +				     SN622X_SDCA_CTL_SAMPLE_FREQ_INDEX, 0))
> +#define SN622X_REG_DMIC_MFPU_BYPASS \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_MFPU08, \
> +				     SN622X_SDCA_CTL_FU_MUTE, 0))
> +#define SN622X_REG_DMIC_MFPU_ALGO_ENABLE \
> +	SN622X_SDCA_U32(SDW_SDCA_CTL(SN622X_FUNC_NUM_MIC_ARRAY, SN622X_SDCA_ENT_MFPU08, \
> +				     SN622X_SDCA_CTL_FU_VOLUME, 0))

[ ... ]

> +/* DMIC vendor init table; run when analog not yet restored for this attach. */
> +static void sn622x_restore_dmic_analog(struct device *dev,
> +				       struct sn622x_sdca_priv *sn622x,
> +				       const char *why)
> +{
> +	struct reg_sequence clear_dmic =
> +		REG_SEQ0(SN622X_REG_DMIC_FUN_STATUS_CTL, 0x61);
> +	int ret;
> +
> +	if (!sn622x || !sn622x->regmap || !sn622x->slave)
> +		return;
> +	if (!sn622x_slave_attached(sn622x->slave)) {
> +		dev_dbg(dev, "sn622x: restore dmic skip (%s): not ATTACHED\n",
> +			why ? why : "?");
> +		return;
> +	}
> +	if (sn622x->dmic_analog_restored) {
> +		dev_dbg(dev, "sn622x: restore dmic skip (%s): already done\n",
> +			why ? why : "?");
> +		return;
> +	}
> +
> +	dev_dbg(dev, "sn622x: restore dmic analog (%s)\n", why ? why : "?");
> +
> +	ret = sn622x_dmic_apply_defaults(dev, sn622x);
> +	if (ret < 0) {
> +		dev_warn(dev, "sn622x: restore dmic: init table failed (%d)\n",
> +			 ret);
> +		return;
> +	}
> +
> +	ret = regmap_multi_reg_write_bypassed(sn622x->regmap, &clear_dmic, 1);
> +	if (ret < 0) {
> +		dev_warn(dev, "sn622x: restore dmic: FUN STATUS clear failed (%d)\n",
> +			 ret);
> +		return;
> +	}
> +	usleep_range(1000, 1500);
> +	sn622x->dmic_analog_restored = true;
> +}
> +
> +/* DMIC vendor/analog after sdw_stream_add_slave; PDE/FU via DAPM. */
> +static void sn622x_dmic_capture_prepare(struct device *dev,
> +					struct sn622x_sdca_priv *sn622x,
> +					unsigned int pcm_rate,
> +					bool bringup)
> +{
> +	unsigned int st = 0;
> +	struct reg_sequence clear_dmic =
> +		REG_SEQ0(SN622X_REG_DMIC_FUN_STATUS_CTL, 0x61);
> +	int r;
> +
> +	if (!sn622x || !sn622x->regmap || !sn622x->slave)
> +		return;
> +
> +	mutex_lock(&sn622x->path_lock);
> +
> +	if (!sn622x_slave_attached(sn622x->slave)) {
> +		dev_dbg(dev, "sn622x: dmic prepare: skip (not ATTACHED)\n");
> +		goto out_unlock;
> +	}
> +
> +	if (regmap_read_bypassed(sn622x->regmap, SN622X_REG_DMIC_FUN_STATUS_CTL,
> +				 &st) == 0 &&
> +	    (st & (SN622X_FUN_NEEDS_INIT | SN622X_FUN_HAS_BEEN_RESET))) {
> +		regmap_multi_reg_write_bypassed(sn622x->regmap, &clear_dmic, 1);
> +		usleep_range(1000, 1500);
> +	}
> +
> +	if (bringup || !sn622x->dmic_analog_restored)
> +		sn622x_restore_dmic_analog(dev, sn622x,
> +					   bringup ? "dmic_pmu" : "dmic_recover");
> +
> +	if (!sn622x->dmic_cap_cfg_done) {
> +		static const struct reg_sequence cap_cfg[] = {
> +			REG_SEQ0(0x00002126u, 0x18),
> +			REG_SEQ0(0x00002127u, 0x01),
> +			REG_SEQ0(0x000020f3u, 0x30),
> +		};
> +
> +		r = regmap_multi_reg_write_bypassed(sn622x->regmap, cap_cfg,
> +						    ARRAY_SIZE(cap_cfg));
> +		if (r < 0)
> +			dev_warn(dev,
> +				 "sn622x: dmic prepare: cap vendor cfg failed (%d)\n",
> +				 r);
> +		else
> +			sn622x->dmic_cap_cfg_done = true;
> +	}
> +
> +	sn622x->dmic_route_latched = true;
> +	(void)pcm_rate;
> +
> +out_unlock:
> +	mutex_unlock(&sn622x->path_lock);
> +}

[Severity: High]
Are dmic_analog_restored and dmic_cap_cfg_done left set across device
resets and system suspend?

Once a first capture stream sets both flags, neither is ever cleared on
SDW_SLAVE_UNATTACHED, system suspend, or when SN622X_REG_DMIC_FUN_STATUS_CTL
reports SN622X_FUN_NEEDS_INIT | SN622X_FUN_HAS_BEEN_RESET.  After a codec
reset or power loss, sn622x_sdca_io_init() and
sn622x_dmic_capture_prepare() acknowledge and clear the Function Status
reset bits without re-running sn622x_dmic_apply_defaults() or
reprogramming cap_cfg[].

[ ... ]

> +static int sn622x_sdca_mbq_size(struct device *dev, unsigned int reg)
> +{
> +	if (!SDW_SDCA_VALID_CTL(reg))
> +		return 1;
> +
> +	switch (reg) {
> +	case SN622X_REG_VOL_SECOND:
> +	case SN622X_REG_CHR_VOL_SECOND:
> +	case SN622X_REG_DMIC_CAP_VOL_INT:
> +	case SN622X_REG_DMIC_CAP_VOL_FRAC:
> +	case SN622X_REG_DMIC_CAP_CHR_VOL_INT:
> +	case SN622X_REG_DMIC_CAP_CHR_VOL_FRAC:
> +		return 2;
> +	default:
> +		return 1;
> +	}
> +}

[Severity: High]
Does sn622x_sdca_mbq_size() reject the SDW_SDCA_MBQ_CTL() volume addresses
while sn622x_fu_mute_event() writes the MBQ bytes in reverse order?

SDW_SDCA_MBQ_CTL() sets BIT(13), which makes SDW_SDCA_VALID_CTL(reg) false.
As a result, the SN622X_REG_*_VOL_SECOND and SN622X_REG_DMIC_CAP_*_VOL_INT
cases are unreachable, SN622X_REG_DMIC_CAP_*_VOL_FRAC returns 2, and
SN622X_REG_*_VOL_PRIM returns 1.

In addition, sn622x_fu_mute_event() writes the base address (BIT(13) == 0)
before the MBQ staging address (BIT(13) == 1) instead of letting
regmap-sdw-mbq perform a single 2-byte write to the base control address
(which stages the upper byte at BIT(13) == 1 first and commits via
BIT(13) == 0 second).  For DMIC, writing 0x4d to VOL_FRAC (size 2) latches
0x004d and the subsequent 1-byte write of 0xfb to VOL_INT is left
uncommitted in the MBQ latch; for speaker, writing 0x00 to VOL_PRIM
commits a stale MBQ byte and leaves 0xfa in VOL_SECOND uncommitted.

[ ... ]

> +static void sn622x_sdca_sdca_irq_mask_all(struct sn622x_sdca_priv *sn622x)
> +{
> +	if (!sn622x->slave)
> +		return;
> +
> +	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK1, 0);
> +	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK2, 0);
> +	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK3, 0);
> +	sdw_write_no_pm(sn622x->slave, SDW_SCP_SDCA_INTMASK4, 0);
> +	SN622X_DBG(&sn622x->slave->dev,
> +		   "SDCA INTMASK1-4 = 0 (all SDCA sources masked)\n");
> +}
> +
> +static int sn622x_sdca_io_init(struct device *dev, struct sdw_slave *slave)
> +{
> +	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
> +	int ret;
> +	unsigned int dmic_func_status;
> +	if (sn622x->hw_init) {
> +		SN622X_DBG(dev, "io_init: skip (hw_init already true)\n");
> +		return 0;
> +	}
> +
> +	mutex_lock(&sn622x->path_lock);
> +	if (sn622x->hw_init) {
> +		mutex_unlock(&sn622x->path_lock);
> +		return 0;
> +	}
> +	/* PCM open: defer full io_init until streams close (same bus, no extra SCP). */
> +	if (sn622x->first_hw_init &&
> +	    (sn622x->playback_active || sn622x->dmic_active)) {
> +		dev_dbg(dev, "sn622x: io_init: stream open — skip bus access\n");
> +		sn622x->hw_init = true;
> +		mutex_unlock(&sn622x->path_lock);
> +		return 0;
> +	}
> +	/* Capture still active: minimal cache/PM + DMIC FUN ACK; route in prepare. */
> +	if (sn622x->dmic_active) {

[Severity: High]
Does the first dmic_active check in sn622x_sdca_io_init() make the
following if (sn622x->dmic_active) block unreachable and skip re-attach
initialization?

sn622x->dmic_active can only become true in sn622x_sdca_trigger() after
initial attachment has already set sn622x->first_hw_init = true.  When the
slave detaches and re-attaches while a playback or capture stream is open,
the first branch always matches, sets sn622x->hw_init = true, and returns
without disabling regcache_cache_only, masking SDCA interrupts, or
acknowledging Function Status, and io_init is never re-run when the stream
closes.

[ ... ]

> +static bool sn622x_dmic_needs_recover(const struct sn622x_sdca_priv *sn622x)
> +{
> +	if (!sn622x->dmic_active)
> +		return false;
> +	if (!sn622x->dmic_route_latched)
> +		return true;
> +	if (sn622x->dmic_recover_until &&
> +	    time_before(jiffies, sn622x->dmic_recover_until))
> +		return true;
> +	return false;
> +}
> +
> +/*
> + * Deferred bring-up after UNATTACH (external HP mux): runtime PM cleanup,
> + * io_init when re-attached, DMIC vendor prepare retries while capture is open.
> + */
> +static void sn622x_bus_recover_work(struct work_struct *work)
> +{
> +	struct sn622x_sdca_priv *sn622x =
> +		container_of(work, struct sn622x_sdca_priv, bus_recover_work.work);
> +	struct device *dev;
> +	bool got_pm = false;
> +	int ret;
> +
> +	if (!sn622x->slave)
> +		return;
> +
> +	dev = &sn622x->slave->dev;
> +
> +	if (!sn622x_slave_attached(sn622x->slave)) {
> +		if (sn622x_dmic_needs_recover(sn622x))
> +			sn622x_schedule_bus_recover(sn622x,
> +						    SN622X_BUS_RECOVER_DMIC_MS);
> +		return;
> +	}
> +
> +	ret = pm_runtime_resume_and_get(dev);
> +	if (ret < 0 && ret != -EACCES)
> +		return;
> +	if (ret == 0)
> +		got_pm = true;
> +
> +	sn622x_pm_recover(dev);
> +
> +	if (!sn622x->hw_init)
> +		sn622x_sdca_io_init(dev, sn622x->slave);
> +
> +	if (sn622x_dmic_needs_recover(sn622x) &&
> +	    (!sn622x->playback_active || !sn622x->dmic_route_latched)) {
> +		dev_dbg(dev, "sn622x: bus_recover: DMIC capture prepare\n");
> +		sn622x_dmic_capture_prepare(dev, sn622x, sn622x->dmic_rate, false);
> +		if (sn622x_dmic_needs_recover(sn622x))
> +			sn622x_schedule_bus_recover(sn622x,
> +						    SN622X_BUS_RECOVER_DMIC_MS);
> +	}

[Severity: Medium]
Does sn622x_dmic_needs_recover() cause sn622x_bus_recover_work() to poll
indefinitely while unattached and repeatedly after recovery?

Because !sn622x->dmic_route_latched is checked before
sn622x->dmic_recover_until, an unattached slave reschedules
bus_recover_work every 150 ms without bound instead of stopping at the 2
second deadline.  Once attached, sn622x_dmic_capture_prepare() sets
dmic_route_latched = true without clearing dmic_recover_until, so
sn622x_dmic_needs_recover() keeps returning true for the full 2 seconds
and repeatedly re-runs sn622x_dmic_capture_prepare() every 150 ms when
playback_active is 0.

> +
> +	if (got_pm) {
> +		pm_runtime_mark_last_busy(dev);
> +		pm_runtime_put_autosuspend(dev);
> +	}
> +}
> +
> +static int sn622x_sdca_update_status(struct sdw_slave *slave,
> +				     enum sdw_slave_status status)
> +{
> +	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
> +
> +	SN622X_DBG(&slave->dev, "update_status: %s hw_init=%d dev_num=%u\n",
> +		   sn622x_status_str(status), sn622x->hw_init, slave->dev_num);
> +
> +	if (status == SDW_SLAVE_UNATTACHED) {
> +		unsigned long prev_unattach = sn622x->last_unattach_jiffies;
> +
> +		sn622x->hw_init = false;
> +		sn622x->last_unattach_jiffies = jiffies;
> +		/* After ATTACH, capture prepare re-latches route; keep dmic_analog_restored. */
> +		sn622x->dmic_route_latched = false;
> +		if (prev_unattach &&
> +		    time_before(jiffies, prev_unattach +
> +				msecs_to_jiffies(SN622X_UNATTACH_STORM_WINDOW_MS)))
> +			sn622x->unattach_storm++;
> +		else
> +			sn622x->unattach_storm = 1;
> +		if (sn622x->dmic_active &&
> +		    sn622x->unattach_storm >= SN622X_UNATTACH_STORM_MAX) {
> +			dev_warn(&slave->dev,
> +				 "sn622x: rapid UNATTACH — stop DMIC recover\n");
> +			sn622x->dmic_active = false;
> +			sn622x->dmic_recover_until = 0;
> +			cancel_delayed_work(&sn622x->bus_recover_work);
> +		} else if (sn622x->dmic_active) {
> +			sn622x->dmic_recover_until = jiffies + 2 * HZ;
> +		}
> +		sn622x_schedule_bus_recover(sn622x, SN622X_BUS_RECOVER_SETTLE_MS);
> +	}

[Severity: Medium]
Doesn't sn622x_schedule_bus_recover() immediately re-queue
bus_recover_work right after the unattach-storm branch cancels it?

Also, when SDW_SLAVE_ATTACHED occurs within SN622X_ATTACH_DEBOUNCE_MS,
sn622x_sdca_update_status() defers sn622x_sdca_io_init() to
bus_recover_work; if the capture stream closes during that window,
cancel_delayed_work_sync(&sn622x->bus_recover_work) in
sn622x_sdca_pcm_hw_free() cancels the pending io_init and leaves hw_init
false while attached.  In addition, dmic_active, dmic_route_latched,
dmic_recover_until, dmic_rate, playback_active, and hw_init are accessed
across PCM callbacks, update_status, and bus_recover_work without common
locking.

[ ... ]

> +static int sn622x_sdca_read_prop(struct sdw_slave *slave)
> +{
> +	struct sdw_slave_prop *prop = &slave->prop;
> +	struct sdw_dpn_prop *dpn;
> +	unsigned long addr;
> +	unsigned int bit;
> +	int nval;
> +	int i, j;
> +
> +	sdw_slave_read_lane_mapping(slave);
> +	prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY;
> +	prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
> +	prop->paging_support = true;
> +	prop->use_domain_irq = true;
> +	/* dev_num 1 on this link: wake_capable is unsupported on Intel hosts. */
> +	prop->wake_capable = false;
> +
> +	/* SN6220: speaker playback (port1) + DMIC capture (port3) only */
> +	prop->source_ports = BIT(SN622X_PORT_DMIC_CAPTURE);

[Severity: Medium]
Should sn622x_sdca_read_prop(), sn622x_sdca_io_init(), and
sn622x_restore_dmic_analog() check sn622x_sdca_disco_omits_mic(slave)?

Currently only sn622x_dmic_apply_defaults() checks
sn622x_sdca_disco_omits_mic(slave).  On platforms where DisCo omits the
mic function, sn622x_sdca_read_prop() still exposes
SN622X_PORT_DMIC_CAPTURE, and sn622x_sdca_io_init() and
sn622x_restore_dmic_analog() still read and write
SN622X_REG_DMIC_FUN_STATUS_CTL on a non-existent SDCA function.

[ ... ]

> +/* PoC: clear DP0 sticky bits so bus alert handler can finish (DevNum assign). */
> +static int sn622x_clear_dp0_int(struct sdw_slave *slave)
> +{
> +	int status, status2, ret, count = 0;
> +	u8 clear, impl_int_mask;
> +
> +	status = sdw_read_no_pm(slave, SDW_DP0_INT);
> +	if (status < 0)
> +		return status;
> +
> +	do {
> +		clear = status & ~(SDW_DP0_INTERRUPTS | SDW_DP0_SDCA_CASCADE);
> +
> +		if (status & SDW_DP0_INT_TEST_FAIL)
> +			clear |= SDW_DP0_INT_TEST_FAIL;
> +
> +		if (status & SDW_DP0_INT_PORT_READY) {
> +			complete(&slave->port_ready[0]);
> +			clear |= SDW_DP0_INT_PORT_READY;
> +		}

[Severity: Medium]
Why does sn622x_clear_dp0_int() duplicate the SoundWire bus core's
sdw_handle_dp0_interrupt()?

The bus core already clears SDW_DP0_INT and completes slave->port_ready[0]
in sdw_handle_slave_alerts() before invoking interrupt_callback, and
SDW_DP0_SDCA_CASCADE clears once SDW_SCP_SDCA_INT1..4 are cleared.
Clearing DP0 interrupt bits and signaling slave->port_ready[0] from the
codec driver's interrupt_callback and clk_stop paths risks losing DP0
status notifications or causing spurious port_ready completions.

[ ... ]

> +	snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
> +	stream_config.frame_rate = 48000;
> +	if (stream_config.bps > 16 &&
> +	    params_format(params) == SNDRV_PCM_FORMAT_S16_LE)
> +		stream_config.bps = 16;

[Severity: Low]
Can stream_config.bps > 16 ever be true when params_format(params) is
SNDRV_PCM_FORMAT_S16_LE?

snd_sdw_params_to_config() sets stream_config.bps to
snd_pcm_format_width(params_format(params)), which is already 16 for
SNDRV_PCM_FORMAT_S16_LE.  In addition, SN622X_SPK_CHR_VOL_PRIM_DEFAULT,
SN622X_REG_DMIC_MFPU_BYPASS, SN622X_REG_DMIC_MFPU_ALGO_ENABLE,
SN622X_SDCA_ENT_MFPU08, SN622X_ROUTE_AFTER_D3_US_MIN/MAX,
SN622X_ROUTE_BEFORE_ACTIVE_US_MIN/MAX, SN622X_UAJ_DMIC_PPU11, and the
pcm_rate parameter of sn622x_dmic_capture_prepare() (making
sn622x->dmic_rate and sn622x->disable_irq write-only) are unused.

> +	port_config.num = port;
> +
> +	ret = sdw_stream_add_slave(sn622x->slave, &stream_config,
> +				   &port_config, 1, sdw_stream);
> +
> +	if (ret) {
> +		dev_err(dai->dev, "%s: sdw_stream_add_slave port %d failed: %d\n",
> +			__func__, port, ret);
> +		goto out;
> +	}
> +
> +	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
> +	    dai->id == SN622X_DAI_SPEAKER) {
> +		sn622x->playback_active |= SN622X_PB_ACTIVE_SPK;
> +		ret = regmap_write(sn622x->regmap, SN622X_REG_RATE_SEL, 0x01);
> +		if (ret < 0)
> +			dev_warn(dai->dev,
> +				 "sn622x: hw_params: speaker rate_sel failed (%d)\n",
> +				 ret);
> +		sn622x_speaker_playback_prepare(dai->dev, sn622x);
> +	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
> +		   dai->id == SN622X_DAI_DMIC) {
> +		sn622x->dmic_route_latched = false;
> +		sn622x->dmic_rate = params_rate(params);
> +		ret = regmap_write(sn622x->regmap, SN622X_REG_DMIC_CAP_RATE_SEL,
> +				   0x01);
> +		if (ret < 0)
> +			dev_warn(dai->dev,
> +				 "sn622x: hw_params: dmic rate_sel failed (%d)\n",
> +				 ret);
> +		sn622x_dmic_capture_prepare(dai->dev, sn622x, sn622x->dmic_rate,
> +					    true);
> +	}
> +out:
> +	if (got_pm) {
> +		pm_runtime_mark_last_busy(component->dev);
> +		pm_runtime_put_autosuspend(component->dev);
> +	}
> +	return ret;
> +}

[Severity: Medium]
If regmap_write() fails here after sdw_stream_add_slave() succeeds, does
sn622x_sdca_pcm_hw_params() leak the SoundWire stream runtime and leave
SN622X_PB_ACTIVE_SPK set?

When hw_params returns a negative error code, ASoC does not mark the DAI
for hw_free rollback, so sdw_stream_remove_slave() is never called on
stream teardown (leaving m_rt linked on bus->m_rt_list) and
sn622x->playback_active remains stuck set.

> +
> +static int sn622x_sdca_pcm_hw_free(struct snd_pcm_substream *substream,
> +				   struct snd_soc_dai *dai)
> +{
> +	struct snd_soc_component *component = dai->component;
> +	struct sn622x_sdca_priv *sn622x = snd_soc_component_get_drvdata(component);
> +	struct sdw_stream_runtime *sdw_stream =
> +		snd_soc_dai_get_dma_data(dai, substream);
> +	int port;
> +	bool got_pm = false;
> +	int ret;
> +
> +	if (!sn622x->slave)
> +		return -EINVAL;
> +
> +	port = sn622x_hw_params_port(dai, substream);
> +	if (port < 0)
> +		return port;
> +
> +	ret = pm_runtime_resume_and_get(component->dev);
> +	if (ret < 0 && ret != -EACCES)
> +		return ret;
> +	if (ret == 0)
> +		got_pm = true;
> +
> +
> +	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
> +	    dai->id == SN622X_DAI_DMIC) {
> +		sn622x->dmic_active = false;
> +		sn622x->dmic_route_latched = false;
> +		sn622x->dmic_recover_until = 0;
> +		cancel_delayed_work_sync(&sn622x->bus_recover_work);
> +	}
> +	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
> +	    dai->id == SN622X_DAI_SPEAKER) {
> +		sn622x->playback_active &= ~SN622X_PB_ACTIVE_SPK;
> +	}
> +
> +	sdw_stream_remove_slave(sn622x->slave, sdw_stream);

[Severity: Medium]
Does returning early when pm_runtime_resume_and_get() fails in
sn622x_sdca_pcm_hw_free() skip sdw_stream_remove_slave() and work
cancellation?

sn622x_sdca_pcm_hw_free() performs no hardware register I/O, so aborting on
a runtime resume failure leaks the slave stream runtime and leaves
bus_recover_work and dmic_active / playback_active active after PCM close.

[ ... ]

> +	pm_runtime_set_autosuspend_delay(dev, 3000);
> +	pm_runtime_use_autosuspend(dev);
> +	pm_runtime_mark_last_busy(dev);
> +	/*
> +	 * Fresh probe: disable_depth is already 1. Only disable when a previous
> +	 * instance left runtime_error set, then enable exactly once.
> +	 */
> +	if (dev->power.runtime_error)
> +		pm_runtime_disable(dev);
> +	pm_runtime_set_suspended(dev);
> +	pm_runtime_enable(dev);
> +
> +	return 0;
> +}

[Severity: High]
Does enabling runtime PM in RPM_SUSPENDED state during sn622x_sdca_init()
cause pm_runtime_set_active() in sn622x_sdca_io_init() to always fail with
-EAGAIN?

__pm_runtime_set_status() rejects pm_runtime_set_active() with -EAGAIN when
runtime PM is already enabled (disable_depth == 0) and runtime_error == 0.
When the slave attaches and sn622x_sdca_io_init() runs,
pm_runtime_set_active(dev) fails, leaving dev->power.runtime_status at
RPM_SUSPENDED while regcache_cache_only is false, so
pm_runtime_put_autosuspend(dev) sees the device as already suspended and
never invokes sn622x_sdca_dev_suspend().

In addition, if dev->power.runtime_error is set at probe when
disable_depth is already 1, calling pm_runtime_disable(dev) increments
disable_depth to 2 while pm_runtime_enable(dev) only decrements it to 1;
sn622x_sdca_sdw_remove() only calls pm_runtime_disable() when
first_hw_init is true (leaking the enable count if unbound before attach)
and omits pm_runtime_dont_use_autosuspend(); sn622x_bus_recover_work()
returns early when pm_runtime_resume_and_get() fails with -EINVAL before
reaching sn622x_pm_recover(); and reading dev->power.runtime_error
directly fails to compile when CONFIG_PM is disabled.

> +
> +static int sn622x_sdca_sdw_probe(struct sdw_slave *slave,
> +				 const struct sdw_device_id *id)
> +{
> +	struct regmap *regmap;
> +	int ret;
> +
> +	SN622X_DBG(&slave->dev, "sdw_probe: dev_num=%u status=%s\n",
> +		   slave->dev_num, sn622x_status_str(slave->status));
> +
> +	/*
> +	 * read_prop runs once at slave add; force again on driver bind so a
> +	 * module reload picks up lane_control_support=false without reboot.
> +	 */
> +	slave->prop.lane_control_support = false;
> +
> +	regmap = devm_regmap_init_sdw_mbq_cfg(&slave->dev, slave,
> +					      &sn622x_sdca_regmap,
> +					      &sn622x_sdca_mbq_cfg);
> +	if (IS_ERR(regmap)) {
> +		dev_err(&slave->dev,
> +			"sn622x: devm_regmap_init_sdw_mbq_cfg failed (%ld)\n",
> +			PTR_ERR(regmap));
> +		return PTR_ERR(regmap);
> +	}
> +
> +	ret = sn622x_sdca_init(&slave->dev, regmap, slave);
> +	if (ret < 0)
> +		dev_err(&slave->dev, "sn622x: sn622x_sdca_init failed (%d)\n", ret);
> +	else {
> +		struct sn622x_sdca_priv *sn622x = dev_get_drvdata(&slave->dev);
> +
> +		if (sn622x)
> +			sn622x_sdca_sdca_irq_mask_all(sn622x);
> +		SN622X_DBG(&slave->dev, "SoundWire probe finished OK\n");
> +	}
> +
> +	return ret;
> +}

[ ... ]

> +static int sn622x_sdca_dev_system_suspend(struct device *dev)
> +{
> +	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
> +
> +	if (!sn622x->first_hw_init)
> +		return 0;
> +
> +	SN622X_DBG(dev, "system suspend: mask SDCA IRQs\n");
> +	mutex_lock(&sn622x->disable_irq_lock);
> +	sn622x->disable_irq = true;
> +	sn622x_sdca_sdca_irq_mask_all(sn622x);
> +	mutex_unlock(&sn622x->disable_irq_lock);
> +
> +	return sn622x_sdca_dev_suspend(dev);
> +}

[Severity: High]
Can sn622x_sdca_sdw_probe() and sn622x_sdca_dev_system_suspend() call
sn622x_sdca_sdca_irq_mask_all() while the slave is unattached or the
SoundWire bus is runtime-suspended?

sn622x_sdca_sdca_irq_mask_all() issues four sdw_write_no_pm() transfers.
In sn622x_sdca_sdw_probe(), the slave may still be SDW_SLAVE_UNATTACHED
before update_status() runs.  In sn622x_sdca_dev_system_suspend(), checking
!sn622x->first_hw_init instead of !sn622x->hw_init means that if the codec
and parent SoundWire controller have already runtime-suspended and stopped
the clock, system suspend issues SoundWire transactions over a
suspended/unattached bus.

[Severity: Medium]
Can sn622x->bus_recover_work run concurrently with or after
sn622x_sdca_dev_system_suspend()?

Neither sn622x_sdca_dev_system_suspend() nor sn622x_sdca_dev_suspend()
cancels bus_recover_work.  Because sn622x_bus_recover_work() continues
when pm_runtime_resume_and_get(dev) returns -EACCES (which the PM core
returns while runtime PM is disabled for system sleep), a pending work item
can run during system suspend and call sn622x_sdca_io_init(), clearing
disable_irq, disabling regcache_cache_only, and issuing bus transfers.

> +
> +static int sn622x_sdca_dev_resume(struct device *dev)
> +{
> +	struct sdw_slave *slave = dev_to_sdw_dev(dev);
> +	struct sn622x_sdca_priv *sn622x = dev_get_drvdata(dev);
> +	int ret;
> +
> +	if (!sn622x->first_hw_init)
> +		return 0;
> +
> +	SN622X_DBG(dev, "resume: unattach_request=%u status=%s\n",
> +		   slave->unattach_request, sn622x_status_str(slave->status));
> +
> +	if (slave->unattach_request) {
> +		ret = sdw_slave_wait_for_init(slave, SN622X_PROBE_TIMEOUT_MS);
> +		if (ret)
> +			dev_dbg(dev, "sn622x: resume: init wait failed (%d)\n", ret);
> +	}
> +
> +	mutex_lock(&sn622x->disable_irq_lock);
> +	sn622x->disable_irq = false;
> +	mutex_unlock(&sn622x->disable_irq_lock);
> +
> +	slave->unattach_request = 0;
> +	if (!sn622x_slave_attached(slave))
> +		return 0;
> +
> +	/* Resume: enable regmap I/O; avoid regcache_sync (stale cache vs live device). */
> +	regcache_cache_only(sn622x->regmap, false);
> +
> +	return 0;
> +}

[Severity: High]
Does sn622x_sdca_dev_resume() leave sn622x->regmap stuck in cache-only
mode when the slave resumes for a SoundWire alert or when
sdw_slave_wait_for_init() fails?

When a runtime-suspended slave raises an alert, sdw_handle_slave_alerts()
sets slave->status = SDW_SLAVE_ALERT before calling
pm_runtime_get_sync(&slave->dev).  Because sn622x_slave_attached() only
checks slave->status == SDW_SLAVE_ATTACHED, sn622x_sdca_dev_resume()
returns 0 without calling regcache_cache_only(sn622x->regmap, false), so
the device transitions to RPM_ACTIVE while regmap stays cache-only (and
when the slave returns to SDW_SLAVE_ATTACHED, sn622x_sdca_update_status()
sees hw_init == true and skips io_init).

[Severity: Medium]
Should sn622x_sdca_dev_resume() propagate errors when
sdw_slave_wait_for_init() fails or the slave is still unattached instead
of clearing slave->unattach_request and returning 0?

Returning 0 when initialization has not completed marks the device
RPM_ACTIVE with slave->unattach_request cleared and regcache_cache_only
still set to true.  Also, when the slave re-attaches within
SN622X_ATTACH_DEBOUNCE_MS, sn622x_sdca_update_status() defers
sn622x_sdca_io_init() to bus_recover_work and returns 0, which causes the
SoundWire bus core to complete slave->initialization_complete and wake
sdw_slave_wait_for_init() before io_init has run.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201025636.60506-1-qianghua.wang@senarytech.com?part=1

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

end of thread, other threads:[~2026-12-01  3:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  2:56 [PATCH v2 0/3] ASoC: add Senary SN622x SDCA SoundWire support Qianghua Wang
2026-12-01  2:56 ` [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support Qianghua Wang
2026-12-01  3:23   ` sashiko-bot
2026-12-01  2:56 ` [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks Qianghua Wang
2026-12-01  3:08   ` sashiko-bot
2026-12-01  2:56 ` [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines Qianghua Wang
2026-12-01  3:06   ` sashiko-bot

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