2 * File: arch/blackfin/mach-common/ints-priority.c
7 * Description: Set up the interrupt priorities
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>
16 * Copyright 2004-2008 Analog Devices Inc.
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
36 #include <linux/module.h>
37 #include <linux/kernel_stat.h>
38 #include <linux/seq_file.h>
39 #include <linux/irq.h>
41 #include <linux/kgdb.h>
43 #include <asm/traps.h>
44 #include <asm/blackfin.h>
46 #include <asm/irq_handler.h>
49 # define BF537_GENERIC_ERROR_INT_DEMUX
51 # undef BF537_GENERIC_ERROR_INT_DEMUX
56 * - we have separated the physical Hardware interrupt from the
57 * levels that the LINUX kernel sees (see the description in irq.h)
61 /* Initialize this to an actual value to force it into the .data
62 * section so that we know it is properly initialized at entry into
63 * the kernel but before bss is initialized to zero (which is where
64 * it would live otherwise). The 0x1f magic represents the IRQs we
65 * cannot actually mask out in hardware.
67 unsigned long irq_flags
= 0x1f;
69 /* The number of spurious interrupts */
70 atomic_t num_spurious
;
73 unsigned long bfin_sic_iwr
[3]; /* Up to 3 SIC_IWRx registers */
77 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
78 /* irq number for request_irq, available in mach-bf533/irq.h */
80 /* irq number for request_irq, available in mach-bf5xx/irq.h */
81 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
83 /* corresponding bit in the SIC_ISR register */
85 } ivg_table
[NR_PERI_INTS
];
88 /* position of first irq in ivg_table for given ivg */
91 } ivg7_13
[IVG13
- IVG7
+ 1];
93 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
94 static void search_IAR(void);
96 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
99 * Search SIC_IAR and fill tables with the irqvalues
100 * and their positions in the SIC_ISR register.
102 static void __init
search_IAR(void)
104 unsigned ivg
, irq_pos
= 0;
105 for (ivg
= 0; ivg
<= IVG13
- IVG7
; ivg
++) {
108 ivg7_13
[ivg
].istop
= ivg7_13
[ivg
].ifirst
= &ivg_table
[irq_pos
];
110 for (irqn
= 0; irqn
< NR_PERI_INTS
; irqn
++) {
111 int iar_shift
= (irqn
& 7) * 4;
114 bfin_read32((unsigned long *)SIC_IAR0
+
115 (irqn
>> 3)) >> iar_shift
)) {
117 bfin_read32((unsigned long *)SIC_IAR0
+
118 ((irqn
%32) >> 3) + ((irqn
/ 32) * 16)) >> iar_shift
)) {
120 ivg_table
[irq_pos
].irqno
= IVG7
+ irqn
;
121 ivg_table
[irq_pos
].isrflag
= 1 << (irqn
% 32);
122 ivg7_13
[ivg
].istop
++;
130 <<<<<<< HEAD:arch/blackfin/mach-common/ints-priority.c
131 * This is for BF533 internal IRQs
133 * This is for core internal IRQs
134 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/blackfin/mach-common/ints-priority.c
137 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
138 static void ack_noop(unsigned int irq
)
140 static void bfin_ack_noop(unsigned int irq
)
141 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
143 /* Dummy function. */
146 static void bfin_core_mask_irq(unsigned int irq
)
148 irq_flags
&= ~(1 << irq
);
149 if (!irqs_disabled())
153 static void bfin_core_unmask_irq(unsigned int irq
)
155 irq_flags
|= 1 << irq
;
157 * If interrupts are enabled, IMASK must contain the same value
158 * as irq_flags. Make sure that invariant holds. If interrupts
159 * are currently disabled we need not do anything; one of the
160 * callers will take care of setting IMASK to the proper value
161 * when reenabling interrupts.
162 * local_irq_enable just does "STI irq_flags", so it's exactly
165 if (!irqs_disabled())
170 static void bfin_internal_mask_irq(unsigned int irq
)
173 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
174 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
175 ~(1 << (irq
- (IRQ_CORETMR
+ 1))));
177 ~(1 << SIC_SYSIRQ(irq
)));
178 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
180 unsigned mask_bank
, mask_bit
;
181 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
182 mask_bank
= (irq
- (IRQ_CORETMR
+ 1)) / 32;
183 mask_bit
= (irq
- (IRQ_CORETMR
+ 1)) % 32;
185 mask_bank
= SIC_SYSIRQ(irq
) / 32;
186 mask_bit
= SIC_SYSIRQ(irq
) % 32;
187 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
188 bfin_write_SIC_IMASK(mask_bank
, bfin_read_SIC_IMASK(mask_bank
) &
194 static void bfin_internal_unmask_irq(unsigned int irq
)
197 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() |
198 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
199 (1 << (irq
- (IRQ_CORETMR
+ 1))));
201 (1 << SIC_SYSIRQ(irq
)));
202 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
204 unsigned mask_bank
, mask_bit
;
205 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
206 mask_bank
= (irq
- (IRQ_CORETMR
+ 1)) / 32;
207 mask_bit
= (irq
- (IRQ_CORETMR
+ 1)) % 32;
209 mask_bank
= SIC_SYSIRQ(irq
) / 32;
210 mask_bit
= SIC_SYSIRQ(irq
) % 32;
211 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
212 bfin_write_SIC_IMASK(mask_bank
, bfin_read_SIC_IMASK(mask_bank
) |
219 int bfin_internal_set_wake(unsigned int irq
, unsigned int state
)
223 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
224 bank
= (irq
- (IRQ_CORETMR
+ 1)) / 32;
225 bit
= (irq
- (IRQ_CORETMR
+ 1)) % 32;
227 bank
= SIC_SYSIRQ(irq
) / 32;
228 bit
= SIC_SYSIRQ(irq
) % 32;
229 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
231 local_irq_save(flags
);
234 bfin_sic_iwr
[bank
] |= (1 << bit
);
236 bfin_sic_iwr
[bank
] &= ~(1 << bit
);
238 local_irq_restore(flags
);
244 static struct irq_chip bfin_core_irqchip
= {
245 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
248 .ack
= bfin_ack_noop
,
249 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
250 .mask
= bfin_core_mask_irq
,
251 .unmask
= bfin_core_unmask_irq
,
254 static struct irq_chip bfin_internal_irqchip
= {
255 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
258 .ack
= bfin_ack_noop
,
259 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
260 .mask
= bfin_internal_mask_irq
,
261 .unmask
= bfin_internal_unmask_irq
,
262 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
264 .mask_ack
= bfin_internal_mask_irq
,
265 .disable
= bfin_internal_mask_irq
,
266 .enable
= bfin_internal_unmask_irq
,
267 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
269 .set_wake
= bfin_internal_set_wake
,
273 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
274 static int error_int_mask
;
276 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
277 static void bfin_generic_error_ack_irq(unsigned int irq
)
283 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
284 static void bfin_generic_error_mask_irq(unsigned int irq
)
286 error_int_mask
&= ~(1L << (irq
- IRQ_PPI_ERROR
));
288 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
289 if (!error_int_mask
) {
291 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
292 ~(1 << (IRQ_GENERIC_ERROR
-
293 (IRQ_CORETMR
+ 1))));
299 bfin_internal_mask_irq(IRQ_GENERIC_ERROR
);
300 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
303 static void bfin_generic_error_unmask_irq(unsigned int irq
)
305 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
307 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | 1 <<
308 (IRQ_GENERIC_ERROR
- (IRQ_CORETMR
+ 1)));
313 bfin_internal_unmask_irq(IRQ_GENERIC_ERROR
);
314 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
315 error_int_mask
|= 1L << (irq
- IRQ_PPI_ERROR
);
318 static struct irq_chip bfin_generic_error_irqchip
= {
319 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
320 .ack
= bfin_generic_error_ack_irq
,
322 .ack
= bfin_ack_noop
,
323 .mask_ack
= bfin_generic_error_mask_irq
,
324 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
325 .mask
= bfin_generic_error_mask_irq
,
326 .unmask
= bfin_generic_error_unmask_irq
,
329 static void bfin_demux_error_irq(unsigned int int_err_irq
,
330 struct irq_desc
*inta_desc
)
336 #if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
337 if (bfin_read_EMAC_SYSTAT() & EMAC_ERR_MASK
)
341 if (bfin_read_SPORT0_STAT() & SPORT_ERR_MASK
)
342 irq
= IRQ_SPORT0_ERROR
;
343 else if (bfin_read_SPORT1_STAT() & SPORT_ERR_MASK
)
344 irq
= IRQ_SPORT1_ERROR
;
345 else if (bfin_read_PPI_STATUS() & PPI_ERR_MASK
)
347 else if (bfin_read_CAN_GIF() & CAN_ERR_MASK
)
349 else if (bfin_read_SPI_STAT() & SPI_ERR_MASK
)
351 else if ((bfin_read_UART0_IIR() & UART_ERR_MASK_STAT1
) &&
352 (bfin_read_UART0_IIR() & UART_ERR_MASK_STAT0
))
353 irq
= IRQ_UART0_ERROR
;
354 else if ((bfin_read_UART1_IIR() & UART_ERR_MASK_STAT1
) &&
355 (bfin_read_UART1_IIR() & UART_ERR_MASK_STAT0
))
356 irq
= IRQ_UART1_ERROR
;
359 if (error_int_mask
& (1L << (irq
- IRQ_PPI_ERROR
))) {
360 struct irq_desc
*desc
= irq_desc
+ irq
;
361 desc
->handle_irq(irq
, desc
);
366 bfin_write_PPI_STATUS(PPI_ERR_MASK
);
368 #if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
370 bfin_write_EMAC_SYSTAT(EMAC_ERR_MASK
);
373 case IRQ_SPORT0_ERROR
:
374 bfin_write_SPORT0_STAT(SPORT_ERR_MASK
);
377 case IRQ_SPORT1_ERROR
:
378 bfin_write_SPORT1_STAT(SPORT_ERR_MASK
);
382 bfin_write_CAN_GIS(CAN_ERR_MASK
);
386 bfin_write_SPI_STAT(SPI_ERR_MASK
);
394 " MASKED PERIPHERAL ERROR INTERRUPT ASSERTED\n",
399 "%s : %s : LINE %d :\nIRQ ?: PERIPHERAL ERROR"
400 " INTERRUPT ASSERTED BUT NO SOURCE FOUND\n",
401 __FUNCTION__
, __FILE__
, __LINE__
);
404 #endif /* BF537_GENERIC_ERROR_INT_DEMUX */
406 #if !defined(CONFIG_BF54x)
408 static unsigned short gpio_enabled
[gpio_bank(MAX_BLACKFIN_GPIOS
)];
409 static unsigned short gpio_edge_triggered
[gpio_bank(MAX_BLACKFIN_GPIOS
)];
412 static void bfin_gpio_ack_irq(unsigned int irq
)
414 u16 gpionr
= irq
- IRQ_PF0
;
416 if (gpio_edge_triggered
[gpio_bank(gpionr
)] & gpio_bit(gpionr
)) {
417 set_gpio_data(gpionr
, 0);
422 static void bfin_gpio_mask_ack_irq(unsigned int irq
)
424 u16 gpionr
= irq
- IRQ_PF0
;
426 if (gpio_edge_triggered
[gpio_bank(gpionr
)] & gpio_bit(gpionr
)) {
427 set_gpio_data(gpionr
, 0);
431 set_gpio_maska(gpionr
, 0);
435 static void bfin_gpio_mask_irq(unsigned int irq
)
437 set_gpio_maska(irq
- IRQ_PF0
, 0);
441 static void bfin_gpio_unmask_irq(unsigned int irq
)
443 set_gpio_maska(irq
- IRQ_PF0
, 1);
447 static unsigned int bfin_gpio_irq_startup(unsigned int irq
)
450 u16 gpionr
= irq
- IRQ_PF0
;
453 if (!(gpio_enabled
[gpio_bank(gpionr
)] & gpio_bit(gpionr
))) {
454 snprintf(buf
, sizeof buf
, "IRQ %d", irq
);
455 ret
= gpio_request(gpionr
, buf
);
460 gpio_enabled
[gpio_bank(gpionr
)] |= gpio_bit(gpionr
);
461 bfin_gpio_unmask_irq(irq
);
466 static void bfin_gpio_irq_shutdown(unsigned int irq
)
468 bfin_gpio_mask_irq(irq
);
469 gpio_free(irq
- IRQ_PF0
);
470 gpio_enabled
[gpio_bank(irq
- IRQ_PF0
)] &= ~gpio_bit(irq
- IRQ_PF0
);
473 static int bfin_gpio_irq_type(unsigned int irq
, unsigned int type
)
478 u16 gpionr
= irq
- IRQ_PF0
;
480 if (type
== IRQ_TYPE_PROBE
) {
481 /* only probe unenabled GPIO interrupt lines */
482 if (gpio_enabled
[gpio_bank(gpionr
)] & gpio_bit(gpionr
))
484 type
= IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
;
487 if (type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
|
488 IRQ_TYPE_LEVEL_HIGH
| IRQ_TYPE_LEVEL_LOW
)) {
489 if (!(gpio_enabled
[gpio_bank(gpionr
)] & gpio_bit(gpionr
))) {
490 snprintf(buf
, sizeof buf
, "IRQ %d", irq
);
491 ret
= gpio_request(gpionr
, buf
);
496 gpio_enabled
[gpio_bank(gpionr
)] |= gpio_bit(gpionr
);
498 gpio_enabled
[gpio_bank(gpionr
)] &= ~gpio_bit(gpionr
);
502 set_gpio_inen(gpionr
, 0);
503 set_gpio_dir(gpionr
, 0);
505 if ((type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
))
506 == (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
))
507 set_gpio_both(gpionr
, 1);
509 set_gpio_both(gpionr
, 0);
511 if ((type
& (IRQ_TYPE_EDGE_FALLING
| IRQ_TYPE_LEVEL_LOW
)))
512 set_gpio_polar(gpionr
, 1); /* low or falling edge denoted by one */
514 set_gpio_polar(gpionr
, 0); /* high or rising edge denoted by zero */
516 if (type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
)) {
517 set_gpio_edge(gpionr
, 1);
518 set_gpio_inen(gpionr
, 1);
519 gpio_edge_triggered
[gpio_bank(gpionr
)] |= gpio_bit(gpionr
);
520 set_gpio_data(gpionr
, 0);
523 set_gpio_edge(gpionr
, 0);
524 gpio_edge_triggered
[gpio_bank(gpionr
)] &= ~gpio_bit(gpionr
);
525 set_gpio_inen(gpionr
, 1);
530 if (type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
))
531 set_irq_handler(irq
, handle_edge_irq
);
533 set_irq_handler(irq
, handle_level_irq
);
539 int bfin_gpio_set_wake(unsigned int irq
, unsigned int state
)
541 unsigned gpio
= irq_to_gpio(irq
);
544 gpio_pm_wakeup_request(gpio
, PM_WAKE_IGNORE
);
546 gpio_pm_wakeup_free(gpio
);
552 static struct irq_chip bfin_gpio_irqchip
= {
553 .ack
= bfin_gpio_ack_irq
,
554 .mask
= bfin_gpio_mask_irq
,
555 .mask_ack
= bfin_gpio_mask_ack_irq
,
556 .unmask
= bfin_gpio_unmask_irq
,
557 .set_type
= bfin_gpio_irq_type
,
558 .startup
= bfin_gpio_irq_startup
,
559 .shutdown
= bfin_gpio_irq_shutdown
,
561 .set_wake
= bfin_gpio_set_wake
,
565 static void bfin_demux_gpio_irq(unsigned int inta_irq
,
566 struct irq_desc
*desc
)
568 unsigned int i
, gpio
, mask
, irq
, search
= 0;
571 #if defined(CONFIG_BF53x)
576 # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
581 #elif defined(CONFIG_BF52x)
591 #elif defined(CONFIG_BF561)
608 for (i
= 0; i
< MAX_BLACKFIN_GPIOS
; i
+= GPIO_BANKSIZE
) {
611 mask
= get_gpiop_data(i
) &
612 (gpio_enabled
[gpio_bank(i
)] &
617 desc
= irq_desc
+ irq
;
618 desc
->handle_irq(irq
, desc
);
625 gpio
= irq_to_gpio(irq
);
626 mask
= get_gpiop_data(gpio
) &
627 (gpio_enabled
[gpio_bank(gpio
)] &
628 get_gpiop_maska(gpio
));
632 desc
= irq_desc
+ irq
;
633 desc
->handle_irq(irq
, desc
);
642 #else /* CONFIG_BF54x */
644 #define NR_PINT_SYS_IRQS 4
645 #define NR_PINT_BITS 32
647 #define IRQ_NOT_AVAIL 0xFF
649 #define PINT_2_BANK(x) ((x) >> 5)
650 #define PINT_2_BIT(x) ((x) & 0x1F)
651 #define PINT_BIT(x) (1 << (PINT_2_BIT(x)))
653 static unsigned char irq2pint_lut
[NR_PINTS
];
654 static unsigned char pint2irq_lut
[NR_PINT_SYS_IRQS
* NR_PINT_BITS
];
656 static unsigned int gpio_both_edge_triggered
[NR_PINT_SYS_IRQS
];
657 static unsigned short gpio_enabled
[gpio_bank(MAX_BLACKFIN_GPIOS
)];
661 unsigned int mask_set
;
662 unsigned int mask_clear
;
663 unsigned int request
;
665 unsigned int edge_set
;
666 unsigned int edge_clear
;
667 unsigned int invert_set
;
668 unsigned int invert_clear
;
669 unsigned int pinstate
;
673 static struct pin_int_t
*pint
[NR_PINT_SYS_IRQS
] = {
674 (struct pin_int_t
*)PINT0_MASK_SET
,
675 (struct pin_int_t
*)PINT1_MASK_SET
,
676 (struct pin_int_t
*)PINT2_MASK_SET
,
677 (struct pin_int_t
*)PINT3_MASK_SET
,
680 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
681 unsigned short get_irq_base(u8 bank
, u8 bmap
)
683 inline unsigned short get_irq_base(u8 bank
, u8 bmap
)
684 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
689 if (bank
< 2) { /*PA-PB */
690 irq_base
= IRQ_PA0
+ bmap
* 16;
692 irq_base
= IRQ_PC0
+ bmap
* 16;
699 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
700 void init_pint_lut(void)
702 u16 bank
, bit
, irq_base
, bit_pos
;
706 memset(irq2pint_lut
, IRQ_NOT_AVAIL
, sizeof(irq2pint_lut
));
708 for (bank
= 0; bank
< NR_PINT_SYS_IRQS
; bank
++) {
710 pint_assign
= pint
[bank
]->assign
;
712 for (bit
= 0; bit
< NR_PINT_BITS
; bit
++) {
714 bmap
= (pint_assign
>> ((bit
/ 8) * 8)) & 0xFF;
716 irq_base
= get_irq_base(bank
, bmap
);
718 irq_base
+= (bit
% 8) + ((bit
/ 8) & 1 ? 8 : 0);
719 bit_pos
= bit
+ bank
* NR_PINT_BITS
;
721 pint2irq_lut
[bit_pos
] = irq_base
- SYS_IRQS
;
722 irq2pint_lut
[irq_base
- SYS_IRQS
] = bit_pos
;
730 static void bfin_gpio_ack_irq(unsigned int irq
)
732 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
733 u32 pintbit
= PINT_BIT(pint_val
);
734 u8 bank
= PINT_2_BANK(pint_val
);
736 if (unlikely(gpio_both_edge_triggered
[bank
] & pintbit
)) {
737 if (pint
[bank
]->invert_set
& pintbit
)
738 pint
[bank
]->invert_clear
= pintbit
;
740 pint
[bank
]->invert_set
= pintbit
;
742 pint
[bank
]->request
= pintbit
;
747 static void bfin_gpio_mask_ack_irq(unsigned int irq
)
749 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
750 u32 pintbit
= PINT_BIT(pint_val
);
751 u8 bank
= PINT_2_BANK(pint_val
);
753 if (unlikely(gpio_both_edge_triggered
[bank
] & pintbit
)) {
754 if (pint
[bank
]->invert_set
& pintbit
)
755 pint
[bank
]->invert_clear
= pintbit
;
757 pint
[bank
]->invert_set
= pintbit
;
760 pint
[bank
]->request
= pintbit
;
761 pint
[bank
]->mask_clear
= pintbit
;
765 static void bfin_gpio_mask_irq(unsigned int irq
)
767 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
769 pint
[PINT_2_BANK(pint_val
)]->mask_clear
= PINT_BIT(pint_val
);
773 static void bfin_gpio_unmask_irq(unsigned int irq
)
775 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
776 u32 pintbit
= PINT_BIT(pint_val
);
777 u8 bank
= PINT_2_BANK(pint_val
);
779 pint
[bank
]->request
= pintbit
;
780 pint
[bank
]->mask_set
= pintbit
;
784 static unsigned int bfin_gpio_irq_startup(unsigned int irq
)
788 u16 gpionr
= irq_to_gpio(irq
);
789 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
791 if (pint_val
== IRQ_NOT_AVAIL
) {
793 "GPIO IRQ %d :Not in PINT Assign table "
794 "Reconfigure Interrupt to Port Assignemt\n", irq
);
798 if (!(gpio_enabled
[gpio_bank(gpionr
)] & gpio_bit(gpionr
))) {
799 snprintf(buf
, sizeof buf
, "IRQ %d", irq
);
800 ret
= gpio_request(gpionr
, buf
);
805 gpio_enabled
[gpio_bank(gpionr
)] |= gpio_bit(gpionr
);
806 bfin_gpio_unmask_irq(irq
);
811 static void bfin_gpio_irq_shutdown(unsigned int irq
)
813 u16 gpionr
= irq_to_gpio(irq
);
815 bfin_gpio_mask_irq(irq
);
817 gpio_enabled
[gpio_bank(gpionr
)] &= ~gpio_bit(gpionr
);
820 static int bfin_gpio_irq_type(unsigned int irq
, unsigned int type
)
825 u16 gpionr
= irq_to_gpio(irq
);
826 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
827 u32 pintbit
= PINT_BIT(pint_val
);
828 u8 bank
= PINT_2_BANK(pint_val
);
830 if (pint_val
== IRQ_NOT_AVAIL
)
833 if (type
== IRQ_TYPE_PROBE
) {
834 /* only probe unenabled GPIO interrupt lines */
835 if (gpio_enabled
[gpio_bank(gpionr
)] & gpio_bit(gpionr
))
837 type
= IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
;
840 if (type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
|
841 IRQ_TYPE_LEVEL_HIGH
| IRQ_TYPE_LEVEL_LOW
)) {
842 if (!(gpio_enabled
[gpio_bank(gpionr
)] & gpio_bit(gpionr
))) {
843 snprintf(buf
, sizeof buf
, "IRQ %d", irq
);
844 ret
= gpio_request(gpionr
, buf
);
849 gpio_enabled
[gpio_bank(gpionr
)] |= gpio_bit(gpionr
);
851 gpio_enabled
[gpio_bank(gpionr
)] &= ~gpio_bit(gpionr
);
855 gpio_direction_input(gpionr
);
857 if ((type
& (IRQ_TYPE_EDGE_FALLING
| IRQ_TYPE_LEVEL_LOW
)))
858 pint
[bank
]->invert_set
= pintbit
; /* low or falling edge denoted by one */
860 pint
[bank
]->invert_clear
= pintbit
; /* high or rising edge denoted by zero */
862 if ((type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
))
863 == (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
)) {
865 gpio_both_edge_triggered
[bank
] |= pintbit
;
867 if (gpio_get_value(gpionr
))
868 pint
[bank
]->invert_set
= pintbit
;
870 pint
[bank
]->invert_clear
= pintbit
;
872 gpio_both_edge_triggered
[bank
] &= ~pintbit
;
875 if (type
& (IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
)) {
876 pint
[bank
]->edge_set
= pintbit
;
877 set_irq_handler(irq
, handle_edge_irq
);
879 pint
[bank
]->edge_clear
= pintbit
;
880 set_irq_handler(irq
, handle_level_irq
);
889 u32 pint_saved_masks
[NR_PINT_SYS_IRQS
];
890 u32 pint_wakeup_masks
[NR_PINT_SYS_IRQS
];
892 int bfin_gpio_set_wake(unsigned int irq
, unsigned int state
)
895 u8 pint_val
= irq2pint_lut
[irq
- SYS_IRQS
];
896 u32 bank
= PINT_2_BANK(pint_val
);
897 u32 pintbit
= PINT_BIT(pint_val
);
901 pint_irq
= IRQ_PINT0
;
904 pint_irq
= IRQ_PINT2
;
907 pint_irq
= IRQ_PINT3
;
910 pint_irq
= IRQ_PINT1
;
916 bfin_internal_set_wake(pint_irq
, state
);
919 pint_wakeup_masks
[bank
] |= pintbit
;
921 pint_wakeup_masks
[bank
] &= ~pintbit
;
926 u32
bfin_pm_setup(void)
930 for (i
= 0; i
< NR_PINT_SYS_IRQS
; i
++) {
931 val
= pint
[i
]->mask_clear
;
932 pint_saved_masks
[i
] = val
;
933 if (val
^ pint_wakeup_masks
[i
]) {
934 pint
[i
]->mask_clear
= val
;
935 pint
[i
]->mask_set
= pint_wakeup_masks
[i
];
942 void bfin_pm_restore(void)
946 for (i
= 0; i
< NR_PINT_SYS_IRQS
; i
++) {
947 val
= pint_saved_masks
[i
];
948 if (val
^ pint_wakeup_masks
[i
]) {
949 pint
[i
]->mask_clear
= pint
[i
]->mask_clear
;
950 pint
[i
]->mask_set
= val
;
956 static struct irq_chip bfin_gpio_irqchip
= {
957 .ack
= bfin_gpio_ack_irq
,
958 .mask
= bfin_gpio_mask_irq
,
959 .mask_ack
= bfin_gpio_mask_ack_irq
,
960 .unmask
= bfin_gpio_unmask_irq
,
961 .set_type
= bfin_gpio_irq_type
,
962 .startup
= bfin_gpio_irq_startup
,
963 .shutdown
= bfin_gpio_irq_shutdown
,
965 .set_wake
= bfin_gpio_set_wake
,
969 static void bfin_demux_gpio_irq(unsigned int inta_irq
,
970 struct irq_desc
*desc
)
992 pint_val
= bank
* NR_PINT_BITS
;
994 request
= pint
[bank
]->request
;
998 irq
= pint2irq_lut
[pint_val
] + SYS_IRQS
;
999 desc
= irq_desc
+ irq
;
1000 desc
->handle_irq(irq
, desc
);
1009 void __init
init_exception_vectors(void)
1013 /* cannot program in software:
1014 * evt0 - emulation (jtag)
1017 bfin_write_EVT2(evt_nmi
);
1018 bfin_write_EVT3(trap
);
1019 bfin_write_EVT5(evt_ivhw
);
1020 bfin_write_EVT6(evt_timer
);
1021 bfin_write_EVT7(evt_evt7
);
1022 bfin_write_EVT8(evt_evt8
);
1023 bfin_write_EVT9(evt_evt9
);
1024 bfin_write_EVT10(evt_evt10
);
1025 bfin_write_EVT11(evt_evt11
);
1026 bfin_write_EVT12(evt_evt12
);
1027 bfin_write_EVT13(evt_evt13
);
1028 bfin_write_EVT14(evt14_softirq
);
1029 bfin_write_EVT15(evt_system_call
);
1034 * This function should be called during kernel startup to initialize
1035 * the BFin IRQ handling routines.
1037 int __init
init_arch_irq(void)
1040 unsigned long ilat
= 0;
1041 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
1042 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
1043 bfin_write_SIC_IMASK0(SIC_UNMASK_ALL
);
1044 bfin_write_SIC_IMASK1(SIC_UNMASK_ALL
);
1045 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1046 bfin_write_SIC_IWR0(IWR_ENABLE_ALL
);
1047 bfin_write_SIC_IWR1(IWR_ENABLE_ALL
);
1049 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1050 # ifdef CONFIG_BF54x
1051 bfin_write_SIC_IMASK2(SIC_UNMASK_ALL
);
1052 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1053 bfin_write_SIC_IWR2(IWR_ENABLE_ALL
);
1055 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1058 bfin_write_SIC_IMASK(SIC_UNMASK_ALL
);
1059 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1060 bfin_write_SIC_IWR(IWR_ENABLE_ALL
);
1062 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1064 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1067 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1069 local_irq_disable();
1071 init_exception_buff();
1074 # ifdef CONFIG_PINTx_REASSIGN
1075 pint
[0]->assign
= CONFIG_PINT0_ASSIGN
;
1076 pint
[1]->assign
= CONFIG_PINT1_ASSIGN
;
1077 pint
[2]->assign
= CONFIG_PINT2_ASSIGN
;
1078 pint
[3]->assign
= CONFIG_PINT3_ASSIGN
;
1080 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
1084 for (irq
= 0; irq
<= SYS_IRQS
; irq
++) {
1085 if (irq
<= IRQ_CORETMR
)
1086 set_irq_chip(irq
, &bfin_core_irqchip
);
1088 set_irq_chip(irq
, &bfin_internal_irqchip
);
1089 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1090 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
1091 if (irq
!= IRQ_GENERIC_ERROR
) {
1094 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1096 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1100 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1101 #if defined(CONFIG_BF53x)
1102 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1104 set_irq_chained_handler(irq
,
1105 bfin_demux_gpio_irq
);
1109 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1110 # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
1111 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1113 set_irq_chained_handler(irq
,
1114 bfin_demux_gpio_irq
);
1118 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1120 #elif defined(CONFIG_BF54x)
1121 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1123 set_irq_chained_handler(irq
,
1124 bfin_demux_gpio_irq
);
1127 set_irq_chained_handler(irq
,
1128 bfin_demux_gpio_irq
);
1131 set_irq_chained_handler(irq
,
1132 bfin_demux_gpio_irq
);
1135 set_irq_chained_handler(irq
,
1136 bfin_demux_gpio_irq
);
1143 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1144 #elif defined(CONFIG_BF52x)
1145 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1146 case IRQ_PORTF_INTA
:
1147 set_irq_chained_handler(irq
,
1148 bfin_demux_gpio_irq
);
1150 case IRQ_PORTG_INTA
:
1151 set_irq_chained_handler(irq
,
1152 bfin_demux_gpio_irq
);
1154 case IRQ_PORTH_INTA
:
1155 set_irq_chained_handler(irq
,
1156 bfin_demux_gpio_irq
);
1159 case IRQ_PORTF_INTA
:
1160 case IRQ_PORTG_INTA
:
1161 case IRQ_PORTH_INTA
:
1162 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1163 #elif defined(CONFIG_BF561)
1164 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1165 case IRQ_PROG0_INTA
:
1166 set_irq_chained_handler(irq
,
1167 bfin_demux_gpio_irq
);
1169 case IRQ_PROG1_INTA
:
1170 set_irq_chained_handler(irq
,
1171 bfin_demux_gpio_irq
);
1173 case IRQ_PROG2_INTA
:
1174 set_irq_chained_handler(irq
,
1175 bfin_demux_gpio_irq
);
1178 case IRQ_PROG0_INTA
:
1179 case IRQ_PROG1_INTA
:
1180 case IRQ_PROG2_INTA
:
1181 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1183 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1185 set_irq_handler(irq
, handle_simple_irq
);
1190 set_irq_chained_handler(irq
,
1191 bfin_demux_gpio_irq
);
1193 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1194 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
1195 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1198 case IRQ_GENERIC_ERROR
:
1199 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1200 set_irq_handler(irq
, bfin_demux_error_irq
);
1201 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1206 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1208 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1211 set_irq_handler(irq
, handle_simple_irq
);
1214 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1216 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1219 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1220 #ifdef BF537_GENERIC_ERROR_INT_DEMUX
1221 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1222 for (irq
= IRQ_PPI_ERROR
; irq
<= IRQ_UART1_ERROR
; irq
++) {
1223 set_irq_chip(irq
, &bfin_generic_error_irqchip
);
1224 set_irq_handler(irq
, handle_level_irq
);
1227 for (irq
= IRQ_PPI_ERROR
; irq
<= IRQ_UART1_ERROR
; irq
++)
1228 set_irq_chip_and_handler(irq
, &bfin_generic_error_irqchip
,
1230 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1233 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1234 for (irq
= GPIO_IRQ_BASE
; irq
< NR_IRQS
; irq
++) {
1236 /* if configured as edge, then will be changed to do_edge_IRQ */
1237 for (irq
= GPIO_IRQ_BASE
; irq
< NR_IRQS
; irq
++)
1238 set_irq_chip_and_handler(irq
, &bfin_gpio_irqchip
,
1240 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1242 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1243 set_irq_chip(irq
, &bfin_gpio_irqchip
);
1244 /* if configured as edge, then will be changed to do_edge_IRQ */
1245 set_irq_handler(irq
, handle_level_irq
);
1248 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1250 bfin_write_IMASK(0);
1252 ilat
= bfin_read_ILAT();
1254 bfin_write_ILAT(ilat
);
1257 printk(KERN_INFO
"Configuring Blackfin Priority Driven Interrupts\n");
1258 /* IMASK=xxx is equivalent to STI xx or irq_flags=xx,
1259 * local_irq_enable()
1262 /* Therefore it's better to setup IARs before interrupts enabled */
1265 /* Enable interrupts IVG7-15 */
1266 irq_flags
= irq_flags
| IMASK_IVG15
|
1267 IMASK_IVG14
| IMASK_IVG13
| IMASK_IVG12
| IMASK_IVG11
|
1268 IMASK_IVG10
| IMASK_IVG9
| IMASK_IVG8
| IMASK_IVG7
| IMASK_IVGHW
;
1270 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1272 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
1273 bfin_write_SIC_IWR0(IWR_ENABLE_ALL
);
1274 bfin_write_SIC_IWR1(IWR_ENABLE_ALL
);
1275 # ifdef CONFIG_BF54x
1276 bfin_write_SIC_IWR2(IWR_ENABLE_ALL
);
1279 bfin_write_SIC_IWR(IWR_ENABLE_ALL
);
1282 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1286 #ifdef CONFIG_DO_IRQ_L1
1287 __attribute__((l1_text
))
1289 void do_irq(int vec
, struct pt_regs
*fp
)
1291 if (vec
== EVT_IVTMR_P
) {
1294 struct ivgx
*ivg
= ivg7_13
[vec
- IVG7
].ifirst
;
1295 struct ivgx
*ivg_stop
= ivg7_13
[vec
- IVG7
].istop
;
1296 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
1297 unsigned long sic_status
[3];
1299 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1302 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1303 sic_status
[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0();
1304 sic_status
[1] = bfin_read_SIC_ISR1() & bfin_read_SIC_IMASK1();
1306 sic_status
[2] = bfin_read_SIC_ISR2() & bfin_read_SIC_IMASK2();
1309 if (ivg
>= ivg_stop
) {
1310 atomic_inc(&num_spurious
);
1313 if (sic_status
[(ivg
->irqno
- IVG7
) / 32] & ivg
->isrflag
)
1317 unsigned long sic_status
;
1318 <<<<<<< HEAD
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1322 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/blackfin
/mach
-common
/ints
-priority
.c
1323 sic_status
= bfin_read_SIC_IMASK() & bfin_read_SIC_ISR();
1326 if (ivg
>= ivg_stop
) {
1327 atomic_inc(&num_spurious
);
1329 } else if (sic_status
& ivg
->isrflag
)
1335 asm_do_IRQ(vec
, fp
);
1338 kgdb_process_breakpoint();