Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> |
| 7 | * Copyright (C) 2008 Nicolas Schichan <nschichan@freebox.fr> |
| 8 | */ |
| 9 | |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/module.h> |
David Howells | ca4d3e67 | 2010-10-07 14:08:54 +0100 | [diff] [blame] | 14 | #include <linux/irq.h> |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 15 | #include <asm/irq_cpu.h> |
| 16 | #include <asm/mipsregs.h> |
| 17 | #include <bcm63xx_cpu.h> |
| 18 | #include <bcm63xx_regs.h> |
| 19 | #include <bcm63xx_io.h> |
| 20 | #include <bcm63xx_irq.h> |
| 21 | |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 22 | static void __dispatch_internal(void) __maybe_unused; |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 23 | static void __dispatch_internal_64(void) __maybe_unused; |
| 24 | static void __internal_irq_mask_32(unsigned int irq) __maybe_unused; |
| 25 | static void __internal_irq_mask_64(unsigned int irq) __maybe_unused; |
| 26 | static void __internal_irq_unmask_32(unsigned int irq) __maybe_unused; |
| 27 | static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused; |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 28 | |
| 29 | #ifndef BCMCPU_RUNTIME_DETECT |
| 30 | #ifdef CONFIG_BCM63XX_CPU_6338 |
| 31 | #define irq_stat_reg PERF_IRQSTAT_6338_REG |
| 32 | #define irq_mask_reg PERF_IRQMASK_6338_REG |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 33 | #define irq_bits 32 |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 34 | #define is_ext_irq_cascaded 0 |
| 35 | #define ext_irq_start 0 |
| 36 | #define ext_irq_end 0 |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 37 | #endif |
| 38 | #ifdef CONFIG_BCM63XX_CPU_6345 |
| 39 | #define irq_stat_reg PERF_IRQSTAT_6345_REG |
| 40 | #define irq_mask_reg PERF_IRQMASK_6345_REG |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 41 | #define irq_bits 32 |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 42 | #define is_ext_irq_cascaded 0 |
| 43 | #define ext_irq_start 0 |
| 44 | #define ext_irq_end 0 |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 45 | #endif |
| 46 | #ifdef CONFIG_BCM63XX_CPU_6348 |
| 47 | #define irq_stat_reg PERF_IRQSTAT_6348_REG |
| 48 | #define irq_mask_reg PERF_IRQMASK_6348_REG |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 49 | #define irq_bits 32 |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 50 | #define is_ext_irq_cascaded 0 |
| 51 | #define ext_irq_start 0 |
| 52 | #define ext_irq_end 0 |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 53 | #endif |
| 54 | #ifdef CONFIG_BCM63XX_CPU_6358 |
| 55 | #define irq_stat_reg PERF_IRQSTAT_6358_REG |
| 56 | #define irq_mask_reg PERF_IRQMASK_6358_REG |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 57 | #define irq_bits 32 |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 58 | #define is_ext_irq_cascaded 1 |
| 59 | #define ext_irq_start (BCM_6358_EXT_IRQ0 - IRQ_INTERNAL_BASE) |
| 60 | #define ext_irq_end (BCM_6358_EXT_IRQ3 - IRQ_INTERNAL_BASE) |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 61 | #endif |
| 62 | |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 63 | #if irq_bits == 32 |
| 64 | #define dispatch_internal __dispatch_internal |
| 65 | #define internal_irq_mask __internal_irq_mask_32 |
| 66 | #define internal_irq_unmask __internal_irq_unmask_32 |
| 67 | #else |
| 68 | #define dispatch_internal __dispatch_internal_64 |
| 69 | #define internal_irq_mask __internal_irq_mask_64 |
| 70 | #define internal_irq_unmask __internal_irq_unmask_64 |
| 71 | #endif |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 72 | |
| 73 | #define irq_stat_addr (bcm63xx_regset_address(RSET_PERF) + irq_stat_reg) |
| 74 | #define irq_mask_addr (bcm63xx_regset_address(RSET_PERF) + irq_mask_reg) |
| 75 | |
| 76 | static inline void bcm63xx_init_irq(void) |
| 77 | { |
| 78 | } |
| 79 | #else /* ! BCMCPU_RUNTIME_DETECT */ |
| 80 | |
| 81 | static u32 irq_stat_addr, irq_mask_addr; |
| 82 | static void (*dispatch_internal)(void); |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 83 | static int is_ext_irq_cascaded; |
| 84 | static unsigned int ext_irq_start, ext_irq_end; |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 85 | static void (*internal_irq_mask)(unsigned int irq); |
| 86 | static void (*internal_irq_unmask)(unsigned int irq); |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 87 | |
| 88 | static void bcm63xx_init_irq(void) |
| 89 | { |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 90 | int irq_bits; |
| 91 | |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 92 | irq_stat_addr = bcm63xx_regset_address(RSET_PERF); |
| 93 | irq_mask_addr = bcm63xx_regset_address(RSET_PERF); |
| 94 | |
| 95 | switch (bcm63xx_get_cpu_id()) { |
| 96 | case BCM6338_CPU_ID: |
| 97 | irq_stat_addr += PERF_IRQSTAT_6338_REG; |
| 98 | irq_mask_addr += PERF_IRQMASK_6338_REG; |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 99 | irq_bits = 32; |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 100 | break; |
| 101 | case BCM6345_CPU_ID: |
| 102 | irq_stat_addr += PERF_IRQSTAT_6345_REG; |
| 103 | irq_mask_addr += PERF_IRQMASK_6345_REG; |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 104 | irq_bits = 32; |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 105 | break; |
| 106 | case BCM6348_CPU_ID: |
| 107 | irq_stat_addr += PERF_IRQSTAT_6348_REG; |
| 108 | irq_mask_addr += PERF_IRQMASK_6348_REG; |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 109 | irq_bits = 32; |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 110 | break; |
| 111 | case BCM6358_CPU_ID: |
| 112 | irq_stat_addr += PERF_IRQSTAT_6358_REG; |
| 113 | irq_mask_addr += PERF_IRQMASK_6358_REG; |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 114 | irq_bits = 32; |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 115 | is_ext_irq_cascaded = 1; |
| 116 | ext_irq_start = BCM_6358_EXT_IRQ0 - IRQ_INTERNAL_BASE; |
| 117 | ext_irq_end = BCM_6358_EXT_IRQ3 - IRQ_INTERNAL_BASE; |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 118 | break; |
| 119 | default: |
| 120 | BUG(); |
| 121 | } |
| 122 | |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 123 | if (irq_bits == 32) { |
| 124 | dispatch_internal = __dispatch_internal; |
| 125 | internal_irq_mask = __internal_irq_mask_32; |
| 126 | internal_irq_unmask = __internal_irq_unmask_32; |
| 127 | } else { |
| 128 | dispatch_internal = __dispatch_internal_64; |
| 129 | internal_irq_mask = __internal_irq_mask_64; |
| 130 | internal_irq_unmask = __internal_irq_unmask_64; |
| 131 | } |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 132 | } |
| 133 | #endif /* ! BCMCPU_RUNTIME_DETECT */ |
| 134 | |
| 135 | static inline void handle_internal(int intbit) |
| 136 | { |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 137 | if (is_ext_irq_cascaded && |
| 138 | intbit >= ext_irq_start && intbit <= ext_irq_end) |
| 139 | do_IRQ(intbit - ext_irq_start + IRQ_EXTERNAL_BASE); |
| 140 | else |
| 141 | do_IRQ(intbit + IRQ_INTERNAL_BASE); |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 144 | /* |
| 145 | * dispatch internal devices IRQ (uart, enet, watchdog, ...). do not |
| 146 | * prioritize any interrupt relatively to another. the static counter |
| 147 | * will resume the loop where it ended the last time we left this |
| 148 | * function. |
| 149 | */ |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 150 | static void __dispatch_internal(void) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 151 | { |
| 152 | u32 pending; |
| 153 | static int i; |
| 154 | |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 155 | pending = bcm_readl(irq_stat_addr) & bcm_readl(irq_mask_addr); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 156 | |
| 157 | if (!pending) |
| 158 | return ; |
| 159 | |
| 160 | while (1) { |
| 161 | int to_call = i; |
| 162 | |
| 163 | i = (i + 1) & 0x1f; |
| 164 | if (pending & (1 << to_call)) { |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 165 | handle_internal(to_call); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 166 | break; |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 171 | static void __dispatch_internal_64(void) |
| 172 | { |
| 173 | u64 pending; |
| 174 | static int i; |
| 175 | |
| 176 | pending = bcm_readq(irq_stat_addr) & bcm_readq(irq_mask_addr); |
| 177 | |
| 178 | if (!pending) |
| 179 | return ; |
| 180 | |
| 181 | while (1) { |
| 182 | int to_call = i; |
| 183 | |
| 184 | i = (i + 1) & 0x3f; |
| 185 | if (pending & (1ull << to_call)) { |
| 186 | handle_internal(to_call); |
| 187 | break; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 192 | asmlinkage void plat_irq_dispatch(void) |
| 193 | { |
| 194 | u32 cause; |
| 195 | |
| 196 | do { |
| 197 | cause = read_c0_cause() & read_c0_status() & ST0_IM; |
| 198 | |
| 199 | if (!cause) |
| 200 | break; |
| 201 | |
| 202 | if (cause & CAUSEF_IP7) |
| 203 | do_IRQ(7); |
| 204 | if (cause & CAUSEF_IP2) |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 205 | dispatch_internal(); |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 206 | if (!is_ext_irq_cascaded) { |
| 207 | if (cause & CAUSEF_IP3) |
| 208 | do_IRQ(IRQ_EXT_0); |
| 209 | if (cause & CAUSEF_IP4) |
| 210 | do_IRQ(IRQ_EXT_1); |
| 211 | if (cause & CAUSEF_IP5) |
| 212 | do_IRQ(IRQ_EXT_2); |
| 213 | if (cause & CAUSEF_IP6) |
| 214 | do_IRQ(IRQ_EXT_3); |
| 215 | } |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 216 | } while (1); |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | * internal IRQs operations: only mask/unmask on PERF irq mask |
| 221 | * register. |
| 222 | */ |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 223 | static void __internal_irq_mask_32(unsigned int irq) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 224 | { |
| 225 | u32 mask; |
| 226 | |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 227 | mask = bcm_readl(irq_mask_addr); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 228 | mask &= ~(1 << irq); |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 229 | bcm_writel(mask, irq_mask_addr); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 230 | } |
| 231 | |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 232 | static void __internal_irq_mask_64(unsigned int irq) |
| 233 | { |
| 234 | u64 mask; |
| 235 | |
| 236 | mask = bcm_readq(irq_mask_addr); |
| 237 | mask &= ~(1ull << irq); |
| 238 | bcm_writeq(mask, irq_mask_addr); |
| 239 | } |
| 240 | |
| 241 | static void __internal_irq_unmask_32(unsigned int irq) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 242 | { |
| 243 | u32 mask; |
| 244 | |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 245 | mask = bcm_readl(irq_mask_addr); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 246 | mask |= (1 << irq); |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 247 | bcm_writel(mask, irq_mask_addr); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 248 | } |
| 249 | |
Maxime Bizon | 71a4392 | 2011-11-04 19:09:33 +0100 | [diff] [blame^] | 250 | static void __internal_irq_unmask_64(unsigned int irq) |
| 251 | { |
| 252 | u64 mask; |
| 253 | |
| 254 | mask = bcm_readq(irq_mask_addr); |
| 255 | mask |= (1ull << irq); |
| 256 | bcm_writeq(mask, irq_mask_addr); |
| 257 | } |
| 258 | |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 259 | static void bcm63xx_internal_irq_mask(struct irq_data *d) |
| 260 | { |
| 261 | internal_irq_mask(d->irq - IRQ_INTERNAL_BASE); |
| 262 | } |
| 263 | |
| 264 | static void bcm63xx_internal_irq_unmask(struct irq_data *d) |
| 265 | { |
| 266 | internal_irq_unmask(d->irq - IRQ_INTERNAL_BASE); |
| 267 | } |
| 268 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 269 | /* |
| 270 | * external IRQs operations: mask/unmask and clear on PERF external |
| 271 | * irq control register. |
| 272 | */ |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 273 | static void bcm63xx_external_irq_mask(struct irq_data *d) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 274 | { |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 275 | unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 276 | u32 reg; |
| 277 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 278 | reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG); |
| 279 | reg &= ~EXTIRQ_CFG_MASK(irq); |
| 280 | bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG); |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 281 | if (is_ext_irq_cascaded) |
| 282 | internal_irq_mask(irq + ext_irq_start); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 283 | } |
| 284 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 285 | static void bcm63xx_external_irq_unmask(struct irq_data *d) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 286 | { |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 287 | unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 288 | u32 reg; |
| 289 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 290 | reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG); |
| 291 | reg |= EXTIRQ_CFG_MASK(irq); |
| 292 | bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG); |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 293 | if (is_ext_irq_cascaded) |
| 294 | internal_irq_unmask(irq + ext_irq_start); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 295 | } |
| 296 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 297 | static void bcm63xx_external_irq_clear(struct irq_data *d) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 298 | { |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 299 | unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 300 | u32 reg; |
| 301 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 302 | reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG); |
| 303 | reg |= EXTIRQ_CFG_CLEAR(irq); |
| 304 | bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG); |
| 305 | } |
| 306 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 307 | static int bcm63xx_external_irq_set_type(struct irq_data *d, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 308 | unsigned int flow_type) |
| 309 | { |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 310 | unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 311 | u32 reg; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 312 | |
| 313 | flow_type &= IRQ_TYPE_SENSE_MASK; |
| 314 | |
| 315 | if (flow_type == IRQ_TYPE_NONE) |
| 316 | flow_type = IRQ_TYPE_LEVEL_LOW; |
| 317 | |
| 318 | reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG); |
| 319 | switch (flow_type) { |
| 320 | case IRQ_TYPE_EDGE_BOTH: |
| 321 | reg &= ~EXTIRQ_CFG_LEVELSENSE(irq); |
| 322 | reg |= EXTIRQ_CFG_BOTHEDGE(irq); |
| 323 | break; |
| 324 | |
| 325 | case IRQ_TYPE_EDGE_RISING: |
| 326 | reg &= ~EXTIRQ_CFG_LEVELSENSE(irq); |
| 327 | reg |= EXTIRQ_CFG_SENSE(irq); |
| 328 | reg &= ~EXTIRQ_CFG_BOTHEDGE(irq); |
| 329 | break; |
| 330 | |
| 331 | case IRQ_TYPE_EDGE_FALLING: |
| 332 | reg &= ~EXTIRQ_CFG_LEVELSENSE(irq); |
| 333 | reg &= ~EXTIRQ_CFG_SENSE(irq); |
| 334 | reg &= ~EXTIRQ_CFG_BOTHEDGE(irq); |
| 335 | break; |
| 336 | |
| 337 | case IRQ_TYPE_LEVEL_HIGH: |
| 338 | reg |= EXTIRQ_CFG_LEVELSENSE(irq); |
| 339 | reg |= EXTIRQ_CFG_SENSE(irq); |
| 340 | break; |
| 341 | |
| 342 | case IRQ_TYPE_LEVEL_LOW: |
| 343 | reg |= EXTIRQ_CFG_LEVELSENSE(irq); |
| 344 | reg &= ~EXTIRQ_CFG_SENSE(irq); |
| 345 | break; |
| 346 | |
| 347 | default: |
| 348 | printk(KERN_ERR "bogus flow type combination given !\n"); |
| 349 | return -EINVAL; |
| 350 | } |
| 351 | bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG); |
| 352 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 353 | irqd_set_trigger_type(d, flow_type); |
| 354 | if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) |
| 355 | __irq_set_handler_locked(d->irq, handle_level_irq); |
| 356 | else |
| 357 | __irq_set_handler_locked(d->irq, handle_edge_irq); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 358 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 359 | return IRQ_SET_MASK_OK_NOCOPY; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | static struct irq_chip bcm63xx_internal_irq_chip = { |
| 363 | .name = "bcm63xx_ipic", |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 364 | .irq_mask = bcm63xx_internal_irq_mask, |
| 365 | .irq_unmask = bcm63xx_internal_irq_unmask, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 366 | }; |
| 367 | |
| 368 | static struct irq_chip bcm63xx_external_irq_chip = { |
| 369 | .name = "bcm63xx_epic", |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 370 | .irq_ack = bcm63xx_external_irq_clear, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 371 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 372 | .irq_mask = bcm63xx_external_irq_mask, |
| 373 | .irq_unmask = bcm63xx_external_irq_unmask, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 374 | |
Thomas Gleixner | 93f2936 | 2011-03-23 21:08:47 +0000 | [diff] [blame] | 375 | .irq_set_type = bcm63xx_external_irq_set_type, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | static struct irqaction cpu_ip2_cascade_action = { |
| 379 | .handler = no_action, |
| 380 | .name = "cascade_ip2", |
Wu Zhangjin | 5a4a4ad | 2011-07-23 12:41:24 +0000 | [diff] [blame] | 381 | .flags = IRQF_NO_THREAD, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 382 | }; |
| 383 | |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 384 | static struct irqaction cpu_ext_cascade_action = { |
| 385 | .handler = no_action, |
| 386 | .name = "cascade_extirq", |
| 387 | .flags = IRQF_NO_THREAD, |
| 388 | }; |
| 389 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 390 | void __init arch_init_irq(void) |
| 391 | { |
| 392 | int i; |
| 393 | |
Maxime Bizon | f61cced | 2011-11-04 19:09:31 +0100 | [diff] [blame] | 394 | bcm63xx_init_irq(); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 395 | mips_cpu_irq_init(); |
| 396 | for (i = IRQ_INTERNAL_BASE; i < NR_IRQS; ++i) |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 397 | irq_set_chip_and_handler(i, &bcm63xx_internal_irq_chip, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 398 | handle_level_irq); |
| 399 | |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 400 | for (i = IRQ_EXTERNAL_BASE; i < IRQ_EXTERNAL_BASE + 4; ++i) |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 401 | irq_set_chip_and_handler(i, &bcm63xx_external_irq_chip, |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 402 | handle_edge_irq); |
| 403 | |
Maxime Bizon | 37c42a7 | 2011-11-04 19:09:32 +0100 | [diff] [blame] | 404 | if (!is_ext_irq_cascaded) { |
| 405 | for (i = 3; i < 7; ++i) |
| 406 | setup_irq(MIPS_CPU_IRQ_BASE + i, &cpu_ext_cascade_action); |
| 407 | } |
| 408 | |
| 409 | setup_irq(MIPS_CPU_IRQ_BASE + 2, &cpu_ip2_cascade_action); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 410 | } |