mpic.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. #ifndef _ASM_POWERPC_MPIC_H
  2. #define _ASM_POWERPC_MPIC_H
  3. #ifdef __KERNEL__
  4. #include <linux/irq.h>
  5. /*
  6. * Global registers
  7. */
  8. #define MPIC_GREG_BASE 0x01000
  9. #define MPIC_GREG_FEATURE_0 0x00000
  10. #define MPIC_GREG_FEATURE_LAST_SRC_MASK 0x07ff0000
  11. #define MPIC_GREG_FEATURE_LAST_SRC_SHIFT 16
  12. #define MPIC_GREG_FEATURE_LAST_CPU_MASK 0x00001f00
  13. #define MPIC_GREG_FEATURE_LAST_CPU_SHIFT 8
  14. #define MPIC_GREG_FEATURE_VERSION_MASK 0xff
  15. #define MPIC_GREG_FEATURE_1 0x00010
  16. #define MPIC_GREG_GLOBAL_CONF_0 0x00020
  17. #define MPIC_GREG_GCONF_RESET 0x80000000
  18. #define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000
  19. #define MPIC_GREG_GCONF_BASE_MASK 0x000fffff
  20. #define MPIC_GREG_GLOBAL_CONF_1 0x00030
  21. #define MPIC_GREG_GLOBAL_CONF_1_SIE 0x08000000
  22. #define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK 0x70000000
  23. #define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO(r) \
  24. (((r) << 28) & MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK)
  25. #define MPIC_GREG_VENDOR_0 0x00040
  26. #define MPIC_GREG_VENDOR_1 0x00050
  27. #define MPIC_GREG_VENDOR_2 0x00060
  28. #define MPIC_GREG_VENDOR_3 0x00070
  29. #define MPIC_GREG_VENDOR_ID 0x00080
  30. #define MPIC_GREG_VENDOR_ID_STEPPING_MASK 0x00ff0000
  31. #define MPIC_GREG_VENDOR_ID_STEPPING_SHIFT 16
  32. #define MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00
  33. #define MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT 8
  34. #define MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK 0x000000ff
  35. #define MPIC_GREG_PROCESSOR_INIT 0x00090
  36. #define MPIC_GREG_IPI_VECTOR_PRI_0 0x000a0
  37. #define MPIC_GREG_IPI_VECTOR_PRI_1 0x000b0
  38. #define MPIC_GREG_IPI_VECTOR_PRI_2 0x000c0
  39. #define MPIC_GREG_IPI_VECTOR_PRI_3 0x000d0
  40. #define MPIC_GREG_SPURIOUS 0x000e0
  41. #define MPIC_GREG_TIMER_FREQ 0x000f0
  42. /*
  43. *
  44. * Timer registers
  45. */
  46. #define MPIC_TIMER_BASE 0x01100
  47. #define MPIC_TIMER_STRIDE 0x40
  48. #define MPIC_TIMER_CURRENT_CNT 0x00000
  49. #define MPIC_TIMER_BASE_CNT 0x00010
  50. #define MPIC_TIMER_VECTOR_PRI 0x00020
  51. #define MPIC_TIMER_DESTINATION 0x00030
  52. /*
  53. * Per-Processor registers
  54. */
  55. #define MPIC_CPU_THISBASE 0x00000
  56. #define MPIC_CPU_BASE 0x20000
  57. #define MPIC_CPU_STRIDE 0x01000
  58. #define MPIC_CPU_IPI_DISPATCH_0 0x00040
  59. #define MPIC_CPU_IPI_DISPATCH_1 0x00050
  60. #define MPIC_CPU_IPI_DISPATCH_2 0x00060
  61. #define MPIC_CPU_IPI_DISPATCH_3 0x00070
  62. #define MPIC_CPU_CURRENT_TASK_PRI 0x00080
  63. #define MPIC_CPU_TASKPRI_MASK 0x0000000f
  64. #define MPIC_CPU_WHOAMI 0x00090
  65. #define MPIC_CPU_WHOAMI_MASK 0x0000001f
  66. #define MPIC_CPU_INTACK 0x000a0
  67. #define MPIC_CPU_EOI 0x000b0
  68. /*
  69. * Per-source registers
  70. */
  71. #define MPIC_IRQ_BASE 0x10000
  72. #define MPIC_IRQ_STRIDE 0x00020
  73. #define MPIC_IRQ_VECTOR_PRI 0x00000
  74. #define MPIC_VECPRI_MASK 0x80000000
  75. #define MPIC_VECPRI_ACTIVITY 0x40000000 /* Read Only */
  76. #define MPIC_VECPRI_PRIORITY_MASK 0x000f0000
  77. #define MPIC_VECPRI_PRIORITY_SHIFT 16
  78. #define MPIC_VECPRI_VECTOR_MASK 0x000007ff
  79. #define MPIC_VECPRI_POLARITY_POSITIVE 0x00800000
  80. #define MPIC_VECPRI_POLARITY_NEGATIVE 0x00000000
  81. #define MPIC_VECPRI_POLARITY_MASK 0x00800000
  82. #define MPIC_VECPRI_SENSE_LEVEL 0x00400000
  83. #define MPIC_VECPRI_SENSE_EDGE 0x00000000
  84. #define MPIC_VECPRI_SENSE_MASK 0x00400000
  85. #define MPIC_IRQ_DESTINATION 0x00010
  86. #define MPIC_MAX_IRQ_SOURCES 2048
  87. #define MPIC_MAX_CPUS 32
  88. #define MPIC_MAX_ISU 32
  89. /*
  90. * Special vector numbers (internal use only)
  91. */
  92. #define MPIC_VEC_SPURRIOUS 255
  93. #define MPIC_VEC_IPI_3 254
  94. #define MPIC_VEC_IPI_2 253
  95. #define MPIC_VEC_IPI_1 252
  96. #define MPIC_VEC_IPI_0 251
  97. /* unused */
  98. #define MPIC_VEC_TIMER_3 250
  99. #define MPIC_VEC_TIMER_2 249
  100. #define MPIC_VEC_TIMER_1 248
  101. #define MPIC_VEC_TIMER_0 247
  102. /* Type definition of the cascade handler */
  103. typedef int (*mpic_cascade_t)(struct pt_regs *regs, void *data);
  104. #ifdef CONFIG_MPIC_BROKEN_U3
  105. /* Fixup table entry */
  106. struct mpic_irq_fixup
  107. {
  108. u8 __iomem *base;
  109. u8 __iomem *applebase;
  110. u32 data;
  111. unsigned int index;
  112. };
  113. #endif /* CONFIG_MPIC_BROKEN_U3 */
  114. /* The instance data of a given MPIC */
  115. struct mpic
  116. {
  117. /* The "linux" controller struct */
  118. hw_irq_controller hc_irq;
  119. #ifdef CONFIG_SMP
  120. hw_irq_controller hc_ipi;
  121. #endif
  122. const char *name;
  123. /* Flags */
  124. unsigned int flags;
  125. /* How many irq sources in a given ISU */
  126. unsigned int isu_size;
  127. unsigned int isu_shift;
  128. unsigned int isu_mask;
  129. /* Offset of irq vector numbers */
  130. unsigned int irq_offset;
  131. unsigned int irq_count;
  132. /* Offset of ipi vector numbers */
  133. unsigned int ipi_offset;
  134. /* Number of sources */
  135. unsigned int num_sources;
  136. /* Number of CPUs */
  137. unsigned int num_cpus;
  138. /* cascade handler */
  139. mpic_cascade_t cascade;
  140. void *cascade_data;
  141. unsigned int cascade_vec;
  142. /* senses array */
  143. unsigned char *senses;
  144. unsigned int senses_count;
  145. #ifdef CONFIG_MPIC_BROKEN_U3
  146. /* The fixup table */
  147. struct mpic_irq_fixup *fixups;
  148. spinlock_t fixup_lock;
  149. #endif
  150. /* The various ioremap'ed bases */
  151. volatile u32 __iomem *gregs;
  152. volatile u32 __iomem *tmregs;
  153. volatile u32 __iomem *cpuregs[MPIC_MAX_CPUS];
  154. volatile u32 __iomem *isus[MPIC_MAX_ISU];
  155. /* link */
  156. struct mpic *next;
  157. };
  158. /* This is the primary controller, only that one has IPIs and
  159. * has afinity control. A non-primary MPIC always uses CPU0
  160. * registers only
  161. */
  162. #define MPIC_PRIMARY 0x00000001
  163. /* Set this for a big-endian MPIC */
  164. #define MPIC_BIG_ENDIAN 0x00000002
  165. /* Broken U3 MPIC */
  166. #define MPIC_BROKEN_U3 0x00000004
  167. /* Broken IPI registers (autodetected) */
  168. #define MPIC_BROKEN_IPI 0x00000008
  169. /* MPIC wants a reset */
  170. #define MPIC_WANTS_RESET 0x00000010
  171. /* Allocate the controller structure and setup the linux irq descs
  172. * for the range if interrupts passed in. No HW initialization is
  173. * actually performed.
  174. *
  175. * @phys_addr: physial base address of the MPIC
  176. * @flags: flags, see constants above
  177. * @isu_size: number of interrupts in an ISU. Use 0 to use a
  178. * standard ISU-less setup (aka powermac)
  179. * @irq_offset: first irq number to assign to this mpic
  180. * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0
  181. * to match the number of sources
  182. * @ipi_offset: first irq number to assign to this mpic IPI sources,
  183. * used only on primary mpic
  184. * @senses: array of sense values
  185. * @senses_num: number of entries in the array
  186. *
  187. * Note about the sense array. If none is passed, all interrupts are
  188. * setup to be level negative unless MPIC_BROKEN_U3 is set in which
  189. * case they are edge positive (and the array is ignored anyway).
  190. * The values in the array start at the first source of the MPIC,
  191. * that is senses[0] correspond to linux irq "irq_offset".
  192. */
  193. extern struct mpic *mpic_alloc(unsigned long phys_addr,
  194. unsigned int flags,
  195. unsigned int isu_size,
  196. unsigned int irq_offset,
  197. unsigned int irq_count,
  198. unsigned int ipi_offset,
  199. unsigned char *senses,
  200. unsigned int senses_num,
  201. const char *name);
  202. /* Assign ISUs, to call before mpic_init()
  203. *
  204. * @mpic: controller structure as returned by mpic_alloc()
  205. * @isu_num: ISU number
  206. * @phys_addr: physical address of the ISU
  207. */
  208. extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
  209. unsigned long phys_addr);
  210. /* Initialize the controller. After this has been called, none of the above
  211. * should be called again for this mpic
  212. */
  213. extern void mpic_init(struct mpic *mpic);
  214. /* Setup a cascade. Currently, only one cascade is supported this
  215. * way, though you can always do a normal request_irq() and add
  216. * other cascades this way. You should call this _after_ having
  217. * added all the ISUs
  218. *
  219. * @irq_no: "linux" irq number of the cascade (that is offset'ed vector)
  220. * @handler: cascade handler function
  221. */
  222. extern void mpic_setup_cascade(unsigned int irq_no, mpic_cascade_t hanlder,
  223. void *data);
  224. /*
  225. * All of the following functions must only be used after the
  226. * ISUs have been assigned and the controller fully initialized
  227. * with mpic_init()
  228. */
  229. /* Change/Read the priority of an interrupt. Default is 8 for irqs and
  230. * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the
  231. * IPI number is then the offset'ed (linux irq number mapped to the IPI)
  232. */
  233. extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri);
  234. extern unsigned int mpic_irq_get_priority(unsigned int irq);
  235. /* Setup a non-boot CPU */
  236. extern void mpic_setup_this_cpu(void);
  237. /* Clean up for kexec (or cpu offline or ...) */
  238. extern void mpic_teardown_this_cpu(int secondary);
  239. /* Get the current cpu priority for this cpu (0..15) */
  240. extern int mpic_cpu_get_priority(void);
  241. /* Set the current cpu priority for this cpu */
  242. extern void mpic_cpu_set_priority(int prio);
  243. /* Request IPIs on primary mpic */
  244. extern void mpic_request_ipis(void);
  245. /* Send an IPI (non offseted number 0..3) */
  246. extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask);
  247. /* Send a message (IPI) to a given target (cpu number or MSG_*) */
  248. void smp_mpic_message_pass(int target, int msg);
  249. /* Fetch interrupt from a given mpic */
  250. extern int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs);
  251. /* This one gets to the primary mpic */
  252. extern int mpic_get_irq(struct pt_regs *regs);
  253. /* Set the EPIC clock ratio */
  254. void mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio);
  255. /* Enable/Disable EPIC serial interrupt mode */
  256. void mpic_set_serial_int(struct mpic *mpic, int enable);
  257. /* global mpic for pSeries */
  258. extern struct mpic *pSeries_mpic;
  259. #endif /* __KERNEL__ */
  260. #endif /* _ASM_POWERPC_MPIC_H */