sdca_interrupts.h 3.5 KB

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