Skip to contentSkip to conversation

Add SDCA IRQ support and some misc fixups

PATCH In review Charles Keepax 3 participants 10 messages Jun 24, 2025 – Jul 1, 2025

Subsystems (3)
lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

v3 cover Add SDCA IRQ support and some misc fixups

Add a maintainers entry for SDCA, do a couple of small fixups for previous chains, and then adding the beginnings of the SDCA IRQ handling. This is based around a regmap IRQ chip and a few helper functions that can be called from the client drivers to setup the IRQs.

Thanks,
Charles

Changes since v2:
- Just a rebase to avoid a conflict with the recently merged SDCA HID stuff.

Charles Keepax (6):
MAINTAINERS: Add SDCA maintainers entry
ASoC: SDCA: Add missing default in switch in entity_pde_event()
ASoC: SDCA: Fixup some kernel doc errors
ASoC: SDCA: Minor selected/detected mode control fixups
ASoC: SDCA: Add flag for unused IRQs
ASoC: SDCA: Add some initial IRQ handlers

Maciej Strozek (1):
ASoC: SDCA: Generic interrupt support

 MAINTAINERS                      |  11 +
 include/sound/sdca_function.h    |  11 +
 include/sound/sdca_interrupts.h  |  78 ++++++
 sound/soc/sdca/Kconfig           |   7 +
 sound/soc/sdca/Makefile          |   5 +-
 sound/soc/sdca/sdca_asoc.c       |  19 +-
 sound/soc/sdca/sdca_functions.c  |   2 +
 sound/soc/sdca/sdca_interrupts.c | 439 +++++++++++++++++++++++++++++++
 8 files changed, 564 insertions(+), 8 deletions(-)
 create mode 100644 include/sound/sdca_interrupts.h
 create mode 100644 sound/soc/sdca/sdca_interrupts.c
Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH v3 1/7 MAINTAINERS: Add SDCA maintainers entry

Add a maintainers entry for the new SDCA support code.

---

No change since v2.

 MAINTAINERS | 11 +++++++++++
 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
index c3f7fbd0d67af..669b28f696915 100644
@@ -22298,6 +22298,17 @@ M:	Jim Cromie <[email protected]>
 S:	Maintained
 F:	drivers/clocksource/scx200_hrt.c
 
