of_irq.h 2.8 KB

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