aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorHuacai Chen <chenhc@lemote.com>2014-03-21 06:44:04 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-03-31 12:17:12 -0400
commitd788bfa900748f3325894d18a763d1ba42326c28 (patch)
treef472705a13af83771f410b406af8e6954db9bd67 /arch/mips
parentc7d3555ac07503d471d0ef75495c7370f7ec7aa1 (diff)
MIPS: Loongson 3: Add IRQ init and dispatch support
IRQ routing path of Loongson-3: Devices(most) --> I8259 --> HT Controller --> IRQ Routing Table --> CPU ^ | Device(legacy devices such as UART) --> Bonito ---| IRQ Routing Table route 32 INTs to CPU's INT0~INT3(IP2~IP5 of CP0), 32 INTs include 16 HT INTs(mostly), 4 PCI INTs, 1 LPC INT, etc. IP6 is used for IPI and IP7 is used for internal MIPS timer. LOONGSON_INT_ROUTER_* are IRQ Routing Table registers. I8259 IRQs are 1:1 mapped to HT1 INTs. LOONGSON_HT1_* are configuration registers of HT1 controller. Signed-off-by: Huacai Chen <chenhc@lemote.com> Signed-off-by: Hongliang Tao <taohl@lemote.com> Signed-off-by: Hua Yan <yanh@lemote.com> Tested-by: Alex Smith <alex.smith@imgtec.com> Reviewed-by: Alex Smith <alex.smith@imgtec.com> Cc: John Crispin <john@phrozen.org> Cc: Steven J. Hill <Steven.Hill@imgtec.com> Cc: Aurelien Jarno <aurelien@aurel32.net> Cc: linux-mips@linux-mips.org Cc: Fuxin Zhang <zhangfx@lemote.com> Cc: Zhangjin Wu <wuzhangjin@gmail.com> Patchwork: https://patchwork.linux-mips.org/patch/6634 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/include/asm/mach-loongson/irq.h41
-rw-r--r--arch/mips/include/asm/mach-loongson/loongson.h10
-rw-r--r--arch/mips/loongson/Makefile6
-rw-r--r--arch/mips/loongson/loongson-3/Makefile4
-rw-r--r--arch/mips/loongson/loongson-3/irq.c96
5 files changed, 157 insertions, 0 deletions
diff --git a/arch/mips/include/asm/mach-loongson/irq.h b/arch/mips/include/asm/mach-loongson/irq.h
new file mode 100644
index 000000000000..29c2dff3aae8
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson/irq.h
@@ -0,0 +1,41 @@
1#ifndef __ASM_MACH_LOONGSON_IRQ_H_
2#define __ASM_MACH_LOONGSON_IRQ_H_
3
4#include <boot_param.h>
5
6#ifdef CONFIG_CPU_LOONGSON3
7
8/* cpu core interrupt numbers */
9#define MIPS_CPU_IRQ_BASE 56
10
11#define LOONGSON_UART_IRQ (MIPS_CPU_IRQ_BASE + 2) /* UART */
12#define LOONGSON_HT1_IRQ (MIPS_CPU_IRQ_BASE + 3) /* HT1 */
13#define LOONGSON_TIMER_IRQ (MIPS_CPU_IRQ_BASE + 7) /* CPU Timer */
14
15#define LOONGSON_HT1_CFG_BASE loongson_sysconf.ht_control_base
16#define LOONGSON_HT1_INT_VECTOR_BASE (LOONGSON_HT1_CFG_BASE + 0x80)
17#define LOONGSON_HT1_INT_EN_BASE (LOONGSON_HT1_CFG_BASE + 0xa0)
18#define LOONGSON_HT1_INT_VECTOR(n) \
19 LOONGSON3_REG32(LOONGSON_HT1_INT_VECTOR_BASE, 4 * (n))
20#define LOONGSON_HT1_INTN_EN(n) \
21 LOONGSON3_REG32(LOONGSON_HT1_INT_EN_BASE, 4 * (n))
22
23#define LOONGSON_INT_ROUTER_OFFSET 0x1400
24#define LOONGSON_INT_ROUTER_INTEN \
25 LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x24)
26#define LOONGSON_INT_ROUTER_INTENSET \
27 LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x28)
28#define LOONGSON_INT_ROUTER_INTENCLR \
29 LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x2c)
30#define LOONGSON_INT_ROUTER_ENTRY(n) \
31 LOONGSON3_REG8(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + n)
32#define LOONGSON_INT_ROUTER_LPC LOONGSON_INT_ROUTER_ENTRY(0x0a)
33#define LOONGSON_INT_ROUTER_HT1(n) LOONGSON_INT_ROUTER_ENTRY(n + 0x18)
34
35#define LOONGSON_INT_CORE0_INT0 0x11 /* route to int 0 of core 0 */
36#define LOONGSON_INT_CORE0_INT1 0x21 /* route to int 1 of core 0 */
37
38#endif
39
40#include_next <irq.h>
41#endif /* __ASM_MACH_LOONGSON_IRQ_H_ */
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index f0367ffbf8c1..69e9d9ea90c4 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -62,6 +62,12 @@ extern int mach_i8259_irq(void);
62#define LOONGSON_REG(x) \ 62#define LOONGSON_REG(x) \
63 (*(volatile u32 *)((char *)CKSEG1ADDR(LOONGSON_REG_BASE) + (x))) 63 (*(volatile u32 *)((char *)CKSEG1ADDR(LOONGSON_REG_BASE) + (x)))
64 64
65#define LOONGSON3_REG8(base, x) \
66 (*(volatile u8 *)((char *)TO_UNCAC(base) + (x)))
67
68#define LOONGSON3_REG32(base, x) \
69 (*(volatile u32 *)((char *)TO_UNCAC(base) + (x)))
70
65#define LOONGSON_IRQ_BASE 32 71#define LOONGSON_IRQ_BASE 32
66#define LOONGSON2_PERFCNT_IRQ (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */ 72#define LOONGSON2_PERFCNT_IRQ (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */
67 73
@@ -87,6 +93,10 @@ static inline void do_perfcnt_IRQ(void)
87#define LOONGSON_REG_BASE 0x1fe00000 93#define LOONGSON_REG_BASE 0x1fe00000
88#define LOONGSON_REG_SIZE 0x00100000 /* 256Bytes + 256Bytes + ??? */ 94#define LOONGSON_REG_SIZE 0x00100000 /* 256Bytes + 256Bytes + ??? */
89#define LOONGSON_REG_TOP (LOONGSON_REG_BASE+LOONGSON_REG_SIZE-1) 95#define LOONGSON_REG_TOP (LOONGSON_REG_BASE+LOONGSON_REG_SIZE-1)
96/* Loongson-3 specific registers */
97#define LOONGSON3_REG_BASE 0x3ff00000
98#define LOONGSON3_REG_SIZE 0x00100000 /* 256Bytes + 256Bytes + ??? */
99#define LOONGSON3_REG_TOP (LOONGSON3_REG_BASE+LOONGSON3_REG_SIZE-1)
90 100
91#define LOONGSON_LIO1_BASE 0x1ff00000 101#define LOONGSON_LIO1_BASE 0x1ff00000
92#define LOONGSON_LIO1_SIZE 0x00100000 /* 1M */ 102#define LOONGSON_LIO1_SIZE 0x00100000 /* 1M */
diff --git a/arch/mips/loongson/Makefile b/arch/mips/loongson/Makefile
index 0dc0055754cd..7429994e7604 100644
--- a/arch/mips/loongson/Makefile
+++ b/arch/mips/loongson/Makefile
@@ -15,3 +15,9 @@ obj-$(CONFIG_LEMOTE_FULOONG2E) += fuloong-2e/
15# 15#
16 16
17obj-$(CONFIG_LEMOTE_MACH2F) += lemote-2f/ 17obj-$(CONFIG_LEMOTE_MACH2F) += lemote-2f/
18
19#
20# All Loongson-3 family machines
21#
22
23obj-$(CONFIG_CPU_LOONGSON3) += loongson-3/
diff --git a/arch/mips/loongson/loongson-3/Makefile b/arch/mips/loongson/loongson-3/Makefile
new file mode 100644
index 000000000000..b9968cd1602e
--- /dev/null
+++ b/arch/mips/loongson/loongson-3/Makefile
@@ -0,0 +1,4 @@
1#
2# Makefile for Loongson-3 family machines
3#
4obj-y += irq.o
diff --git a/arch/mips/loongson/loongson-3/irq.c b/arch/mips/loongson/loongson-3/irq.c
new file mode 100644
index 000000000000..b2dc62b97a0f
--- /dev/null
+++ b/arch/mips/loongson/loongson-3/irq.c
@@ -0,0 +1,96 @@
1#include <loongson.h>
2#include <irq.h>
3#include <linux/interrupt.h>
4#include <linux/module.h>
5
6#include <asm/irq_cpu.h>
7#include <asm/i8259.h>
8#include <asm/mipsregs.h>
9
10unsigned int ht_irq[] = {1, 3, 4, 5, 6, 7, 8, 12, 14, 15};
11
12static void ht_irqdispatch(void)
13{
14 unsigned int i, irq;
15
16 irq = LOONGSON_HT1_INT_VECTOR(0);
17 LOONGSON_HT1_INT_VECTOR(0) = irq; /* Acknowledge the IRQs */
18
19 for (i = 0; i < ARRAY_SIZE(ht_irq); i++) {
20 if (irq & (0x1 << ht_irq[i]))
21 do_IRQ(ht_irq[i]);
22 }
23}
24
25void mach_irq_dispatch(unsigned int pending)
26{
27 if (pending & CAUSEF_IP7)
28 do_IRQ(LOONGSON_TIMER_IRQ);
29 else if (pending & CAUSEF_IP3)
30 ht_irqdispatch();
31 else if (pending & CAUSEF_IP2)
32 do_IRQ(LOONGSON_UART_IRQ);
33 else {
34 pr_err("%s : spurious interrupt\n", __func__);
35 spurious_interrupt();
36 }
37}
38
39static struct irqaction cascade_irqaction = {
40 .handler = no_action,
41 .name = "cascade",
42};
43
44static inline void mask_loongson_irq(struct irq_data *d)
45{
46 clear_c0_status(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
47 irq_disable_hazard();
48}
49
50static inline void unmask_loongson_irq(struct irq_data *d)
51{
52 set_c0_status(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
53 irq_enable_hazard();
54}
55
56 /* For MIPS IRQs which shared by all cores */
57static struct irq_chip loongson_irq_chip = {
58 .name = "Loongson",
59 .irq_ack = mask_loongson_irq,
60 .irq_mask = mask_loongson_irq,
61 .irq_mask_ack = mask_loongson_irq,
62 .irq_unmask = unmask_loongson_irq,
63 .irq_eoi = unmask_loongson_irq,
64};
65
66void irq_router_init(void)
67{
68 int i;
69
70 /* route LPC int to cpu core0 int 0 */
71 LOONGSON_INT_ROUTER_LPC = LOONGSON_INT_CORE0_INT0;
72 /* route HT1 int0 ~ int7 to cpu core0 INT1*/
73 for (i = 0; i < 8; i++)
74 LOONGSON_INT_ROUTER_HT1(i) = LOONGSON_INT_CORE0_INT1;
75 /* enable HT1 interrupt */
76 LOONGSON_HT1_INTN_EN(0) = 0xffffffff;
77 /* enable router interrupt intenset */
78 LOONGSON_INT_ROUTER_INTENSET =
79 LOONGSON_INT_ROUTER_INTEN | (0xffff << 16) | 0x1 << 10;
80}
81
82void __init mach_init_irq(void)
83{
84 clear_c0_status(ST0_IM | ST0_BEV);
85
86 irq_router_init();
87 mips_cpu_irq_init();
88 init_i8259_irqs();
89 irq_set_chip_and_handler(LOONGSON_UART_IRQ,
90 &loongson_irq_chip, handle_level_irq);
91
92 /* setup HT1 irq */
93 setup_irq(LOONGSON_HT1_IRQ, &cascade_irqaction);
94
95 set_c0_status(STATUSF_IP2 | STATUSF_IP6);
96}