of_irq.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
  10. /*
  11. * Workarounds only applied to 32bit powermac machines
  12. */
  13. #define OF_IMAP_OLDWORLD_MAC 0x00000001
  14. #define OF_IMAP_NO_PHANDLE 0x00000002
  15. #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC)
  16. extern unsigned int of_irq_workarounds;
  17. extern struct device_node *of_irq_dflt_pic;
  18. extern int of_irq_parse_oldworld(struct device_node *device, int index,
  19. struct of_phandle_args *out_irq);
  20. #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
  21. #define of_irq_workarounds (0)
  22. #define of_irq_dflt_pic (NULL)
  23. static inline int of_irq_parse_oldworld(struct device_node *device, int index,
  24. struct of_phandle_args *out_irq)
  25. {
  26. return -EINVAL;
  27. }
  28. #endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
  29. extern int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq);
  30. extern int of_irq_parse_one(struct device_node *device, int index,
  31. struct of_phandle_args *out_irq);
  32. extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data);
  33. extern int of_irq_to_resource(struct device_node *dev, int index,
  34. struct resource *r);
  35. extern void of_irq_init(const struct of_device_id *matches);
  36. #ifdef CONFIG_OF_IRQ
  37. extern int of_irq_count(struct device_node *dev);
  38. extern int of_irq_get(struct device_node *dev, int index);
  39. extern int of_irq_get_byname(struct device_node *dev, const char *name);
  40. extern int of_irq_to_resource_table(struct device_node *dev,
  41. struct resource *res, int nr_irqs);
  42. extern struct device_node *of_irq_find_parent(struct device_node *child);
  43. extern struct irq_domain *of_msi_get_domain(struct device *dev,
  44. struct device_node *np,
  45. enum irq_domain_bus_token token);
  46. extern struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
  47. u32 rid);
  48. extern void of_msi_configure(struct device *dev, struct device_node *np);
  49. u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in);
  50. #else
  51. static inline int of_irq_count(struct device_node *dev)
  52. {
  53. return 0;
  54. }
  55. static inline int of_irq_get(struct device_node *dev, int index)
  56. {
  57. return 0;
  58. }
  59. static inline int of_irq_get_byname(struct device_node *dev, const char *name)
  60. {
  61. return 0;
  62. }
  63. static inline int of_irq_to_resource_table(struct device_node *dev,
  64. struct resource *res, int nr_irqs)
  65. {
  66. return 0;
  67. }
  68. static inline void *of_irq_find_parent(struct device_node *child)
  69. {
  70. return NULL;
  71. }
  72. static inline struct irq_domain *of_msi_get_domain(struct device *dev,
  73. struct device_node *np,
  74. enum irq_domain_bus_token token)
  75. {
  76. return NULL;
  77. }
  78. static inline struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
  79. u32 rid)
  80. {
  81. return NULL;
  82. }
  83. static inline void of_msi_configure(struct device *dev, struct device_node *np)
  84. {
  85. }
  86. static inline u32 of_msi_map_rid(struct device *dev,
  87. struct device_node *msi_np, u32 rid_in)
  88. {
  89. return rid_in;
  90. }
  91. #endif
  92. #if defined(CONFIG_OF_IRQ) || defined(CONFIG_SPARC)
  93. /*
  94. * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC
  95. * implements it differently. However, the prototype is the same for all,
  96. * so declare it here regardless of the CONFIG_OF_IRQ setting.
  97. */
  98. extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
  99. #else /* !CONFIG_OF && !CONFIG_SPARC */
  100. static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
  101. int index)
  102. {
  103. return 0;
  104. }
  105. #endif /* !CONFIG_OF */
  106. #endif /* __OF_IRQ_H */