of_irq.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #else
  41. static inline int of_irq_count(struct device_node *dev)
  42. {
  43. return 0;
  44. }
  45. #endif
  46. #if defined(CONFIG_OF)
  47. /*
  48. * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC
  49. * implements it differently. However, the prototype is the same for all,
  50. * so declare it here regardless of the CONFIG_OF_IRQ setting.
  51. */
  52. extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
  53. extern struct device_node *of_irq_find_parent(struct device_node *child);
  54. #else /* !CONFIG_OF */
  55. static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
  56. int index)
  57. {
  58. return 0;
  59. }
  60. static inline void *of_irq_find_parent(struct device_node *child)
  61. {
  62. return NULL;
  63. }
  64. #endif /* !CONFIG_OF */
  65. #endif /* __OF_IRQ_H */