| 1 |
|
| 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
|
| 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 | * @handler: Handler function to be called for the IRQ.
|
| 34 | * @priv: Pointer to private data for use by the handler.
|
| 35 | * @free_priv: Pointer to a function that can be used to free the priv data.
|
| 36 | * @irq: IRQ number allocated to this interrupt, also used internally to track
|
| 37 | * the IRQ being assigned.
|
| 38 | * @early_request: Flag to indicate this IRQ was requested at bus probe time.
|
| 39 |
|
| 40 | struct sdca_interrupt {
|
| 41 | const char *name;
|
| 42 |
|
| 43 | struct device *dev;
|
| 44 | struct regmap *device_regmap;
|
| 45 | struct regmap *function_regmap;
|
| 46 | struct snd_soc_component *component;
|
| 47 | struct sdca_function_data *function;
|
| 48 | struct sdca_entity *entity;
|
| 49 | struct sdca_control *control;
|
| 50 | irq_handler_t handler;
|
| 51 |
|
| 52 | void *priv;
|
| 53 | void (*free_priv)(struct sdca_interrupt *interrupt);
|
| 54 |
|
| 55 | int irq;
|
| 56 | bool early_request;
|
| 57 | };
|
| 58 |
|
| 59 | |
| 60 | * struct sdca_interrupt_info - contains top-level SDCA interrupt information
|
| 61 | * @irq_chip: regmap irq chip structure.
|
| 62 | * @irq_data: regmap irq chip data structure.
|
| 63 | * @irqs: Array of data for each individual IRQ.
|
| 64 | * @irq_lock: Protects access to the list of sdca_interrupt structures.
|
| 65 |
|
| 66 | struct sdca_interrupt_info {
|
| 67 | struct regmap_irq_chip irq_chip;
|
| 68 | struct regmap_irq_chip_data *irq_data;
|
| 69 |
|
| 70 | struct sdca_interrupt irqs[SDCA_MAX_INTERRUPTS];
|
| 71 |
|
| 72 | struct mutex irq_lock;
|
| 73 | };
|
| 74 |
|
| 75 | int sdca_irq_request(struct device *dev, struct sdca_interrupt_info *interrupt_info,
|
| 76 | int sdca_irq, const char *name, irq_handler_t handler,
|
| 77 | void *data);
|
| 78 | void sdca_irq_free(struct device *dev, struct sdca_interrupt_info *interrupt_info,
|
| 79 | int sdca_irq, const char *name, void *data);
|
| 80 | int sdca_irq_data_populate(struct device *dev, struct regmap *function_regmap,
|
| 81 | struct snd_soc_component *component,
|
| 82 | struct sdca_function_data *function,
|
| 83 | struct sdca_entity *entity,
|
| 84 | struct sdca_control *control,
|
| 85 | struct sdca_interrupt *interrupt);
|
| 86 | int sdca_irq_populate_early(struct device *dev, struct regmap *function_regmap,
|
| 87 | struct sdca_function_data *function,
|
| 88 | struct sdca_interrupt_info *info);
|
| 89 | int sdca_irq_populate(struct sdca_function_data *function,
|
| 90 | struct snd_soc_component *component,
|
| 91 | struct sdca_interrupt_info *info);
|
| 92 | void sdca_irq_cleanup(struct device *dev,
|
| 93 | struct sdca_function_data *function,
|
| 94 | struct sdca_interrupt_info *info);
|
| 95 | void sdca_irq_cleanup_late(struct device *dev,
|
| 96 | struct sdca_function_data *function,
|
| 97 | struct sdca_interrupt_info *info);
|
| 98 |
|
| 99 | struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *dev,
|
| 100 | struct regmap *regmap, int irq);
|
| 101 |
|
| 102 | void sdca_irq_enable_early(struct sdca_function_data *function,
|
| 103 | struct sdca_interrupt_info *info);
|
| 104 | void sdca_irq_enable(struct sdca_function_data *function,
|
| 105 | struct sdca_interrupt_info *info);
|
| 106 | void sdca_irq_disable(struct sdca_function_data *function,
|
| 107 | struct sdca_interrupt_info *info);
|
| 108 |
|
| 109 | #endif
|