Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/mach-common/ints-priority-sc.c |
| 3 | * Based on: |
| 4 | * Author: |
| 5 | * |
| 6 | * Created: ? |
Simon Arlott | d2d50aa | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 7 | * Description: Set up the interrupt priorities |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 8 | * |
| 9 | * Modified: |
| 10 | * 1996 Roman Zippel |
| 11 | * 1999 D. Jeff Dionne <jeff@uclinux.org> |
| 12 | * 2000-2001 Lineo, Inc. D. Jefff Dionne <jeff@lineo.ca> |
| 13 | * 2002 Arcturus Networks Inc. MaTed <mated@sympatico.ca> |
| 14 | * 2003 Metrowerks/Motorola |
| 15 | * 2003 Bas Vermeulen <bas@buyways.nl> |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 16 | * Copyright 2004-2007 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 17 | * |
| 18 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 19 | * |
| 20 | * This program is free software; you can redistribute it and/or modify |
| 21 | * it under the terms of the GNU General Public License as published by |
| 22 | * the Free Software Foundation; either version 2 of the License, or |
| 23 | * (at your option) any later version. |
| 24 | * |
| 25 | * This program is distributed in the hope that it will be useful, |
| 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 28 | * GNU General Public License for more details. |
| 29 | * |
| 30 | * You should have received a copy of the GNU General Public License |
| 31 | * along with this program; if not, see the file COPYING, or write |
| 32 | * to the Free Software Foundation, Inc., |
| 33 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 34 | */ |
| 35 | |
| 36 | #include <linux/module.h> |
| 37 | #include <linux/kernel_stat.h> |
| 38 | #include <linux/seq_file.h> |
| 39 | #include <linux/irq.h> |
| 40 | #ifdef CONFIG_KGDB |
| 41 | #include <linux/kgdb.h> |
| 42 | #endif |
| 43 | #include <asm/traps.h> |
| 44 | #include <asm/blackfin.h> |
| 45 | #include <asm/gpio.h> |
| 46 | #include <asm/irq_handler.h> |
| 47 | |
| 48 | #ifdef BF537_FAMILY |
| 49 | # define BF537_GENERIC_ERROR_INT_DEMUX |
| 50 | #else |
| 51 | # undef BF537_GENERIC_ERROR_INT_DEMUX |
| 52 | #endif |
| 53 | |
| 54 | /* |
| 55 | * NOTES: |
| 56 | * - we have separated the physical Hardware interrupt from the |
| 57 | * levels that the LINUX kernel sees (see the description in irq.h) |
| 58 | * - |
| 59 | */ |
| 60 | |
| 61 | unsigned long irq_flags = 0; |
| 62 | |
| 63 | /* The number of spurious interrupts */ |
| 64 | atomic_t num_spurious; |
| 65 | |
| 66 | struct ivgx { |
| 67 | /* irq number for request_irq, available in mach-bf533/irq.h */ |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 68 | unsigned int irqno; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 69 | /* corresponding bit in the SIC_ISR register */ |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 70 | unsigned int isrflag; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 71 | } ivg_table[NR_PERI_INTS]; |
| 72 | |
| 73 | struct ivg_slice { |
| 74 | /* position of first irq in ivg_table for given ivg */ |
| 75 | struct ivgx *ifirst; |
| 76 | struct ivgx *istop; |
| 77 | } ivg7_13[IVG13 - IVG7 + 1]; |
| 78 | |
| 79 | static void search_IAR(void); |
| 80 | |
| 81 | /* |
| 82 | * Search SIC_IAR and fill tables with the irqvalues |
| 83 | * and their positions in the SIC_ISR register. |
| 84 | */ |
| 85 | static void __init search_IAR(void) |
| 86 | { |
| 87 | unsigned ivg, irq_pos = 0; |
| 88 | for (ivg = 0; ivg <= IVG13 - IVG7; ivg++) { |
| 89 | int irqn; |
| 90 | |
| 91 | ivg7_13[ivg].istop = ivg7_13[ivg].ifirst = |
| 92 | &ivg_table[irq_pos]; |
| 93 | |
| 94 | for (irqn = 0; irqn < NR_PERI_INTS; irqn++) { |
| 95 | int iar_shift = (irqn & 7) * 4; |
| 96 | if (ivg == |
| 97 | (0xf & |
| 98 | bfin_read32((unsigned long *) SIC_IAR0 + |
| 99 | (irqn >> 3)) >> iar_shift)) { |
| 100 | ivg_table[irq_pos].irqno = IVG7 + irqn; |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 101 | ivg_table[irq_pos].isrflag = 1 << (irqn % 32); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 102 | ivg7_13[ivg].istop++; |
| 103 | irq_pos++; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | * This is for BF533 internal IRQs |
| 111 | */ |
| 112 | |
| 113 | static void ack_noop(unsigned int irq) |
| 114 | { |
| 115 | /* Dummy function. */ |
| 116 | } |
| 117 | |
| 118 | static void bfin_core_mask_irq(unsigned int irq) |
| 119 | { |
| 120 | irq_flags &= ~(1 << irq); |
| 121 | if (!irqs_disabled()) |
| 122 | local_irq_enable(); |
| 123 | } |
| 124 | |
| 125 | static void bfin_core_unmask_irq(unsigned int irq) |
| 126 | { |
| 127 | irq_flags |= 1 << irq; |
| 128 | /* |
| 129 | * If interrupts are enabled, IMASK must contain the same value |
| 130 | * as irq_flags. Make sure that invariant holds. If interrupts |
| 131 | * are currently disabled we need not do anything; one of the |
| 132 | * callers will take care of setting IMASK to the proper value |
| 133 | * when reenabling interrupts. |
| 134 | * local_irq_enable just does "STI irq_flags", so it's exactly |
| 135 | * what we need. |
| 136 | */ |
| 137 | if (!irqs_disabled()) |
| 138 | local_irq_enable(); |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | static void bfin_internal_mask_irq(unsigned int irq) |
| 143 | { |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 144 | #ifndef CONFIG_BF54x |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 145 | bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() & |
| 146 | ~(1 << (irq - (IRQ_CORETMR + 1)))); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 147 | #else |
| 148 | unsigned mask_bank, mask_bit; |
| 149 | mask_bank = (irq - (IRQ_CORETMR +1))/32; |
| 150 | mask_bit = (irq - (IRQ_CORETMR + 1))%32; |
| 151 | bfin_write_SIC_IMASK( mask_bank, bfin_read_SIC_IMASK(mask_bank) & \ |
| 152 | ~(1 << mask_bit)); |
| 153 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 154 | SSYNC(); |
| 155 | } |
| 156 | |
| 157 | static void bfin_internal_unmask_irq(unsigned int irq) |
| 158 | { |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 159 | #ifndef CONFIG_BF54x |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 160 | bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | |
| 161 | (1 << (irq - (IRQ_CORETMR + 1)))); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 162 | #else |
| 163 | unsigned mask_bank, mask_bit; |
| 164 | mask_bank = (irq - (IRQ_CORETMR +1))/32; |
| 165 | mask_bit = (irq - (IRQ_CORETMR + 1))%32; |
| 166 | bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) | \ |
| 167 | ( 1 << mask_bit)); |
| 168 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 169 | SSYNC(); |
| 170 | } |
| 171 | |
| 172 | static struct irq_chip bfin_core_irqchip = { |
| 173 | .ack = ack_noop, |
| 174 | .mask = bfin_core_mask_irq, |
| 175 | .unmask = bfin_core_unmask_irq, |
| 176 | }; |
| 177 | |
| 178 | static struct irq_chip bfin_internal_irqchip = { |
| 179 | .ack = ack_noop, |
| 180 | .mask = bfin_internal_mask_irq, |
| 181 | .unmask = bfin_internal_unmask_irq, |
| 182 | }; |
| 183 | |
| 184 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 185 | static int error_int_mask; |
| 186 | |
| 187 | static void bfin_generic_error_ack_irq(unsigned int irq) |
| 188 | { |
| 189 | |
| 190 | } |
| 191 | |
| 192 | static void bfin_generic_error_mask_irq(unsigned int irq) |
| 193 | { |
| 194 | error_int_mask &= ~(1L << (irq - IRQ_PPI_ERROR)); |
| 195 | |
| 196 | if (!error_int_mask) { |
| 197 | local_irq_disable(); |
| 198 | bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() & |
| 199 | ~(1 << |
| 200 | (IRQ_GENERIC_ERROR - |
| 201 | (IRQ_CORETMR + 1)))); |
| 202 | SSYNC(); |
| 203 | local_irq_enable(); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | static void bfin_generic_error_unmask_irq(unsigned int irq) |
| 208 | { |
| 209 | local_irq_disable(); |
| 210 | bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | 1 << |
| 211 | (IRQ_GENERIC_ERROR - (IRQ_CORETMR + 1))); |
| 212 | SSYNC(); |
| 213 | local_irq_enable(); |
| 214 | |
| 215 | error_int_mask |= 1L << (irq - IRQ_PPI_ERROR); |
| 216 | } |
| 217 | |
| 218 | static struct irq_chip bfin_generic_error_irqchip = { |
| 219 | .ack = bfin_generic_error_ack_irq, |
| 220 | .mask = bfin_generic_error_mask_irq, |
| 221 | .unmask = bfin_generic_error_unmask_irq, |
| 222 | }; |
| 223 | |
| 224 | static void bfin_demux_error_irq(unsigned int int_err_irq, |
| 225 | struct irq_desc *intb_desc) |
| 226 | { |
| 227 | int irq = 0; |
| 228 | |
| 229 | SSYNC(); |
| 230 | |
| 231 | #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) |
| 232 | if (bfin_read_EMAC_SYSTAT() & EMAC_ERR_MASK) |
| 233 | irq = IRQ_MAC_ERROR; |
| 234 | else |
| 235 | #endif |
| 236 | if (bfin_read_SPORT0_STAT() & SPORT_ERR_MASK) |
| 237 | irq = IRQ_SPORT0_ERROR; |
| 238 | else if (bfin_read_SPORT1_STAT() & SPORT_ERR_MASK) |
| 239 | irq = IRQ_SPORT1_ERROR; |
| 240 | else if (bfin_read_PPI_STATUS() & PPI_ERR_MASK) |
| 241 | irq = IRQ_PPI_ERROR; |
| 242 | else if (bfin_read_CAN_GIF() & CAN_ERR_MASK) |
| 243 | irq = IRQ_CAN_ERROR; |
| 244 | else if (bfin_read_SPI_STAT() & SPI_ERR_MASK) |
| 245 | irq = IRQ_SPI_ERROR; |
| 246 | else if ((bfin_read_UART0_IIR() & UART_ERR_MASK_STAT1) && |
| 247 | (bfin_read_UART0_IIR() & UART_ERR_MASK_STAT0)) |
| 248 | irq = IRQ_UART0_ERROR; |
| 249 | else if ((bfin_read_UART1_IIR() & UART_ERR_MASK_STAT1) && |
| 250 | (bfin_read_UART1_IIR() & UART_ERR_MASK_STAT0)) |
| 251 | irq = IRQ_UART1_ERROR; |
| 252 | |
| 253 | if (irq) { |
| 254 | if (error_int_mask & (1L << (irq - IRQ_PPI_ERROR))) { |
| 255 | struct irq_desc *desc = irq_desc + irq; |
| 256 | desc->handle_irq(irq, desc); |
| 257 | } else { |
| 258 | |
| 259 | switch (irq) { |
| 260 | case IRQ_PPI_ERROR: |
| 261 | bfin_write_PPI_STATUS(PPI_ERR_MASK); |
| 262 | break; |
| 263 | #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) |
| 264 | case IRQ_MAC_ERROR: |
| 265 | bfin_write_EMAC_SYSTAT(EMAC_ERR_MASK); |
| 266 | break; |
| 267 | #endif |
| 268 | case IRQ_SPORT0_ERROR: |
| 269 | bfin_write_SPORT0_STAT(SPORT_ERR_MASK); |
| 270 | break; |
| 271 | |
| 272 | case IRQ_SPORT1_ERROR: |
| 273 | bfin_write_SPORT1_STAT(SPORT_ERR_MASK); |
| 274 | break; |
| 275 | |
| 276 | case IRQ_CAN_ERROR: |
| 277 | bfin_write_CAN_GIS(CAN_ERR_MASK); |
| 278 | break; |
| 279 | |
| 280 | case IRQ_SPI_ERROR: |
| 281 | bfin_write_SPI_STAT(SPI_ERR_MASK); |
| 282 | break; |
| 283 | |
| 284 | default: |
| 285 | break; |
| 286 | } |
| 287 | |
| 288 | pr_debug("IRQ %d:" |
| 289 | " MASKED PERIPHERAL ERROR INTERRUPT ASSERTED\n", |
| 290 | irq); |
| 291 | } |
| 292 | } else |
| 293 | printk(KERN_ERR |
| 294 | "%s : %s : LINE %d :\nIRQ ?: PERIPHERAL ERROR" |
| 295 | " INTERRUPT ASSERTED BUT NO SOURCE FOUND\n", |
| 296 | __FUNCTION__, __FILE__, __LINE__); |
| 297 | |
| 298 | |
| 299 | } |
| 300 | #endif /* BF537_GENERIC_ERROR_INT_DEMUX */ |
| 301 | |
| 302 | #ifdef CONFIG_IRQCHIP_DEMUX_GPIO |
| 303 | |
| 304 | static unsigned short gpio_enabled[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| 305 | static unsigned short gpio_edge_triggered[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| 306 | |
| 307 | static void bfin_gpio_ack_irq(unsigned int irq) |
| 308 | { |
| 309 | u16 gpionr = irq - IRQ_PF0; |
| 310 | |
| 311 | if (gpio_edge_triggered[gpio_bank(gpionr)] & gpio_bit(gpionr)) { |
| 312 | set_gpio_data(gpionr, 0); |
| 313 | SSYNC(); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | static void bfin_gpio_mask_ack_irq(unsigned int irq) |
| 318 | { |
| 319 | u16 gpionr = irq - IRQ_PF0; |
| 320 | |
| 321 | if (gpio_edge_triggered[gpio_bank(gpionr)] & gpio_bit(gpionr)) { |
| 322 | set_gpio_data(gpionr, 0); |
| 323 | SSYNC(); |
| 324 | } |
| 325 | |
| 326 | set_gpio_maska(gpionr, 0); |
| 327 | SSYNC(); |
| 328 | } |
| 329 | |
| 330 | static void bfin_gpio_mask_irq(unsigned int irq) |
| 331 | { |
| 332 | set_gpio_maska(irq - IRQ_PF0, 0); |
| 333 | SSYNC(); |
| 334 | } |
| 335 | |
| 336 | static void bfin_gpio_unmask_irq(unsigned int irq) |
| 337 | { |
| 338 | set_gpio_maska(irq - IRQ_PF0, 1); |
| 339 | SSYNC(); |
| 340 | } |
| 341 | |
| 342 | static unsigned int bfin_gpio_irq_startup(unsigned int irq) |
| 343 | { |
| 344 | unsigned int ret; |
| 345 | u16 gpionr = irq - IRQ_PF0; |
| 346 | |
| 347 | if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) { |
| 348 | ret = gpio_request(gpionr, NULL); |
| 349 | if (ret) |
| 350 | return ret; |
| 351 | } |
| 352 | |
| 353 | gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr); |
| 354 | bfin_gpio_unmask_irq(irq); |
| 355 | |
| 356 | return ret; |
| 357 | } |
| 358 | |
| 359 | static void bfin_gpio_irq_shutdown(unsigned int irq) |
| 360 | { |
| 361 | bfin_gpio_mask_irq(irq); |
| 362 | gpio_free(irq - IRQ_PF0); |
| 363 | gpio_enabled[gpio_bank(irq - IRQ_PF0)] &= ~gpio_bit(irq - IRQ_PF0); |
| 364 | } |
| 365 | |
| 366 | static int bfin_gpio_irq_type(unsigned int irq, unsigned int type) |
| 367 | { |
| 368 | |
| 369 | unsigned int ret; |
| 370 | u16 gpionr = irq - IRQ_PF0; |
| 371 | |
| 372 | if (type == IRQ_TYPE_PROBE) { |
| 373 | /* only probe unenabled GPIO interrupt lines */ |
| 374 | if (gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr)) |
| 375 | return 0; |
| 376 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; |
| 377 | } |
| 378 | |
| 379 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING | |
| 380 | IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) |
| 381 | { |
| 382 | if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) { |
| 383 | ret = gpio_request(gpionr, NULL); |
| 384 | if (ret) |
| 385 | return ret; |
| 386 | } |
| 387 | |
| 388 | gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr); |
| 389 | } else { |
| 390 | gpio_enabled[gpio_bank(gpionr)] &= ~gpio_bit(gpionr); |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | set_gpio_dir(gpionr, 0); |
| 395 | set_gpio_inen(gpionr, 1); |
| 396 | |
| 397 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { |
| 398 | gpio_edge_triggered[gpio_bank(gpionr)] |= gpio_bit(gpionr); |
| 399 | set_gpio_edge(gpionr, 1); |
| 400 | } else { |
| 401 | set_gpio_edge(gpionr, 0); |
| 402 | gpio_edge_triggered[gpio_bank(gpionr)] &= ~gpio_bit(gpionr); |
| 403 | } |
| 404 | |
| 405 | if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
| 406 | == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
| 407 | set_gpio_both(gpionr, 1); |
| 408 | else |
| 409 | set_gpio_both(gpionr, 0); |
| 410 | |
| 411 | if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW))) |
| 412 | set_gpio_polar(gpionr, 1); /* low or falling edge denoted by one */ |
| 413 | else |
| 414 | set_gpio_polar(gpionr, 0); /* high or rising edge denoted by zero */ |
| 415 | |
| 416 | SSYNC(); |
| 417 | |
| 418 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
| 419 | set_irq_handler(irq, handle_edge_irq); |
| 420 | else |
| 421 | set_irq_handler(irq, handle_level_irq); |
| 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | |
| 427 | static struct irq_chip bfin_gpio_irqchip = { |
| 428 | .ack = bfin_gpio_ack_irq, |
| 429 | .mask = bfin_gpio_mask_irq, |
| 430 | .mask_ack = bfin_gpio_mask_ack_irq, |
| 431 | .unmask = bfin_gpio_unmask_irq, |
| 432 | .set_type = bfin_gpio_irq_type, |
| 433 | .startup = bfin_gpio_irq_startup, |
| 434 | .shutdown = bfin_gpio_irq_shutdown |
| 435 | }; |
| 436 | |
| 437 | static void bfin_demux_gpio_irq(unsigned int intb_irq, |
| 438 | struct irq_desc *intb_desc) |
| 439 | { |
| 440 | u16 i; |
| 441 | |
| 442 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i+=16) { |
| 443 | int irq = IRQ_PF0 + i; |
| 444 | int flag_d = get_gpiop_data(i); |
| 445 | int mask = |
| 446 | flag_d & (gpio_enabled[gpio_bank(i)] & |
| 447 | get_gpiop_maska(i)); |
| 448 | |
| 449 | while (mask) { |
| 450 | if (mask & 1) { |
| 451 | struct irq_desc *desc = irq_desc + irq; |
| 452 | desc->handle_irq(irq, desc); |
| 453 | } |
| 454 | irq++; |
| 455 | mask >>= 1; |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | #endif /* CONFIG_IRQCHIP_DEMUX_GPIO */ |
| 461 | |
| 462 | /* |
| 463 | * This function should be called during kernel startup to initialize |
| 464 | * the BFin IRQ handling routines. |
| 465 | */ |
| 466 | int __init init_arch_irq(void) |
| 467 | { |
| 468 | int irq; |
| 469 | unsigned long ilat = 0; |
| 470 | /* Disable all the peripheral intrs - page 4-29 HW Ref manual */ |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 471 | #ifdef CONFIG_BF54x |
| 472 | bfin_write_SIC_IMASK0(SIC_UNMASK_ALL); |
| 473 | bfin_write_SIC_IMASK1(SIC_UNMASK_ALL); |
| 474 | bfin_write_SIC_IMASK2(SIC_UNMASK_ALL); |
Michael Hennerich | 1c5d226 | 2007-06-21 11:34:16 +0800 | [diff] [blame^] | 475 | bfin_write_SIC_IWR0(IWR_ENABLE_ALL); |
| 476 | bfin_write_SIC_IWR1(IWR_ENABLE_ALL); |
| 477 | bfin_write_SIC_IWR2(IWR_ENABLE_ALL); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 478 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 479 | bfin_write_SIC_IMASK(SIC_UNMASK_ALL); |
Michael Hennerich | 1c5d226 | 2007-06-21 11:34:16 +0800 | [diff] [blame^] | 480 | bfin_write_SIC_IWR(IWR_ENABLE_ALL); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 481 | #endif |
| 482 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 483 | SSYNC(); |
| 484 | |
| 485 | local_irq_disable(); |
| 486 | |
| 487 | #ifndef CONFIG_KGDB |
| 488 | bfin_write_EVT0(evt_emulation); |
| 489 | #endif |
| 490 | bfin_write_EVT2(evt_evt2); |
| 491 | bfin_write_EVT3(trap); |
| 492 | bfin_write_EVT5(evt_ivhw); |
| 493 | bfin_write_EVT6(evt_timer); |
| 494 | bfin_write_EVT7(evt_evt7); |
| 495 | bfin_write_EVT8(evt_evt8); |
| 496 | bfin_write_EVT9(evt_evt9); |
| 497 | bfin_write_EVT10(evt_evt10); |
| 498 | bfin_write_EVT11(evt_evt11); |
| 499 | bfin_write_EVT12(evt_evt12); |
| 500 | bfin_write_EVT13(evt_evt13); |
| 501 | bfin_write_EVT14(evt14_softirq); |
| 502 | bfin_write_EVT15(evt_system_call); |
| 503 | CSYNC(); |
| 504 | |
| 505 | for (irq = 0; irq < SYS_IRQS; irq++) { |
| 506 | if (irq <= IRQ_CORETMR) |
| 507 | set_irq_chip(irq, &bfin_core_irqchip); |
| 508 | else |
| 509 | set_irq_chip(irq, &bfin_internal_irqchip); |
| 510 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 511 | if (irq != IRQ_GENERIC_ERROR) { |
| 512 | #endif |
| 513 | |
| 514 | #ifdef CONFIG_IRQCHIP_DEMUX_GPIO |
| 515 | if ((irq != IRQ_PROG_INTA) /*PORT F & G MASK_A Interrupt*/ |
| 516 | # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) |
| 517 | && (irq != IRQ_MAC_RX) /*PORT H MASK_A Interrupt*/ |
| 518 | # endif |
| 519 | ) { |
| 520 | #endif |
| 521 | set_irq_handler(irq, handle_simple_irq); |
| 522 | #ifdef CONFIG_IRQCHIP_DEMUX_GPIO |
| 523 | } else { |
| 524 | set_irq_chained_handler(irq, |
| 525 | bfin_demux_gpio_irq); |
| 526 | } |
| 527 | #endif |
| 528 | |
| 529 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 530 | } else { |
| 531 | set_irq_handler(irq, bfin_demux_error_irq); |
| 532 | } |
| 533 | #endif |
| 534 | } |
| 535 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 536 | for (irq = IRQ_PPI_ERROR; irq <= IRQ_UART1_ERROR; irq++) { |
| 537 | set_irq_chip(irq, &bfin_generic_error_irqchip); |
| 538 | set_irq_handler(irq, handle_level_irq); |
| 539 | } |
| 540 | #endif |
| 541 | |
| 542 | #ifdef CONFIG_IRQCHIP_DEMUX_GPIO |
| 543 | for (irq = IRQ_PF0; irq < NR_IRQS; irq++) { |
| 544 | set_irq_chip(irq, &bfin_gpio_irqchip); |
| 545 | /* if configured as edge, then will be changed to do_edge_IRQ */ |
| 546 | set_irq_handler(irq, handle_level_irq); |
| 547 | } |
| 548 | #endif |
| 549 | bfin_write_IMASK(0); |
| 550 | CSYNC(); |
| 551 | ilat = bfin_read_ILAT(); |
| 552 | CSYNC(); |
| 553 | bfin_write_ILAT(ilat); |
| 554 | CSYNC(); |
| 555 | |
| 556 | printk(KERN_INFO |
| 557 | "Configuring Blackfin Priority Driven Interrupts\n"); |
| 558 | /* IMASK=xxx is equivalent to STI xx or irq_flags=xx, |
| 559 | * local_irq_enable() |
| 560 | */ |
| 561 | program_IAR(); |
| 562 | /* Therefore it's better to setup IARs before interrupts enabled */ |
| 563 | search_IAR(); |
| 564 | |
| 565 | /* Enable interrupts IVG7-15 */ |
| 566 | irq_flags = irq_flags | IMASK_IVG15 | |
| 567 | IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 | |
| 568 | IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | |
| 569 | IMASK_IVGHW; |
| 570 | |
| 571 | return 0; |
| 572 | } |
| 573 | |
| 574 | #ifdef CONFIG_DO_IRQ_L1 |
| 575 | void do_irq(int vec, struct pt_regs *fp)__attribute__((l1_text)); |
| 576 | #endif |
| 577 | |
| 578 | void do_irq(int vec, struct pt_regs *fp) |
| 579 | { |
| 580 | if (vec == EVT_IVTMR_P) { |
| 581 | vec = IRQ_CORETMR; |
| 582 | } else { |
| 583 | struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst; |
| 584 | struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop; |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 585 | #ifdef CONFIG_BF54x |
| 586 | unsigned long sic_status[3]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 587 | |
| 588 | SSYNC(); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 589 | sic_status[0] = bfin_read_SIC_ISR(0) & bfin_read_SIC_IMASK(0); |
| 590 | sic_status[1] = bfin_read_SIC_ISR(1) & bfin_read_SIC_IMASK(1); |
| 591 | sic_status[2] = bfin_read_SIC_ISR(2) & bfin_read_SIC_IMASK(2); |
| 592 | SSYNC(); |
| 593 | for(;; ivg++) { |
| 594 | if (ivg >= ivg_stop) { |
| 595 | atomic_inc(&num_spurious); |
| 596 | return; |
| 597 | } |
| 598 | if (sic_status[(ivg->irqno - IVG7)/32] & ivg->isrflag) |
| 599 | break; |
| 600 | } |
| 601 | #else |
| 602 | unsigned long sic_status; |
| 603 | SSYNC(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 604 | sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR(); |
| 605 | |
| 606 | for (;; ivg++) { |
| 607 | if (ivg >= ivg_stop) { |
| 608 | atomic_inc(&num_spurious); |
| 609 | return; |
| 610 | } else if (sic_status & ivg->isrflag) |
| 611 | break; |
| 612 | } |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 613 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 614 | vec = ivg->irqno; |
| 615 | } |
| 616 | asm_do_IRQ(vec, fp); |
| 617 | |
| 618 | #ifdef CONFIG_KGDB |
| 619 | kgdb_process_breakpoint(); |
| 620 | #endif |
| 621 | } |