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 * @dev: Pointer to the Function device. 27 * @device_regmap: Pointer to the IRQ regmap. 28 * @function_regmap: Pointer to the SDCA Function regmap. 29 * @component: Pointer to the ASoC component owns the interrupt. 30 * @function: Pointer to the Function that the interrupt is associated with. 31 * @entity: Pointer to the Entity that the interrupt is associated with. 32 * @control: Pointer to the Control that the interrupt is associated with. 33 * @priv: Pointer to private data for use by the handler. 34 * @irq: IRQ number allocated to this interrupt, also used internally to track 35 * the IRQ being assigned. 36 */ 37 struct sdca_interrupt { 38 const char *name; 39 40 struct device *dev; 41 struct regmap *device_regmap; 42 struct regmap *function_regmap; 43 struct snd_soc_component *component; 44 struct sdca_function_data *function; 45 struct sdca_entity *entity; 46 struct sdca_control *control; 47 48 void *priv; 49 50 int irq; 51 }; 52 53 /** 54 * struct sdca_interrupt_info - contains top-level SDCA interrupt information 55 * @irq_chip: regmap irq chip structure. 56 * @irq_data: regmap irq chip data structure. 57 * @irqs: Array of data for each individual IRQ. 58 * @irq_lock: Protects access to the list of sdca_interrupt structures. 59 */ 60 struct sdca_interrupt_info { 61 struct regmap_irq_chip irq_chip; 62 struct regmap_irq_chip_data *irq_data; 63 64 struct sdca_interrupt irqs[SDCA_MAX_INTERRUPTS]; 65 66 struct mutex irq_lock; /* Protect irqs list across functions */ 67 }; 68 69 int sdca_irq_request(struct device *dev, struct sdca_interrupt_info *interrupt_info, 70 int sdca_irq, const char *name, irq_handler_t handler, 71 void *data); 72 int sdca_irq_data_populate(struct device *dev, struct regmap *function_regmap, 73 struct snd_soc_component *component, 74 struct sdca_function_data *function, 75 struct sdca_entity *entity, 76 struct sdca_control *control, 77 struct sdca_interrupt *interrupt); 78 int sdca_irq_populate_early(struct device *dev, struct regmap *function_regmap, 79 struct sdca_function_data *function, 80 struct sdca_interrupt_info *info); 81 int sdca_irq_populate(struct sdca_function_data *function, 82 struct snd_soc_component *component, 83 struct sdca_interrupt_info *info); 84 struct sdca_interrupt_info *sdca_irq_allocate(struct device *dev, 85 struct regmap *regmap, int irq); 86 87 #endif 88