xref: /openbmc/linux/arch/powerpc/include/asm/mpic.h (revision 0f99153def98134403c9149128e59d3e1786cf04)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2b8b572e1SStephen Rothwell #ifndef _ASM_POWERPC_MPIC_H
3b8b572e1SStephen Rothwell #define _ASM_POWERPC_MPIC_H
4b8b572e1SStephen Rothwell #ifdef __KERNEL__
5b8b572e1SStephen Rothwell 
6b8b572e1SStephen Rothwell #include <linux/irq.h>
7b8b572e1SStephen Rothwell #include <asm/dcr.h>
825235f71SMichael Ellerman #include <asm/msi_bitmap.h>
9b8b572e1SStephen Rothwell 
10b8b572e1SStephen Rothwell /*
11b8b572e1SStephen Rothwell  * Global registers
12b8b572e1SStephen Rothwell  */
13b8b572e1SStephen Rothwell 
14b8b572e1SStephen Rothwell #define MPIC_GREG_BASE			0x01000
15b8b572e1SStephen Rothwell 
16b8b572e1SStephen Rothwell #define MPIC_GREG_FEATURE_0		0x00000
17b8b572e1SStephen Rothwell #define		MPIC_GREG_FEATURE_LAST_SRC_MASK		0x07ff0000
18b8b572e1SStephen Rothwell #define		MPIC_GREG_FEATURE_LAST_SRC_SHIFT	16
19b8b572e1SStephen Rothwell #define		MPIC_GREG_FEATURE_LAST_CPU_MASK		0x00001f00
20b8b572e1SStephen Rothwell #define		MPIC_GREG_FEATURE_LAST_CPU_SHIFT	8
21b8b572e1SStephen Rothwell #define		MPIC_GREG_FEATURE_VERSION_MASK		0xff
22b8b572e1SStephen Rothwell #define MPIC_GREG_FEATURE_1		0x00010
23b8b572e1SStephen Rothwell #define MPIC_GREG_GLOBAL_CONF_0		0x00020
24b8b572e1SStephen Rothwell #define		MPIC_GREG_GCONF_RESET			0x80000000
25d91e4ea7SKumar Gala /* On the FSL mpic implementations the Mode field is expand to be
26d91e4ea7SKumar Gala  * 2 bits wide:
27d91e4ea7SKumar Gala  *	0b00 = pass through (interrupts routed to IRQ0)
28d91e4ea7SKumar Gala  *	0b01 = Mixed mode
29d91e4ea7SKumar Gala  *	0b10 = reserved
30d91e4ea7SKumar Gala  *	0b11 = External proxy / coreint
31d91e4ea7SKumar Gala  */
32d91e4ea7SKumar Gala #define		MPIC_GREG_GCONF_COREINT			0x60000000
33b8b572e1SStephen Rothwell #define		MPIC_GREG_GCONF_8259_PTHROU_DIS		0x20000000
34b8b572e1SStephen Rothwell #define		MPIC_GREG_GCONF_NO_BIAS			0x10000000
35b8b572e1SStephen Rothwell #define		MPIC_GREG_GCONF_BASE_MASK		0x000fffff
36b8b572e1SStephen Rothwell #define		MPIC_GREG_GCONF_MCK			0x08000000
37b8b572e1SStephen Rothwell #define MPIC_GREG_GLOBAL_CONF_1		0x00030
38b8b572e1SStephen Rothwell #define MPIC_GREG_VENDOR_0		0x00040
39b8b572e1SStephen Rothwell #define MPIC_GREG_VENDOR_1		0x00050
40b8b572e1SStephen Rothwell #define MPIC_GREG_VENDOR_2		0x00060
41b8b572e1SStephen Rothwell #define MPIC_GREG_VENDOR_3		0x00070
42b8b572e1SStephen Rothwell #define MPIC_GREG_VENDOR_ID		0x00080
43b8b572e1SStephen Rothwell #define 	MPIC_GREG_VENDOR_ID_STEPPING_MASK	0x00ff0000
44b8b572e1SStephen Rothwell #define 	MPIC_GREG_VENDOR_ID_STEPPING_SHIFT	16
45b8b572e1SStephen Rothwell #define 	MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK	0x0000ff00
46b8b572e1SStephen Rothwell #define 	MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT	8
47b8b572e1SStephen Rothwell #define 	MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK	0x000000ff
48b8b572e1SStephen Rothwell #define MPIC_GREG_PROCESSOR_INIT	0x00090
49b8b572e1SStephen Rothwell #define MPIC_GREG_IPI_VECTOR_PRI_0	0x000a0
50b8b572e1SStephen Rothwell #define MPIC_GREG_IPI_VECTOR_PRI_1	0x000b0
51b8b572e1SStephen Rothwell #define MPIC_GREG_IPI_VECTOR_PRI_2	0x000c0
52b8b572e1SStephen Rothwell #define MPIC_GREG_IPI_VECTOR_PRI_3	0x000d0
53b8b572e1SStephen Rothwell #define MPIC_GREG_IPI_STRIDE		0x10
54b8b572e1SStephen Rothwell #define MPIC_GREG_SPURIOUS		0x000e0
55b8b572e1SStephen Rothwell #define MPIC_GREG_TIMER_FREQ		0x000f0
56b8b572e1SStephen Rothwell 
57b8b572e1SStephen Rothwell /*
58b8b572e1SStephen Rothwell  *
59b8b572e1SStephen Rothwell  * Timer registers
60b8b572e1SStephen Rothwell  */
61b8b572e1SStephen Rothwell #define MPIC_TIMER_BASE			0x01100
62b8b572e1SStephen Rothwell #define MPIC_TIMER_STRIDE		0x40
6303bcb7e3SVarun Sethi #define MPIC_TIMER_GROUP_STRIDE		0x1000
64b8b572e1SStephen Rothwell 
65b8b572e1SStephen Rothwell #define MPIC_TIMER_CURRENT_CNT		0x00000
66b8b572e1SStephen Rothwell #define MPIC_TIMER_BASE_CNT		0x00010
67b8b572e1SStephen Rothwell #define MPIC_TIMER_VECTOR_PRI		0x00020
68b8b572e1SStephen Rothwell #define MPIC_TIMER_DESTINATION		0x00030
69b8b572e1SStephen Rothwell 
70b8b572e1SStephen Rothwell /*
71b8b572e1SStephen Rothwell  * Per-Processor registers
72b8b572e1SStephen Rothwell  */
73b8b572e1SStephen Rothwell 
74b8b572e1SStephen Rothwell #define MPIC_CPU_THISBASE		0x00000
75b8b572e1SStephen Rothwell #define MPIC_CPU_BASE			0x20000
76b8b572e1SStephen Rothwell #define MPIC_CPU_STRIDE			0x01000
77b8b572e1SStephen Rothwell 
78b8b572e1SStephen Rothwell #define MPIC_CPU_IPI_DISPATCH_0		0x00040
79b8b572e1SStephen Rothwell #define MPIC_CPU_IPI_DISPATCH_1		0x00050
80b8b572e1SStephen Rothwell #define MPIC_CPU_IPI_DISPATCH_2		0x00060
81b8b572e1SStephen Rothwell #define MPIC_CPU_IPI_DISPATCH_3		0x00070
82b8b572e1SStephen Rothwell #define MPIC_CPU_IPI_DISPATCH_STRIDE	0x00010
83b8b572e1SStephen Rothwell #define MPIC_CPU_CURRENT_TASK_PRI	0x00080
84b8b572e1SStephen Rothwell #define 	MPIC_CPU_TASKPRI_MASK			0x0000000f
85b8b572e1SStephen Rothwell #define MPIC_CPU_WHOAMI			0x00090
86b8b572e1SStephen Rothwell #define 	MPIC_CPU_WHOAMI_MASK			0x0000001f
87b8b572e1SStephen Rothwell #define MPIC_CPU_INTACK			0x000a0
88b8b572e1SStephen Rothwell #define MPIC_CPU_EOI			0x000b0
89b8b572e1SStephen Rothwell #define MPIC_CPU_MCACK			0x000c0
90b8b572e1SStephen Rothwell 
91b8b572e1SStephen Rothwell /*
92b8b572e1SStephen Rothwell  * Per-source registers
93b8b572e1SStephen Rothwell  */
94b8b572e1SStephen Rothwell 
95b8b572e1SStephen Rothwell #define MPIC_IRQ_BASE			0x10000
96b8b572e1SStephen Rothwell #define MPIC_IRQ_STRIDE			0x00020
97b8b572e1SStephen Rothwell #define MPIC_IRQ_VECTOR_PRI		0x00000
98b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_MASK			0x80000000
99b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_ACTIVITY			0x40000000	/* Read Only */
100b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_PRIORITY_MASK		0x000f0000
101b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_PRIORITY_SHIFT		16
102b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_VECTOR_MASK			0x000007ff
103b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_POLARITY_POSITIVE		0x00800000
104b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_POLARITY_NEGATIVE		0x00000000
105b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_POLARITY_MASK		0x00800000
106b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_SENSE_LEVEL			0x00400000
107b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_SENSE_EDGE			0x00000000
108b8b572e1SStephen Rothwell #define 	MPIC_VECPRI_SENSE_MASK			0x00400000
109b8b572e1SStephen Rothwell #define MPIC_IRQ_DESTINATION		0x00010
110b8b572e1SStephen Rothwell 
11103bcb7e3SVarun Sethi #define MPIC_FSL_BRR1			0x00000
11203bcb7e3SVarun Sethi #define 	MPIC_FSL_BRR1_VER			0x0000ffff
11303bcb7e3SVarun Sethi 
114b8b572e1SStephen Rothwell #define MPIC_MAX_IRQ_SOURCES	2048
115b8b572e1SStephen Rothwell #define MPIC_MAX_CPUS		32
116b8b572e1SStephen Rothwell #define MPIC_MAX_ISU		32
117b8b572e1SStephen Rothwell 
1180a408164SVarun Sethi #define MPIC_MAX_ERR      32
1190a408164SVarun Sethi #define MPIC_FSL_ERR_INT  16
1200a408164SVarun Sethi 
121b8b572e1SStephen Rothwell /*
122b8b572e1SStephen Rothwell  * Tsi108 implementation of MPIC has many differences from the original one
123b8b572e1SStephen Rothwell  */
124b8b572e1SStephen Rothwell 
125b8b572e1SStephen Rothwell /*
126b8b572e1SStephen Rothwell  * Global registers
127b8b572e1SStephen Rothwell  */
128b8b572e1SStephen Rothwell 
129b8b572e1SStephen Rothwell #define TSI108_GREG_BASE		0x00000
130b8b572e1SStephen Rothwell #define TSI108_GREG_FEATURE_0		0x00000
131b8b572e1SStephen Rothwell #define TSI108_GREG_GLOBAL_CONF_0	0x00004
132b8b572e1SStephen Rothwell #define TSI108_GREG_VENDOR_ID		0x0000c
133b8b572e1SStephen Rothwell #define TSI108_GREG_IPI_VECTOR_PRI_0	0x00204		/* Doorbell 0 */
134b8b572e1SStephen Rothwell #define TSI108_GREG_IPI_STRIDE		0x0c
135b8b572e1SStephen Rothwell #define TSI108_GREG_SPURIOUS		0x00010
136b8b572e1SStephen Rothwell #define TSI108_GREG_TIMER_FREQ		0x00014
137b8b572e1SStephen Rothwell 
138b8b572e1SStephen Rothwell /*
139b8b572e1SStephen Rothwell  * Timer registers
140b8b572e1SStephen Rothwell  */
141b8b572e1SStephen Rothwell #define TSI108_TIMER_BASE		0x0030
142b8b572e1SStephen Rothwell #define TSI108_TIMER_STRIDE		0x10
143b8b572e1SStephen Rothwell #define TSI108_TIMER_CURRENT_CNT	0x00000
144b8b572e1SStephen Rothwell #define TSI108_TIMER_BASE_CNT		0x00004
145b8b572e1SStephen Rothwell #define TSI108_TIMER_VECTOR_PRI		0x00008
146b8b572e1SStephen Rothwell #define TSI108_TIMER_DESTINATION	0x0000c
147b8b572e1SStephen Rothwell 
148b8b572e1SStephen Rothwell /*
149b8b572e1SStephen Rothwell  * Per-Processor registers
150b8b572e1SStephen Rothwell  */
151b8b572e1SStephen Rothwell #define TSI108_CPU_BASE			0x00300
152b8b572e1SStephen Rothwell #define TSI108_CPU_STRIDE		0x00040
153b8b572e1SStephen Rothwell #define TSI108_CPU_IPI_DISPATCH_0	0x00200
154b8b572e1SStephen Rothwell #define TSI108_CPU_IPI_DISPATCH_STRIDE	0x00000
155b8b572e1SStephen Rothwell #define TSI108_CPU_CURRENT_TASK_PRI	0x00000
156b8b572e1SStephen Rothwell #define TSI108_CPU_WHOAMI		0xffffffff
157b8b572e1SStephen Rothwell #define TSI108_CPU_INTACK		0x00004
158b8b572e1SStephen Rothwell #define TSI108_CPU_EOI			0x00008
159b8b572e1SStephen Rothwell #define TSI108_CPU_MCACK		0x00004 /* Doesn't really exist here */
160b8b572e1SStephen Rothwell 
161b8b572e1SStephen Rothwell /*
162b8b572e1SStephen Rothwell  * Per-source registers
163b8b572e1SStephen Rothwell  */
164b8b572e1SStephen Rothwell #define TSI108_IRQ_BASE			0x00100
165b8b572e1SStephen Rothwell #define TSI108_IRQ_STRIDE		0x00008
166b8b572e1SStephen Rothwell #define TSI108_IRQ_VECTOR_PRI		0x00000
167b8b572e1SStephen Rothwell #define TSI108_VECPRI_VECTOR_MASK	0x000000ff
168b8b572e1SStephen Rothwell #define TSI108_VECPRI_POLARITY_POSITIVE	0x01000000
169b8b572e1SStephen Rothwell #define TSI108_VECPRI_POLARITY_NEGATIVE	0x00000000
170b8b572e1SStephen Rothwell #define TSI108_VECPRI_SENSE_LEVEL	0x02000000
171b8b572e1SStephen Rothwell #define TSI108_VECPRI_SENSE_EDGE	0x00000000
172b8b572e1SStephen Rothwell #define TSI108_VECPRI_POLARITY_MASK	0x01000000
173b8b572e1SStephen Rothwell #define TSI108_VECPRI_SENSE_MASK	0x02000000
174b8b572e1SStephen Rothwell #define TSI108_IRQ_DESTINATION		0x00004
175b8b572e1SStephen Rothwell 
176b8b572e1SStephen Rothwell /* weird mpic register indices and mask bits in the HW info array */
177b8b572e1SStephen Rothwell enum {
178b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_BASE = 0,
179b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_FEATURE_0,
180b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_GLOBAL_CONF_0,
181b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_VENDOR_ID,
182b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_IPI_VECTOR_PRI_0,
183b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_IPI_STRIDE,
184b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_SPURIOUS,
185b8b572e1SStephen Rothwell 	MPIC_IDX_GREG_TIMER_FREQ,
186b8b572e1SStephen Rothwell 
187b8b572e1SStephen Rothwell 	MPIC_IDX_TIMER_BASE,
188b8b572e1SStephen Rothwell 	MPIC_IDX_TIMER_STRIDE,
189b8b572e1SStephen Rothwell 	MPIC_IDX_TIMER_CURRENT_CNT,
190b8b572e1SStephen Rothwell 	MPIC_IDX_TIMER_BASE_CNT,
191b8b572e1SStephen Rothwell 	MPIC_IDX_TIMER_VECTOR_PRI,
192b8b572e1SStephen Rothwell 	MPIC_IDX_TIMER_DESTINATION,
193b8b572e1SStephen Rothwell 
194b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_BASE,
195b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_STRIDE,
196b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_IPI_DISPATCH_0,
197b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_IPI_DISPATCH_STRIDE,
198b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_CURRENT_TASK_PRI,
199b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_WHOAMI,
200b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_INTACK,
201b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_EOI,
202b8b572e1SStephen Rothwell 	MPIC_IDX_CPU_MCACK,
203b8b572e1SStephen Rothwell 
204b8b572e1SStephen Rothwell 	MPIC_IDX_IRQ_BASE,
205b8b572e1SStephen Rothwell 	MPIC_IDX_IRQ_STRIDE,
206b8b572e1SStephen Rothwell 	MPIC_IDX_IRQ_VECTOR_PRI,
207b8b572e1SStephen Rothwell 
208b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_VECTOR_MASK,
209b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_POLARITY_POSITIVE,
210b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_POLARITY_NEGATIVE,
211b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_SENSE_LEVEL,
212b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_SENSE_EDGE,
213b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_POLARITY_MASK,
214b8b572e1SStephen Rothwell 	MPIC_IDX_VECPRI_SENSE_MASK,
215b8b572e1SStephen Rothwell 	MPIC_IDX_IRQ_DESTINATION,
216b8b572e1SStephen Rothwell 	MPIC_IDX_END
217b8b572e1SStephen Rothwell };
218b8b572e1SStephen Rothwell 
219b8b572e1SStephen Rothwell 
220b8b572e1SStephen Rothwell #ifdef CONFIG_MPIC_U3_HT_IRQS
221b8b572e1SStephen Rothwell /* Fixup table entry */
222b8b572e1SStephen Rothwell struct mpic_irq_fixup
223b8b572e1SStephen Rothwell {
224b8b572e1SStephen Rothwell 	u8 __iomem	*base;
225b8b572e1SStephen Rothwell 	u8 __iomem	*applebase;
226b8b572e1SStephen Rothwell 	u32		data;
227b8b572e1SStephen Rothwell 	unsigned int	index;
228b8b572e1SStephen Rothwell };
229b8b572e1SStephen Rothwell #endif /* CONFIG_MPIC_U3_HT_IRQS */
230b8b572e1SStephen Rothwell 
231b8b572e1SStephen Rothwell 
232b8b572e1SStephen Rothwell enum mpic_reg_type {
233b8b572e1SStephen Rothwell 	mpic_access_mmio_le,
234b8b572e1SStephen Rothwell 	mpic_access_mmio_be,
235b8b572e1SStephen Rothwell #ifdef CONFIG_PPC_DCR
236b8b572e1SStephen Rothwell 	mpic_access_dcr
237b8b572e1SStephen Rothwell #endif
238b8b572e1SStephen Rothwell };
239b8b572e1SStephen Rothwell 
240b8b572e1SStephen Rothwell struct mpic_reg_bank {
241b8b572e1SStephen Rothwell 	u32 __iomem	*base;
242b8b572e1SStephen Rothwell #ifdef CONFIG_PPC_DCR
243b8b572e1SStephen Rothwell 	dcr_host_t	dhost;
244b8b572e1SStephen Rothwell #endif /* CONFIG_PPC_DCR */
245b8b572e1SStephen Rothwell };
246b8b572e1SStephen Rothwell 
247b8b572e1SStephen Rothwell struct mpic_irq_save {
248b8b572e1SStephen Rothwell 	u32		vecprio,
249b8b572e1SStephen Rothwell 			dest;
250b8b572e1SStephen Rothwell #ifdef CONFIG_MPIC_U3_HT_IRQS
251b8b572e1SStephen Rothwell 	u32		fixup_data;
252b8b572e1SStephen Rothwell #endif
253b8b572e1SStephen Rothwell };
254b8b572e1SStephen Rothwell 
255b8b572e1SStephen Rothwell /* The instance data of a given MPIC */
256b8b572e1SStephen Rothwell struct mpic
257b8b572e1SStephen Rothwell {
258c51242e7SKyle Moffett 	/* The OpenFirmware dt node for this MPIC */
259c51242e7SKyle Moffett 	struct device_node *node;
260c51242e7SKyle Moffett 
261b8b572e1SStephen Rothwell 	/* The remapper for this MPIC */
262bae1d8f1SGrant Likely 	struct irq_domain	*irqhost;
263b8b572e1SStephen Rothwell 
264b8b572e1SStephen Rothwell 	/* The "linux" controller struct */
265b8b572e1SStephen Rothwell 	struct irq_chip		hc_irq;
266b8b572e1SStephen Rothwell #ifdef CONFIG_MPIC_U3_HT_IRQS
267b8b572e1SStephen Rothwell 	struct irq_chip		hc_ht_irq;
268b8b572e1SStephen Rothwell #endif
269b8b572e1SStephen Rothwell #ifdef CONFIG_SMP
270b8b572e1SStephen Rothwell 	struct irq_chip		hc_ipi;
271b8b572e1SStephen Rothwell #endif
272ea94187fSScott Wood 	struct irq_chip		hc_tm;
2730a408164SVarun Sethi 	struct irq_chip		hc_err;
274b8b572e1SStephen Rothwell 	const char		*name;
275b8b572e1SStephen Rothwell 	/* Flags */
276b8b572e1SStephen Rothwell 	unsigned int		flags;
277b8b572e1SStephen Rothwell 	/* How many irq sources in a given ISU */
278b8b572e1SStephen Rothwell 	unsigned int		isu_size;
279b8b572e1SStephen Rothwell 	unsigned int		isu_shift;
280b8b572e1SStephen Rothwell 	unsigned int		isu_mask;
281b8b572e1SStephen Rothwell 	/* Number of sources */
282b8b572e1SStephen Rothwell 	unsigned int		num_sources;
283b8b572e1SStephen Rothwell 
284b8b572e1SStephen Rothwell 	/* vector numbers used for internal sources (ipi/timers) */
285b8b572e1SStephen Rothwell 	unsigned int		ipi_vecs[4];
286ea94187fSScott Wood 	unsigned int		timer_vecs[8];
2870a408164SVarun Sethi 	/* vector numbers used for FSL MPIC error interrupts */
2880a408164SVarun Sethi 	unsigned int		err_int_vecs[MPIC_MAX_ERR];
289b8b572e1SStephen Rothwell 
290b8b572e1SStephen Rothwell 	/* Spurious vector to program into unused sources */
291b8b572e1SStephen Rothwell 	unsigned int		spurious_vec;
292b8b572e1SStephen Rothwell 
293b8b572e1SStephen Rothwell #ifdef CONFIG_MPIC_U3_HT_IRQS
294b8b572e1SStephen Rothwell 	/* The fixup table */
295b8b572e1SStephen Rothwell 	struct mpic_irq_fixup	*fixups;
296203041adSThomas Gleixner 	raw_spinlock_t	fixup_lock;
297b8b572e1SStephen Rothwell #endif
298b8b572e1SStephen Rothwell 
299b8b572e1SStephen Rothwell 	/* Register access method */
300b8b572e1SStephen Rothwell 	enum mpic_reg_type	reg_type;
301b8b572e1SStephen Rothwell 
302e7a98675SKyle Moffett 	/* The physical base address of the MPIC */
303e7a98675SKyle Moffett 	phys_addr_t paddr;
304e7a98675SKyle Moffett 
305b8b572e1SStephen Rothwell 	/* The various ioremap'ed bases */
30603bcb7e3SVarun Sethi 	struct mpic_reg_bank	thiscpuregs;
307b8b572e1SStephen Rothwell 	struct mpic_reg_bank	gregs;
308b8b572e1SStephen Rothwell 	struct mpic_reg_bank	tmregs;
309b8b572e1SStephen Rothwell 	struct mpic_reg_bank	cpuregs[MPIC_MAX_CPUS];
310b8b572e1SStephen Rothwell 	struct mpic_reg_bank	isus[MPIC_MAX_ISU];
311b8b572e1SStephen Rothwell 
3120a408164SVarun Sethi 	/* ioremap'ed base for error interrupt registers */
3130a408164SVarun Sethi 	u32 __iomem	*err_regs;
3140a408164SVarun Sethi 
315b8b572e1SStephen Rothwell 	/* Protected sources */
316b8b572e1SStephen Rothwell 	unsigned long		*protected;
317b8b572e1SStephen Rothwell 
318b8b572e1SStephen Rothwell #ifdef CONFIG_MPIC_WEIRD
319b8b572e1SStephen Rothwell 	/* Pointer to HW info array */
320b8b572e1SStephen Rothwell 	u32			*hw_set;
321b8b572e1SStephen Rothwell #endif
322b8b572e1SStephen Rothwell 
323b8b572e1SStephen Rothwell #ifdef CONFIG_PCI_MSI
32425235f71SMichael Ellerman 	struct msi_bitmap	msi_bitmap;
325b8b572e1SStephen Rothwell #endif
326b8b572e1SStephen Rothwell 
327b8b572e1SStephen Rothwell #ifdef CONFIG_MPIC_BROKEN_REGREAD
328b8b572e1SStephen Rothwell 	u32			isu_reg0_shadow[MPIC_MAX_IRQ_SOURCES];
329b8b572e1SStephen Rothwell #endif
330b8b572e1SStephen Rothwell 
331b8b572e1SStephen Rothwell 	/* link */
332b8b572e1SStephen Rothwell 	struct mpic		*next;
333b8b572e1SStephen Rothwell 
334b8b572e1SStephen Rothwell #ifdef CONFIG_PM
335b8b572e1SStephen Rothwell 	struct mpic_irq_save	*save_data;
336b8b572e1SStephen Rothwell #endif
337b8b572e1SStephen Rothwell };
338b8b572e1SStephen Rothwell 
3399e6f31a9SDongsheng.wang@freescale.com extern struct bus_type mpic_subsys;
3409e6f31a9SDongsheng.wang@freescale.com 
341b8b572e1SStephen Rothwell /*
342b8b572e1SStephen Rothwell  * MPIC flags (passed to mpic_alloc)
343b8b572e1SStephen Rothwell  *
344b8b572e1SStephen Rothwell  * The top 4 bits contain an MPIC bhw id that is used to index the
345b8b572e1SStephen Rothwell  * register offsets and some masks when CONFIG_MPIC_WEIRD is set.
346b8b572e1SStephen Rothwell  * Note setting any ID (leaving those bits to 0) means standard MPIC
347b8b572e1SStephen Rothwell  */
348b8b572e1SStephen Rothwell 
349be8bec56SKyle Moffett /*
350be8bec56SKyle Moffett  * This is a secondary ("chained") controller; it only uses the CPU0
351be8bec56SKyle Moffett  * registers.  Primary controllers have IPIs and affinity control.
352b8b572e1SStephen Rothwell  */
353be8bec56SKyle Moffett #define MPIC_SECONDARY			0x00000001
354b8b572e1SStephen Rothwell 
355b8b572e1SStephen Rothwell /* Set this for a big-endian MPIC */
356b8b572e1SStephen Rothwell #define MPIC_BIG_ENDIAN			0x00000002
357b8b572e1SStephen Rothwell /* Broken U3 MPIC */
358b8b572e1SStephen Rothwell #define MPIC_U3_HT_IRQS			0x00000004
359b8b572e1SStephen Rothwell /* Broken IPI registers (autodetected) */
360b8b572e1SStephen Rothwell #define MPIC_BROKEN_IPI			0x00000008
361b8b572e1SStephen Rothwell /* Spurious vector requires EOI */
362b8b572e1SStephen Rothwell #define MPIC_SPV_EOI			0x00000020
363b8b572e1SStephen Rothwell /* No passthrough disable */
364b8b572e1SStephen Rothwell #define MPIC_NO_PTHROU_DIS		0x00000040
365b8b572e1SStephen Rothwell /* DCR based MPIC */
366b8b572e1SStephen Rothwell #define MPIC_USES_DCR			0x00000080
367b8b572e1SStephen Rothwell /* MPIC has 11-bit vector fields (or larger) */
368b8b572e1SStephen Rothwell #define MPIC_LARGE_VECTORS		0x00000100
369b8b572e1SStephen Rothwell /* Enable delivery of prio 15 interrupts as MCK instead of EE */
370b8b572e1SStephen Rothwell #define MPIC_ENABLE_MCK			0x00000200
371b8b572e1SStephen Rothwell /* Disable bias among target selection, spread interrupts evenly */
372b8b572e1SStephen Rothwell #define MPIC_NO_BIAS			0x00000400
3733c10c9c4SKumar Gala /* Destination only supports a single CPU at a time */
3743c10c9c4SKumar Gala #define MPIC_SINGLE_DEST_CPU		0x00001000
375d91e4ea7SKumar Gala /* Enable CoreInt delivery of interrupts */
376d91e4ea7SKumar Gala #define MPIC_ENABLE_COREINT		0x00002000
377e55d7f73SKyle Moffett /* Do not reset the MPIC during initialization */
378dfec2202SMeador Inge #define MPIC_NO_RESET			0x00004000
37922d168ceSScott Wood /* Freescale MPIC (compatible includes "fsl,mpic") */
38022d168ceSScott Wood #define MPIC_FSL			0x00008000
3810a408164SVarun Sethi /* Freescale MPIC supports EIMR (error interrupt mask register).
3820a408164SVarun Sethi  * This flag is set for MPIC version >= 4.1 (version determined
3830a408164SVarun Sethi  * from the BRR1 register).
3840a408164SVarun Sethi */
3850a408164SVarun Sethi #define MPIC_FSL_HAS_EIMR		0x00010000
386b8b572e1SStephen Rothwell 
387b8b572e1SStephen Rothwell /* MPIC HW modification ID */
388b8b572e1SStephen Rothwell #define MPIC_REGSET_MASK		0xf0000000
389b8b572e1SStephen Rothwell #define MPIC_REGSET(val)		(((val) & 0xf ) << 28)
390b8b572e1SStephen Rothwell #define MPIC_GET_REGSET(flags)		(((flags) >> 28) & 0xf)
391b8b572e1SStephen Rothwell 
392b8b572e1SStephen Rothwell #define	MPIC_REGSET_STANDARD		MPIC_REGSET(0)	/* Original MPIC */
393b8b572e1SStephen Rothwell #define	MPIC_REGSET_TSI108		MPIC_REGSET(1)	/* Tsi108/109 PIC */
394b8b572e1SStephen Rothwell 
395807d38b7SHongtao Jia /* Get the version of primary MPIC */
396*0f99153dSChristophe Leroy #ifdef CONFIG_MPIC
397807d38b7SHongtao Jia extern u32 fsl_mpic_primary_get_version(void);
398*0f99153dSChristophe Leroy #else
399*0f99153dSChristophe Leroy static inline u32 fsl_mpic_primary_get_version(void)
400*0f99153dSChristophe Leroy {
401*0f99153dSChristophe Leroy 	return 0;
402*0f99153dSChristophe Leroy }
403*0f99153dSChristophe Leroy #endif
404807d38b7SHongtao Jia 
405b8b572e1SStephen Rothwell /* Allocate the controller structure and setup the linux irq descs
406b8b572e1SStephen Rothwell  * for the range if interrupts passed in. No HW initialization is
407b8b572e1SStephen Rothwell  * actually performed.
408b8b572e1SStephen Rothwell  *
409b8b572e1SStephen Rothwell  * @phys_addr:	physial base address of the MPIC
410b8b572e1SStephen Rothwell  * @flags:	flags, see constants above
411b8b572e1SStephen Rothwell  * @isu_size:	number of interrupts in an ISU. Use 0 to use a
412b8b572e1SStephen Rothwell  *              standard ISU-less setup (aka powermac)
413b8b572e1SStephen Rothwell  * @irq_offset: first irq number to assign to this mpic
414b8b572e1SStephen Rothwell  * @irq_count:  number of irqs to use with this mpic IRQ sources. Pass 0
415b8b572e1SStephen Rothwell  *	        to match the number of sources
416b8b572e1SStephen Rothwell  * @ipi_offset: first irq number to assign to this mpic IPI sources,
417b8b572e1SStephen Rothwell  *		used only on primary mpic
418b8b572e1SStephen Rothwell  * @senses:	array of sense values
419b8b572e1SStephen Rothwell  * @senses_num: number of entries in the array
420b8b572e1SStephen Rothwell  *
421b8b572e1SStephen Rothwell  * Note about the sense array. If none is passed, all interrupts are
422b8b572e1SStephen Rothwell  * setup to be level negative unless MPIC_U3_HT_IRQS is set in which
423b8b572e1SStephen Rothwell  * case they are edge positive (and the array is ignored anyway).
424b8b572e1SStephen Rothwell  * The values in the array start at the first source of the MPIC,
425b8b572e1SStephen Rothwell  * that is senses[0] correspond to linux irq "irq_offset".
426b8b572e1SStephen Rothwell  */
427b8b572e1SStephen Rothwell extern struct mpic *mpic_alloc(struct device_node *node,
428b8b572e1SStephen Rothwell 			       phys_addr_t phys_addr,
429b8b572e1SStephen Rothwell 			       unsigned int flags,
430b8b572e1SStephen Rothwell 			       unsigned int isu_size,
431b8b572e1SStephen Rothwell 			       unsigned int irq_count,
432b8b572e1SStephen Rothwell 			       const char *name);
433b8b572e1SStephen Rothwell 
434b8b572e1SStephen Rothwell /* Assign ISUs, to call before mpic_init()
435b8b572e1SStephen Rothwell  *
436b8b572e1SStephen Rothwell  * @mpic:	controller structure as returned by mpic_alloc()
437b8b572e1SStephen Rothwell  * @isu_num:	ISU number
438b8b572e1SStephen Rothwell  * @phys_addr:	physical address of the ISU
439b8b572e1SStephen Rothwell  */
440b8b572e1SStephen Rothwell extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
441b8b572e1SStephen Rothwell 			    phys_addr_t phys_addr);
442b8b572e1SStephen Rothwell 
443b8b572e1SStephen Rothwell 
444b8b572e1SStephen Rothwell /* Initialize the controller. After this has been called, none of the above
445b8b572e1SStephen Rothwell  * should be called again for this mpic
446b8b572e1SStephen Rothwell  */
447b8b572e1SStephen Rothwell extern void mpic_init(struct mpic *mpic);
448b8b572e1SStephen Rothwell 
449b8b572e1SStephen Rothwell /*
450b8b572e1SStephen Rothwell  * All of the following functions must only be used after the
451b8b572e1SStephen Rothwell  * ISUs have been assigned and the controller fully initialized
452b8b572e1SStephen Rothwell  * with mpic_init()
453b8b572e1SStephen Rothwell  */
454b8b572e1SStephen Rothwell 
455b8b572e1SStephen Rothwell 
456b8b572e1SStephen Rothwell /* Change the priority of an interrupt. Default is 8 for irqs and
457b8b572e1SStephen Rothwell  * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the
458b8b572e1SStephen Rothwell  * IPI number is then the offset'ed (linux irq number mapped to the IPI)
459b8b572e1SStephen Rothwell  */
460b8b572e1SStephen Rothwell extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri);
461b8b572e1SStephen Rothwell 
462b8b572e1SStephen Rothwell /* Setup a non-boot CPU */
463b8b572e1SStephen Rothwell extern void mpic_setup_this_cpu(void);
464b8b572e1SStephen Rothwell 
465b8b572e1SStephen Rothwell /* Clean up for kexec (or cpu offline or ...) */
466b8b572e1SStephen Rothwell extern void mpic_teardown_this_cpu(int secondary);
467b8b572e1SStephen Rothwell 
468b8b572e1SStephen Rothwell /* Get the current cpu priority for this cpu (0..15) */
469b8b572e1SStephen Rothwell extern int mpic_cpu_get_priority(void);
470b8b572e1SStephen Rothwell 
471b8b572e1SStephen Rothwell /* Set the current cpu priority for this cpu */
472b8b572e1SStephen Rothwell extern void mpic_cpu_set_priority(int prio);
473b8b572e1SStephen Rothwell 
474b8b572e1SStephen Rothwell /* Request IPIs on primary mpic */
475b8b572e1SStephen Rothwell extern void mpic_request_ipis(void);
476b8b572e1SStephen Rothwell 
477b8b572e1SStephen Rothwell /* Send a message (IPI) to a given target (cpu number or MSG_*) */
478b8b572e1SStephen Rothwell void smp_mpic_message_pass(int target, int msg);
479b8b572e1SStephen Rothwell 
480b8b572e1SStephen Rothwell /* Unmask a specific virq */
481835c0553SLennert Buytenhek extern void mpic_unmask_irq(struct irq_data *d);
482b8b572e1SStephen Rothwell /* Mask a specific virq */
483835c0553SLennert Buytenhek extern void mpic_mask_irq(struct irq_data *d);
484b8b572e1SStephen Rothwell /* EOI a specific virq */
485835c0553SLennert Buytenhek extern void mpic_end_irq(struct irq_data *d);
486b8b572e1SStephen Rothwell 
487b8b572e1SStephen Rothwell /* Fetch interrupt from a given mpic */
488b8b572e1SStephen Rothwell extern unsigned int mpic_get_one_irq(struct mpic *mpic);
489b8b572e1SStephen Rothwell /* This one gets from the primary mpic */
490b8b572e1SStephen Rothwell extern unsigned int mpic_get_irq(void);
491d91e4ea7SKumar Gala /* This one gets from the primary mpic via CoreInt*/
492d91e4ea7SKumar Gala extern unsigned int mpic_get_coreint_irq(void);
493b8b572e1SStephen Rothwell /* Fetch Machine Check interrupt from primary mpic */
494b8b572e1SStephen Rothwell extern unsigned int mpic_get_mcirq(void);
495b8b572e1SStephen Rothwell 
496b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
497b8b572e1SStephen Rothwell #endif	/* _ASM_POWERPC_MPIC_H */
498