2 * File: arch/blackfin/mach-common/ints-priority.c
4 * Description: Set up the interrupt priorities
8 * 1999 D. Jeff Dionne <jeff@uclinux.org>
9 * 2000-2001 Lineo, Inc. D. Jefff Dionne <jeff@lineo.ca>
10 * 2002 Arcturus Networks Inc. MaTed <mated@sympatico.ca>
11 * 2003 Metrowerks/Motorola
12 * 2003 Bas Vermeulen <bas@buyways.nl>
13 * Copyright 2004-2008 Analog Devices Inc.
15 * Bugs: Enter bugs at http://blackfin.uclinux.org/
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, see the file COPYING, or write
29 * to the Free Software Foundation, Inc.,
30 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include <linux/module.h>
34 #include <linux/kernel_stat.h>
35 #include <linux/seq_file.h>
36 #include <linux/irq.h>
38 #include <linux/kgdb.h>
40 #include <asm/traps.h>
41 #include <asm/blackfin.h>
43 #include <asm/irq_handler.h>
46 # define BF537_GENERIC_ERROR_INT_DEMUX
48 # undef BF537_GENERIC_ERROR_INT_DEMUX
53 * - we have separated the physical Hardware interrupt from the
54 * levels that the LINUX kernel sees (see the description in irq.h)
58 /* Initialize this to an actual value to force it into the .data
59 * section so that we know it is properly initialized at entry into
60 * the kernel but before bss is initialized to zero (which is where
61 * it would live otherwise). The 0x1f magic represents the IRQs we
62 * cannot actually mask out in hardware.
64 unsigned long irq_flags = 0x1f;
65 EXPORT_SYMBOL(irq_flags);
67 /* The number of spurious interrupts */
68 atomic_t num_spurious;
71 unsigned long bfin_sic_iwr[3]; /* Up to 3 SIC_IWRx registers */
76 /* irq number for request_irq, available in mach-bf5xx/irq.h */
78 /* corresponding bit in the SIC_ISR register */
80 } ivg_table[NR_PERI_INTS];
83 /* position of first irq in ivg_table for given ivg */
86 } ivg7_13[IVG13 - IVG7 + 1];
90 * Search SIC_IAR and fill tables with the irqvalues
91 * and their positions in the SIC_ISR register.
93 static void __init search_IAR(void)
95 unsigned ivg, irq_pos = 0;
96 for (ivg = 0; ivg <= IVG13 - IVG7; ivg++) {
99 ivg7_13[ivg].istop = ivg7_13[ivg].ifirst = &ivg_table[irq_pos];
101 for (irqn = 0; irqn < NR_PERI_INTS; irqn++) {
102 int iar_shift = (irqn & 7) * 4;
104 #if defined(CONFIG_BF52x) || defined(CONFIG_BF538) \
105 || defined(CONFIG_BF539) || defined(CONFIG_BF51x)
106 bfin_read32((unsigned long *)SIC_IAR0 +
107 ((irqn % 32) >> 3) + ((irqn / 32) *
108 ((SIC_IAR4 - SIC_IAR0) / 4))) >> iar_shift)) {
110 bfin_read32((unsigned long *)SIC_IAR0 +
111 (irqn >> 3)) >> iar_shift)) {
113 ivg_table[irq_pos].irqno = IVG7 + irqn;
114 ivg_table[irq_pos].isrflag = 1 << (irqn % 32);
115 ivg7_13[ivg].istop++;
123 * This is for core internal IRQs
126 static void bfin_ack_noop(unsigned int irq)
128 /* Dummy function. */
131 static void bfin_core_mask_irq(unsigned int irq)
133 irq_flags &= ~(1 << irq);
134 if (!irqs_disabled())
138 static void bfin_core_unmask_irq(unsigned int irq)
140 irq_flags |= 1 << irq;
142 * If interrupts are enabled, IMASK must contain the same value
143 * as irq_flags. Make sure that invariant holds. If interrupts
144 * are currently disabled we need not do anything; one of the
145 * callers will take care of setting IMASK to the proper value
146 * when reenabling interrupts.
147 * local_irq_enable just does "STI irq_flags", so it's exactly
150 if (!irqs_disabled())
155 static void bfin_internal_mask_irq(unsigned int irq)
158 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
159 ~(1 << SIC_SYSIRQ(irq)));
161 unsigned mask_bank, mask_bit;
162 mask_bank = SIC_SYSIRQ(irq) / 32;
163 mask_bit = SIC_SYSIRQ(irq) % 32;
164 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) &
169 static void bfin_internal_unmask_irq(unsigned int irq)
172 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() |
173 (1 << SIC_SYSIRQ(irq)));
175 unsigned mask_bank, mask_bit;
176 mask_bank = SIC_SYSIRQ(irq) / 32;
177 mask_bit = SIC_SYSIRQ(irq) % 32;
178 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) |
184 int bfin_internal_set_wake(unsigned int irq, unsigned int state)
186 u32 bank, bit, wakeup = 0;
188 bank = SIC_SYSIRQ(irq) / 32;
189 bit = SIC_SYSIRQ(irq) % 32;
226 local_irq_save(flags);
229 bfin_sic_iwr[bank] |= (1 << bit);
233 bfin_sic_iwr[bank] &= ~(1 << bit);
234 vr_wakeup &= ~wakeup;
237 local_irq_restore(flags);
243 static struct irq_chip bfin_core_irqchip = {
245 .ack = bfin_ack_noop,
246 .mask = bfin_core_mask_irq,
247 .unmask = bfin_core_unmask_irq,
250 static struct irq_chip bfin_internal_irqchip = {
252 .ack = bfin_ack_noop,
253 .mask = bfin_internal_mask_irq,
254 .unmask = bfin_internal_unmask_irq,
255 .mask_ack = bfin_internal_mask_irq,
256 .disable = bfin_internal_mask_irq,
257 .enable = bfin_internal_unmask_irq,
259 .set_wake = bfin_internal_set_wake,
263 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
264 static int error_int_mask;
266 static void bfin_generic_error_mask_irq(unsigned int irq)
268 error_int_mask &= ~(1L << (irq - IRQ_PPI_ERROR));
271 bfin_internal_mask_irq(IRQ_GENERIC_ERROR);
274 static void bfin_generic_error_unmask_irq(unsigned int irq)
276 bfin_internal_unmask_irq(IRQ_GENERIC_ERROR);
277 error_int_mask |= 1L << (irq - IRQ_PPI_ERROR);
280 static struct irq_chip bfin_generic_error_irqchip = {
282 .ack = bfin_ack_noop,
283 .mask_ack = bfin_generic_error_mask_irq,
284 .mask = bfin_generic_error_mask_irq,
285 .unmask = bfin_generic_error_unmask_irq,
288 static void bfin_demux_error_irq(unsigned int int_err_irq,
289 struct irq_desc *inta_desc)
293 #if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
294 if (bfin_read_EMAC_SYSTAT() & EMAC_ERR_MASK)
298 if (bfin_read_SPORT0_STAT() & SPORT_ERR_MASK)
299 irq = IRQ_SPORT0_ERROR;
300 else if (bfin_read_SPORT1_STAT() & SPORT_ERR_MASK)
301 irq = IRQ_SPORT1_ERROR;
302 else if (bfin_read_PPI_STATUS() & PPI_ERR_MASK)
304 else if (bfin_read_CAN_GIF() & CAN_ERR_MASK)
306 else if (bfin_read_SPI_STAT() & SPI_ERR_MASK)
308 else if ((bfin_read_UART0_IIR() & UART_ERR_MASK_STAT1) &&
309 (bfin_read_UART0_IIR() & UART_ERR_MASK_STAT0))
310 irq = IRQ_UART0_ERROR;
311 else if ((bfin_read_UART1_IIR() & UART_ERR_MASK_STAT1) &&
312 (bfin_read_UART1_IIR() & UART_ERR_MASK_STAT0))
313 irq = IRQ_UART1_ERROR;
316 if (error_int_mask & (1L << (irq - IRQ_PPI_ERROR))) {
317 struct irq_desc *desc = irq_desc + irq;
318 desc->handle_irq(irq, desc);
323 bfin_write_PPI_STATUS(PPI_ERR_MASK);
325 #if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
327 bfin_write_EMAC_SYSTAT(EMAC_ERR_MASK);
330 case IRQ_SPORT0_ERROR:
331 bfin_write_SPORT0_STAT(SPORT_ERR_MASK);
334 case IRQ_SPORT1_ERROR:
335 bfin_write_SPORT1_STAT(SPORT_ERR_MASK);
339 bfin_write_CAN_GIS(CAN_ERR_MASK);
343 bfin_write_SPI_STAT(SPI_ERR_MASK);
351 " MASKED PERIPHERAL ERROR INTERRUPT ASSERTED\n",
356 "%s : %s : LINE %d :\nIRQ ?: PERIPHERAL ERROR"
357 " INTERRUPT ASSERTED BUT NO SOURCE FOUND\n",
358 __func__, __FILE__, __LINE__);
361 #endif /* BF537_GENERIC_ERROR_INT_DEMUX */
363 static inline void bfin_set_irq_handler(unsigned irq, irq_flow_handler_t handle)
365 struct irq_desc *desc = irq_desc + irq;
366 /* May not call generic set_irq_handler() due to spinlock
368 desc->handle_irq = handle;
371 static DECLARE_BITMAP(gpio_enabled, MAX_BLACKFIN_GPIOS);
372 extern void bfin_gpio_irq_prepare(unsigned gpio);
374 #if !defined(CONFIG_BF54x)
376 static void bfin_gpio_ack_irq(unsigned int irq)
378 /* AFAIK ack_irq in case mask_ack is provided
379 * get's only called for edge sense irqs
381 set_gpio_data(irq_to_gpio(irq), 0);
384 static void bfin_gpio_mask_ack_irq(unsigned int irq)
386 struct irq_desc *desc = irq_desc + irq;
387 u32 gpionr = irq_to_gpio(irq);
389 if (desc->handle_irq == handle_edge_irq)
390 set_gpio_data(gpionr, 0);
392 set_gpio_maska(gpionr, 0);
395 static void bfin_gpio_mask_irq(unsigned int irq)
397 set_gpio_maska(irq_to_gpio(irq), 0);
400 static void bfin_gpio_unmask_irq(unsigned int irq)
402 set_gpio_maska(irq_to_gpio(irq), 1);
405 static unsigned int bfin_gpio_irq_startup(unsigned int irq)
407 u32 gpionr = irq_to_gpio(irq);
409 if (__test_and_set_bit(gpionr, gpio_enabled))
410 bfin_gpio_irq_prepare(gpionr);
412 bfin_gpio_unmask_irq(irq);
417 static void bfin_gpio_irq_shutdown(unsigned int irq)
419 bfin_gpio_mask_irq(irq);
420 __clear_bit(irq_to_gpio(irq), gpio_enabled);
423 static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
425 u32 gpionr = irq_to_gpio(irq);
427 if (type == IRQ_TYPE_PROBE) {
428 /* only probe unenabled GPIO interrupt lines */
429 if (__test_bit(gpionr, gpio_enabled))
431 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
434 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
435 IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
437 if (__test_and_set_bit(gpionr, gpio_enabled))
438 bfin_gpio_irq_prepare(gpionr);
441 __clear_bit(gpionr, gpio_enabled);
445 set_gpio_inen(gpionr, 0);
446 set_gpio_dir(gpionr, 0);
448 if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
449 == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
450 set_gpio_both(gpionr, 1);
452 set_gpio_both(gpionr, 0);
454 if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)))
455 set_gpio_polar(gpionr, 1); /* low or falling edge denoted by one */
457 set_gpio_polar(gpionr, 0); /* high or rising edge denoted by zero */
459 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
460 set_gpio_edge(gpionr, 1);
461 set_gpio_inen(gpionr, 1);
462 set_gpio_data(gpionr, 0);
465 set_gpio_edge(gpionr, 0);
466 set_gpio_inen(gpionr, 1);
469 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
470 bfin_set_irq_handler(irq, handle_edge_irq);
472 bfin_set_irq_handler(irq, handle_level_irq);
478 int bfin_gpio_set_wake(unsigned int irq, unsigned int state)
480 unsigned gpio = irq_to_gpio(irq);
483 gpio_pm_wakeup_request(gpio, PM_WAKE_IGNORE);
485 gpio_pm_wakeup_free(gpio);
491 static void bfin_demux_gpio_irq(unsigned int inta_irq,
492 struct irq_desc *desc)
494 unsigned int i, gpio, mask, irq, search = 0;
497 #if defined(CONFIG_BF53x)
502 # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
507 #elif defined(CONFIG_BF538) || defined(CONFIG_BF539)
511 #elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x)
521 #elif defined(CONFIG_BF561)
538 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
541 mask = get_gpiop_data(i) & get_gpiop_maska(i);
545 desc = irq_desc + irq;
546 desc->handle_irq(irq, desc);
553 gpio = irq_to_gpio(irq);
554 mask = get_gpiop_data(gpio) & get_gpiop_maska(gpio);
558 desc = irq_desc + irq;
559 desc->handle_irq(irq, desc);
568 #else /* CONFIG_BF54x */
570 #define NR_PINT_SYS_IRQS 4
571 #define NR_PINT_BITS 32
573 #define IRQ_NOT_AVAIL 0xFF
575 #define PINT_2_BANK(x) ((x) >> 5)
576 #define PINT_2_BIT(x) ((x) & 0x1F)
577 #define PINT_BIT(x) (1 << (PINT_2_BIT(x)))
579 static unsigned char irq2pint_lut[NR_PINTS];
580 static unsigned char pint2irq_lut[NR_PINT_SYS_IRQS * NR_PINT_BITS];
583 unsigned int mask_set;
584 unsigned int mask_clear;
585 unsigned int request;
587 unsigned int edge_set;
588 unsigned int edge_clear;
589 unsigned int invert_set;
590 unsigned int invert_clear;
591 unsigned int pinstate;
595 static struct pin_int_t *pint[NR_PINT_SYS_IRQS] = {
596 (struct pin_int_t *)PINT0_MASK_SET,
597 (struct pin_int_t *)PINT1_MASK_SET,
598 (struct pin_int_t *)PINT2_MASK_SET,
599 (struct pin_int_t *)PINT3_MASK_SET,
602 inline unsigned int get_irq_base(u32 bank, u8 bmap)
604 unsigned int irq_base;
606 if (bank < 2) { /*PA-PB */
607 irq_base = IRQ_PA0 + bmap * 16;
609 irq_base = IRQ_PC0 + bmap * 16;
615 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
616 void init_pint_lut(void)
618 u16 bank, bit, irq_base, bit_pos;
622 memset(irq2pint_lut, IRQ_NOT_AVAIL, sizeof(irq2pint_lut));
624 for (bank = 0; bank < NR_PINT_SYS_IRQS; bank++) {
626 pint_assign = pint[bank]->assign;
628 for (bit = 0; bit < NR_PINT_BITS; bit++) {
630 bmap = (pint_assign >> ((bit / 8) * 8)) & 0xFF;
632 irq_base = get_irq_base(bank, bmap);
634 irq_base += (bit % 8) + ((bit / 8) & 1 ? 8 : 0);
635 bit_pos = bit + bank * NR_PINT_BITS;
637 pint2irq_lut[bit_pos] = irq_base - SYS_IRQS;
638 irq2pint_lut[irq_base - SYS_IRQS] = bit_pos;
643 static void bfin_gpio_ack_irq(unsigned int irq)
645 struct irq_desc *desc = irq_desc + irq;
646 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
647 u32 pintbit = PINT_BIT(pint_val);
648 u32 bank = PINT_2_BANK(pint_val);
650 if ((desc->status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
651 if (pint[bank]->invert_set & pintbit)
652 pint[bank]->invert_clear = pintbit;
654 pint[bank]->invert_set = pintbit;
656 pint[bank]->request = pintbit;
660 static void bfin_gpio_mask_ack_irq(unsigned int irq)
662 struct irq_desc *desc = irq_desc + irq;
663 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
664 u32 pintbit = PINT_BIT(pint_val);
665 u32 bank = PINT_2_BANK(pint_val);
667 if ((desc->status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
668 if (pint[bank]->invert_set & pintbit)
669 pint[bank]->invert_clear = pintbit;
671 pint[bank]->invert_set = pintbit;
674 pint[bank]->request = pintbit;
675 pint[bank]->mask_clear = pintbit;
678 static void bfin_gpio_mask_irq(unsigned int irq)
680 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
682 pint[PINT_2_BANK(pint_val)]->mask_clear = PINT_BIT(pint_val);
685 static void bfin_gpio_unmask_irq(unsigned int irq)
687 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
688 u32 pintbit = PINT_BIT(pint_val);
689 u32 bank = PINT_2_BANK(pint_val);
691 pint[bank]->request = pintbit;
692 pint[bank]->mask_set = pintbit;
695 static unsigned int bfin_gpio_irq_startup(unsigned int irq)
697 u32 gpionr = irq_to_gpio(irq);
698 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
700 if (pint_val == IRQ_NOT_AVAIL) {
702 "GPIO IRQ %d :Not in PINT Assign table "
703 "Reconfigure Interrupt to Port Assignemt\n", irq);
707 if (__test_and_set_bit(gpionr, gpio_enabled))
708 bfin_gpio_irq_prepare(gpionr);
710 bfin_gpio_unmask_irq(irq);
715 static void bfin_gpio_irq_shutdown(unsigned int irq)
717 u32 gpionr = irq_to_gpio(irq);
719 bfin_gpio_mask_irq(irq);
720 __clear_bit(gpionr, gpio_enabled);
723 static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
726 u32 gpionr = irq_to_gpio(irq);
727 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
728 u32 pintbit = PINT_BIT(pint_val);
729 u32 bank = PINT_2_BANK(pint_val);
731 if (pint_val == IRQ_NOT_AVAIL)
734 if (type == IRQ_TYPE_PROBE) {
735 /* only probe unenabled GPIO interrupt lines */
736 if (__test_bit(gpionr, gpio_enabled))
738 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
741 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
742 IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
743 if (__test_and_set_bit(gpionr, gpio_enabled))
744 bfin_gpio_irq_prepare(gpionr);
747 __clear_bit(gpionr, gpio_enabled);
751 if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)))
752 pint[bank]->invert_set = pintbit; /* low or falling edge denoted by one */
754 pint[bank]->invert_clear = pintbit; /* high or rising edge denoted by zero */
756 if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
757 == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
758 if (gpio_get_value(gpionr))
759 pint[bank]->invert_set = pintbit;
761 pint[bank]->invert_clear = pintbit;
764 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
765 pint[bank]->edge_set = pintbit;
766 bfin_set_irq_handler(irq, handle_edge_irq);
768 pint[bank]->edge_clear = pintbit;
769 bfin_set_irq_handler(irq, handle_level_irq);
776 u32 pint_saved_masks[NR_PINT_SYS_IRQS];
777 u32 pint_wakeup_masks[NR_PINT_SYS_IRQS];
779 int bfin_gpio_set_wake(unsigned int irq, unsigned int state)
782 u32 pint_val = irq2pint_lut[irq - SYS_IRQS];
783 u32 bank = PINT_2_BANK(pint_val);
784 u32 pintbit = PINT_BIT(pint_val);
788 pint_irq = IRQ_PINT0;
791 pint_irq = IRQ_PINT2;
794 pint_irq = IRQ_PINT3;
797 pint_irq = IRQ_PINT1;
803 bfin_internal_set_wake(pint_irq, state);
806 pint_wakeup_masks[bank] |= pintbit;
808 pint_wakeup_masks[bank] &= ~pintbit;
813 u32 bfin_pm_setup(void)
817 for (i = 0; i < NR_PINT_SYS_IRQS; i++) {
818 val = pint[i]->mask_clear;
819 pint_saved_masks[i] = val;
820 if (val ^ pint_wakeup_masks[i]) {
821 pint[i]->mask_clear = val;
822 pint[i]->mask_set = pint_wakeup_masks[i];
829 void bfin_pm_restore(void)
833 for (i = 0; i < NR_PINT_SYS_IRQS; i++) {
834 val = pint_saved_masks[i];
835 if (val ^ pint_wakeup_masks[i]) {
836 pint[i]->mask_clear = pint[i]->mask_clear;
837 pint[i]->mask_set = val;
843 static void bfin_demux_gpio_irq(unsigned int inta_irq,
844 struct irq_desc *desc)
866 pint_val = bank * NR_PINT_BITS;
868 request = pint[bank]->request;
872 irq = pint2irq_lut[pint_val] + SYS_IRQS;
873 desc = irq_desc + irq;
874 desc->handle_irq(irq, desc);
883 static struct irq_chip bfin_gpio_irqchip = {
885 .ack = bfin_gpio_ack_irq,
886 .mask = bfin_gpio_mask_irq,
887 .mask_ack = bfin_gpio_mask_ack_irq,
888 .unmask = bfin_gpio_unmask_irq,
889 .disable = bfin_gpio_mask_irq,
890 .enable = bfin_gpio_unmask_irq,
891 .set_type = bfin_gpio_irq_type,
892 .startup = bfin_gpio_irq_startup,
893 .shutdown = bfin_gpio_irq_shutdown,
895 .set_wake = bfin_gpio_set_wake,
899 void __init init_exception_vectors(void)
901 /* cannot program in software:
902 * evt0 - emulation (jtag)
905 bfin_write_EVT2(evt_nmi);
906 bfin_write_EVT3(trap);
907 bfin_write_EVT5(evt_ivhw);
908 bfin_write_EVT6(evt_timer);
909 bfin_write_EVT7(evt_evt7);
910 bfin_write_EVT8(evt_evt8);
911 bfin_write_EVT9(evt_evt9);
912 bfin_write_EVT10(evt_evt10);
913 bfin_write_EVT11(evt_evt11);
914 bfin_write_EVT12(evt_evt12);
915 bfin_write_EVT13(evt_evt13);
916 bfin_write_EVT14(evt14_softirq);
917 bfin_write_EVT15(evt_system_call);
922 * This function should be called during kernel startup to initialize
923 * the BFin IRQ handling routines.
926 int __init init_arch_irq(void)
929 unsigned long ilat = 0;
930 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
931 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) \
932 || defined(BF538_FAMILY) || defined(CONFIG_BF51x)
933 bfin_write_SIC_IMASK0(SIC_UNMASK_ALL);
934 bfin_write_SIC_IMASK1(SIC_UNMASK_ALL);
936 bfin_write_SIC_IMASK2(SIC_UNMASK_ALL);
939 bfin_write_SIC_IMASK(SIC_UNMASK_ALL);
944 #if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
945 /* Clear EMAC Interrupt Status bits so we can demux it later */
946 bfin_write_EMAC_SYSTAT(-1);
950 # ifdef CONFIG_PINTx_REASSIGN
951 pint[0]->assign = CONFIG_PINT0_ASSIGN;
952 pint[1]->assign = CONFIG_PINT1_ASSIGN;
953 pint[2]->assign = CONFIG_PINT2_ASSIGN;
954 pint[3]->assign = CONFIG_PINT3_ASSIGN;
956 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
960 for (irq = 0; irq <= SYS_IRQS; irq++) {
961 if (irq <= IRQ_CORETMR)
962 set_irq_chip(irq, &bfin_core_irqchip);
964 set_irq_chip(irq, &bfin_internal_irqchip);
967 #if defined(CONFIG_BF53x)
969 # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
972 #elif defined(CONFIG_BF54x)
977 #elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x)
981 #elif defined(CONFIG_BF561)
985 #elif defined(CONFIG_BF538) || defined(CONFIG_BF539)
989 set_irq_chained_handler(irq,
990 bfin_demux_gpio_irq);
992 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
993 case IRQ_GENERIC_ERROR:
994 set_irq_handler(irq, bfin_demux_error_irq);
999 set_irq_handler(irq, handle_simple_irq);
1004 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
1005 for (irq = IRQ_PPI_ERROR; irq <= IRQ_UART1_ERROR; irq++)
1006 set_irq_chip_and_handler(irq, &bfin_generic_error_irqchip,
1010 /* if configured as edge, then will be changed to do_edge_IRQ */
1011 for (irq = GPIO_IRQ_BASE; irq < NR_IRQS; irq++)
1012 set_irq_chip_and_handler(irq, &bfin_gpio_irqchip,
1016 bfin_write_IMASK(0);
1018 ilat = bfin_read_ILAT();
1020 bfin_write_ILAT(ilat);
1023 printk(KERN_INFO "Configuring Blackfin Priority Driven Interrupts\n");
1024 /* IMASK=xxx is equivalent to STI xx or irq_flags=xx,
1025 * local_irq_enable()
1028 /* Therefore it's better to setup IARs before interrupts enabled */
1031 /* Enable interrupts IVG7-15 */
1032 irq_flags = irq_flags | IMASK_IVG15 |
1033 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
1034 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
1036 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) \
1037 || defined(BF538_FAMILY) || defined(CONFIG_BF51x)
1038 bfin_write_SIC_IWR0(IWR_DISABLE_ALL);
1039 #if defined(CONFIG_BF52x) || defined(CONFIG_BF51x)
1040 /* BF52x/BF51x system reset does not properly reset SIC_IWR1 which
1041 * will screw up the bootrom as it relies on MDMA0/1 waking it
1042 * up from IDLE instructions. See this report for more info:
1043 * http://blackfin.uclinux.org/gf/tracker/4323
1045 bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11));
1047 bfin_write_SIC_IWR1(IWR_DISABLE_ALL);
1049 # ifdef CONFIG_BF54x
1050 bfin_write_SIC_IWR2(IWR_DISABLE_ALL);
1053 bfin_write_SIC_IWR(IWR_DISABLE_ALL);
1059 #ifdef CONFIG_DO_IRQ_L1
1060 __attribute__((l1_text))
1062 void do_irq(int vec, struct pt_regs *fp)
1064 if (vec == EVT_IVTMR_P) {
1067 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst;
1068 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop;
1069 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) \
1070 || defined(BF538_FAMILY) || defined(CONFIG_BF51x)
1071 unsigned long sic_status[3];
1073 sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0();
1074 sic_status[1] = bfin_read_SIC_ISR1() & bfin_read_SIC_IMASK1();
1076 sic_status[2] = bfin_read_SIC_ISR2() & bfin_read_SIC_IMASK2();
1079 if (ivg >= ivg_stop) {
1080 atomic_inc(&num_spurious);
1083 if (sic_status[(ivg->irqno - IVG7) / 32] & ivg->isrflag)
1087 unsigned long sic_status;
1089 sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR();
1092 if (ivg >= ivg_stop) {
1093 atomic_inc(&num_spurious);
1095 } else if (sic_status & ivg->isrflag)
1101 asm_do_IRQ(vec, fp);