2 * Copyright 2005-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later
7 #include <linux/kernel_stat.h>
8 #include <linux/module.h>
9 #include <linux/random.h>
10 #include <linux/seq_file.h>
11 #include <linux/kallsyms.h>
12 #include <linux/interrupt.h>
13 #include <linux/irq.h>
14 #include <linux/seq_file.h>
15 #include <asm/irq_handler.h>
16 #include <asm/trace.h>
19 static atomic_t irq_err_count
;
20 void ack_bad_irq(unsigned int irq
)
22 atomic_inc(&irq_err_count
);
23 printk(KERN_ERR
"IRQ: spurious interrupt %d\n", irq
);
26 static struct irq_desc bad_irq_desc
= {
27 .handle_irq
= handle_bad_irq
,
28 .lock
= __RAW_SPIN_LOCK_UNLOCKED(bad_irq_desc
.lock
),
31 #ifdef CONFIG_CPUMASK_OFFSTACK
32 /* We are not allocating a variable-sized bad_irq_desc.affinity */
33 #error "Blackfin architecture does not support CONFIG_CPUMASK_OFFSTACK."
37 int arch_show_interrupts(struct seq_file
*p
, int prec
)
41 seq_printf(p
, "%*s: ", prec
, "NMI");
42 for_each_online_cpu(j
)
43 seq_printf(p
, "%10u ", cpu_pda
[j
].__nmi_count
);
44 seq_printf(p
, " CORE Non Maskable Interrupt\n");
45 seq_printf(p
, "%*s: %10u\n", prec
, "ERR", atomic_read(&irq_err_count
));
50 #ifdef CONFIG_DEBUG_STACKOVERFLOW
51 static void check_stack_overflow(int irq
)
53 /* Debugging check for stack overflow: is there less than STACK_WARN free? */
54 long sp
= __get_SP() & (THREAD_SIZE
- 1);
56 if (unlikely(sp
< (sizeof(struct thread_info
) + STACK_WARN
))) {
58 pr_emerg("irq%i: possible stack overflow only %ld bytes free\n",
59 irq
, sp
- sizeof(struct thread_info
));
63 static inline void check_stack_overflow(int irq
) { }
67 static void maybe_lower_to_irq14(void)
69 unsigned short pending
, other_ints
;
72 * If we're the only interrupt running (ignoring IRQ15 which
73 * is for syscalls), lower our priority to IRQ14 so that
74 * softirqs run at that level. If there's another,
75 * lower-level interrupt, irq_exit will defer softirqs to
76 * that. If the interrupt pipeline is enabled, we are already
77 * running at IRQ14 priority, so we don't need this code.
80 pending
= bfin_read_IPEND() & ~0x8000;
81 other_ints
= pending
& (pending
- 1);
86 static inline void maybe_lower_to_irq14(void) { }
90 * do_IRQ handles all hardware IRQs. Decoded IRQs should not
91 * come via this function. Instead, they should provide their
94 #ifdef CONFIG_DO_IRQ_L1
95 __attribute__((l1_text
))
97 asmlinkage
void asm_do_IRQ(unsigned int irq
, struct pt_regs
*regs
)
99 struct pt_regs
*old_regs
= set_irq_regs(regs
);
103 check_stack_overflow(irq
);
106 * Some hardware gives randomly wrong interrupts. Rather
107 * than crashing, do something sensible.
110 handle_bad_irq(&bad_irq_desc
);
112 generic_handle_irq(irq
);
114 maybe_lower_to_irq14();
118 set_irq_regs(old_regs
);
121 void __init
init_IRQ(void)
125 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
126 /* Now that evt_ivhw is set up, turn this on */
127 trace_buff_offset
= 0;
128 bfin_write_TBUFCTL(BFIN_TRACE_ON
);
129 printk(KERN_INFO
"Hardware Trace expanded to %ik\n",
130 1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN
);