irq.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #ifdef __KERNEL__
  2. #ifndef _ASM_POWERPC_IRQ_H
  3. #define _ASM_POWERPC_IRQ_H
  4. /*
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #include <linux/irqdomain.h>
  11. #include <linux/threads.h>
  12. #include <linux/list.h>
  13. #include <linux/radix-tree.h>
  14. #include <asm/types.h>
  15. #include <linux/atomic.h>
  16. /* Define a way to iterate across irqs. */
  17. #define for_each_irq(i) \
  18. for ((i) = 0; (i) < NR_IRQS; ++(i))
  19. extern atomic_t ppc_n_lost_interrupts;
  20. /* This number is used when no interrupt has been assigned */
  21. #define NO_IRQ (0)
  22. /* This is a special irq number to return from get_irq() to tell that
  23. * no interrupt happened _and_ ignore it (don't count it as bad). Some
  24. * platforms like iSeries rely on that.
  25. */
  26. #define NO_IRQ_IGNORE ((unsigned int)-1)
  27. /* Total number of virq in the platform */
  28. #define NR_IRQS CONFIG_NR_IRQS
  29. /* Number of irqs reserved for the legacy controller */
  30. #define NUM_ISA_INTERRUPTS 16
  31. /* Same thing, used by the generic IRQ code */
  32. #define NR_IRQS_LEGACY NUM_ISA_INTERRUPTS
  33. /*
  34. * The host code and data structures are fairly agnostic to the fact that
  35. * we use an open firmware device-tree. We do have references to struct
  36. * device_node in two places: in irq_find_host() to find the host matching
  37. * a given interrupt controller node, and of course as an argument to its
  38. * counterpart host->ops->match() callback. However, those are treated as
  39. * generic pointers by the core and the fact that it's actually a device-node
  40. * pointer is purely a convention between callers and implementation. This
  41. * code could thus be used on other architectures by replacing those two
  42. * by some sort of arch-specific void * "token" used to identify interrupt
  43. * controllers.
  44. */
  45. struct irq_data;
  46. extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d);
  47. extern irq_hw_number_t virq_to_hw(unsigned int virq);
  48. /**
  49. * irq_alloc_host - Allocate a new irq_domain data structure
  50. * @of_node: optional device-tree node of the interrupt controller
  51. * @revmap_type: type of reverse mapping to use
  52. * @revmap_arg: for IRQ_DOMAIN_MAP_LINEAR linear only: size of the map
  53. * @ops: map/unmap host callbacks
  54. * @inval_irq: provide a hw number in that host space that is always invalid
  55. *
  56. * Allocates and initialize and irq_domain structure. Note that in the case of
  57. * IRQ_DOMAIN_MAP_LEGACY, the map() callback will be called before this returns
  58. * for all legacy interrupts except 0 (which is always the invalid irq for
  59. * a legacy controller). For a IRQ_DOMAIN_MAP_LINEAR, the map is allocated by
  60. * this call as well. For a IRQ_DOMAIN_MAP_TREE, the radix tree will be allocated
  61. * later during boot automatically (the reverse mapping will use the slow path
  62. * until that happens).
  63. */
  64. extern struct irq_domain *irq_alloc_host(struct device_node *of_node,
  65. unsigned int revmap_type,
  66. unsigned int revmap_arg,
  67. struct irq_domain_ops *ops,
  68. irq_hw_number_t inval_irq);
  69. /**
  70. * irq_find_host - Locates a host for a given device node
  71. * @node: device-tree node of the interrupt controller
  72. */
  73. extern struct irq_domain *irq_find_host(struct device_node *node);
  74. /**
  75. * irq_set_default_host - Set a "default" host
  76. * @host: default host pointer
  77. *
  78. * For convenience, it's possible to set a "default" host that will be used
  79. * whenever NULL is passed to irq_create_mapping(). It makes life easier for
  80. * platforms that want to manipulate a few hard coded interrupt numbers that
  81. * aren't properly represented in the device-tree.
  82. */
  83. extern void irq_set_default_host(struct irq_domain *host);
  84. /**
  85. * irq_set_virq_count - Set the maximum number of virt irqs
  86. * @count: number of linux virtual irqs, capped with NR_IRQS
  87. *
  88. * This is mainly for use by platforms like iSeries who want to program
  89. * the virtual irq number in the controller to avoid the reverse mapping
  90. */
  91. extern void irq_set_virq_count(unsigned int count);
  92. /**
  93. * irq_create_mapping - Map a hardware interrupt into linux virq space
  94. * @host: host owning this hardware interrupt or NULL for default host
  95. * @hwirq: hardware irq number in that host space
  96. *
  97. * Only one mapping per hardware interrupt is permitted. Returns a linux
  98. * virq number.
  99. * If the sense/trigger is to be specified, set_irq_type() should be called
  100. * on the number returned from that call.
  101. */
  102. extern unsigned int irq_create_mapping(struct irq_domain *host,
  103. irq_hw_number_t hwirq);
  104. /**
  105. * irq_dispose_mapping - Unmap an interrupt
  106. * @virq: linux virq number of the interrupt to unmap
  107. */
  108. extern void irq_dispose_mapping(unsigned int virq);
  109. /**
  110. * irq_find_mapping - Find a linux virq from an hw irq number.
  111. * @host: host owning this hardware interrupt
  112. * @hwirq: hardware irq number in that host space
  113. *
  114. * This is a slow path, for use by generic code. It's expected that an
  115. * irq controller implementation directly calls the appropriate low level
  116. * mapping function.
  117. */
  118. extern unsigned int irq_find_mapping(struct irq_domain *host,
  119. irq_hw_number_t hwirq);
  120. /**
  121. * irq_create_direct_mapping - Allocate a virq for direct mapping
  122. * @host: host to allocate the virq for or NULL for default host
  123. *
  124. * This routine is used for irq controllers which can choose the hardware
  125. * interrupt numbers they generate. In such a case it's simplest to use
  126. * the linux virq as the hardware interrupt number.
  127. */
  128. extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
  129. /**
  130. * irq_radix_revmap_insert - Insert a hw irq to linux virq number mapping.
  131. * @host: host owning this hardware interrupt
  132. * @virq: linux irq number
  133. * @hwirq: hardware irq number in that host space
  134. *
  135. * This is for use by irq controllers that use a radix tree reverse
  136. * mapping for fast lookup.
  137. */
  138. extern void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq,
  139. irq_hw_number_t hwirq);
  140. /**
  141. * irq_radix_revmap_lookup - Find a linux virq from a hw irq number.
  142. * @host: host owning this hardware interrupt
  143. * @hwirq: hardware irq number in that host space
  144. *
  145. * This is a fast path, for use by irq controller code that uses radix tree
  146. * revmaps
  147. */
  148. extern unsigned int irq_radix_revmap_lookup(struct irq_domain *host,
  149. irq_hw_number_t hwirq);
  150. /**
  151. * irq_linear_revmap - Find a linux virq from a hw irq number.
  152. * @host: host owning this hardware interrupt
  153. * @hwirq: hardware irq number in that host space
  154. *
  155. * This is a fast path, for use by irq controller code that uses linear
  156. * revmaps. It does fallback to the slow path if the revmap doesn't exist
  157. * yet and will create the revmap entry with appropriate locking
  158. */
  159. extern unsigned int irq_linear_revmap(struct irq_domain *host,
  160. irq_hw_number_t hwirq);
  161. /**
  162. * irq_early_init - Init irq remapping subsystem
  163. */
  164. extern void irq_early_init(void);
  165. static __inline__ int irq_canonicalize(int irq)
  166. {
  167. return irq;
  168. }
  169. extern int distribute_irqs;
  170. struct irqaction;
  171. struct pt_regs;
  172. #define __ARCH_HAS_DO_SOFTIRQ
  173. #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
  174. /*
  175. * Per-cpu stacks for handling critical, debug and machine check
  176. * level interrupts.
  177. */
  178. extern struct thread_info *critirq_ctx[NR_CPUS];
  179. extern struct thread_info *dbgirq_ctx[NR_CPUS];
  180. extern struct thread_info *mcheckirq_ctx[NR_CPUS];
  181. extern void exc_lvl_ctx_init(void);
  182. #else
  183. #define exc_lvl_ctx_init()
  184. #endif
  185. /*
  186. * Per-cpu stacks for handling hard and soft interrupts.
  187. */
  188. extern struct thread_info *hardirq_ctx[NR_CPUS];
  189. extern struct thread_info *softirq_ctx[NR_CPUS];
  190. extern void irq_ctx_init(void);
  191. extern void call_do_softirq(struct thread_info *tp);
  192. extern int call_handle_irq(int irq, void *p1,
  193. struct thread_info *tp, void *func);
  194. extern void do_IRQ(struct pt_regs *regs);
  195. int irq_choose_cpu(const struct cpumask *mask);
  196. #endif /* _ASM_IRQ_H */
  197. #endif /* __KERNEL__ */