of_irq.h 2.7 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. 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 void of_msi_configure(struct device *dev, struct device_node *np);
  43. #else
  44. static inline int of_irq_count(struct device_node *dev)
  45. {
  46. return 0;
  47. }
  48. static inline int of_irq_get(struct device_node *dev, int index)
  49. {
  50. return 0;
  51. }
  52. static inline int of_irq_get_byname(struct device_node *dev, const char *name)
  53. {
  54. return 0;
  55. }
  56. static inline int of_irq_to_resource_table(struct device_node *dev,
  57. struct resource *res, int nr_irqs)
  58. {
  59. return 0;
  60. }
  61. static inline void of_msi_configure(struct device *dev, struct device_node *np)
  62. {
  63. }
  64. #endif
  65. #if defined(CONFIG_OF)
  66. /*
  67. * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC
  68. * implements it differently. However, the prototype is the same for all,
  69. * so declare it here regardless of the CONFIG_OF_IRQ setting.
  70. */
  71. extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
  72. #else /* !CONFIG_OF */
  73. static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
  74. int index)
  75. {
  76. return 0;
  77. }
  78. #endif /* !CONFIG_OF */
  79. #endif /* __OF_IRQ_H */