Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #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 Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 18 | #include <asm/irq_regs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/seq_file.h> |
| 20 | |
| 21 | extern void sun3_leds (unsigned char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | void sun3_disable_interrupts(void) |
| 24 | { |
| 25 | sun3_disable_irq(0); |
| 26 | } |
| 27 | |
| 28 | void sun3_enable_interrupts(void) |
| 29 | { |
| 30 | sun3_enable_irq(0); |
| 31 | } |
| 32 | |
Adrian Bunk | 07b8125 | 2008-07-17 21:16:27 +0200 | [diff] [blame] | 33 | static int led_pattern[8] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | ~(0x80), ~(0x01), |
| 35 | ~(0x40), ~(0x02), |
| 36 | ~(0x20), ~(0x04), |
| 37 | ~(0x10), ~(0x08) |
| 38 | }; |
| 39 | |
| 40 | volatile unsigned char* sun3_intreg; |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | void sun3_enable_irq(unsigned int irq) |
| 43 | { |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 44 | *sun3_intreg |= (1 << irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void sun3_disable_irq(unsigned int irq) |
| 48 | { |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 49 | *sun3_intreg &= ~(1 << irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 52 | static irqreturn_t sun3_int7(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Geert Uytterhoeven | 4045513 | 2011-08-18 22:46:01 +0200 | [diff] [blame^] | 54 | unsigned int cnt; |
| 55 | |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 56 | *sun3_intreg |= (1 << irq); |
Geert Uytterhoeven | 4045513 | 2011-08-18 22:46:01 +0200 | [diff] [blame^] | 57 | cnt = kstat_irqs_cpu(irq, 0); |
| 58 | if (!(cnt % 2000)) |
| 59 | sun3_leds(led_pattern[cnt % 16000 / 2000]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | return IRQ_HANDLED; |
| 61 | } |
| 62 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 63 | static irqreturn_t sun3_int5(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { |
Geert Uytterhoeven | 4045513 | 2011-08-18 22:46:01 +0200 | [diff] [blame^] | 65 | unsigned int cnt; |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #ifdef CONFIG_SUN3 |
| 68 | intersil_clear(); |
| 69 | #endif |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 70 | *sun3_intreg |= (1 << irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | #ifdef CONFIG_SUN3 |
| 72 | intersil_clear(); |
| 73 | #endif |
Torben Hohn | e53f276 | 2011-01-27 16:00:06 +0100 | [diff] [blame] | 74 | xtime_update(1); |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 75 | update_process_times(user_mode(get_irq_regs())); |
Geert Uytterhoeven | 4045513 | 2011-08-18 22:46:01 +0200 | [diff] [blame^] | 76 | cnt = kstat_irqs_cpu(irq, 0); |
| 77 | if (!(cnt % 20)) |
| 78 | sun3_leds(led_pattern[cnt % 160 / 20]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | return IRQ_HANDLED; |
| 80 | } |
| 81 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 82 | static irqreturn_t sun3_vec255(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { |
| 84 | // intersil_clear(); |
| 85 | return IRQ_HANDLED; |
| 86 | } |
| 87 | |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 88 | static void sun3_inthandle(unsigned int irq, struct pt_regs *fp) |
| 89 | { |
| 90 | *sun3_intreg &= ~(1 << irq); |
| 91 | |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 92 | do_IRQ(irq, fp); |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame] | 95 | static void sun3_irq_enable(struct irq_data *data) |
| 96 | { |
| 97 | sun3_enable_irq(data->irq); |
| 98 | }; |
| 99 | |
| 100 | static void sun3_irq_disable(struct irq_data *data) |
| 101 | { |
| 102 | sun3_disable_irq(data->irq); |
| 103 | }; |
| 104 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 105 | static struct irq_chip sun3_irq_chip = { |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 106 | .name = "sun3", |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 107 | .irq_startup = m68k_irq_startup, |
| 108 | .irq_shutdown = m68k_irq_shutdown, |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame] | 109 | .irq_enable = sun3_irq_enable, |
| 110 | .irq_disable = sun3_irq_disable, |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
Al Viro | 66a3f82 | 2007-07-20 04:33:28 +0100 | [diff] [blame] | 113 | void __init sun3_init_IRQ(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | *sun3_intreg = 1; |
| 116 | |
Roman Zippel | ebba61d | 2006-06-25 05:47:05 -0700 | [diff] [blame] | 117 | m68k_setup_auto_interrupt(sun3_inthandle); |
Geert Uytterhoeven | edb3472 | 2011-06-01 11:15:21 +0200 | [diff] [blame] | 118 | m68k_setup_irq_controller(&sun3_irq_chip, handle_simple_irq, |
| 119 | IRQ_AUTO_1, 7); |
Sam Creasey | 35bdd52 | 2007-05-01 22:32:47 +0200 | [diff] [blame] | 120 | m68k_setup_user_interrupt(VEC_USER, 128, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Geert Uytterhoeven | 07e449b | 2008-12-30 14:05:24 +0100 | [diff] [blame] | 122 | if (request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL)) |
| 123 | pr_err("Couldn't register %s interrupt\n", "int5"); |
| 124 | if (request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL)) |
| 125 | pr_err("Couldn't register %s interrupt\n", "int7"); |
| 126 | if (request_irq(IRQ_USER+127, sun3_vec255, 0, "vec255", NULL)) |
| 127 | pr_err("Couldn't register %s interrupt\n", "vec255"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | } |