Stephen Rothwell | bbeb3f4 | 2005-09-27 13:51:59 +1000 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_MPIC_H |
| 2 | #define _ASM_POWERPC_MPIC_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 3 | #ifdef __KERNEL__ |
Stephen Rothwell | bbeb3f4 | 2005-09-27 13:51:59 +1000 | [diff] [blame] | 4 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 5 | #include <linux/irq.h> |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 6 | #include <asm/dcr.h> |
Michael Ellerman | 25235f7 | 2008-08-06 09:10:03 +1000 | [diff] [blame] | 7 | #include <asm/msi_bitmap.h> |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 8 | |
| 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 Gala | d91e4ea | 2009-01-07 15:53:29 -0600 | [diff] [blame] | 24 | /* 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 Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 32 | #define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000 |
Olof Johansson | d87bf3b | 2007-12-27 22:16:29 -0600 | [diff] [blame] | 33 | #define MPIC_GREG_GCONF_NO_BIAS 0x10000000 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 34 | #define MPIC_GREG_GCONF_BASE_MASK 0x000fffff |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 35 | #define MPIC_GREG_GCONF_MCK 0x08000000 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 36 | #define MPIC_GREG_GLOBAL_CONF_1 0x00030 |
Mark A. Greer | 868ea0c | 2006-06-20 14:15:36 -0700 | [diff] [blame] | 37 | #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 Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 41 | #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-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 56 | #define MPIC_GREG_IPI_STRIDE 0x10 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 57 | #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 Sethi | 03bcb7e | 2012-07-09 14:15:42 +0530 | [diff] [blame] | 66 | #define MPIC_TIMER_GROUP_STRIDE 0x1000 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 67 | |
| 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-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 85 | #define MPIC_CPU_IPI_DISPATCH_STRIDE 0x00010 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 86 | #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 Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 92 | #define MPIC_CPU_MCACK 0x000c0 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 93 | |
| 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 Sethi | 03bcb7e | 2012-07-09 14:15:42 +0530 | [diff] [blame] | 114 | #define MPIC_FSL_BRR1 0x00000 |
| 115 | #define MPIC_FSL_BRR1_VER 0x0000ffff |
| 116 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 117 | #define MPIC_MAX_IRQ_SOURCES 2048 |
| 118 | #define MPIC_MAX_CPUS 32 |
| 119 | #define MPIC_MAX_ISU 32 |
| 120 | |
Varun Sethi | 0a40816 | 2012-08-08 09:36:09 +0530 | [diff] [blame] | 121 | #define MPIC_MAX_ERR 32 |
| 122 | #define MPIC_FSL_ERR_INT 16 |
| 123 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 124 | /* |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 125 | * Tsi108 implementation of MPIC has many differences from the original one |
| 126 | */ |
| 127 | |
| 128 | /* |
| 129 | * Global registers |
| 130 | */ |
| 131 | |
| 132 | #define TSI108_GREG_BASE 0x00000 |
| 133 | #define TSI108_GREG_FEATURE_0 0x00000 |
| 134 | #define TSI108_GREG_GLOBAL_CONF_0 0x00004 |
| 135 | #define TSI108_GREG_VENDOR_ID 0x0000c |
| 136 | #define TSI108_GREG_IPI_VECTOR_PRI_0 0x00204 /* Doorbell 0 */ |
| 137 | #define TSI108_GREG_IPI_STRIDE 0x0c |
| 138 | #define TSI108_GREG_SPURIOUS 0x00010 |
| 139 | #define TSI108_GREG_TIMER_FREQ 0x00014 |
| 140 | |
| 141 | /* |
| 142 | * Timer registers |
| 143 | */ |
| 144 | #define TSI108_TIMER_BASE 0x0030 |
| 145 | #define TSI108_TIMER_STRIDE 0x10 |
| 146 | #define TSI108_TIMER_CURRENT_CNT 0x00000 |
| 147 | #define TSI108_TIMER_BASE_CNT 0x00004 |
| 148 | #define TSI108_TIMER_VECTOR_PRI 0x00008 |
| 149 | #define TSI108_TIMER_DESTINATION 0x0000c |
| 150 | |
| 151 | /* |
| 152 | * Per-Processor registers |
| 153 | */ |
| 154 | #define TSI108_CPU_BASE 0x00300 |
| 155 | #define TSI108_CPU_STRIDE 0x00040 |
| 156 | #define TSI108_CPU_IPI_DISPATCH_0 0x00200 |
| 157 | #define TSI108_CPU_IPI_DISPATCH_STRIDE 0x00000 |
| 158 | #define TSI108_CPU_CURRENT_TASK_PRI 0x00000 |
| 159 | #define TSI108_CPU_WHOAMI 0xffffffff |
| 160 | #define TSI108_CPU_INTACK 0x00004 |
| 161 | #define TSI108_CPU_EOI 0x00008 |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 162 | #define TSI108_CPU_MCACK 0x00004 /* Doesn't really exist here */ |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * Per-source registers |
| 166 | */ |
| 167 | #define TSI108_IRQ_BASE 0x00100 |
| 168 | #define TSI108_IRQ_STRIDE 0x00008 |
| 169 | #define TSI108_IRQ_VECTOR_PRI 0x00000 |
| 170 | #define TSI108_VECPRI_VECTOR_MASK 0x000000ff |
| 171 | #define TSI108_VECPRI_POLARITY_POSITIVE 0x01000000 |
| 172 | #define TSI108_VECPRI_POLARITY_NEGATIVE 0x00000000 |
| 173 | #define TSI108_VECPRI_SENSE_LEVEL 0x02000000 |
| 174 | #define TSI108_VECPRI_SENSE_EDGE 0x00000000 |
| 175 | #define TSI108_VECPRI_POLARITY_MASK 0x01000000 |
| 176 | #define TSI108_VECPRI_SENSE_MASK 0x02000000 |
| 177 | #define TSI108_IRQ_DESTINATION 0x00004 |
| 178 | |
| 179 | /* weird mpic register indices and mask bits in the HW info array */ |
| 180 | enum { |
| 181 | MPIC_IDX_GREG_BASE = 0, |
| 182 | MPIC_IDX_GREG_FEATURE_0, |
| 183 | MPIC_IDX_GREG_GLOBAL_CONF_0, |
| 184 | MPIC_IDX_GREG_VENDOR_ID, |
| 185 | MPIC_IDX_GREG_IPI_VECTOR_PRI_0, |
| 186 | MPIC_IDX_GREG_IPI_STRIDE, |
| 187 | MPIC_IDX_GREG_SPURIOUS, |
| 188 | MPIC_IDX_GREG_TIMER_FREQ, |
| 189 | |
| 190 | MPIC_IDX_TIMER_BASE, |
| 191 | MPIC_IDX_TIMER_STRIDE, |
| 192 | MPIC_IDX_TIMER_CURRENT_CNT, |
| 193 | MPIC_IDX_TIMER_BASE_CNT, |
| 194 | MPIC_IDX_TIMER_VECTOR_PRI, |
| 195 | MPIC_IDX_TIMER_DESTINATION, |
| 196 | |
| 197 | MPIC_IDX_CPU_BASE, |
| 198 | MPIC_IDX_CPU_STRIDE, |
| 199 | MPIC_IDX_CPU_IPI_DISPATCH_0, |
| 200 | MPIC_IDX_CPU_IPI_DISPATCH_STRIDE, |
| 201 | MPIC_IDX_CPU_CURRENT_TASK_PRI, |
| 202 | MPIC_IDX_CPU_WHOAMI, |
| 203 | MPIC_IDX_CPU_INTACK, |
| 204 | MPIC_IDX_CPU_EOI, |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 205 | MPIC_IDX_CPU_MCACK, |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 206 | |
| 207 | MPIC_IDX_IRQ_BASE, |
| 208 | MPIC_IDX_IRQ_STRIDE, |
| 209 | MPIC_IDX_IRQ_VECTOR_PRI, |
| 210 | |
| 211 | MPIC_IDX_VECPRI_VECTOR_MASK, |
| 212 | MPIC_IDX_VECPRI_POLARITY_POSITIVE, |
| 213 | MPIC_IDX_VECPRI_POLARITY_NEGATIVE, |
| 214 | MPIC_IDX_VECPRI_SENSE_LEVEL, |
| 215 | MPIC_IDX_VECPRI_SENSE_EDGE, |
| 216 | MPIC_IDX_VECPRI_POLARITY_MASK, |
| 217 | MPIC_IDX_VECPRI_SENSE_MASK, |
| 218 | MPIC_IDX_IRQ_DESTINATION, |
| 219 | MPIC_IDX_END |
| 220 | }; |
| 221 | |
| 222 | |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 223 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 224 | /* Fixup table entry */ |
| 225 | struct mpic_irq_fixup |
| 226 | { |
| 227 | u8 __iomem *base; |
Benjamin Herrenschmidt | 1beb6a7 | 2005-12-14 13:10:10 +1100 | [diff] [blame] | 228 | u8 __iomem *applebase; |
Segher Boessenkool | c4b22f2 | 2005-12-13 18:04:29 +1100 | [diff] [blame] | 229 | u32 data; |
Benjamin Herrenschmidt | 1beb6a7 | 2005-12-14 13:10:10 +1100 | [diff] [blame] | 230 | unsigned int index; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 231 | }; |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 232 | #endif /* CONFIG_MPIC_U3_HT_IRQS */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 233 | |
| 234 | |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 235 | enum mpic_reg_type { |
| 236 | mpic_access_mmio_le, |
| 237 | mpic_access_mmio_be, |
| 238 | #ifdef CONFIG_PPC_DCR |
| 239 | mpic_access_dcr |
| 240 | #endif |
| 241 | }; |
| 242 | |
| 243 | struct mpic_reg_bank { |
| 244 | u32 __iomem *base; |
| 245 | #ifdef CONFIG_PPC_DCR |
| 246 | dcr_host_t dhost; |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 247 | #endif /* CONFIG_PPC_DCR */ |
| 248 | }; |
| 249 | |
Johannes Berg | 3669e93 | 2007-05-02 16:33:41 +1000 | [diff] [blame] | 250 | struct mpic_irq_save { |
| 251 | u32 vecprio, |
| 252 | dest; |
| 253 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
| 254 | u32 fixup_data; |
| 255 | #endif |
| 256 | }; |
| 257 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 258 | /* The instance data of a given MPIC */ |
| 259 | struct mpic |
| 260 | { |
Kyle Moffett | c51242e | 2011-12-02 06:28:06 +0000 | [diff] [blame] | 261 | /* The OpenFirmware dt node for this MPIC */ |
| 262 | struct device_node *node; |
| 263 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 264 | /* The remapper for this MPIC */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 265 | struct irq_domain *irqhost; |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 266 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 267 | /* The "linux" controller struct */ |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 268 | struct irq_chip hc_irq; |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 269 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 270 | struct irq_chip hc_ht_irq; |
| 271 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 272 | #ifdef CONFIG_SMP |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 273 | struct irq_chip hc_ipi; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 274 | #endif |
Scott Wood | ea94187 | 2011-03-24 16:43:55 -0500 | [diff] [blame] | 275 | struct irq_chip hc_tm; |
Varun Sethi | 0a40816 | 2012-08-08 09:36:09 +0530 | [diff] [blame] | 276 | struct irq_chip hc_err; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 277 | const char *name; |
| 278 | /* Flags */ |
| 279 | unsigned int flags; |
| 280 | /* How many irq sources in a given ISU */ |
| 281 | unsigned int isu_size; |
| 282 | unsigned int isu_shift; |
| 283 | unsigned int isu_mask; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 284 | /* Number of sources */ |
| 285 | unsigned int num_sources; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 286 | |
Olof Johansson | 7df2457 | 2007-01-28 23:33:18 -0600 | [diff] [blame] | 287 | /* vector numbers used for internal sources (ipi/timers) */ |
| 288 | unsigned int ipi_vecs[4]; |
Scott Wood | ea94187 | 2011-03-24 16:43:55 -0500 | [diff] [blame] | 289 | unsigned int timer_vecs[8]; |
Varun Sethi | 0a40816 | 2012-08-08 09:36:09 +0530 | [diff] [blame] | 290 | /* vector numbers used for FSL MPIC error interrupts */ |
| 291 | unsigned int err_int_vecs[MPIC_MAX_ERR]; |
Olof Johansson | 7df2457 | 2007-01-28 23:33:18 -0600 | [diff] [blame] | 292 | |
| 293 | /* Spurious vector to program into unused sources */ |
| 294 | unsigned int spurious_vec; |
| 295 | |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 296 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 297 | /* The fixup table */ |
| 298 | struct mpic_irq_fixup *fixups; |
Thomas Gleixner | 203041a | 2010-02-18 02:23:18 +0000 | [diff] [blame] | 299 | raw_spinlock_t fixup_lock; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 300 | #endif |
| 301 | |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 302 | /* Register access method */ |
| 303 | enum mpic_reg_type reg_type; |
| 304 | |
Kyle Moffett | e7a9867 | 2011-12-02 06:28:01 +0000 | [diff] [blame] | 305 | /* The physical base address of the MPIC */ |
| 306 | phys_addr_t paddr; |
| 307 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 308 | /* The various ioremap'ed bases */ |
Varun Sethi | 03bcb7e | 2012-07-09 14:15:42 +0530 | [diff] [blame] | 309 | struct mpic_reg_bank thiscpuregs; |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 310 | struct mpic_reg_bank gregs; |
| 311 | struct mpic_reg_bank tmregs; |
| 312 | struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS]; |
| 313 | struct mpic_reg_bank isus[MPIC_MAX_ISU]; |
| 314 | |
Varun Sethi | 0a40816 | 2012-08-08 09:36:09 +0530 | [diff] [blame] | 315 | /* ioremap'ed base for error interrupt registers */ |
| 316 | u32 __iomem *err_regs; |
| 317 | |
Benjamin Herrenschmidt | 7fd7218 | 2007-07-21 09:55:21 +1000 | [diff] [blame] | 318 | /* Protected sources */ |
| 319 | unsigned long *protected; |
| 320 | |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 321 | #ifdef CONFIG_MPIC_WEIRD |
| 322 | /* Pointer to HW info array */ |
| 323 | u32 *hw_set; |
| 324 | #endif |
| 325 | |
Michael Ellerman | a7de7c7 | 2007-05-08 12:58:36 +1000 | [diff] [blame] | 326 | #ifdef CONFIG_PCI_MSI |
Michael Ellerman | 25235f7 | 2008-08-06 09:10:03 +1000 | [diff] [blame] | 327 | struct msi_bitmap msi_bitmap; |
Michael Ellerman | a7de7c7 | 2007-05-08 12:58:36 +1000 | [diff] [blame] | 328 | #endif |
| 329 | |
Olof Johansson | 0d72ba9 | 2007-09-08 05:13:19 +1000 | [diff] [blame] | 330 | #ifdef CONFIG_MPIC_BROKEN_REGREAD |
| 331 | u32 isu_reg0_shadow[MPIC_MAX_IRQ_SOURCES]; |
| 332 | #endif |
| 333 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 334 | /* link */ |
| 335 | struct mpic *next; |
Johannes Berg | 3669e93 | 2007-05-02 16:33:41 +1000 | [diff] [blame] | 336 | |
Johannes Berg | 3669e93 | 2007-05-02 16:33:41 +1000 | [diff] [blame] | 337 | #ifdef CONFIG_PM |
| 338 | struct mpic_irq_save *save_data; |
| 339 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 340 | }; |
| 341 | |
Dongsheng.wang@freescale.com | 9e6f31a | 2013-04-09 10:22:31 +0800 | [diff] [blame] | 342 | extern struct bus_type mpic_subsys; |
| 343 | |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 344 | /* |
| 345 | * MPIC flags (passed to mpic_alloc) |
| 346 | * |
| 347 | * The top 4 bits contain an MPIC bhw id that is used to index the |
| 348 | * register offsets and some masks when CONFIG_MPIC_WEIRD is set. |
| 349 | * Note setting any ID (leaving those bits to 0) means standard MPIC |
| 350 | */ |
| 351 | |
Kyle Moffett | be8bec5 | 2011-12-02 06:28:03 +0000 | [diff] [blame] | 352 | /* |
| 353 | * This is a secondary ("chained") controller; it only uses the CPU0 |
| 354 | * registers. Primary controllers have IPIs and affinity control. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 355 | */ |
Kyle Moffett | be8bec5 | 2011-12-02 06:28:03 +0000 | [diff] [blame] | 356 | #define MPIC_SECONDARY 0x00000001 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 357 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 358 | /* Set this for a big-endian MPIC */ |
| 359 | #define MPIC_BIG_ENDIAN 0x00000002 |
| 360 | /* Broken U3 MPIC */ |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 361 | #define MPIC_U3_HT_IRQS 0x00000004 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 362 | /* Broken IPI registers (autodetected) */ |
| 363 | #define MPIC_BROKEN_IPI 0x00000008 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 364 | /* Spurious vector requires EOI */ |
| 365 | #define MPIC_SPV_EOI 0x00000020 |
| 366 | /* No passthrough disable */ |
| 367 | #define MPIC_NO_PTHROU_DIS 0x00000040 |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 368 | /* DCR based MPIC */ |
| 369 | #define MPIC_USES_DCR 0x00000080 |
Olof Johansson | 7df2457 | 2007-01-28 23:33:18 -0600 | [diff] [blame] | 370 | /* MPIC has 11-bit vector fields (or larger) */ |
| 371 | #define MPIC_LARGE_VECTORS 0x00000100 |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 372 | /* Enable delivery of prio 15 interrupts as MCK instead of EE */ |
| 373 | #define MPIC_ENABLE_MCK 0x00000200 |
Olof Johansson | d87bf3b | 2007-12-27 22:16:29 -0600 | [diff] [blame] | 374 | /* Disable bias among target selection, spread interrupts evenly */ |
| 375 | #define MPIC_NO_BIAS 0x00000400 |
Kumar Gala | 3c10c9c | 2008-10-28 18:01:39 +0000 | [diff] [blame] | 376 | /* Destination only supports a single CPU at a time */ |
| 377 | #define MPIC_SINGLE_DEST_CPU 0x00001000 |
Kumar Gala | d91e4ea | 2009-01-07 15:53:29 -0600 | [diff] [blame] | 378 | /* Enable CoreInt delivery of interrupts */ |
| 379 | #define MPIC_ENABLE_COREINT 0x00002000 |
Kyle Moffett | e55d7f7 | 2011-12-22 10:19:14 +0000 | [diff] [blame] | 380 | /* Do not reset the MPIC during initialization */ |
Meador Inge | dfec220 | 2011-03-14 10:01:06 +0000 | [diff] [blame] | 381 | #define MPIC_NO_RESET 0x00004000 |
Scott Wood | 22d168c | 2011-03-24 16:43:54 -0500 | [diff] [blame] | 382 | /* Freescale MPIC (compatible includes "fsl,mpic") */ |
| 383 | #define MPIC_FSL 0x00008000 |
Varun Sethi | 0a40816 | 2012-08-08 09:36:09 +0530 | [diff] [blame] | 384 | /* Freescale MPIC supports EIMR (error interrupt mask register). |
| 385 | * This flag is set for MPIC version >= 4.1 (version determined |
| 386 | * from the BRR1 register). |
| 387 | */ |
| 388 | #define MPIC_FSL_HAS_EIMR 0x00010000 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 389 | |
| 390 | /* MPIC HW modification ID */ |
| 391 | #define MPIC_REGSET_MASK 0xf0000000 |
| 392 | #define MPIC_REGSET(val) (((val) & 0xf ) << 28) |
| 393 | #define MPIC_GET_REGSET(flags) (((flags) >> 28) & 0xf) |
| 394 | |
| 395 | #define MPIC_REGSET_STANDARD MPIC_REGSET(0) /* Original MPIC */ |
| 396 | #define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 397 | |
Hongtao Jia | 86d3796 | 2013-04-10 10:52:55 +0800 | [diff] [blame] | 398 | /* Get the version of primary MPIC */ |
Hongtao Jia | df1024a | 2013-07-02 09:36:37 +0800 | [diff] [blame] | 399 | #ifdef CONFIG_MPIC |
Hongtao Jia | 86d3796 | 2013-04-10 10:52:55 +0800 | [diff] [blame] | 400 | extern u32 fsl_mpic_primary_get_version(void); |
Hongtao Jia | df1024a | 2013-07-02 09:36:37 +0800 | [diff] [blame] | 401 | #else |
| 402 | static inline u32 fsl_mpic_primary_get_version(void) |
| 403 | { |
| 404 | return 0; |
| 405 | } |
| 406 | #endif |
Hongtao Jia | 86d3796 | 2013-04-10 10:52:55 +0800 | [diff] [blame] | 407 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 408 | /* Allocate the controller structure and setup the linux irq descs |
| 409 | * for the range if interrupts passed in. No HW initialization is |
| 410 | * actually performed. |
| 411 | * |
| 412 | * @phys_addr: physial base address of the MPIC |
| 413 | * @flags: flags, see constants above |
| 414 | * @isu_size: number of interrupts in an ISU. Use 0 to use a |
| 415 | * standard ISU-less setup (aka powermac) |
| 416 | * @irq_offset: first irq number to assign to this mpic |
| 417 | * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0 |
| 418 | * to match the number of sources |
| 419 | * @ipi_offset: first irq number to assign to this mpic IPI sources, |
| 420 | * used only on primary mpic |
| 421 | * @senses: array of sense values |
| 422 | * @senses_num: number of entries in the array |
| 423 | * |
| 424 | * Note about the sense array. If none is passed, all interrupts are |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 425 | * setup to be level negative unless MPIC_U3_HT_IRQS is set in which |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 426 | * case they are edge positive (and the array is ignored anyway). |
| 427 | * The values in the array start at the first source of the MPIC, |
| 428 | * that is senses[0] correspond to linux irq "irq_offset". |
| 429 | */ |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 430 | extern struct mpic *mpic_alloc(struct device_node *node, |
Benjamin Herrenschmidt | a959ff5 | 2006-11-11 17:24:56 +1100 | [diff] [blame] | 431 | phys_addr_t phys_addr, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 432 | unsigned int flags, |
| 433 | unsigned int isu_size, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 434 | unsigned int irq_count, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 435 | const char *name); |
| 436 | |
| 437 | /* Assign ISUs, to call before mpic_init() |
| 438 | * |
| 439 | * @mpic: controller structure as returned by mpic_alloc() |
| 440 | * @isu_num: ISU number |
| 441 | * @phys_addr: physical address of the ISU |
| 442 | */ |
| 443 | extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, |
Benjamin Herrenschmidt | a959ff5 | 2006-11-11 17:24:56 +1100 | [diff] [blame] | 444 | phys_addr_t phys_addr); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 445 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 446 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 447 | /* Initialize the controller. After this has been called, none of the above |
| 448 | * should be called again for this mpic |
| 449 | */ |
| 450 | extern void mpic_init(struct mpic *mpic); |
| 451 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 452 | /* |
| 453 | * All of the following functions must only be used after the |
| 454 | * ISUs have been assigned and the controller fully initialized |
| 455 | * with mpic_init() |
| 456 | */ |
| 457 | |
| 458 | |
Stephen Rothwell | 06a901c | 2008-05-21 16:24:31 +1000 | [diff] [blame] | 459 | /* Change the priority of an interrupt. Default is 8 for irqs and |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 460 | * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the |
| 461 | * IPI number is then the offset'ed (linux irq number mapped to the IPI) |
| 462 | */ |
| 463 | extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 464 | |
| 465 | /* Setup a non-boot CPU */ |
| 466 | extern void mpic_setup_this_cpu(void); |
| 467 | |
| 468 | /* Clean up for kexec (or cpu offline or ...) */ |
| 469 | extern void mpic_teardown_this_cpu(int secondary); |
| 470 | |
| 471 | /* Get the current cpu priority for this cpu (0..15) */ |
| 472 | extern int mpic_cpu_get_priority(void); |
| 473 | |
| 474 | /* Set the current cpu priority for this cpu */ |
| 475 | extern void mpic_cpu_set_priority(int prio); |
| 476 | |
| 477 | /* Request IPIs on primary mpic */ |
| 478 | extern void mpic_request_ipis(void); |
| 479 | |
Paul Mackerras | a9c5926 | 2005-10-20 17:09:51 +1000 | [diff] [blame] | 480 | /* Send a message (IPI) to a given target (cpu number or MSG_*) */ |
| 481 | void smp_mpic_message_pass(int target, int msg); |
| 482 | |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 483 | /* Unmask a specific virq */ |
Lennert Buytenhek | 835c0553 | 2011-03-08 22:26:43 +0000 | [diff] [blame] | 484 | extern void mpic_unmask_irq(struct irq_data *d); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 485 | /* Mask a specific virq */ |
Lennert Buytenhek | 835c0553 | 2011-03-08 22:26:43 +0000 | [diff] [blame] | 486 | extern void mpic_mask_irq(struct irq_data *d); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 487 | /* EOI a specific virq */ |
Lennert Buytenhek | 835c0553 | 2011-03-08 22:26:43 +0000 | [diff] [blame] | 488 | extern void mpic_end_irq(struct irq_data *d); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 489 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 490 | /* Fetch interrupt from a given mpic */ |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 491 | extern unsigned int mpic_get_one_irq(struct mpic *mpic); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 492 | /* This one gets from the primary mpic */ |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 493 | extern unsigned int mpic_get_irq(void); |
Kumar Gala | d91e4ea | 2009-01-07 15:53:29 -0600 | [diff] [blame] | 494 | /* This one gets from the primary mpic via CoreInt*/ |
| 495 | extern unsigned int mpic_get_coreint_irq(void); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 496 | /* Fetch Machine Check interrupt from primary mpic */ |
| 497 | extern unsigned int mpic_get_mcirq(void); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 498 | |
Mark A. Greer | 868ea0c | 2006-06-20 14:15:36 -0700 | [diff] [blame] | 499 | /* Set the EPIC clock ratio */ |
| 500 | void mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio); |
| 501 | |
| 502 | /* Enable/Disable EPIC serial interrupt mode */ |
| 503 | void mpic_set_serial_int(struct mpic *mpic, int enable); |
| 504 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 505 | #endif /* __KERNEL__ */ |
Stephen Rothwell | bbeb3f4 | 2005-09-27 13:51:59 +1000 | [diff] [blame] | 506 | #endif /* _ASM_POWERPC_MPIC_H */ |