Skip to content

Commit c1d10f4

Browse files
committed
ASoC: Add SDCA IRQ support and some misc fixups
Merge series from Charles Keepax <[email protected]>: 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.
2 parents 29ddce1 + b9ab3b6 commit c1d10f4

File tree

8 files changed

+564
-8
lines changed

8 files changed

+564
-8
lines changed

MAINTAINERS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22298,6 +22298,17 @@ M: Jim Cromie <[email protected]>
2229822298
S: Maintained
2229922299
F: drivers/clocksource/scx200_hrt.c
2230022300

22301+
SDCA LIBRARY AND CLASS DRIVER
22302+
M: Charles Keepax <[email protected]>
22303+
M: Maciej Strozek <[email protected]>
22304+
R: Bard Liao <[email protected]>
22305+
R: Pierre-Louis Bossart <[email protected]>
22306+
22307+
22308+
S: Maintained
22309+
F: include/sound/sdca*
22310+
F: sound/soc/sdca/*
22311+
2230122312
SDRICOH_CS MMC/SD HOST CONTROLLER INTERFACE DRIVER
2230222313
M: Sascha Sommer <[email protected]>
2230322314
L: [email protected] (subscribers-only)

include/sound/sdca_function.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ struct device;
1717
struct sdca_entity;
1818
struct sdca_function_desc;
1919

20+
#define SDCA_NO_INTERRUPT -1
21+
2022
/*
2123
* The addressing space for SDCA relies on 7 bits for Entities, so a
2224
* maximum of 128 Entities per function can be represented.
@@ -319,6 +321,15 @@ enum sdca_selected_mode_range {
319321
SDCA_SELECTED_MODE_NCOLS = 2,
320322
};
321323

324+
/**
325+
* enum sdca_detected_mode_values - Predefined GE Detected Mode values
326+
*/
327+
enum sdca_detected_mode_values {
328+
SDCA_DETECTED_MODE_JACK_UNPLUGGED = 0,
329+
SDCA_DETECTED_MODE_JACK_UNKNOWN = 1,
330+
SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS = 2,
331+
};
332+
322333
/**
323334
* enum sdca_spe_controls - SDCA Controls for Security & Privacy Unit
324335
*

include/sound/sdca_interrupts.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* The MIPI SDCA specification is available for public downloads at
4+
* https://www.mipi.org/mipi-sdca-v1-0-download
5+
*
6+
* Copyright (C) 2025 Cirrus Logic, Inc. and
7+
* Cirrus Logic International Semiconductor Ltd.
8+
*/
9+
10+
#ifndef __SDCA_INTERRUPTS_H__
11+
#define __SDCA_INTERRUPTS_H__
12+
13+
#include <linux/interrupt.h>
14+
#include <linux/mutex.h>
15+
#include <linux/regmap.h>
16+
17+
struct device;
18+
struct snd_soc_component;
19+
struct sdca_function_data;
20+
21+
#define SDCA_MAX_INTERRUPTS 31 /* the last bit is reserved for future extensions */
22+
23+
/**
24+
* struct sdca_interrupt - contains information about a single SDCA interrupt
25+
* @name: The name of the interrupt.
26+
* @component: Pointer to the ASoC component owns the interrupt.
27+
* @function: Pointer to the Function that the interrupt is associated with.
28+
* @entity: Pointer to the Entity that the interrupt is associated with.
29+
* @control: Pointer to the Control that the interrupt is associated with.
30+
* @priv: Pointer to private data for use by the handler.
31+
* @externally_requested: Internal flag used to check if a client driver has
32+
* already requested the interrupt, for custom handling, allowing the core to
33+
* skip handling this interrupt.
34+
*/
35+
struct sdca_interrupt {
36+
const char *name;
37+
38+
struct snd_soc_component *component;
39+
struct sdca_function_data *function;
40+
struct sdca_entity *entity;
41+
struct sdca_control *control;
42+
43+
void *priv;
44+
45+
bool externally_requested;
46+
};
47+
48+
/**
49+
* struct sdca_interrupt_info - contains top-level SDCA interrupt information
50+
* @irq_chip: regmap irq chip structure.
51+
* @irq_data: regmap irq chip data structure.
52+
* @irqs: Array of data for each individual IRQ.
53+
* @irq_lock: Protects access to the list of sdca_interrupt structures.
54+
*/
55+
struct sdca_interrupt_info {
56+
struct regmap_irq_chip irq_chip;
57+
struct regmap_irq_chip_data *irq_data;
58+
59+
struct sdca_interrupt irqs[SDCA_MAX_INTERRUPTS];
60+
61+
struct mutex irq_lock; /* Protect irqs list across functions */
62+
};
63+
64+
int sdca_irq_request(struct device *dev, struct sdca_interrupt_info *interrupt_info,
65+
int sdca_irq, const char *name, irq_handler_t handler,
66+
void *data);
67+
int sdca_irq_data_populate(struct snd_soc_component *component,
68+
struct sdca_function_data *function,
69+
struct sdca_entity *entity,
70+
struct sdca_control *control,
71+
struct sdca_interrupt *interrupt);
72+
int sdca_irq_populate(struct sdca_function_data *function,
73+
struct snd_soc_component *component,
74+
struct sdca_interrupt_info *info);
75+
struct sdca_interrupt_info *sdca_irq_allocate(struct device *dev,
76+
struct regmap *regmap, int irq);
77+
78+
#endif