+SDCA LIBRARY AND CLASS DRIVER
+M:	Charles Keepax <[email protected]>
+M:	Maciej Strozek <[email protected]>
+R:	Bard Liao <[email protected]>
+R:	Pierre-Louis Bossart <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	include/sound/sdca*
+F:	sound/soc/sdca/*
+
 SDRICOH_CS MMC/SD HOST CONTROLLER INTERFACE DRIVER
 M:	Sascha Sommer <[email protected]>
 L:	[email protected] (subscribers-only)
Signature · 1 line
2.39.5
author maintainer
#2 lore raw

PATCH v3 2/7 ASoC: SDCA: Add missing default in switch in entity_pde_event()

In reply to Charles Keepax

The current code should be safe as the PDE widget only registers for the two events handled in the switch statement. However, it is causing a smatch warning and also is a little fragile to future code changes, add a default case to avoid the warning and make the code more robust.

Fixes 2c8b3a8e6aa8 ("ASoC: SDCA: Create DAPM widgets and routes from DisCo")

---

No change since v2.

 sound/soc/sdca/sdca_asoc.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/sdca/sdca_asoc.c +2 -0
index 7bc8f6069f3d4..e96e696cb1079 100644
@@ -397,6 +397,8 @@ static int entity_pde_event(struct snd_soc_dapm_widget *widget,
 		from = widget->off_val;
 		to = widget->on_val;
 		break;
+	default:
+		return 0;
 	}
 
 	for (i = 0; i < entity->pde.num_max_delay; i++) {
Signature · 1 line
2.39.5
author maintainer
#3 lore raw

PATCH v3 3/7 ASoC: SDCA: Fixup some kernel doc errors

In reply to Charles Keepax

Correct some typos and omissions in the kernel doc for the ASoC SDCA code.

Fixes 2c8b3a8e6aa8 ("ASoC: SDCA: Create DAPM widgets and routes from DisCo")

---

No change since v2.

 sound/soc/sdca/sdca_asoc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
sound/soc/sdca/sdca_asoc.c +7 -2
index e96e696cb1079..83911dab73ae2 100644
@@ -93,6 +93,7 @@ static bool readonly_control(struct sdca_control *control)
 
 /**
  * sdca_asoc_count_component - count the various component parts
+ * @dev: Pointer to the device against which allocations will be done.
  * @function: Pointer to the Function information.
  * @num_widgets: Output integer pointer, will be filled with the
  * required number of DAPM widgets for the Function.
@@ -997,7 +998,7 @@ static int populate_pin_switch(struct device *dev,
  * sdca_asoc_populate_controls - fill in an array of ALSA controls for a Function
  * @dev: Pointer to the device against which allocations will be done.
  * @function: Pointer to the Function information.
- * @route: Array of ALSA controls to be populated.
+ * @kctl: Array of ALSA controls to be populated.
  *
  * This function populates an array of ALSA controls from the DisCo
  * information for a particular SDCA Function. Typically,
@@ -1244,7 +1245,11 @@ EXPORT_SYMBOL_NS(sdca_asoc_populate_dais, "SND_SOC_SDCA");
  * sdca_asoc_populate_component - fill in a component driver for a Function
  * @dev: Pointer to the device against which allocations will be done.
  * @function: Pointer to the Function information.
- * @copmonent_drv: Pointer to the component driver to be populated.
+ * @component_drv: Pointer to the component driver to be populated.
+ * @dai_drv: Pointer to the DAI driver array to be allocated and populated.
+ * @num_dai_drv: Pointer to integer that will be populated with the number of
+ * DAI drivers.
+ * @ops: DAI ops pointer that will be used for each DAI driver.
  *
  * This function populates a snd_soc_component_driver structure based
  * on the DisCo information for a particular SDCA Function. It does
Signature · 1 line
2.39.5
author maintainer
#4 lore raw

PATCH v3 4/7 ASoC: SDCA: Minor selected/detected mode control fixups

In reply to Charles Keepax

Make the names a slightly better match for the specification and add some constants for the values rather than hard coding.

---

No change since v2.

 include/sound/sdca_function.h | 9 +++++++++
 sound/soc/sdca/sdca_asoc.c    | 8 ++++----
 2 files changed, 13 insertions(+), 4 deletions(-)
include/sound/sdca_function.h +9 -0
index 856b0f40ce5eb..4b278513597e5 100644
@@ -319,6 +319,15 @@ enum sdca_selected_mode_range {
 	SDCA_SELECTED_MODE_NCOLS			= 2,
 };
 
+/**
+ * enum sdca_detected_mode_values - Predefined GE Detected Mode values
+ */
+enum sdca_detected_mode_values {
+	SDCA_DETECTED_MODE_JACK_UNPLUGGED		= 0,
+	SDCA_DETECTED_MODE_JACK_UNKNOWN			= 1,
+	SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS	= 2,
+};
+
 /**
  * enum sdca_spe_controls - SDCA Controls for Security & Privacy Unit
  *
sound/soc/sdca/sdca_asoc.c +4 -4
index 83911dab73ae2..dd7b19083c85f 100644
@@ -246,12 +246,12 @@ static int entity_early_parse_ge(struct device *dev,
 	if (!values)
 		return -ENOMEM;
 
-	texts[0] = "No Jack";
+	texts[0] = "Jack Unplugged";
 	texts[1] = "Jack Unknown";
 	texts[2] = "Detection in Progress";
-	values[0] = 0;
-	values[1] = 1;
-	values[2] = 2;
+	values[0] = SDCA_DETECTED_MODE_JACK_UNPLUGGED;
+	values[1] = SDCA_DETECTED_MODE_JACK_UNKNOWN;
+	values[2] = SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS;
 	for (i = 0; i < range->rows; i++) {
 		enum sdca_terminal_type type;
 
Signature · 1 line
2.39.5
author maintainer
#5 lore raw

PATCH v3 5/7 ASoC: SDCA: Add flag for unused IRQs

In reply to Charles Keepax

Zero is a valid SDCA IRQ interrupt position so add a special value to indicate that the IRQ is not used.

---

No change since v2.

 include/sound/sdca_function.h   | 2 ++
 sound/soc/sdca/sdca_functions.c | 2 ++
 2 files changed, 4 insertions(+)
include/sound/sdca_function.h +2 -0
index 4b278513597e5..b4a97ff087294 100644
@@ -17,6 +17,8 @@ struct device;
 struct sdca_entity;
 struct sdca_function_desc;
 
+#define SDCA_NO_INTERRUPT -1
+
 /*
  * The addressing space for SDCA relies on 7 bits for Entities, so a
  * maximum of 128 Entities per function can be represented.
sound/soc/sdca/sdca_functions.c +2 -0
index 093c681e93879..c34f3bf629833 100644
@@ -912,6 +912,8 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
 				       &tmp);
 	if (!ret)
 		control->interrupt_position = tmp;
+	else
+		control->interrupt_position = SDCA_NO_INTERRUPT;
 
 	control->label = find_sdca_control_label(dev, entity, control);
 	if (!control->label)
Signature · 1 line
2.39.5
author maintainer
#6 lore raw

PATCH v3 6/7 ASoC: SDCA: Generic interrupt support

In reply to Charles Keepax

From: Maciej Strozek <[email protected]>

Add a library supporting usage of SDCA interrupts, using regmap irq framework. The library adds functions for parsing ACPI for interrupt-related information, configuring irq chip and requesting individual irqs. Calling code (SDCA function code) is expected to also substitute the library's base irq handler for its own, appropriate callback.

---

No change since v2.

 include/sound/sdca_interrupts.h  |  75 ++++++++
 sound/soc/sdca/Kconfig           |   7 +
 sound/soc/sdca/Makefile          |   5 +-
 sound/soc/sdca/sdca_interrupts.c | 284 +++++++++++++++++++++++++++++++
 4 files changed, 369 insertions(+), 2 deletions(-)
 create mode 100644 include/sound/sdca_interrupts.h
 create mode 100644 sound/soc/sdca/sdca_interrupts.c
include/sound/sdca_interrupts.h new file +75 -0
new file mode 100644
index 0000000000000..4cda8b75bae0e
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * The MIPI SDCA specification is available for public downloads at
+ * https://www.mipi.org/mipi-sdca-v1-0-download
+ *
+ * Copyright (C) 2025 Cirrus Logic, Inc. and
+ *                    Cirrus Logic International Semiconductor Ltd.
+ */
+
+#ifndef __SDCA_INTERRUPTS_H__
+#define __SDCA_INTERRUPTS_H__
+
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/regmap.h>
+
+struct device;
+struct snd_soc_component;
+struct sdca_function_data;
+
+#define SDCA_MAX_INTERRUPTS 31 /* the last bit is reserved for future extensions */
+
+/**
+ * struct sdca_interrupt - contains information about a single SDCA interrupt
+ * @name: The name of the interrupt.
+ * @component: Pointer to the ASoC component owns the interrupt.
+ * @function: Pointer to the Function that the interrupt is associated with.
+ * @entity: Pointer to the Entity that the interrupt is associated with.
+ * @control: Pointer to the Control that the interrupt is associated with.
+ * @externally_requested: Internal flag used to check if a client driver has
+ * already requested the interrupt, for custom handling, allowing the core to
+ * skip handling this interrupt.
+ */
+struct sdca_interrupt {
+	const char *name;
+
+	struct snd_soc_component *component;
+	struct sdca_function_data *function;
+	struct sdca_entity *entity;
+	struct sdca_control *control;
+
+	bool externally_requested;
+};
+
+/**
+ * struct sdca_interrupt_info - contains top-level SDCA interrupt information
+ * @irq_chip: regmap irq chip structure.
+ * @irq_data: regmap irq chip data structure.
+ * @irqs: Array of data for each individual IRQ.
+ * @irq_lock: Protects access to the list of sdca_interrupt structures.
+ */
+struct sdca_interrupt_info {
+	struct regmap_irq_chip irq_chip;
+	struct regmap_irq_chip_data *irq_data;
+
+	struct sdca_interrupt irqs[SDCA_MAX_INTERRUPTS];
+
+	struct mutex irq_lock; /* Protect irqs list across functions */
+};
+
+int sdca_irq_request(struct device *dev, struct sdca_interrupt_info *interrupt_info,
+		     int sdca_irq, const char *name, irq_handler_t handler,
+		     void *data);
+int sdca_irq_data_populate(struct snd_soc_component *component,
+			   struct sdca_function_data *function,
+			   struct sdca_entity *entity,
+			   struct sdca_control *control,
+			   struct sdca_interrupt *interrupt);
+int sdca_irq_populate(struct sdca_function_data *function,
+		      struct snd_soc_component *component,
+		      struct sdca_interrupt_info *info);
+struct sdca_interrupt_info *sdca_irq_allocate(struct device *dev,
+					      struct regmap *regmap, int irq);
+
+#endif
sound/soc/sdca/Kconfig +7 -0
index ec28855fe3b09..a633d5a0fea51 100644
@@ -13,3 +13,10 @@ config SND_SOC_SDCA_OPTIONAL
 config SND_SOC_SDCA_HID
 	tristate "SDCA HID support"
 	depends on SND_SOC_SDCA && HID
