xref: /linux/sound/soc/sdca/sdca_interrupts.c (revision 250922577ed16c29b994197b84a231dcbe7798e8)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2025 Cirrus Logic, Inc. and
3 //                    Cirrus Logic International Semiconductor Ltd.
4 
5 /*
6  * The MIPI SDCA specification is available for public downloads at
7  * https://www.mipi.org/mipi-sdca-v1-0-download
8  */
9 
10 #include <linux/bitmap.h>
11 #include <linux/bits.h>
12 #include <linux/cleanup.h>
13 #include <linux/device.h>
14 #include <linux/dev_printk.h>
15 #include <linux/interrupt.h>
16 #include <linux/pm_runtime.h>
17 #include <linux/regmap.h>
18 #include <linux/soundwire/sdw.h>
19 #include <linux/soundwire/sdw_registers.h>
20 #include <sound/sdca.h>
21 #include <sound/sdca_fdl.h>
22 #include <sound/sdca_function.h>
23 #include <sound/sdca_hid.h>
24 #include <sound/sdca_interrupts.h>
25 #include <sound/sdca_jack.h>
26 #include <sound/sdca_ump.h>
27 #include <sound/soc-component.h>
28 #include <sound/soc.h>
29 
30 #define IRQ_SDCA(number) REGMAP_IRQ_REG(number, ((number) / BITS_PER_BYTE), \
31 					SDW_SCP_SDCA_INTMASK_SDCA_##number)
32 
33 static const struct regmap_irq regmap_irqs[SDCA_MAX_INTERRUPTS] = {
34 	IRQ_SDCA(0),
35 	IRQ_SDCA(1),
36 	IRQ_SDCA(2),
37 	IRQ_SDCA(3),
38 	IRQ_SDCA(4),
39 	IRQ_SDCA(5),
40 	IRQ_SDCA(6),
41 	IRQ_SDCA(7),
42 	IRQ_SDCA(8),
43 	IRQ_SDCA(9),
44 	IRQ_SDCA(10),
45 	IRQ_SDCA(11),
46 	IRQ_SDCA(12),
47 	IRQ_SDCA(13),
48 	IRQ_SDCA(14),
49 	IRQ_SDCA(15),
50 	IRQ_SDCA(16),
51 	IRQ_SDCA(17),
52 	IRQ_SDCA(18),
53 	IRQ_SDCA(19),
54 	IRQ_SDCA(20),
55 	IRQ_SDCA(21),
56 	IRQ_SDCA(22),
57 	IRQ_SDCA(23),
58 	IRQ_SDCA(24),
59 	IRQ_SDCA(25),
60 	IRQ_SDCA(26),
61 	IRQ_SDCA(27),
62 	IRQ_SDCA(28),
63 	IRQ_SDCA(29),
64 	IRQ_SDCA(30),
65 };
66 
67 static const struct regmap_irq_chip sdca_irq_chip = {
68 	.name = "sdca_irq",
69 
70 	.status_base = SDW_SCP_SDCA_INT1,
71 	.unmask_base = SDW_SCP_SDCA_INTMASK1,
72 	.ack_base = SDW_SCP_SDCA_INT1,
73 	.num_regs = 4,
74 
75 	.irqs = regmap_irqs,
76 	.num_irqs = SDCA_MAX_INTERRUPTS,
77 
78 	.runtime_pm = true,
79 };
80 
81 static irqreturn_t base_handler(int irq, void *data)
82 {
83 	struct sdca_interrupt *interrupt = data;
84 	struct device *dev = interrupt->dev;
85 
86 	dev_info(dev, "%s irq without full handling\n", interrupt->name);
87 
88 	return IRQ_HANDLED;
89 }
90 
91 static irqreturn_t function_status_handler(int irq, void *data)
92 {
93 	struct sdca_interrupt *interrupt = data;
94 	struct device *dev = interrupt->dev;
95 	irqreturn_t irqret = IRQ_NONE;
96 	unsigned int reg, val;
97 	unsigned long status;
98 	unsigned int mask;
99 	int ret;
100 
101 	ret = pm_runtime_get_sync(dev);
102 	if (ret < 0) {
103 		dev_err(dev, "failed to resume for function status: %d\n", ret);
104 		goto error;
105 	}
106 
107 	reg = SDW_SDCA_CTL(interrupt->function->desc->adr, interrupt->entity->id,
108 			   interrupt->control->sel, 0);
109 
110 	ret = regmap_read(interrupt->function_regmap, reg, &val);
111 	if (ret < 0) {
112 		dev_err(dev, "failed to read function status: %d\n", ret);
113 		goto error;
114 	}
115 
116 	dev_dbg(dev, "function status: %#x\n", val);
117 
118 	status = val;
119 	for_each_set_bit(mask, &status, BITS_PER_BYTE) {
120 		switch (BIT(mask)) {
121 		case SDCA_CTL_ENTITY_0_FUNCTION_NEEDS_INITIALIZATION:
122 /*
123  * FIXME: Should this do init writes?
124  *
125  * Currently init writes/cache sync are done from the suspend/resume
126  * infrastructure. It is unclear in what situations one would receive this
127  * IRQ outside of that flow. Presumably it would be something like the chip
128  * crashing. In that case however doing the init writes and a cache sync might
129  * not be sufficient, for example if the failure was during audio playback
130  * there could be ordering constraints on the register writes to restore the
131  * state that are not handled by a simple cache sync.
132  */
133 			break;
134 		case SDCA_CTL_ENTITY_0_FUNCTION_FAULT:
135 			dev_err(dev, "function fault\n");
136 			break;
137 		case SDCA_CTL_ENTITY_0_UMP_SEQUENCE_FAULT:
138 			dev_err(dev, "ump sequence fault\n");
139 			break;
140 		case SDCA_CTL_ENTITY_0_FUNCTION_BUSY:
141 			dev_info(dev, "unexpected function busy\n");
142 			break;
143 		case SDCA_CTL_ENTITY_0_DEVICE_NEWLY_ATTACHED:
144 		case SDCA_CTL_ENTITY_0_INTS_DISABLED_ABNORMALLY:
145 		case SDCA_CTL_ENTITY_0_STREAMING_STOPPED_ABNORMALLY:
146 		case SDCA_CTL_ENTITY_0_FUNCTION_HAS_BEEN_RESET:
147 			break;
148 		}
149 	}
150 
151 	ret = regmap_write(interrupt->function_regmap, reg, val & 0x7F);
152 	if (ret < 0) {
153 		dev_err(dev, "failed to clear function status: %d\n", ret);
154 		goto error;
155 	}
156 
157 	irqret = IRQ_HANDLED;
158 error:
159 	pm_runtime_put(dev);
160 	return irqret;
161 }
162 
163 static irqreturn_t detected_mode_handler(int irq, void *data)
164 {
165 	struct sdca_interrupt *interrupt = data;
166 	struct device *dev = interrupt->dev;
167 	irqreturn_t irqret = IRQ_NONE;
168 	int ret;
169 
170 	ret = pm_runtime_get_sync(dev);
171 	if (ret < 0) {
172 		dev_err(dev, "failed to resume for detected mode: %d\n", ret);
173 		goto error;
174 	}
175 
176 	ret = sdca_jack_process(interrupt);
177 	if (ret)
178 		goto error;
179 
180 	irqret = IRQ_HANDLED;
181 error:
182 	pm_runtime_put(dev);
183 	return irqret;
184 }
185 
186 static irqreturn_t hid_handler(int irq, void *data)
187 {
188 	struct sdca_interrupt *interrupt = data;
189 	struct device *dev = interrupt->dev;
190 	irqreturn_t irqret = IRQ_NONE;
191 	int ret;
192 
193 	ret = pm_runtime_get_sync(dev);
194 	if (ret < 0) {
195 		dev_err(dev, "failed to resume for hid: %d\n", ret);
196 		goto error;
197 	}
198 
199 	ret = sdca_hid_process_report(interrupt);
200 	if (ret)
201 		goto error;
202 
203 	irqret = IRQ_HANDLED;
204 error:
205 	pm_runtime_put(dev);
206 	return irqret;
207 }
208 
209 #ifdef CONFIG_PM_SLEEP
210 static bool no_pm_in_progress(struct device *dev)
211 {
212 	return completion_done(&dev->power.completion);
213 }
214 #else
215 static bool no_pm_in_progress(struct device *dev)
216 {
217 	return true;
218 }
219 #endif
220 
221 static irqreturn_t fdl_owner_handler(int irq, void *data)
222 {
223 	struct sdca_interrupt *interrupt = data;
224 	struct device *dev = interrupt->dev;
225 	irqreturn_t irqret = IRQ_NONE;
226 	int ret;
227 
228 	/*
229 	 * FDL has to run from the system resume handler, at which point
230 	 * we can't wait for the pm runtime.
231 	 */
232 	if (no_pm_in_progress(dev)) {
233 		ret = pm_runtime_get_sync(dev);
234 		if (ret < 0) {
235 			dev_err(dev, "failed to resume for fdl: %d\n", ret);
236 			goto error;
237 		}
238 	}
239 
240 	ret = sdca_fdl_process(interrupt);
241 	if (ret)
242 		goto error;
243 
244 	irqret = IRQ_HANDLED;
245 error:
246 	if (no_pm_in_progress(dev))
247 		pm_runtime_put(dev);
248 	return irqret;
249 }
250 
251 static int sdca_irq_request_locked(struct device *dev,
252 				   struct sdca_interrupt_info *info,
253 				   int sdca_irq, const char *name,
254 				   irq_handler_t handler, void *data)
255 {
256 	int irq;
257 	int ret;
258 
259 	irq = regmap_irq_get_virq(info->irq_data, sdca_irq);
260 	if (irq < 0)
261 		return irq;
262 
263 	ret = request_threaded_irq(irq, NULL, handler, IRQF_ONESHOT, name, data);
264 	if (ret)
265 		return ret;
266 
267 	info->irqs[sdca_irq].irq = irq;
268 
269 	dev_dbg(dev, "requested irq %d for %s\n", irq, name);
270 
271 	return 0;
272 }
273 
274 static void sdca_irq_free_locked(struct device *dev, struct sdca_interrupt_info *info,
275 				 int sdca_irq, const char *name, void *data)
276 {
277 	int irq;
278 
279 	irq = regmap_irq_get_virq(info->irq_data, sdca_irq);
280 	if (irq < 0)
281 		return;
282 
283 	free_irq(irq, data);
284 
285 	info->irqs[sdca_irq].irq = 0;
286 
287 	dev_dbg(dev, "freed irq %d for %s\n", irq, name);
288 }
289 
290 /**
291  * sdca_irq_request - request an individual SDCA interrupt
292  * @dev: Pointer to the struct device against which things should be allocated.
293  * @info: Pointer to the interrupt information structure.
294  * @sdca_irq: SDCA interrupt position.
295  * @name: Name to be given to the IRQ.
296  * @handler: A callback thread function to be called for the IRQ.
297  * @data: Private data pointer that will be passed to the handler.
298  *
299  * Typically this is handled internally by sdca_irq_populate, however if
300  * a device requires custom IRQ handling this can be called manually before
301  * calling sdca_irq_populate, which will then skip that IRQ whilst processing.
302  *
303  * Return: Zero on success, and a negative error code on failure.
304  */
305 int sdca_irq_request(struct device *dev, struct sdca_interrupt_info *info,
306 		     int sdca_irq, const char *name, irq_handler_t handler,
307 		     void *data)
308 {
309 	int ret;
310 
311 	if (sdca_irq < 0 || sdca_irq >= SDCA_MAX_INTERRUPTS) {
312 		dev_err(dev, "bad irq request: %d\n", sdca_irq);
313 		return -EINVAL;
314 	}
315 
316 	guard(mutex)(&info->irq_lock);
317 
318 	ret = sdca_irq_request_locked(dev, info, sdca_irq, name, handler, data);
319 	if (ret) {
320 		dev_err(dev, "failed to request irq %s: %d\n", name, ret);
321 		return ret;
322 	}
323 
324 	return 0;
325 }
326 EXPORT_SYMBOL_NS_GPL(sdca_irq_request, "SND_SOC_SDCA");
327 
328 /**
329  * sdca_irq_free - free an individual SDCA interrupt
330  * @dev: Pointer to the struct device.
331  * @info: Pointer to the interrupt information structure.
332  * @sdca_irq: SDCA interrupt position.
333  * @name: Name to be given to the IRQ.
334  * @data: Private data pointer that will be passed to the handler.
335  *
336  * Typically this is handled internally by sdca_irq_cleanup, however if
337  * a device requires custom IRQ handling this can be called manually before
338  * calling sdca_irq_cleanup, which will then skip that IRQ whilst processing.
339  */
340 void sdca_irq_free(struct device *dev, struct sdca_interrupt_info *info,
341 		   int sdca_irq, const char *name, void *data)
342 {
343 	if (sdca_irq < 0 || sdca_irq >= SDCA_MAX_INTERRUPTS)
344 		return;
345 
346 	guard(mutex)(&info->irq_lock);
347 
348 	sdca_irq_free_locked(dev, info, sdca_irq, name, data);
349 }
350 EXPORT_SYMBOL_NS_GPL(sdca_irq_free, "SND_SOC_SDCA");
351 
352 /**
353  * sdca_irq_data_populate - Populate common interrupt data
354  * @dev: Pointer to the Function device.
355  * @regmap: Pointer to the Function regmap.
356  * @component: Pointer to the ASoC component for the Function.
357  * @function: Pointer to the SDCA Function.
358  * @entity: Pointer to the SDCA Entity.
359  * @control: Pointer to the SDCA Control.
360  * @interrupt: Pointer to the SDCA interrupt for this IRQ.
361  *
362  * Return: Zero on success, and a negative error code on failure.
363  */
364 int sdca_irq_data_populate(struct device *dev, struct regmap *regmap,
365 			   struct snd_soc_component *component,
366 			   struct sdca_function_data *function,
367 			   struct sdca_entity *entity,
368 			   struct sdca_control *control,
369 			   struct sdca_interrupt *interrupt)
370 {
371 	const char *name;
372 
373 	if (!dev && component)
374 		dev = component->dev;
375 	if (!dev)
376 		return -ENODEV;
377 
378 	name = kasprintf(GFP_KERNEL, "%s %s", entity->label, control->label);
379 	if (!name)
380 		return -ENOMEM;
381 
382 	interrupt->name = name;
383 	interrupt->dev = dev;
384 	if (!regmap && component)
385 		interrupt->function_regmap = component->regmap;
386 	else
387 		interrupt->function_regmap = regmap;
388 	interrupt->component = component;
389 	interrupt->function = function;
390 	interrupt->entity = entity;
391 	interrupt->control = control;
392 
393 	return 0;
394 }
395 EXPORT_SYMBOL_NS_GPL(sdca_irq_data_populate, "SND_SOC_SDCA");
396 
397 static struct sdca_interrupt *get_interrupt_data(struct device *dev, int irq,
398 						 struct sdca_interrupt_info *info)
399 {
400 	if (irq == SDCA_NO_INTERRUPT) {
401 		return NULL;
402 	} else if (irq < 0 || irq >= SDCA_MAX_INTERRUPTS) {
403 		dev_err(dev, "bad irq position: %d\n", irq);
404 		return ERR_PTR(-EINVAL);
405 	}
406 
407 	if (info->irqs[irq].irq) {
408 		dev_dbg(dev, "skipping irq %d, already requested\n", irq);
409 		return NULL;
410 	}
411 
412 	return &info->irqs[irq];
413 }
414 
415 /**
416  * sdca_irq_populate_early - process pre-audio card IRQ registrations
417  * @dev: Device pointer for SDCA Function.
418  * @regmap: Regmap pointer for the SDCA Function.
419  * @function: Pointer to the SDCA Function.
420  * @info: Pointer to the SDCA interrupt info for this device.
421  *
422  * This is intended to be used as part of the Function boot process. It
423  * can be called before the soundcard is registered (ie. doesn't depend
424  * on component) and will register the FDL interrupts.
425  *
426  * Return: Zero on success, and a negative error code on failure.
427  */
428 int sdca_irq_populate_early(struct device *dev, struct regmap *regmap,
429 			    struct sdca_function_data *function,
430 			    struct sdca_interrupt_info *info)
431 {
432 	int i, j;
433 
434 	guard(mutex)(&info->irq_lock);
435 
436 	for (i = 0; i < function->num_entities; i++) {
437 		struct sdca_entity *entity = &function->entities[i];
438 
439 		for (j = 0; j < entity->num_controls; j++) {
440 			struct sdca_control *control = &entity->controls[j];
441 			int irq = control->interrupt_position;
442 			struct sdca_interrupt *interrupt;
443 			int ret;
444 
445 			interrupt = get_interrupt_data(dev, irq, info);
446 			if (IS_ERR(interrupt))
447 				return PTR_ERR(interrupt);
448 			else if (!interrupt)
449 				continue;
450 
451 			switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
452 			case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER):
453 				ret = sdca_irq_data_populate(dev, regmap, NULL,
454 							     function, entity,
455 							     control, interrupt);
456 				if (ret)
457 					return ret;
458 
459 				ret = sdca_fdl_alloc_state(interrupt);
460 				if (ret)
461 					return ret;
462 
463 				ret = sdca_irq_request_locked(dev, info, irq,
464 							      interrupt->name,
465 							      fdl_owner_handler,
466 							      interrupt);
467 				if (ret) {
468 					dev_err(dev, "failed to request irq %s: %d\n",
469 						interrupt->name, ret);
470 					return ret;
471 				}
472 				break;
473 			default:
474 				break;
475 			}
476 		}
477 	}
478 
479 	return 0;
480 }
481 EXPORT_SYMBOL_NS_GPL(sdca_irq_populate_early, "SND_SOC_SDCA");
482 
483 /**
484  * sdca_irq_populate - Request all the individual IRQs for an SDCA Function
485  * @function: Pointer to the SDCA Function.
486  * @component: Pointer to the ASoC component for the Function.
487  * @info: Pointer to the SDCA interrupt info for this device.
488  *
489  * Typically this would be called from the driver for a single SDCA Function.
490  *
491  * Return: Zero on success, and a negative error code on failure.
492  */
493 int sdca_irq_populate(struct sdca_function_data *function,
494 		      struct snd_soc_component *component,
495 		      struct sdca_interrupt_info *info)
496 {
497 	struct device *dev = component->dev;
498 	int i, j;
499 
500 	guard(mutex)(&info->irq_lock);
501 
502 	for (i = 0; i < function->num_entities; i++) {
503 		struct sdca_entity *entity = &function->entities[i];
504 
505 		for (j = 0; j < entity->num_controls; j++) {
506 			struct sdca_control *control = &entity->controls[j];
507 			int irq = control->interrupt_position;
508 			struct sdca_interrupt *interrupt;
509 			irq_handler_t handler;
510 			int ret;
511 
512 			interrupt = get_interrupt_data(dev, irq, info);
513 			if (IS_ERR(interrupt))
514 				return PTR_ERR(interrupt);
515 			else if (!interrupt)
516 				continue;
517 
518 			ret = sdca_irq_data_populate(dev, NULL, component,
519 						     function, entity, control,
520 						     interrupt);
521 			if (ret)
522 				return ret;
523 
524 			handler = base_handler;
525 
526 			switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
527 			case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_STATUS):
528 				handler = function_status_handler;
529 				break;
530 			case SDCA_CTL_TYPE_S(GE, DETECTED_MODE):
531 				ret = sdca_jack_alloc_state(interrupt);
532 				if (ret)
533 					return ret;
534 
535 				handler = detected_mode_handler;
536 				break;
537 			case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER):
538 				ret = sdca_fdl_alloc_state(interrupt);
539 				if (ret)
540 					return ret;
541 
542 				handler = fdl_owner_handler;
543 				break;
544 			case SDCA_CTL_TYPE_S(HIDE, HIDTX_CURRENTOWNER):
545 				handler = hid_handler;
546 				break;
547 			default:
548 				break;
549 			}
550 
551 			ret = sdca_irq_request_locked(dev, info, irq, interrupt->name,
552 						      handler, interrupt);
553 			if (ret) {
554 				dev_err(dev, "failed to request irq %s: %d\n",
555 					interrupt->name, ret);
556 				return ret;
557 			}
558 		}
559 	}
560 
561 	return 0;
562 }
563 EXPORT_SYMBOL_NS_GPL(sdca_irq_populate, "SND_SOC_SDCA");
564 
565 /**
566  * sdca_irq_cleanup - Free all the individual IRQs for an SDCA Function
567  * @dev: Device pointer against which the sdca_interrupt_info was allocated.
568  * @function: Pointer to the SDCA Function.
569  * @info: Pointer to the SDCA interrupt info for this device.
570  *
571  * Typically this would be called from the driver for a single SDCA Function.
572  */
573 void sdca_irq_cleanup(struct device *dev,
574 		      struct sdca_function_data *function,
575 		      struct sdca_interrupt_info *info)
576 {
577 	int i;
578 
579 	guard(mutex)(&info->irq_lock);
580 
581 	for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) {
582 		struct sdca_interrupt *interrupt = &info->irqs[i];
583 
584 		if (interrupt->function != function || !interrupt->irq)
585 			continue;
586 
587 		sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt);
588 
589 		kfree(interrupt->name);
590 	}
591 }
592 EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA");
593 
594 /**
595  * sdca_irq_allocate - allocate an SDCA interrupt structure for a device
596  * @sdev: Device pointer against which things should be allocated.
597  * @regmap: regmap to be used for accessing the SDCA IRQ registers.
598  * @irq: The interrupt number.
599  *
600  * Typically this would be called from the top level driver for the whole
601  * SDCA device, as only a single instance is required across all Functions
602  * on the device.
603  *
604  * Return: A pointer to the allocated sdca_interrupt_info struct, or an
605  * error code.
606  */
607 struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev,
608 					      struct regmap *regmap, int irq)
609 {
610 	struct sdca_interrupt_info *info;
611 	int ret, i;
612 
613 	info = devm_kzalloc(sdev, sizeof(*info), GFP_KERNEL);
614 	if (!info)
615 		return ERR_PTR(-ENOMEM);
616 
617 	info->irq_chip = sdca_irq_chip;
618 
619 	for (i = 0; i < ARRAY_SIZE(info->irqs); i++)
620 		info->irqs[i].device_regmap = regmap;
621 
622 	ret = devm_mutex_init(sdev, &info->irq_lock);
623 	if (ret)
624 		return ERR_PTR(ret);
625 
626 	ret = devm_regmap_add_irq_chip(sdev, regmap, irq, IRQF_ONESHOT, 0,
627 				       &info->irq_chip, &info->irq_data);
628 	if (ret) {
629 		dev_err(sdev, "failed to register irq chip: %d\n", ret);
630 		return ERR_PTR(ret);
631 	}
632 
633 	dev_dbg(sdev, "registered on irq %d\n", irq);
634 
635 	return info;
636 }
637 EXPORT_SYMBOL_NS_GPL(sdca_irq_allocate, "SND_SOC_SDCA");
638 
639 static void irq_enable_flags(struct sdca_function_data *function,
640 			     struct sdca_interrupt_info *info, bool early)
641 {
642 	int i;
643 
644 	for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) {
645 		struct sdca_interrupt *interrupt = &info->irqs[i];
646 
647 		if (!interrupt->irq || interrupt->function != function)
648 			continue;
649 
650 		switch (SDCA_CTL_TYPE(interrupt->entity->type,
651 				      interrupt->control->sel)) {
652 		case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER):
653 			if (early)
654 				enable_irq(interrupt->irq);
655 			break;
656 		default:
657 			if (!early)
658 				enable_irq(interrupt->irq);
659 			break;
660 		}
661 	}
662 }
663 
664 /**
665  * sdca_irq_enable_early - Re-enable early SDCA IRQs for a given function
666  * @function: Pointer to the SDCA Function.
667  * @info: Pointer to the SDCA interrupt info for this device.
668  *
669  * The early version of the IRQ enable allows enabling IRQs which may be
670  * necessary to bootstrap functionality for other IRQs, such as the FDL
671  * process.
672  */
673 void sdca_irq_enable_early(struct sdca_function_data *function,
674 			   struct sdca_interrupt_info *info)
675 {
676 	irq_enable_flags(function, info, true);
677 }
678 EXPORT_SYMBOL_NS_GPL(sdca_irq_enable_early, "SND_SOC_SDCA");
679 
680 /**
681  * sdca_irq_enable - Re-enable SDCA IRQs for a given function
682  * @function: Pointer to the SDCA Function.
683  * @info: Pointer to the SDCA interrupt info for this device.
684  */
685 void sdca_irq_enable(struct sdca_function_data *function,
686 		     struct sdca_interrupt_info *info)
687 {
688 	irq_enable_flags(function, info, false);
689 }
690 EXPORT_SYMBOL_NS_GPL(sdca_irq_enable, "SND_SOC_SDCA");
691 
692 /**
693  * sdca_irq_disable - Disable SDCA IRQs for a given function
694  * @function: Pointer to the SDCA Function.
695  * @info: Pointer to the SDCA interrupt info for this device.
696  */
697 void sdca_irq_disable(struct sdca_function_data *function,
698 		      struct sdca_interrupt_info *info)
699 {
700 	int i;
701 
702 	for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) {
703 		struct sdca_interrupt *interrupt = &info->irqs[i];
704 
705 		if (!interrupt->irq || interrupt->function != function)
706 			continue;
707 
708 		disable_irq(interrupt->irq);
709 	}
710 }
711 EXPORT_SYMBOL_NS_GPL(sdca_irq_disable, "SND_SOC_SDCA");
712