sound/soc/sdca/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ config SND_SOC_SDCA_HID
1515
tristate "SDCA HID support"
1616
depends on SND_SOC_SDCA && HID
1717

18+
config SND_SOC_SDCA_IRQ
19+
tristate
20+
select REGMAP
21+
select REGMAP_IRQ
22+
help
23+
This option enables support for SDCA IRQs.
24+
1825
endmenu

sound/soc/sdca/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

33
snd-soc-sdca-y := sdca_functions.o sdca_device.o sdca_regmap.o sdca_asoc.o
4-
54
snd-soc-sdca-hid-y := sdca_hid.o
5+
snd-soc-sdca-irq-y := sdca_interrupts.o
66

7-
obj-$(CONFIG_SND_SOC_SDCA_HID) += snd-soc-sdca-hid.o
87
obj-$(CONFIG_SND_SOC_SDCA) += snd-soc-sdca.o
8+
obj-$(CONFIG_SND_SOC_SDCA_HID) += snd-soc-sdca-hid.o
9+
obj-$(CONFIG_SND_SOC_SDCA_IRQ) += snd-soc-sdca-irq.o

sound/soc/sdca/sdca_asoc.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static bool readonly_control(struct sdca_control *control)
9393

9494
/**
9595
* sdca_asoc_count_component - count the various component parts
96+
* @dev: Pointer to the device against which allocations will be done.
9697
* @function: Pointer to the Function information.
9798
* @num_widgets: Output integer pointer, will be filled with the
9899
* required number of DAPM widgets for the Function.
@@ -245,12 +246,12 @@ static int entity_early_parse_ge(struct device *dev,
245246
if (!values)
246247
return -ENOMEM;
247248

248-
texts[0] = "No Jack";
249+
texts[0] = "Jack Unplugged";
249250
texts[1] = "Jack Unknown";
250251
texts[2] = "Detection in Progress";
251-
values[0] = 0;
252-
values[1] = 1;
253-
values[2] = 2;
252+
values[0] = SDCA_DETECTED_MODE_JACK_UNPLUGGED;
253+
values[1] = SDCA_DETECTED_MODE_JACK_UNKNOWN;
254+
values[2] = SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS;
254255
for (i = 0; i < range->rows; i++) {
255256
enum sdca_terminal_type type;
256257

@@ -397,6 +398,8 @@ static int entity_pde_event(struct snd_soc_dapm_widget *widget,
397398
from = widget->off_val;
398399
to = widget->on_val;
399400
break;
401+
default:
402+
return 0;
400403
}
401404

402405
for (i = 0; i < entity->pde.num_max_delay; i++) {
@@ -995,7 +998,7 @@ static int populate_pin_switch(struct device *dev,
995998
* sdca_asoc_populate_controls - fill in an array of ALSA controls for a Function
996999
* @dev: Pointer to the device against which allocations will be done.
9971000
* @function: Pointer to the Function information.
998-
* @route: Array of ALSA controls to be populated.
1001+
* @kctl: Array of ALSA controls to be populated.
9991002
*
10001003
* This function populates an array of ALSA controls from the DisCo
10011004
* information for a particular SDCA Function. Typically,
@@ -1242,7 +1245,11 @@ EXPORT_SYMBOL_NS(sdca_asoc_populate_dais, "SND_SOC_SDCA");
12421245
* sdca_asoc_populate_component - fill in a component driver for a Function
12431246
* @dev: Pointer to the device against which allocations will be done.
12441247
* @function: Pointer to the Function information.
1245-
* @copmonent_drv: Pointer to the component driver to be populated.
1248+
* @component_drv: Pointer to the component driver to be populated.
1249+
* @dai_drv: Pointer to the DAI driver array to be allocated and populated.
1250+
* @num_dai_drv: Pointer to integer that will be populated with the number of
1251+
* DAI drivers.
1252+
* @ops: DAI ops pointer that will be used for each DAI driver.
12461253
*
12471254
* This function populates a snd_soc_component_driver structure based
12481255
* on the DisCo information for a particular SDCA Function. It does

sound/soc/sdca/sdca_functions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,8 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
912912
&tmp);
913913
if (!ret)
914914
control->interrupt_position = tmp;
915+
else
916+
control->interrupt_position = SDCA_NO_INTERRUPT;
915917

916918
control->label = find_sdca_control_label(dev, entity, control);
917919
if (!control->label)

0 commit comments

Comments
 (0)