blob: 6bbca30c91884850e45cc07db24b4b17a00b06e5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001 /*
2 * linux/arch/m68k/sun3/sun3ints.c -- Sun-3(x) Linux interrupt handling code
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
7 */
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/types.h>
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/kernel_stat.h>
13#include <linux/interrupt.h>
14#include <asm/segment.h>
15#include <asm/intersil.h>
16#include <asm/oplib.h>
17#include <asm/sun3ints.h>
Al Viro2850bc22006-10-07 14:16:45 +010018#include <asm/irq_regs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/seq_file.h>
20
21extern void sun3_leds (unsigned char);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23void sun3_disable_interrupts(void)
24{
25 sun3_disable_irq(0);
26}
27
28void sun3_enable_interrupts(void)
29{
30 sun3_enable_irq(0);
31}
32
Adrian Bunk07b81252008-07-17 21:16:27 +020033static int led_pattern[8] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 ~(0x80), ~(0x01),
35 ~(0x40), ~(0x02),
36 ~(0x20), ~(0x04),
37 ~(0x10), ~(0x08)
38};
39
40volatile unsigned char* sun3_intreg;
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042void sun3_enable_irq(unsigned int irq)
43{
Roman Zippelebba61d2006-06-25 05:47:05 -070044 *sun3_intreg |= (1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045}
46
47void sun3_disable_irq(unsigned int irq)
48{
Roman Zippelebba61d2006-06-25 05:47:05 -070049 *sun3_intreg &= ~(1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Al Viro2850bc22006-10-07 14:16:45 +010052static irqreturn_t sun3_int7(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
Geert Uytterhoeven40455132011-08-18 22:46:01 +020054 unsigned int cnt;
55
Geert Uytterhoeven40455132011-08-18 22:46:01 +020056 cnt = kstat_irqs_cpu(irq, 0);
57 if (!(cnt % 2000))
58 sun3_leds(led_pattern[cnt % 16000 / 2000]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 return IRQ_HANDLED;
60}
61
Al Viro2850bc22006-10-07 14:16:45 +010062static irqreturn_t sun3_int5(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Geert Uytterhoeven40455132011-08-18 22:46:01 +020064 unsigned int cnt;
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#ifdef CONFIG_SUN3
67 intersil_clear();
68#endif
Thomas Bogendoerfer7f88d2c2012-11-11 13:28:33 +010069 sun3_disable_irq(5);
70 sun3_enable_irq(5);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#ifdef CONFIG_SUN3
72 intersil_clear();
73#endif
Torben Hohne53f2762011-01-27 16:00:06 +010074 xtime_update(1);
Al Viro2850bc22006-10-07 14:16:45 +010075 update_process_times(user_mode(get_irq_regs()));
Geert Uytterhoeven40455132011-08-18 22:46:01 +020076 cnt = kstat_irqs_cpu(irq, 0);
77 if (!(cnt % 20))
78 sun3_leds(led_pattern[cnt % 160 / 20]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 return IRQ_HANDLED;
80}
81
Al Viro2850bc22006-10-07 14:16:45 +010082static irqreturn_t sun3_vec255(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 return IRQ_HANDLED;
85}
86
Al Viro66a3f822007-07-20 04:33:28 +010087void __init sun3_init_IRQ(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 *sun3_intreg = 1;
90
Geert Uytterhoevenf30a6482011-09-11 11:54:50 +020091 m68k_setup_user_interrupt(VEC_USER, 128);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Thomas Bogendoerfer7f88d2c2012-11-11 13:28:33 +010093 if (request_irq(IRQ_AUTO_5, sun3_int5, 0, "clock", NULL))
Geert Uytterhoeven07e449b2008-12-30 14:05:24 +010094 pr_err("Couldn't register %s interrupt\n", "int5");
Thomas Bogendoerfer7f88d2c2012-11-11 13:28:33 +010095 if (request_irq(IRQ_AUTO_7, sun3_int7, 0, "nmi", NULL))
Geert Uytterhoeven07e449b2008-12-30 14:05:24 +010096 pr_err("Couldn't register %s interrupt\n", "int7");
97 if (request_irq(IRQ_USER+127, sun3_vec255, 0, "vec255", NULL))
98 pr_err("Couldn't register %s interrupt\n", "vec255");
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}