of_irq.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef __OF_IRQ_H
  2. #define __OF_IRQ_H
  3. #include <linux/types.h>
  4. #include <linux/errno.h>
  5. #include <linux/irq.h>
  6. #include <linux/irqdomain.h>
  7. #include <linux/ioport.h>
  8. #include <linux/of.h>
  9. /**
  10. * of_irq - container for device_node/irq_specifier pair for an irq controller
  11. * @controller: pointer to interrupt controller device tree node
  12. * @size: size of interrupt specifier
  13. * @specifier: array of cells @size long specifing the specific interrupt
  14. *
  15. * This structure is returned when an interrupt is mapped. The controller
  16. * field needs to be put() after use
  17. */
  18. #define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
  19. struct of_irq {
  20. struct device_node *controller; /* Interrupt controller node */
  21. u32 size; /* Specifier size */
  22. u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
  23. };
  24. typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
  25. /*
  26. * Workarounds only applied to 32bit powermac machines
  27. */
  28. #define OF_IMAP_OLDWORLD_MAC 0x00000001
  29. #define OF_IMAP_NO_PHANDLE 0x00000002
  30. #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC)
  31. extern unsigned int of_irq_workarounds;
  32. extern struct device_node *of_irq_dflt_pic;
  33. extern int of_irq_parse_oldworld(struct device_node *device, int index,
  34. struct of_irq *out_irq);
  35. #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
  36. #define of_irq_workarounds (0)
  37. #define of_irq_dflt_pic (NULL)
  38. static inline int of_irq_parse_oldworld(struct device_node *device, int index,
  39. struct of_irq *out_irq)
  40. {
  41. return -EINVAL;
  42. }
  43. #endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
  44. extern int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec,
  45. u32 ointsize, const __be32 *addr,
  46. struct of_irq *out_irq);
  47. extern int of_irq_parse_one(struct device_node *device, int index,
  48. struct of_irq *out_irq);
  49. extern unsigned int irq_create_of_mapping(struct device_node *controller,
  50. const u32 *intspec,
  51. unsigned int intsize);
  52. extern int of_irq_to_resource(struct device_node *dev, int index,
  53. struct resource *r);
  54. extern int of_irq_count(struct device_node *dev);
  55. extern int of_irq_to_resource_table(struct device_node *dev,
  56. struct resource *res, int nr_irqs);
  57. extern void of_irq_init(const struct of_device_id *matches);
  58. #if defined(CONFIG_OF)
  59. /*
  60. * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC
  61. * implements it differently. However, the prototype is the same for all,
  62. * so declare it here regardless of the CONFIG_OF_IRQ setting.
  63. */
  64. extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
  65. extern struct device_node *of_irq_find_parent(struct device_node *child);
  66. #else /* !CONFIG_OF */
  67. static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
  68. int index)
  69. {
  70. return 0;
  71. }
  72. static inline void *of_irq_find_parent(struct device_node *child)
  73. {
  74. return NULL;
  75. }
  76. #endif /* !CONFIG_OF */
  77. #endif /* __OF_IRQ_H */