+
+config SND_SOC_SDCA_IRQ
+	tristate
+	select REGMAP
+	select REGMAP_IRQ
+	help
+	  This option enables support for SDCA IRQs.
sound/soc/sdca/Makefile +3 -2
index 9af46e7edfd2a..2a3938d11ca90 100644
@@ -1,8 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 snd-soc-sdca-y	:= sdca_functions.o sdca_device.o sdca_regmap.o sdca_asoc.o
-
 snd-soc-sdca-hid-y := sdca_hid.o
+snd-soc-sdca-irq-y := sdca_interrupts.o
 
-obj-$(CONFIG_SND_SOC_SDCA_HID)	+= snd-soc-sdca-hid.o
 obj-$(CONFIG_SND_SOC_SDCA)	+= snd-soc-sdca.o
+obj-$(CONFIG_SND_SOC_SDCA_HID)	+= snd-soc-sdca-hid.o
+obj-$(CONFIG_SND_SOC_SDCA_IRQ)	+= snd-soc-sdca-irq.o
sound/soc/sdca/sdca_interrupts.c new file +284 -0

284 lines not on this page · raw message

Signature · 1 line
2.39.5
author maintainer
#7 lore raw

PATCH v3 7/7 ASoC: SDCA: Add some initial IRQ handlers

In reply to Charles Keepax

Add basic IRQ handlers for the function status and jack detection interrupts.

---

No change since v2.

 include/sound/sdca_interrupts.h  |   3 +
 sound/soc/sdca/sdca_interrupts.c | 157 ++++++++++++++++++++++++++++++-
 2 files changed, 159 insertions(+), 1 deletion(-)
include/sound/sdca_interrupts.h +3 -0
index 4cda8b75bae0e..bbbc3ab27ebae 100644
@@ -27,6 +27,7 @@ struct sdca_function_data;
  * @function: Pointer to the Function that the interrupt is associated with.
  * @entity: Pointer to the Entity that the interrupt is associated with.
  * @control: Pointer to the Control that the interrupt is associated with.
+ * @priv: Pointer to private data for use by the handler.
  * @externally_requested: Internal flag used to check if a client driver has
  * already requested the interrupt, for custom handling, allowing the core to
  * skip handling this interrupt.
@@ -39,6 +40,8 @@ struct sdca_interrupt {
 	struct sdca_entity *entity;
 	struct sdca_control *control;
 
+	void *priv;
+
 	bool externally_requested;
 };
 
sound/soc/sdca/sdca_interrupts.c +156 -1

188 lines not on this page · raw message

Signature · 1 line
2.39.5
reviewer Reviewed-by on the v3 series
#8 lore raw
In reply to Charles Keepax
Quoted 6 lines · Charles Keepax

