intc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef __ASM_AVR32_INTC_H
  2. #define __ASM_AVR32_INTC_H
  3. #include <linux/sysdev.h>
  4. #include <linux/interrupt.h>
  5. struct irq_controller;
  6. struct irqaction;
  7. struct pt_regs;
  8. struct platform_device;
  9. /* Information about the internal interrupt controller */
  10. struct intc_device {
  11. /* ioremapped address of configuration block */
  12. void __iomem *regs;
  13. /* the physical device */
  14. struct platform_device *pdev;
  15. /* Number of interrupt lines per group. */
  16. unsigned int irqs_per_group;
  17. /* The highest group ID + 1 */
  18. unsigned int nr_groups;
  19. /*
  20. * Bitfield indicating which groups are actually in use. The
  21. * size of the array is
  22. * ceil(group_max / (8 * sizeof(unsigned int))).
  23. */
  24. unsigned int group_mask[];
  25. };
  26. struct irq_controller_class {
  27. /*
  28. * A short name identifying this kind of controller.
  29. */
  30. const char *typename;
  31. /*
  32. * Handle the IRQ. Must do any necessary acking and masking.
  33. */
  34. irqreturn_t (*handle)(int irq, void *dev_id, struct pt_regs *regs);
  35. /*
  36. * Register a new IRQ handler.
  37. */
  38. int (*setup)(struct irq_controller *ctrl, unsigned int irq,
  39. struct irqaction *action);
  40. /*
  41. * Unregister a IRQ handler.
  42. */
  43. void (*free)(struct irq_controller *ctrl, unsigned int irq,
  44. void *dev_id);
  45. /*
  46. * Mask the IRQ in the interrupt controller.
  47. */
  48. void (*mask)(struct irq_controller *ctrl, unsigned int irq);
  49. /*
  50. * Unmask the IRQ in the interrupt controller.
  51. */
  52. void (*unmask)(struct irq_controller *ctrl, unsigned int irq);
  53. /*
  54. * Set the type of the IRQ. See below for possible types.
  55. * Return -EINVAL if a given type is not supported
  56. */
  57. int (*set_type)(struct irq_controller *ctrl, unsigned int irq,
  58. unsigned int type);
  59. /*
  60. * Return the IRQ type currently set
  61. */
  62. unsigned int (*get_type)(struct irq_controller *ctrl, unsigned int irq);
  63. };
  64. struct irq_controller {
  65. struct irq_controller_class *class;
  66. unsigned int irq_group;
  67. unsigned int first_irq;
  68. unsigned int nr_irqs;
  69. struct list_head list;
  70. };
  71. struct intc_group_desc {
  72. struct irq_controller *ctrl;
  73. irqreturn_t (*handle)(int, void *, struct pt_regs *);
  74. unsigned long flags;
  75. void *dev_id;
  76. const char *devname;
  77. };
  78. /*
  79. * The internal interrupt controller. Defined in board/part-specific
  80. * devices.c.
  81. * TODO: Should probably be defined per-cpu.
  82. */
  83. extern struct intc_device intc;
  84. extern int request_internal_irq(unsigned int irq,
  85. irqreturn_t (*handler)(int, void *, struct pt_regs *),
  86. unsigned long irqflags,
  87. const char *devname, void *dev_id);
  88. extern void free_internal_irq(unsigned int irq);
  89. /* Only used by time_init() */
  90. extern int setup_internal_irq(unsigned int irq, struct intc_group_desc *desc);
  91. /*
  92. * Set interrupt priority for a given group. `group' can be found by
  93. * using irq_to_group(irq). Priority can be from 0 (lowest) to 3
  94. * (highest). Higher-priority interrupts will preempt lower-priority
  95. * interrupts (unless interrupts are masked globally).
  96. *
  97. * This function does not check for conflicts within a group.
  98. */
  99. extern int intc_set_priority(unsigned int group,
  100. unsigned int priority);
  101. /*
  102. * Returns a bitmask of pending interrupts in a group.
  103. */
  104. extern unsigned long intc_get_pending(unsigned int group);
  105. /*
  106. * Register a new external interrupt controller. Returns the first
  107. * external IRQ number that is assigned to the new controller.
  108. */
  109. extern int intc_register_controller(struct irq_controller *ctrl);
  110. #endif /* __ASM_AVR32_INTC_H */