irqchip.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2012 Thomas Petazzoni
  3. *
  4. * Thomas Petazzoni <[email protected]>
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #ifndef _LINUX_IRQCHIP_H
  11. #define _LINUX_IRQCHIP_H
  12. #include <linux/acpi.h>
  13. #include <linux/module.h>
  14. #include <linux/of.h>
  15. #include <linux/of_irq.h>
  16. #include <linux/platform_device.h>
  17. /* Undefined on purpose */
  18. extern of_irq_init_cb_t typecheck_irq_init_cb;
  19. #define typecheck_irq_init_cb(fn) \
  20. (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn)
  21. /*
  22. * This macro must be used by the different irqchip drivers to declare
  23. * the association between their DT compatible string and their
  24. * initialization function.
  25. *
  26. * @name: name that must be unique across all IRQCHIP_DECLARE of the
  27. * same file.
  28. * @compat: compatible string of the irqchip driver
  29. * @fn: initialization function
  30. */
  31. #define IRQCHIP_DECLARE(name, compat, fn) \
  32. OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn))
  33. extern int platform_irqchip_probe(struct platform_device *pdev);
  34. #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
  35. static const struct of_device_id drv_name##_irqchip_match_table[] = {
  36. #define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \
  37. .data = typecheck_irq_init_cb(fn), },
  38. #define IRQCHIP_PLATFORM_DRIVER_END(drv_name, ...) \
  39. {}, \
  40. }; \
  41. MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \
  42. static struct platform_driver drv_name##_driver = { \
  43. .probe = IS_ENABLED(CONFIG_IRQCHIP) ? \
  44. platform_irqchip_probe : NULL, \
  45. .driver = { \
  46. .name = #drv_name, \
  47. .owner = THIS_MODULE, \
  48. .of_match_table = drv_name##_irqchip_match_table, \
  49. .suppress_bind_attrs = true, \
  50. __VA_ARGS__ \
  51. }, \
  52. }; \
  53. builtin_platform_driver(drv_name##_driver)
  54. /*
  55. * This macro must be used by the different irqchip drivers to declare
  56. * the association between their version and their initialization function.
  57. *
  58. * @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the
  59. * same file.
  60. * @subtable: Subtable to be identified in MADT
  61. * @validate: Function to be called on that subtable to check its validity.
  62. * Can be NULL.
  63. * @data: data to be checked by the validate function.
  64. * @fn: initialization function
  65. */
  66. #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn) \
  67. ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(irqchip, name, \
  68. ACPI_SIG_MADT, subtable, \
  69. validate, data, fn)
  70. #ifdef CONFIG_IRQCHIP
  71. void irqchip_init(void);
  72. #else
  73. static inline void irqchip_init(void) {}
  74. #endif
  75. #endif