Add a maintainers entry for SDCA, do a couple of small fixups for previous chains, and then adding the beginnings of the SDCA IRQ handling. This is based around a regmap IRQ chip and a few helper functions that can be called from the client drivers to setup the IRQs.

Quoted 6 lines

Thanks,
Charles

Changes since v2:
- Just a rebase to avoid a conflict with the recently merged SDCA HID stuff.

For the series:

Quoted 23 lines

Charles Keepax (6):
MAINTAINERS: Add SDCA maintainers entry
ASoC: SDCA: Add missing default in switch in entity_pde_event()
ASoC: SDCA: Fixup some kernel doc errors
ASoC: SDCA: Minor selected/detected mode control fixups
ASoC: SDCA: Add flag for unused IRQs
ASoC: SDCA: Add some initial IRQ handlers

Maciej Strozek (1):
ASoC: SDCA: Generic interrupt support

 MAINTAINERS                      |  11 +
 include/sound/sdca_function.h    |  11 +
 include/sound/sdca_interrupts.h  |  78 ++++++
 sound/soc/sdca/Kconfig           |   7 +
 sound/soc/sdca/Makefile          |   5 +-
 sound/soc/sdca/sdca_asoc.c       |  19 +-
 sound/soc/sdca/sdca_functions.c  |   2 +
 sound/soc/sdca/sdca_interrupts.c | 439 +++++++++++++++++++++++++++++++
 8 files changed, 564 insertions(+), 8 deletions(-)
 create mode 100644 include/sound/sdca_interrupts.h
 create mode 100644 sound/soc/sdca/sdca_interrupts.c
maintainer
#9 lore raw
In reply to Charles Keepax
Quoted 10 lines · Charles Keepax

Add a maintainers entry for SDCA, do a couple of small fixups for previous chains, and then adding the beginnings of the SDCA IRQ handling. This is based around a regmap IRQ chip and a few helper functions that can be called from the client drivers to setup the IRQs.

Thanks,
Charles

[...]

Applied to

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

Thanks!

[1/7] MAINTAINERS: Add SDCA maintainers entry

      commit: 0383a710d28dd5dc43d26ccf9fc74e1ba41868fd
[2/7] ASoC: SDCA: Add missing default in switch in entity_pde_event()
      commit: 2ed526bf04a6d81592b314f81e7719a14048f732
[3/7] ASoC: SDCA: Fixup some kernel doc errors
      commit: b4515fd87cc9a260ae89fb81ca2aa928d496ac86
[4/7] ASoC: SDCA: Minor selected/detected mode control fixups
      commit: 37d2aa62138daa8ecb6442ae4753704e9c92346f
[5/7] ASoC: SDCA: Add flag for unused IRQs
      commit: 775f5729b47d8737f4f98e0141f61b3358245398
[6/7] ASoC: SDCA: Generic interrupt support
      commit: b126394d9ec6f9d8322cf392ba23d4a5f96faf5a
[7/7] ASoC: SDCA: Add some initial IRQ handlers
      commit: b9ab3b61824190b1c6b2c59e7ba4de591f24eb92

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark