blob: e14d35d572af802750796b6ba6e3fd22defe0f3f [file] [log] [blame]
Stephen Rothwellbbeb3f42005-09-27 13:51:59 +10001#ifndef _ASM_POWERPC_MPIC_H
2#define _ASM_POWERPC_MPIC_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01003#ifdef __KERNEL__
Stephen Rothwellbbeb3f42005-09-27 13:51:59 +10004
Paul Mackerras14cf11a2005-09-26 16:04:21 +10005#include <linux/irq.h>
Benjamin Herrenschmidtfbf02742006-11-11 17:24:55 +11006#include <asm/dcr.h>
Michael Ellerman25235f72008-08-06 09:10:03 +10007#include <asm/msi_bitmap.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +10008
9/*
10 * Global registers
11 */
12
13#define MPIC_GREG_BASE 0x01000
14
15#define MPIC_GREG_FEATURE_0 0x00000
16#define MPIC_GREG_FEATURE_LAST_SRC_MASK 0x07ff0000
17#define MPIC_GREG_FEATURE_LAST_SRC_SHIFT 16
18#define MPIC_GREG_FEATURE_LAST_CPU_MASK 0x00001f00
19#define MPIC_GREG_FEATURE_LAST_CPU_SHIFT 8
20#define MPIC_GREG_FEATURE_VERSION_MASK 0xff
21#define MPIC_GREG_FEATURE_1 0x00010
22#define MPIC_GREG_GLOBAL_CONF_0 0x00020
23#define MPIC_GREG_GCONF_RESET 0x80000000
Kumar Galad91e4ea2009-01-07 15:53:29 -060024/* On the FSL mpic implementations the Mode field is expand to be
25 * 2 bits wide:
26 * 0b00 = pass through (interrupts routed to IRQ0)
27 * 0b01 = Mixed mode
28 * 0b10 = reserved
29 * 0b11 = External proxy / coreint
30 */
31#define MPIC_GREG_GCONF_COREINT 0x60000000
Paul Mackerras14cf11a2005-09-26 16:04:21 +100032#define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000
Olof Johanssond87bf3b2007-12-27 22:16:29 -060033#define MPIC_GREG_GCONF_NO_BIAS 0x10000000
Paul Mackerras14cf11a2005-09-26 16:04:21 +100034#define MPIC_GREG_GCONF_BASE_MASK 0x000fffff
Olof Johanssonf3653552007-12-20 13:11:18 -060035#define MPIC_GREG_GCONF_MCK 0x08000000
Paul Mackerras14cf11a2005-09-26 16:04:21 +100036#define MPIC_GREG_GLOBAL_CONF_1 0x00030
Mark A. Greer868ea0c2006-06-20 14:15:36 -070037#define MPIC_GREG_GLOBAL_CONF_1_SIE 0x08000000
38#define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK 0x70000000
39#define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO(r) \
40 (((r) << 28) & MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK)
Paul Mackerras14cf11a2005-09-26 16:04:21 +100041#define MPIC_GREG_VENDOR_0 0x00040
42#define MPIC_GREG_VENDOR_1 0x00050
43#define MPIC_GREG_VENDOR_2 0x00060
44#define MPIC_GREG_VENDOR_3 0x00070
45#define MPIC_GREG_VENDOR_ID 0x00080
46#define MPIC_GREG_VENDOR_ID_STEPPING_MASK 0x00ff0000
47#define MPIC_GREG_VENDOR_ID_STEPPING_SHIFT 16
48#define MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00
49#define MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT 8
50#define MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK 0x000000ff
51#define MPIC_GREG_PROCESSOR_INIT 0x00090
52#define MPIC_GREG_IPI_VECTOR_PRI_0 0x000a0
53#define MPIC_GREG_IPI_VECTOR_PRI_1 0x000b0
54#define MPIC_GREG_IPI_VECTOR_PRI_2 0x000c0
55#define MPIC_GREG_IPI_VECTOR_PRI_3 0x000d0
Zang Roy-r6191172335932006-08-25 14:16:30 +100056#define MPIC_GREG_IPI_STRIDE 0x10
Paul Mackerras14cf11a2005-09-26 16:04:21 +100057#define MPIC_GREG_SPURIOUS 0x000e0
58#define MPIC_GREG_TIMER_FREQ 0x000f0
59
60/*
61 *
62 * Timer registers
63 */
64#define MPIC_TIMER_BASE 0x01100
65#define MPIC_TIMER_STRIDE 0x40
Varun Sethi03bcb7e2012-07-09 14:15:42 +053066#define MPIC_TIMER_GROUP_STRIDE 0x1000
Paul Mackerras14cf11a2005-09-26 16:04:21 +100067
68#define MPIC_TIMER_CURRENT_CNT 0x00000
69#define MPIC_TIMER_BASE_CNT 0x00010
70#define MPIC_TIMER_VECTOR_PRI 0x00020
71#define MPIC_TIMER_DESTINATION 0x00030
72
73/*
74 * Per-Processor registers
75 */
76
77#define MPIC_CPU_THISBASE 0x00000
78#define MPIC_CPU_BASE 0x20000
79#define MPIC_CPU_STRIDE 0x01000
80
81#define MPIC_CPU_IPI_DISPATCH_0 0x00040
82#define MPIC_CPU_IPI_DISPATCH_1 0x00050
83#define MPIC_CPU_IPI_DISPATCH_2 0x00060
84#define MPIC_CPU_IPI_DISPATCH_3 0x00070
Zang Roy-r6191172335932006-08-25 14:16:30 +100085#define MPIC_CPU_IPI_DISPATCH_STRIDE 0x00010
Paul Mackerras14cf11a2005-09-26 16:04:21 +100086#define MPIC_CPU_CURRENT_TASK_PRI 0x00080
87#define MPIC_CPU_TASKPRI_MASK 0x0000000f
88#define MPIC_CPU_WHOAMI 0x00090
89#define MPIC_CPU_WHOAMI_MASK 0x0000001f
90#define MPIC_CPU_INTACK 0x000a0
91#define MPIC_CPU_EOI 0x000b0
Olof Johanssonf3653552007-12-20 13:11:18 -060092#define MPIC_CPU_MCACK 0x000c0
Paul Mackerras14cf11a2005-09-26 16:04:21 +100093
94/*
95 * Per-source registers
96 */
97
98#define MPIC_IRQ_BASE 0x10000
99#define MPIC_IRQ_STRIDE 0x00020
100#define MPIC_IRQ_VECTOR_PRI 0x00000
101#define MPIC_VECPRI_MASK 0x80000000
102#define MPIC_VECPRI_ACTIVITY 0x40000000 /* Read Only */
103#define MPIC_VECPRI_PRIORITY_MASK 0x000f0000
104#define MPIC_VECPRI_PRIORITY_SHIFT 16
105#define MPIC_VECPRI_VECTOR_MASK 0x000007ff
106#define MPIC_VECPRI_POLARITY_POSITIVE 0x00800000
107#define MPIC_VECPRI_POLARITY_NEGATIVE 0x00000000
108#define MPIC_VECPRI_POLARITY_MASK 0x00800000
109#define MPIC_VECPRI_SENSE_LEVEL 0x00400000
110#define MPIC_VECPRI_SENSE_EDGE 0x00000000
111#define MPIC_VECPRI_SENSE_MASK 0x00400000
112#define MPIC_IRQ_DESTINATION 0x00010
113
Varun Sethi03bcb7e2012-07-09 14:15:42 +0530114#define MPIC_FSL_BRR1 0x00000
115#define MPIC_FSL_BRR1_VER 0x0000ffff
116
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000117#define MPIC_MAX_IRQ_SOURCES 2048
118#define MPIC_MAX_CPUS 32
119#define MPIC_MAX_ISU 32
120
121/*
Zang Roy-r6191172335932006-08-25 14:16:30 +1000122 * Tsi108 implementation of MPIC has many differences from the original one
123 */
124
125/*
126 * Global registers
127 */
128
129#define TSI108_GREG_BASE 0x00000
130#define TSI108_GREG_FEATURE_0 0x00000
131#define TSI108_GREG_GLOBAL_CONF_0 0x00004
132#define TSI108_GREG_VENDOR_ID 0x0000c
133#define TSI108_GREG_IPI_VECTOR_PRI_0 0x00204 /* Doorbell 0 */
134#define TSI108_GREG_IPI_STRIDE 0x0c
135#define TSI108_GREG_SPURIOUS 0x00010
136#define TSI108_GREG_TIMER_FREQ 0x00014
137
138/*
139 * Timer registers
140 */
141#define TSI108_TIMER_BASE 0x0030
142#define TSI108_TIMER_STRIDE 0x10
143#define TSI108_TIMER_CURRENT_CNT 0x00000
144#define TSI108_TIMER_BASE_CNT 0x00004
145#define TSI108_TIMER_VECTOR_PRI 0x00008
146#define TSI108_TIMER_DESTINATION 0x0000c
147
148/*
149 * Per-Processor registers
150 */
151#define TSI108_CPU_BASE 0x00300
152#define TSI108_CPU_STRIDE 0x00040
153#define TSI108_CPU_IPI_DISPATCH_0 0x00200
154#define TSI108_CPU_IPI_DISPATCH_STRIDE 0x00000
155#define TSI108_CPU_CURRENT_TASK_PRI 0x00000
156#define TSI108_CPU_WHOAMI 0xffffffff
157#define TSI108_CPU_INTACK 0x00004
158#define TSI108_CPU_EOI 0x00008
Olof Johanssonf3653552007-12-20 13:11:18 -0600159#define TSI108_CPU_MCACK 0x00004 /* Doesn't really exist here */
Zang Roy-r6191172335932006-08-25 14:16:30 +1000160
161/*
162 * Per-source registers
163 */
164#define TSI108_IRQ_BASE 0x00100
165#define TSI108_IRQ_STRIDE 0x00008
166#define TSI108_IRQ_VECTOR_PRI 0x00000
167#define TSI108_VECPRI_VECTOR_MASK 0x000000ff
168#define TSI108_VECPRI_POLARITY_POSITIVE 0x01000000
169#define TSI108_VECPRI_POLARITY_NEGATIVE 0x00000000
170#define TSI108_VECPRI_SENSE_LEVEL 0x02000000
171#define TSI108_VECPRI_SENSE_EDGE 0x00000000
172#define TSI108_VECPRI_POLARITY_MASK 0x01000000
173#define TSI108_VECPRI_SENSE_MASK 0x02000000
174#define TSI108_IRQ_DESTINATION 0x00004
175
176/* weird mpic register indices and mask bits in the HW info array */
177enum {
178 MPIC_IDX_GREG_BASE = 0,
179 MPIC_IDX_GREG_FEATURE_0,
180 MPIC_IDX_GREG_GLOBAL_CONF_0,
181 MPIC_IDX_GREG_VENDOR_ID,
182 MPIC_IDX_GREG_IPI_VECTOR_PRI_0,
183 MPIC_IDX_GREG_IPI_STRIDE,
184 MPIC_IDX_GREG_SPURIOUS,
185 MPIC_IDX_GREG_TIMER_FREQ,
186
187 MPIC_IDX_TIMER_BASE,
188 MPIC_IDX_TIMER_STRIDE,
189 MPIC_IDX_TIMER_CURRENT_CNT,
190 MPIC_IDX_TIMER_BASE_CNT,
191 MPIC_IDX_TIMER_VECTOR_PRI,
192 MPIC_IDX_TIMER_DESTINATION,
193
194 MPIC_IDX_CPU_BASE,
195 MPIC_IDX_CPU_STRIDE,
196 MPIC_IDX_CPU_IPI_DISPATCH_0,
197 MPIC_IDX_CPU_IPI_DISPATCH_STRIDE,
198 MPIC_IDX_CPU_CURRENT_TASK_PRI,
199 MPIC_IDX_CPU_WHOAMI,
200 MPIC_IDX_CPU_INTACK,
201 MPIC_IDX_CPU_EOI,
Olof Johanssonf3653552007-12-20 13:11:18 -0600202 MPIC_IDX_CPU_MCACK,
Zang Roy-r6191172335932006-08-25 14:16:30 +1000203
204 MPIC_IDX_IRQ_BASE,
205 MPIC_IDX_IRQ_STRIDE,
206 MPIC_IDX_IRQ_VECTOR_PRI,
207
208 MPIC_IDX_VECPRI_VECTOR_MASK,
209 MPIC_IDX_VECPRI_POLARITY_POSITIVE,
210 MPIC_IDX_VECPRI_POLARITY_NEGATIVE,
211 MPIC_IDX_VECPRI_SENSE_LEVEL,
212 MPIC_IDX_VECPRI_SENSE_EDGE,
213 MPIC_IDX_VECPRI_POLARITY_MASK,
214 MPIC_IDX_VECPRI_SENSE_MASK,
215 MPIC_IDX_IRQ_DESTINATION,
216 MPIC_IDX_END
217};
218
219
Michael Ellerman6cfef5b2007-04-23 18:47:08 +1000220#ifdef CONFIG_MPIC_U3_HT_IRQS
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000221/* Fixup table entry */
222struct mpic_irq_fixup
223{
224 u8 __iomem *base;
Benjamin Herrenschmidt1beb6a72005-12-14 13:10:10 +1100225 u8 __iomem *applebase;
Segher Boessenkoolc4b22f22005-12-13 18:04:29 +1100226 u32 data;
Benjamin Herrenschmidt1beb6a72005-12-14 13:10:10 +1100227 unsigned int index;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000228};
Michael Ellerman6cfef5b2007-04-23 18:47:08 +1000229#endif /* CONFIG_MPIC_U3_HT_IRQS */
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000230
231
Benjamin Herrenschmidtfbf02742006-11-11 17:24:55 +1100232enum mpic_reg_type {
233 mpic_access_mmio_le,
234 mpic_access_mmio_be,
235#ifdef CONFIG_PPC_DCR
236 mpic_access_dcr
237#endif
238};
239
240struct mpic_reg_bank {
241 u32 __iomem *base;
242#ifdef CONFIG_PPC_DCR
243 dcr_host_t dhost;
Benjamin Herrenschmidtfbf02742006-11-11 17:24:55 +1100244#endif /* CONFIG_PPC_DCR */
245};
246
Johannes Berg3669e932007-05-02 16:33:41 +1000247struct mpic_irq_save {
248 u32 vecprio,
249 dest;
250#ifdef CONFIG_MPIC_U3_HT_IRQS
251 u32 fixup_data;
252#endif
253};
254
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000255/* The instance data of a given MPIC */
256struct mpic
257{
Kyle Moffettc51242e2011-12-02 06:28:06 +0000258 /* The OpenFirmware dt node for this MPIC */
259 struct device_node *node;
260
Benjamin Herrenschmidt0ebfff12006-07-03 21:36:01 +1000261 /* The remapper for this MPIC */
Grant Likelybae1d8f2012-02-14 14:06:50 -0700262 struct irq_domain *irqhost;
Benjamin Herrenschmidt0ebfff12006-07-03 21:36:01 +1000263
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000264 /* The "linux" controller struct */
Benjamin Herrenschmidtb9e5b4e2006-07-03 19:32:51 +1000265 struct irq_chip hc_irq;
Michael Ellerman6cfef5b2007-04-23 18:47:08 +1000266#ifdef CONFIG_MPIC_U3_HT_IRQS
Benjamin Herrenschmidtb9e5b4e2006-07-03 19:32:51 +1000267 struct irq_chip hc_ht_irq;
268#endif
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000269#ifdef CONFIG_SMP
Benjamin Herrenschmidtb9e5b4e2006-07-03 19:32:51 +1000270 struct irq_chip hc_ipi;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000271#endif
Scott Woodea941872011-03-24 16:43:55 -0500272 struct irq_chip hc_tm;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000273 const char *name;
274 /* Flags */
275 unsigned int flags;
276 /* How many irq sources in a given ISU */
277 unsigned int isu_size;
278 unsigned int isu_shift;
279 unsigned int isu_mask;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000280 /* Number of sources */
281 unsigned int num_sources;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000282
Olof Johansson7df24572007-01-28 23:33:18 -0600283 /* vector numbers used for internal sources (ipi/timers) */
284 unsigned int ipi_vecs[4];
Scott Woodea941872011-03-24 16:43:55 -0500285 unsigned int timer_vecs[8];
Olof Johansson7df24572007-01-28 23:33:18 -0600286
287 /* Spurious vector to program into unused sources */
288 unsigned int spurious_vec;
289
Michael Ellerman6cfef5b2007-04-23 18:47:08 +1000290#ifdef CONFIG_MPIC_U3_HT_IRQS
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000291 /* The fixup table */
292 struct mpic_irq_fixup *fixups;
Thomas Gleixner203041a2010-02-18 02:23:18 +0000293 raw_spinlock_t fixup_lock;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000294#endif
295
Benjamin Herrenschmidtfbf02742006-11-11 17:24:55 +1100296 /* Register access method */
297 enum mpic_reg_type reg_type;
298
Kyle Moffette7a98672011-12-02 06:28:01 +0000299 /* The physical base address of the MPIC */
300 phys_addr_t paddr;
301
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000302 /* The various ioremap'ed bases */
Varun Sethi03bcb7e2012-07-09 14:15:42 +0530303 struct mpic_reg_bank thiscpuregs;
Benjamin Herrenschmidtfbf02742006-11-11 17:24:55 +1100304 struct mpic_reg_bank gregs;
305 struct mpic_reg_bank tmregs;
306 struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS];
307 struct mpic_reg_bank isus[MPIC_MAX_ISU];
308
Benjamin Herrenschmidt7fd72182007-07-21 09:55:21 +1000309 /* Protected sources */
310 unsigned long *protected;
311
Zang Roy-r6191172335932006-08-25 14:16:30 +1000312#ifdef CONFIG_MPIC_WEIRD
313 /* Pointer to HW info array */
314 u32 *hw_set;
315#endif
316
Michael Ellermana7de7c72007-05-08 12:58:36 +1000317#ifdef CONFIG_PCI_MSI
Michael Ellerman25235f72008-08-06 09:10:03 +1000318 struct msi_bitmap msi_bitmap;
Michael Ellermana7de7c72007-05-08 12:58:36 +1000319#endif
320
Olof Johansson0d72ba92007-09-08 05:13:19 +1000321#ifdef CONFIG_MPIC_BROKEN_REGREAD
322 u32 isu_reg0_shadow[MPIC_MAX_IRQ_SOURCES];
323#endif
324
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000325 /* link */
326 struct mpic *next;
Johannes Berg3669e932007-05-02 16:33:41 +1000327
Johannes Berg3669e932007-05-02 16:33:41 +1000328#ifdef CONFIG_PM
329 struct mpic_irq_save *save_data;
330#endif
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000331};
332
Zang Roy-r6191172335932006-08-25 14:16:30 +1000333/*
334 * MPIC flags (passed to mpic_alloc)
335 *
336 * The top 4 bits contain an MPIC bhw id that is used to index the
337 * register offsets and some masks when CONFIG_MPIC_WEIRD is set.
338 * Note setting any ID (leaving those bits to 0) means standard MPIC
339 */
340
Kyle Moffettbe8bec52011-12-02 06:28:03 +0000341/*
342 * This is a secondary ("chained") controller; it only uses the CPU0
343 * registers. Primary controllers have IPIs and affinity control.
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000344 */
Kyle Moffettbe8bec52011-12-02 06:28:03 +0000345#define MPIC_SECONDARY 0x00000001
Zang Roy-r6191172335932006-08-25 14:16:30 +1000346
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000347/* Set this for a big-endian MPIC */
348#define MPIC_BIG_ENDIAN 0x00000002
349/* Broken U3 MPIC */
Michael Ellerman6cfef5b2007-04-23 18:47:08 +1000350#define MPIC_U3_HT_IRQS 0x00000004
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000351/* Broken IPI registers (autodetected) */
352#define MPIC_BROKEN_IPI 0x00000008
Zang Roy-r6191172335932006-08-25 14:16:30 +1000353/* Spurious vector requires EOI */
354#define MPIC_SPV_EOI 0x00000020
355/* No passthrough disable */
356#define MPIC_NO_PTHROU_DIS 0x00000040
Benjamin Herrenschmidtfbf02742006-11-11 17:24:55 +1100357/* DCR based MPIC */
358#define MPIC_USES_DCR 0x00000080
Olof Johansson7df24572007-01-28 23:33:18 -0600359/* MPIC has 11-bit vector fields (or larger) */
360#define MPIC_LARGE_VECTORS 0x00000100
Olof Johanssonf3653552007-12-20 13:11:18 -0600361/* Enable delivery of prio 15 interrupts as MCK instead of EE */
362#define MPIC_ENABLE_MCK 0x00000200
Olof Johanssond87bf3b2007-12-27 22:16:29 -0600363/* Disable bias among target selection, spread interrupts evenly */
364#define MPIC_NO_BIAS 0x00000400
Kumar Gala3c10c9c2008-10-28 18:01:39 +0000365/* Destination only supports a single CPU at a time */
366#define MPIC_SINGLE_DEST_CPU 0x00001000
Kumar Galad91e4ea2009-01-07 15:53:29 -0600367/* Enable CoreInt delivery of interrupts */
368#define MPIC_ENABLE_COREINT 0x00002000
Kyle Moffette55d7f72011-12-22 10:19:14 +0000369/* Do not reset the MPIC during initialization */
Meador Ingedfec2202011-03-14 10:01:06 +0000370#define MPIC_NO_RESET 0x00004000
Scott Wood22d168c2011-03-24 16:43:54 -0500371/* Freescale MPIC (compatible includes "fsl,mpic") */
372#define MPIC_FSL 0x00008000
Zang Roy-r6191172335932006-08-25 14:16:30 +1000373
374/* MPIC HW modification ID */
375#define MPIC_REGSET_MASK 0xf0000000
376#define MPIC_REGSET(val) (((val) & 0xf ) << 28)
377#define MPIC_GET_REGSET(flags) (((flags) >> 28) & 0xf)
378
379#define MPIC_REGSET_STANDARD MPIC_REGSET(0) /* Original MPIC */
380#define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000381
382/* Allocate the controller structure and setup the linux irq descs
383 * for the range if interrupts passed in. No HW initialization is
384 * actually performed.
385 *
386 * @phys_addr: physial base address of the MPIC
387 * @flags: flags, see constants above
388 * @isu_size: number of interrupts in an ISU. Use 0 to use a
389 * standard ISU-less setup (aka powermac)
390 * @irq_offset: first irq number to assign to this mpic
391 * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0
392 * to match the number of sources
393 * @ipi_offset: first irq number to assign to this mpic IPI sources,
394 * used only on primary mpic
395 * @senses: array of sense values
396 * @senses_num: number of entries in the array
397 *
398 * Note about the sense array. If none is passed, all interrupts are
Michael Ellerman6cfef5b2007-04-23 18:47:08 +1000399 * setup to be level negative unless MPIC_U3_HT_IRQS is set in which
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000400 * case they are edge positive (and the array is ignored anyway).
401 * The values in the array start at the first source of the MPIC,
402 * that is senses[0] correspond to linux irq "irq_offset".
403 */
Benjamin Herrenschmidt0ebfff12006-07-03 21:36:01 +1000404extern struct mpic *mpic_alloc(struct device_node *node,
Benjamin Herrenschmidta959ff52006-11-11 17:24:56 +1100405 phys_addr_t phys_addr,
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000406 unsigned int flags,
407 unsigned int isu_size,
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000408 unsigned int irq_count,
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000409 const char *name);
410
411/* Assign ISUs, to call before mpic_init()
412 *
413 * @mpic: controller structure as returned by mpic_alloc()
414 * @isu_num: ISU number
415 * @phys_addr: physical address of the ISU
416 */
417extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
Benjamin Herrenschmidta959ff52006-11-11 17:24:56 +1100418 phys_addr_t phys_addr);
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000419
Benjamin Herrenschmidt0ebfff12006-07-03 21:36:01 +1000420
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000421/* Initialize the controller. After this has been called, none of the above
422 * should be called again for this mpic
423 */
424extern void mpic_init(struct mpic *mpic);
425
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000426/*
427 * All of the following functions must only be used after the
428 * ISUs have been assigned and the controller fully initialized
429 * with mpic_init()
430 */
431
432
Stephen Rothwell06a901c2008-05-21 16:24:31 +1000433/* Change the priority of an interrupt. Default is 8 for irqs and
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000434 * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the
435 * IPI number is then the offset'ed (linux irq number mapped to the IPI)
436 */
437extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri);
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000438
439/* Setup a non-boot CPU */
440extern void mpic_setup_this_cpu(void);
441
442/* Clean up for kexec (or cpu offline or ...) */
443extern void mpic_teardown_this_cpu(int secondary);
444
445/* Get the current cpu priority for this cpu (0..15) */
446extern int mpic_cpu_get_priority(void);
447
448/* Set the current cpu priority for this cpu */
449extern void mpic_cpu_set_priority(int prio);
450
451/* Request IPIs on primary mpic */
452extern void mpic_request_ipis(void);
453
Paul Mackerrasa9c59262005-10-20 17:09:51 +1000454/* Send a message (IPI) to a given target (cpu number or MSG_*) */
455void smp_mpic_message_pass(int target, int msg);
456
Olof Johanssonf3653552007-12-20 13:11:18 -0600457/* Unmask a specific virq */
Lennert Buytenhek835c0552011-03-08 22:26:43 +0000458extern void mpic_unmask_irq(struct irq_data *d);
Olof Johanssonf3653552007-12-20 13:11:18 -0600459/* Mask a specific virq */
Lennert Buytenhek835c0552011-03-08 22:26:43 +0000460extern void mpic_mask_irq(struct irq_data *d);
Olof Johanssonf3653552007-12-20 13:11:18 -0600461/* EOI a specific virq */
Lennert Buytenhek835c0552011-03-08 22:26:43 +0000462extern void mpic_end_irq(struct irq_data *d);
Olof Johanssonf3653552007-12-20 13:11:18 -0600463
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000464/* Fetch interrupt from a given mpic */
Olaf Hering35a84c22006-10-07 22:08:26 +1000465extern unsigned int mpic_get_one_irq(struct mpic *mpic);
Olof Johanssonf3653552007-12-20 13:11:18 -0600466/* This one gets from the primary mpic */
Olaf Hering35a84c22006-10-07 22:08:26 +1000467extern unsigned int mpic_get_irq(void);
Kumar Galad91e4ea2009-01-07 15:53:29 -0600468/* This one gets from the primary mpic via CoreInt*/
469extern unsigned int mpic_get_coreint_irq(void);
Olof Johanssonf3653552007-12-20 13:11:18 -0600470/* Fetch Machine Check interrupt from primary mpic */
471extern unsigned int mpic_get_mcirq(void);
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000472
Mark A. Greer868ea0c2006-06-20 14:15:36 -0700473/* Set the EPIC clock ratio */
474void mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio);
475
476/* Enable/Disable EPIC serial interrupt mode */
477void mpic_set_serial_int(struct mpic *mpic, int enable);
478
Arnd Bergmann88ced032005-12-16 22:43:46 +0100479#endif /* __KERNEL__ */
Stephen Rothwellbbeb3f42005-09-27 13:51:59 +1000480#endif /* _ASM_POWERPC_MPIC_H */