of_irq.h 2.5 KB

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