xref: /linux/include/sound/sdca_interrupts.h (revision 22c55fb9eb92395d999b8404d73e58540d11bdd8)
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
79