blob: b7e4025b58a83d940080154b3edb76f3807c9e09 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2003 Ralf Baechle
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * Handler for RM9000 extended interrupts. These are a non-standard
10 * feature so we handle them separately from standard interrupts.
11 */
12#include <linux/init.h>
13#include <linux/interrupt.h>
David Howellsca4d3e672010-10-07 14:08:54 +010014#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
16#include <linux/module.h>
17
18#include <asm/irq_cpu.h>
19#include <asm/mipsregs.h>
20#include <asm/system.h>
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022static inline void unmask_rm9k_irq(unsigned int irq)
23{
Atsushi Nemoto97dcb822007-01-08 02:14:29 +090024 set_c0_intcontrol(0x1000 << (irq - RM9K_CPU_IRQ_BASE));
Linus Torvalds1da177e2005-04-16 15:20:36 -070025}
26
27static inline void mask_rm9k_irq(unsigned int irq)
28{
Atsushi Nemoto97dcb822007-01-08 02:14:29 +090029 clear_c0_intcontrol(0x1000 << (irq - RM9K_CPU_IRQ_BASE));
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
32static inline void rm9k_cpu_irq_enable(unsigned int irq)
33{
34 unsigned long flags;
35
36 local_irq_save(flags);
37 unmask_rm9k_irq(irq);
38 local_irq_restore(flags);
39}
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/*
42 * Performance counter interrupts are global on all processors.
43 */
44static void local_rm9k_perfcounter_irq_startup(void *args)
45{
46 unsigned int irq = (unsigned int) args;
47
48 rm9k_cpu_irq_enable(irq);
49}
50
51static unsigned int rm9k_perfcounter_irq_startup(unsigned int irq)
52{
Jens Axboe15c8b6c2008-05-09 09:39:44 +020053 on_each_cpu(local_rm9k_perfcounter_irq_startup, (void *) irq, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 return 0;
56}
57
58static void local_rm9k_perfcounter_irq_shutdown(void *args)
59{
60 unsigned int irq = (unsigned int) args;
61 unsigned long flags;
62
63 local_irq_save(flags);
64 mask_rm9k_irq(irq);
65 local_irq_restore(flags);
66}
67
68static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
69{
Jens Axboe15c8b6c2008-05-09 09:39:44 +020070 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071}
72
Ralf Baechle94dee172006-07-02 14:41:42 +010073static struct irq_chip rm9k_irq_controller = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090074 .name = "RM9000",
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090075 .ack = mask_rm9k_irq,
76 .mask = mask_rm9k_irq,
77 .mask_ack = mask_rm9k_irq,
78 .unmask = unmask_rm9k_irq,
Thomas Koellerc42d95d2008-02-11 23:42:12 +010079 .eoi = unmask_rm9k_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -070080};
81
Ralf Baechle94dee172006-07-02 14:41:42 +010082static struct irq_chip rm9k_perfcounter_irq = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090083 .name = "RM9000",
Ralf Baechle8ab00b92005-02-28 13:39:57 +000084 .startup = rm9k_perfcounter_irq_startup,
85 .shutdown = rm9k_perfcounter_irq_shutdown,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090086 .ack = mask_rm9k_irq,
87 .mask = mask_rm9k_irq,
88 .mask_ack = mask_rm9k_irq,
89 .unmask = unmask_rm9k_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070090};
91
92unsigned int rm9000_perfcount_irq;
93
94EXPORT_SYMBOL(rm9000_perfcount_irq);
95
Atsushi Nemoto97dcb822007-01-08 02:14:29 +090096void __init rm9k_cpu_irq_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Atsushi Nemoto97dcb822007-01-08 02:14:29 +090098 int base = RM9K_CPU_IRQ_BASE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 int i;
100
101 clear_c0_intcontrol(0x0000f000); /* Mask all */
102
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900103 for (i = base; i < base + 4; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +0900104 set_irq_chip_and_handler(i, &rm9k_irq_controller,
105 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107 rm9000_perfcount_irq = base + 1;
Atsushi Nemoto14178362006-11-14 01:13:18 +0900108 set_irq_chip_and_handler(rm9000_perfcount_irq, &rm9k_perfcounter_irq,
Ralf Baechle30e748a2007-11-15 19:37:15 +0000109 handle_percpu_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110}