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> |
Johannes Berg | 3669e93 | 2007-05-02 16:33:41 +1000 | [diff] [blame] | 6 | #include <linux/sysdev.h> |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 7 | #include <asm/dcr.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 |
| 24 | #define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000 |
| 25 | #define MPIC_GREG_GCONF_BASE_MASK 0x000fffff |
| 26 | #define MPIC_GREG_GLOBAL_CONF_1 0x00030 |
Mark A. Greer | 868ea0c | 2006-06-20 14:15:36 -0700 | [diff] [blame] | 27 | #define MPIC_GREG_GLOBAL_CONF_1_SIE 0x08000000 |
| 28 | #define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK 0x70000000 |
| 29 | #define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO(r) \ |
| 30 | (((r) << 28) & MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 31 | #define MPIC_GREG_VENDOR_0 0x00040 |
| 32 | #define MPIC_GREG_VENDOR_1 0x00050 |
| 33 | #define MPIC_GREG_VENDOR_2 0x00060 |
| 34 | #define MPIC_GREG_VENDOR_3 0x00070 |
| 35 | #define MPIC_GREG_VENDOR_ID 0x00080 |
| 36 | #define MPIC_GREG_VENDOR_ID_STEPPING_MASK 0x00ff0000 |
| 37 | #define MPIC_GREG_VENDOR_ID_STEPPING_SHIFT 16 |
| 38 | #define MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00 |
| 39 | #define MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT 8 |
| 40 | #define MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK 0x000000ff |
| 41 | #define MPIC_GREG_PROCESSOR_INIT 0x00090 |
| 42 | #define MPIC_GREG_IPI_VECTOR_PRI_0 0x000a0 |
| 43 | #define MPIC_GREG_IPI_VECTOR_PRI_1 0x000b0 |
| 44 | #define MPIC_GREG_IPI_VECTOR_PRI_2 0x000c0 |
| 45 | #define MPIC_GREG_IPI_VECTOR_PRI_3 0x000d0 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 46 | #define MPIC_GREG_IPI_STRIDE 0x10 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 47 | #define MPIC_GREG_SPURIOUS 0x000e0 |
| 48 | #define MPIC_GREG_TIMER_FREQ 0x000f0 |
| 49 | |
| 50 | /* |
| 51 | * |
| 52 | * Timer registers |
| 53 | */ |
| 54 | #define MPIC_TIMER_BASE 0x01100 |
| 55 | #define MPIC_TIMER_STRIDE 0x40 |
| 56 | |
| 57 | #define MPIC_TIMER_CURRENT_CNT 0x00000 |
| 58 | #define MPIC_TIMER_BASE_CNT 0x00010 |
| 59 | #define MPIC_TIMER_VECTOR_PRI 0x00020 |
| 60 | #define MPIC_TIMER_DESTINATION 0x00030 |
| 61 | |
| 62 | /* |
| 63 | * Per-Processor registers |
| 64 | */ |
| 65 | |
| 66 | #define MPIC_CPU_THISBASE 0x00000 |
| 67 | #define MPIC_CPU_BASE 0x20000 |
| 68 | #define MPIC_CPU_STRIDE 0x01000 |
| 69 | |
| 70 | #define MPIC_CPU_IPI_DISPATCH_0 0x00040 |
| 71 | #define MPIC_CPU_IPI_DISPATCH_1 0x00050 |
| 72 | #define MPIC_CPU_IPI_DISPATCH_2 0x00060 |
| 73 | #define MPIC_CPU_IPI_DISPATCH_3 0x00070 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 74 | #define MPIC_CPU_IPI_DISPATCH_STRIDE 0x00010 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 75 | #define MPIC_CPU_CURRENT_TASK_PRI 0x00080 |
| 76 | #define MPIC_CPU_TASKPRI_MASK 0x0000000f |
| 77 | #define MPIC_CPU_WHOAMI 0x00090 |
| 78 | #define MPIC_CPU_WHOAMI_MASK 0x0000001f |
| 79 | #define MPIC_CPU_INTACK 0x000a0 |
| 80 | #define MPIC_CPU_EOI 0x000b0 |
| 81 | |
| 82 | /* |
| 83 | * Per-source registers |
| 84 | */ |
| 85 | |
| 86 | #define MPIC_IRQ_BASE 0x10000 |
| 87 | #define MPIC_IRQ_STRIDE 0x00020 |
| 88 | #define MPIC_IRQ_VECTOR_PRI 0x00000 |
| 89 | #define MPIC_VECPRI_MASK 0x80000000 |
| 90 | #define MPIC_VECPRI_ACTIVITY 0x40000000 /* Read Only */ |
| 91 | #define MPIC_VECPRI_PRIORITY_MASK 0x000f0000 |
| 92 | #define MPIC_VECPRI_PRIORITY_SHIFT 16 |
| 93 | #define MPIC_VECPRI_VECTOR_MASK 0x000007ff |
| 94 | #define MPIC_VECPRI_POLARITY_POSITIVE 0x00800000 |
| 95 | #define MPIC_VECPRI_POLARITY_NEGATIVE 0x00000000 |
| 96 | #define MPIC_VECPRI_POLARITY_MASK 0x00800000 |
| 97 | #define MPIC_VECPRI_SENSE_LEVEL 0x00400000 |
| 98 | #define MPIC_VECPRI_SENSE_EDGE 0x00000000 |
| 99 | #define MPIC_VECPRI_SENSE_MASK 0x00400000 |
| 100 | #define MPIC_IRQ_DESTINATION 0x00010 |
| 101 | |
| 102 | #define MPIC_MAX_IRQ_SOURCES 2048 |
| 103 | #define MPIC_MAX_CPUS 32 |
| 104 | #define MPIC_MAX_ISU 32 |
| 105 | |
| 106 | /* |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 107 | * Tsi108 implementation of MPIC has many differences from the original one |
| 108 | */ |
| 109 | |
| 110 | /* |
| 111 | * Global registers |
| 112 | */ |
| 113 | |
| 114 | #define TSI108_GREG_BASE 0x00000 |
| 115 | #define TSI108_GREG_FEATURE_0 0x00000 |
| 116 | #define TSI108_GREG_GLOBAL_CONF_0 0x00004 |
| 117 | #define TSI108_GREG_VENDOR_ID 0x0000c |
| 118 | #define TSI108_GREG_IPI_VECTOR_PRI_0 0x00204 /* Doorbell 0 */ |
| 119 | #define TSI108_GREG_IPI_STRIDE 0x0c |
| 120 | #define TSI108_GREG_SPURIOUS 0x00010 |
| 121 | #define TSI108_GREG_TIMER_FREQ 0x00014 |
| 122 | |
| 123 | /* |
| 124 | * Timer registers |
| 125 | */ |
| 126 | #define TSI108_TIMER_BASE 0x0030 |
| 127 | #define TSI108_TIMER_STRIDE 0x10 |
| 128 | #define TSI108_TIMER_CURRENT_CNT 0x00000 |
| 129 | #define TSI108_TIMER_BASE_CNT 0x00004 |
| 130 | #define TSI108_TIMER_VECTOR_PRI 0x00008 |
| 131 | #define TSI108_TIMER_DESTINATION 0x0000c |
| 132 | |
| 133 | /* |
| 134 | * Per-Processor registers |
| 135 | */ |
| 136 | #define TSI108_CPU_BASE 0x00300 |
| 137 | #define TSI108_CPU_STRIDE 0x00040 |
| 138 | #define TSI108_CPU_IPI_DISPATCH_0 0x00200 |
| 139 | #define TSI108_CPU_IPI_DISPATCH_STRIDE 0x00000 |
| 140 | #define TSI108_CPU_CURRENT_TASK_PRI 0x00000 |
| 141 | #define TSI108_CPU_WHOAMI 0xffffffff |
| 142 | #define TSI108_CPU_INTACK 0x00004 |
| 143 | #define TSI108_CPU_EOI 0x00008 |
| 144 | |
| 145 | /* |
| 146 | * Per-source registers |
| 147 | */ |
| 148 | #define TSI108_IRQ_BASE 0x00100 |
| 149 | #define TSI108_IRQ_STRIDE 0x00008 |
| 150 | #define TSI108_IRQ_VECTOR_PRI 0x00000 |
| 151 | #define TSI108_VECPRI_VECTOR_MASK 0x000000ff |
| 152 | #define TSI108_VECPRI_POLARITY_POSITIVE 0x01000000 |
| 153 | #define TSI108_VECPRI_POLARITY_NEGATIVE 0x00000000 |
| 154 | #define TSI108_VECPRI_SENSE_LEVEL 0x02000000 |
| 155 | #define TSI108_VECPRI_SENSE_EDGE 0x00000000 |
| 156 | #define TSI108_VECPRI_POLARITY_MASK 0x01000000 |
| 157 | #define TSI108_VECPRI_SENSE_MASK 0x02000000 |
| 158 | #define TSI108_IRQ_DESTINATION 0x00004 |
| 159 | |
| 160 | /* weird mpic register indices and mask bits in the HW info array */ |
| 161 | enum { |
| 162 | MPIC_IDX_GREG_BASE = 0, |
| 163 | MPIC_IDX_GREG_FEATURE_0, |
| 164 | MPIC_IDX_GREG_GLOBAL_CONF_0, |
| 165 | MPIC_IDX_GREG_VENDOR_ID, |
| 166 | MPIC_IDX_GREG_IPI_VECTOR_PRI_0, |
| 167 | MPIC_IDX_GREG_IPI_STRIDE, |
| 168 | MPIC_IDX_GREG_SPURIOUS, |
| 169 | MPIC_IDX_GREG_TIMER_FREQ, |
| 170 | |
| 171 | MPIC_IDX_TIMER_BASE, |
| 172 | MPIC_IDX_TIMER_STRIDE, |
| 173 | MPIC_IDX_TIMER_CURRENT_CNT, |
| 174 | MPIC_IDX_TIMER_BASE_CNT, |
| 175 | MPIC_IDX_TIMER_VECTOR_PRI, |
| 176 | MPIC_IDX_TIMER_DESTINATION, |
| 177 | |
| 178 | MPIC_IDX_CPU_BASE, |
| 179 | MPIC_IDX_CPU_STRIDE, |
| 180 | MPIC_IDX_CPU_IPI_DISPATCH_0, |
| 181 | MPIC_IDX_CPU_IPI_DISPATCH_STRIDE, |
| 182 | MPIC_IDX_CPU_CURRENT_TASK_PRI, |
| 183 | MPIC_IDX_CPU_WHOAMI, |
| 184 | MPIC_IDX_CPU_INTACK, |
| 185 | MPIC_IDX_CPU_EOI, |
| 186 | |
| 187 | MPIC_IDX_IRQ_BASE, |
| 188 | MPIC_IDX_IRQ_STRIDE, |
| 189 | MPIC_IDX_IRQ_VECTOR_PRI, |
| 190 | |
| 191 | MPIC_IDX_VECPRI_VECTOR_MASK, |
| 192 | MPIC_IDX_VECPRI_POLARITY_POSITIVE, |
| 193 | MPIC_IDX_VECPRI_POLARITY_NEGATIVE, |
| 194 | MPIC_IDX_VECPRI_SENSE_LEVEL, |
| 195 | MPIC_IDX_VECPRI_SENSE_EDGE, |
| 196 | MPIC_IDX_VECPRI_POLARITY_MASK, |
| 197 | MPIC_IDX_VECPRI_SENSE_MASK, |
| 198 | MPIC_IDX_IRQ_DESTINATION, |
| 199 | MPIC_IDX_END |
| 200 | }; |
| 201 | |
| 202 | |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 203 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 204 | /* Fixup table entry */ |
| 205 | struct mpic_irq_fixup |
| 206 | { |
| 207 | u8 __iomem *base; |
Benjamin Herrenschmidt | 1beb6a7 | 2005-12-14 13:10:10 +1100 | [diff] [blame] | 208 | u8 __iomem *applebase; |
Segher Boessenkool | c4b22f2 | 2005-12-13 18:04:29 +1100 | [diff] [blame] | 209 | u32 data; |
Benjamin Herrenschmidt | 1beb6a7 | 2005-12-14 13:10:10 +1100 | [diff] [blame] | 210 | unsigned int index; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 211 | }; |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 212 | #endif /* CONFIG_MPIC_U3_HT_IRQS */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 213 | |
| 214 | |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 215 | enum mpic_reg_type { |
| 216 | mpic_access_mmio_le, |
| 217 | mpic_access_mmio_be, |
| 218 | #ifdef CONFIG_PPC_DCR |
| 219 | mpic_access_dcr |
| 220 | #endif |
| 221 | }; |
| 222 | |
| 223 | struct mpic_reg_bank { |
| 224 | u32 __iomem *base; |
| 225 | #ifdef CONFIG_PPC_DCR |
| 226 | dcr_host_t dhost; |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 227 | #endif /* CONFIG_PPC_DCR */ |
| 228 | }; |
| 229 | |
Johannes Berg | 3669e93 | 2007-05-02 16:33:41 +1000 | [diff] [blame] | 230 | struct mpic_irq_save { |
| 231 | u32 vecprio, |
| 232 | dest; |
| 233 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
| 234 | u32 fixup_data; |
| 235 | #endif |
| 236 | }; |
| 237 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 238 | /* The instance data of a given MPIC */ |
| 239 | struct mpic |
| 240 | { |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 241 | /* The remapper for this MPIC */ |
| 242 | struct irq_host *irqhost; |
| 243 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 244 | /* The "linux" controller struct */ |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 245 | struct irq_chip hc_irq; |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 246 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 247 | struct irq_chip hc_ht_irq; |
| 248 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 249 | #ifdef CONFIG_SMP |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 250 | struct irq_chip hc_ipi; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 251 | #endif |
| 252 | const char *name; |
| 253 | /* Flags */ |
| 254 | unsigned int flags; |
| 255 | /* How many irq sources in a given ISU */ |
| 256 | unsigned int isu_size; |
| 257 | unsigned int isu_shift; |
| 258 | unsigned int isu_mask; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 259 | unsigned int irq_count; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 260 | /* Number of sources */ |
| 261 | unsigned int num_sources; |
| 262 | /* Number of CPUs */ |
| 263 | unsigned int num_cpus; |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 264 | /* default senses array */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 265 | unsigned char *senses; |
| 266 | unsigned int senses_count; |
| 267 | |
Olof Johansson | 7df2457 | 2007-01-28 23:33:18 -0600 | [diff] [blame] | 268 | /* vector numbers used for internal sources (ipi/timers) */ |
| 269 | unsigned int ipi_vecs[4]; |
| 270 | unsigned int timer_vecs[4]; |
| 271 | |
| 272 | /* Spurious vector to program into unused sources */ |
| 273 | unsigned int spurious_vec; |
| 274 | |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 275 | #ifdef CONFIG_MPIC_U3_HT_IRQS |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 276 | /* The fixup table */ |
| 277 | struct mpic_irq_fixup *fixups; |
| 278 | spinlock_t fixup_lock; |
| 279 | #endif |
| 280 | |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 281 | /* Register access method */ |
| 282 | enum mpic_reg_type reg_type; |
| 283 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 284 | /* The various ioremap'ed bases */ |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 285 | struct mpic_reg_bank gregs; |
| 286 | struct mpic_reg_bank tmregs; |
| 287 | struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS]; |
| 288 | struct mpic_reg_bank isus[MPIC_MAX_ISU]; |
| 289 | |
Benjamin Herrenschmidt | 7fd7218 | 2007-07-21 09:55:21 +1000 | [diff] [blame] | 290 | /* Protected sources */ |
| 291 | unsigned long *protected; |
| 292 | |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 293 | #ifdef CONFIG_MPIC_WEIRD |
| 294 | /* Pointer to HW info array */ |
| 295 | u32 *hw_set; |
| 296 | #endif |
| 297 | |
Michael Ellerman | a7de7c7 | 2007-05-08 12:58:36 +1000 | [diff] [blame] | 298 | #ifdef CONFIG_PCI_MSI |
| 299 | spinlock_t bitmap_lock; |
| 300 | unsigned long *hwirq_bitmap; |
| 301 | #endif |
| 302 | |
Olof Johansson | 0d72ba9 | 2007-09-08 05:13:19 +1000 | [diff] [blame] | 303 | #ifdef CONFIG_MPIC_BROKEN_REGREAD |
| 304 | u32 isu_reg0_shadow[MPIC_MAX_IRQ_SOURCES]; |
| 305 | #endif |
| 306 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 307 | /* link */ |
| 308 | struct mpic *next; |
Johannes Berg | 3669e93 | 2007-05-02 16:33:41 +1000 | [diff] [blame] | 309 | |
| 310 | struct sys_device sysdev; |
| 311 | |
| 312 | #ifdef CONFIG_PM |
| 313 | struct mpic_irq_save *save_data; |
| 314 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 315 | }; |
| 316 | |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 317 | /* |
| 318 | * MPIC flags (passed to mpic_alloc) |
| 319 | * |
| 320 | * The top 4 bits contain an MPIC bhw id that is used to index the |
| 321 | * register offsets and some masks when CONFIG_MPIC_WEIRD is set. |
| 322 | * Note setting any ID (leaving those bits to 0) means standard MPIC |
| 323 | */ |
| 324 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 325 | /* This is the primary controller, only that one has IPIs and |
| 326 | * has afinity control. A non-primary MPIC always uses CPU0 |
| 327 | * registers only |
| 328 | */ |
| 329 | #define MPIC_PRIMARY 0x00000001 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 330 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 331 | /* Set this for a big-endian MPIC */ |
| 332 | #define MPIC_BIG_ENDIAN 0x00000002 |
| 333 | /* Broken U3 MPIC */ |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 334 | #define MPIC_U3_HT_IRQS 0x00000004 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 335 | /* Broken IPI registers (autodetected) */ |
| 336 | #define MPIC_BROKEN_IPI 0x00000008 |
| 337 | /* MPIC wants a reset */ |
| 338 | #define MPIC_WANTS_RESET 0x00000010 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 339 | /* Spurious vector requires EOI */ |
| 340 | #define MPIC_SPV_EOI 0x00000020 |
| 341 | /* No passthrough disable */ |
| 342 | #define MPIC_NO_PTHROU_DIS 0x00000040 |
Benjamin Herrenschmidt | fbf0274 | 2006-11-11 17:24:55 +1100 | [diff] [blame] | 343 | /* DCR based MPIC */ |
| 344 | #define MPIC_USES_DCR 0x00000080 |
Olof Johansson | 7df2457 | 2007-01-28 23:33:18 -0600 | [diff] [blame] | 345 | /* MPIC has 11-bit vector fields (or larger) */ |
| 346 | #define MPIC_LARGE_VECTORS 0x00000100 |
Zang Roy-r61911 | 7233593 | 2006-08-25 14:16:30 +1000 | [diff] [blame] | 347 | |
| 348 | /* MPIC HW modification ID */ |
| 349 | #define MPIC_REGSET_MASK 0xf0000000 |
| 350 | #define MPIC_REGSET(val) (((val) & 0xf ) << 28) |
| 351 | #define MPIC_GET_REGSET(flags) (((flags) >> 28) & 0xf) |
| 352 | |
| 353 | #define MPIC_REGSET_STANDARD MPIC_REGSET(0) /* Original MPIC */ |
| 354 | #define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 355 | |
| 356 | /* Allocate the controller structure and setup the linux irq descs |
| 357 | * for the range if interrupts passed in. No HW initialization is |
| 358 | * actually performed. |
| 359 | * |
| 360 | * @phys_addr: physial base address of the MPIC |
| 361 | * @flags: flags, see constants above |
| 362 | * @isu_size: number of interrupts in an ISU. Use 0 to use a |
| 363 | * standard ISU-less setup (aka powermac) |
| 364 | * @irq_offset: first irq number to assign to this mpic |
| 365 | * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0 |
| 366 | * to match the number of sources |
| 367 | * @ipi_offset: first irq number to assign to this mpic IPI sources, |
| 368 | * used only on primary mpic |
| 369 | * @senses: array of sense values |
| 370 | * @senses_num: number of entries in the array |
| 371 | * |
| 372 | * Note about the sense array. If none is passed, all interrupts are |
Michael Ellerman | 6cfef5b | 2007-04-23 18:47:08 +1000 | [diff] [blame] | 373 | * 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] | 374 | * case they are edge positive (and the array is ignored anyway). |
| 375 | * The values in the array start at the first source of the MPIC, |
| 376 | * that is senses[0] correspond to linux irq "irq_offset". |
| 377 | */ |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 378 | extern struct mpic *mpic_alloc(struct device_node *node, |
Benjamin Herrenschmidt | a959ff5 | 2006-11-11 17:24:56 +1100 | [diff] [blame] | 379 | phys_addr_t phys_addr, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 380 | unsigned int flags, |
| 381 | unsigned int isu_size, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 382 | unsigned int irq_count, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 383 | const char *name); |
| 384 | |
| 385 | /* Assign ISUs, to call before mpic_init() |
| 386 | * |
| 387 | * @mpic: controller structure as returned by mpic_alloc() |
| 388 | * @isu_num: ISU number |
| 389 | * @phys_addr: physical address of the ISU |
| 390 | */ |
| 391 | extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, |
Benjamin Herrenschmidt | a959ff5 | 2006-11-11 17:24:56 +1100 | [diff] [blame] | 392 | phys_addr_t phys_addr); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 393 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 394 | /* Set default sense codes |
| 395 | * |
| 396 | * @mpic: controller |
| 397 | * @senses: array of sense codes |
| 398 | * @count: size of above array |
| 399 | * |
| 400 | * Optionally provide an array (indexed on hardware interrupt numbers |
| 401 | * for this MPIC) of default sense codes for the chip. Those are linux |
| 402 | * sense codes IRQ_TYPE_* |
| 403 | * |
| 404 | * The driver gets ownership of the pointer, don't dispose of it or |
| 405 | * anything like that. __init only. |
| 406 | */ |
| 407 | extern void mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count); |
| 408 | |
| 409 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 410 | /* Initialize the controller. After this has been called, none of the above |
| 411 | * should be called again for this mpic |
| 412 | */ |
| 413 | extern void mpic_init(struct mpic *mpic); |
| 414 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 415 | /* |
| 416 | * All of the following functions must only be used after the |
| 417 | * ISUs have been assigned and the controller fully initialized |
| 418 | * with mpic_init() |
| 419 | */ |
| 420 | |
| 421 | |
| 422 | /* Change/Read the priority of an interrupt. Default is 8 for irqs and |
| 423 | * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the |
| 424 | * IPI number is then the offset'ed (linux irq number mapped to the IPI) |
| 425 | */ |
| 426 | extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri); |
| 427 | extern unsigned int mpic_irq_get_priority(unsigned int irq); |
| 428 | |
| 429 | /* Setup a non-boot CPU */ |
| 430 | extern void mpic_setup_this_cpu(void); |
| 431 | |
| 432 | /* Clean up for kexec (or cpu offline or ...) */ |
| 433 | extern void mpic_teardown_this_cpu(int secondary); |
| 434 | |
| 435 | /* Get the current cpu priority for this cpu (0..15) */ |
| 436 | extern int mpic_cpu_get_priority(void); |
| 437 | |
| 438 | /* Set the current cpu priority for this cpu */ |
| 439 | extern void mpic_cpu_set_priority(int prio); |
| 440 | |
| 441 | /* Request IPIs on primary mpic */ |
| 442 | extern void mpic_request_ipis(void); |
| 443 | |
| 444 | /* Send an IPI (non offseted number 0..3) */ |
| 445 | extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask); |
| 446 | |
Paul Mackerras | a9c5926 | 2005-10-20 17:09:51 +1000 | [diff] [blame] | 447 | /* Send a message (IPI) to a given target (cpu number or MSG_*) */ |
| 448 | void smp_mpic_message_pass(int target, int msg); |
| 449 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 450 | /* Fetch interrupt from a given mpic */ |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 451 | extern unsigned int mpic_get_one_irq(struct mpic *mpic); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 452 | /* This one gets to the primary mpic */ |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 453 | extern unsigned int mpic_get_irq(void); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 454 | |
Mark A. Greer | 868ea0c | 2006-06-20 14:15:36 -0700 | [diff] [blame] | 455 | /* Set the EPIC clock ratio */ |
| 456 | void mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio); |
| 457 | |
| 458 | /* Enable/Disable EPIC serial interrupt mode */ |
| 459 | void mpic_set_serial_int(struct mpic *mpic, int enable); |
| 460 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 461 | #endif /* __KERNEL__ */ |
Stephen Rothwell | bbeb3f4 | 2005-09-27 13:51:59 +1000 | [diff] [blame] | 462 | #endif /* _ASM_POWERPC_MPIC_H */ |