Skip to contentSkip to conversation

Add SDCA IRQ support and some misc fixups

PATCH Superseded Charles Keepax 1 participant 8 messages Jun 23, 2025

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

v2 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 v1:
- Update comments on externally_requested and irq_lock.
- Drop warning in base_handler down to an info.
- Added print for function busy.
- Updated comment on SELECTED_MODE handling in IRQ.

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          |   2 +
 sound/soc/sdca/sdca_asoc.c       |  19 +-
 sound/soc/sdca/sdca_functions.c  |   2 +
 sound/soc/sdca/sdca_interrupts.c | 439 +++++++++++++++++++++++++++++++
 8 files changed, 563 insertions(+), 6 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 v2 1/7 MAINTAINERS: Add SDCA maintainers entry

Add a maintainers entry for the new SDCA support code.

---

No changes since v1.

 MAINTAINERS | 11 +++++++++++
 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
index a92290fffa163..b9782f84bb369 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 v2 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 changes since v1.

 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 v2 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 changes since v1.

 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 v2 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 changes since v1.

 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 eaedb54a83227..e5166583d2581 100644
@@ -318,6 +318,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 v2 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 changes since v1.

 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 e5166583d2581..f208d8f03db4e 100644
@@ -16,6 +16,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 64ac264438907..3afe9a24e4e45 100644
@@ -911,6 +911,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 v2 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.

---

Changes since v1:
- Update comments on externally_requested and irq_lock.
- Drop warning in base_handler down to an info.

 include/sound/sdca_interrupts.h  |  75 ++++++++
 sound/soc/sdca/Kconfig           |   7 +
 sound/soc/sdca/Makefile          |   2 +
 sound/soc/sdca/sdca_interrupts.c | 284 +++++++++++++++++++++++++++++++
 4 files changed, 368 insertions(+)
 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 ee20b9914aa1f..d40331cb0a212 100644
@@ -9,3 +9,10 @@ config SND_SOC_SDCA
 
 config SND_SOC_SDCA_OPTIONAL
 	def_tristate SND_SOC_SDCA || !SND_SOC_SDCA
+
+config SND_SOC_SDCA_IRQ
+	tristate
+	select REGMAP
+	select REGMAP_IRQ
+	help
+	  This option enables support for SDCA IRQs.
sound/soc/sdca/Makefile +2 -0
index 53344f108ca67..d7f9a16790ad8 100644
@@ -1,5 +1,7 @@
 # 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-irq-y := sdca_interrupts.o
 
 obj-$(CONFIG_SND_SOC_SDCA)	+= snd-soc-sdca.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 v2 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.

---

Changes since v1:
- Added print for function busy.
- Updated comment on SELECTED_MODE handling in IRQ.

 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