diff options
author | Jayachandran C <jayachandranc@netlogicmicro.com> | 2011-05-06 16:06:40 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-05-19 04:55:40 -0400 |
commit | 5c642506740ecbf20fb7a9e482287e4e5c639e5c (patch) | |
tree | 1bf19bc57f06db54add1d2b4499b0f141919f9f7 /arch/mips/netlogic/xlr/irq.c | |
parent | efa0f81c11021c95b1e72c65868115b6fb4ecc6a (diff) |
MIPS: Platform files for XLR/XLS processor support
* include/asm/netlogic added with files common for all Netlogic processors
(common with XLP which will be added later)
* include/asm/netlogic/xlr for XLR/XLS chip specific files
* netlogic/xlr for XLR/XLS platform files
Signed-off-by: Jayachandran C <jayachandranc@netlogicmicro.com>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2334/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/netlogic/xlr/irq.c')
-rw-r--r-- | arch/mips/netlogic/xlr/irq.c | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/arch/mips/netlogic/xlr/irq.c b/arch/mips/netlogic/xlr/irq.c new file mode 100644 index 000000000000..2033f5656f68 --- /dev/null +++ b/arch/mips/netlogic/xlr/irq.c | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights | ||
3 | * reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the NetLogic | ||
9 | * license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer. | ||
17 | * 2. Redistributions in binary form must reproduce the above copyright | ||
18 | * notice, this list of conditions and the following disclaimer in | ||
19 | * the documentation and/or other materials provided with the | ||
20 | * distribution. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR | ||
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE | ||
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
30 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
32 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/init.h> | ||
37 | #include <linux/linkage.h> | ||
38 | #include <linux/interrupt.h> | ||
39 | #include <linux/spinlock.h> | ||
40 | #include <linux/mm.h> | ||
41 | |||
42 | #include <asm/mipsregs.h> | ||
43 | |||
44 | #include <asm/netlogic/xlr/iomap.h> | ||
45 | #include <asm/netlogic/xlr/pic.h> | ||
46 | #include <asm/netlogic/xlr/xlr.h> | ||
47 | |||
48 | #include <asm/netlogic/interrupt.h> | ||
49 | #include <asm/netlogic/mips-extns.h> | ||
50 | |||
51 | static u64 nlm_irq_mask; | ||
52 | static DEFINE_SPINLOCK(nlm_pic_lock); | ||
53 | |||
54 | static void xlr_pic_enable(struct irq_data *d) | ||
55 | { | ||
56 | nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); | ||
57 | unsigned long flags; | ||
58 | nlm_reg_t reg; | ||
59 | int irq = d->irq; | ||
60 | |||
61 | WARN(!PIC_IRQ_IS_IRT(irq), "Bad irq %d", irq); | ||
62 | |||
63 | spin_lock_irqsave(&nlm_pic_lock, flags); | ||
64 | reg = netlogic_read_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE); | ||
65 | netlogic_write_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE, | ||
66 | reg | (1 << 6) | (1 << 30) | (1 << 31)); | ||
67 | spin_unlock_irqrestore(&nlm_pic_lock, flags); | ||
68 | } | ||
69 | |||
70 | static void xlr_pic_mask(struct irq_data *d) | ||
71 | { | ||
72 | nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); | ||
73 | unsigned long flags; | ||
74 | nlm_reg_t reg; | ||
75 | int irq = d->irq; | ||
76 | |||
77 | WARN(!PIC_IRQ_IS_IRT(irq), "Bad irq %d", irq); | ||
78 | |||
79 | spin_lock_irqsave(&nlm_pic_lock, flags); | ||
80 | reg = netlogic_read_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE); | ||
81 | netlogic_write_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE, | ||
82 | reg | (1 << 6) | (1 << 30) | (0 << 31)); | ||
83 | spin_unlock_irqrestore(&nlm_pic_lock, flags); | ||
84 | } | ||
85 | |||
86 | static void xlr_pic_ack(struct irq_data *d) | ||
87 | { | ||
88 | unsigned long flags; | ||
89 | nlm_reg_t *mmio; | ||
90 | int irq = d->irq; | ||
91 | |||
92 | WARN(!PIC_IRQ_IS_IRT(irq), "Bad irq %d", irq); | ||
93 | |||
94 | mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); | ||
95 | spin_lock_irqsave(&nlm_pic_lock, flags); | ||
96 | netlogic_write_reg(mmio, PIC_INT_ACK, (1 << (irq - PIC_IRQ_BASE))); | ||
97 | spin_unlock_irqrestore(&nlm_pic_lock, flags); | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * This chip definition handles interrupts routed thru the XLR | ||
102 | * hardware PIC, currently IRQs 8-39 are mapped to hardware intr | ||
103 | * 0-31 wired the XLR PIC | ||
104 | */ | ||
105 | static struct irq_chip xlr_pic = { | ||
106 | .name = "XLR-PIC", | ||
107 | .irq_enable = xlr_pic_enable, | ||
108 | .irq_mask = xlr_pic_mask, | ||
109 | .irq_ack = xlr_pic_ack, | ||
110 | }; | ||
111 | |||
112 | static void rsvd_irq_handler(struct irq_data *d) | ||
113 | { | ||
114 | WARN(d->irq >= PIC_IRQ_BASE, "Bad irq %d", d->irq); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * Chip definition for CPU originated interrupts(timer, msg) and | ||
119 | * IPIs | ||
120 | */ | ||
121 | struct irq_chip nlm_cpu_intr = { | ||
122 | .name = "XLR-CPU-INTR", | ||
123 | .irq_enable = rsvd_irq_handler, | ||
124 | .irq_mask = rsvd_irq_handler, | ||
125 | .irq_ack = rsvd_irq_handler, | ||
126 | }; | ||
127 | |||
128 | void __init init_xlr_irqs(void) | ||
129 | { | ||
130 | nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); | ||
131 | uint32_t thread_mask = 1; | ||
132 | int level, i; | ||
133 | |||
134 | pr_info("Interrupt thread mask [%x]\n", thread_mask); | ||
135 | for (i = 0; i < PIC_NUM_IRTS; i++) { | ||
136 | level = PIC_IRQ_IS_EDGE_TRIGGERED(i); | ||
137 | |||
138 | /* Bind all PIC irqs to boot cpu */ | ||
139 | netlogic_write_reg(mmio, PIC_IRT_0_BASE + i, thread_mask); | ||
140 | |||
141 | /* | ||
142 | * Use local scheduling and high polarity for all IRTs | ||
143 | * Invalidate all IRTs, by default | ||
144 | */ | ||
145 | netlogic_write_reg(mmio, PIC_IRT_1_BASE + i, | ||
146 | (level << 30) | (1 << 6) | (PIC_IRQ_BASE + i)); | ||
147 | } | ||
148 | |||
149 | /* Make all IRQs as level triggered by default */ | ||
150 | for (i = 0; i < NR_IRQS; i++) { | ||
151 | if (PIC_IRQ_IS_IRT(i)) | ||
152 | irq_set_chip_and_handler(i, &xlr_pic, handle_level_irq); | ||
153 | else | ||
154 | irq_set_chip_and_handler(i, &nlm_cpu_intr, | ||
155 | handle_level_irq); | ||
156 | } | ||
157 | #ifdef CONFIG_SMP | ||
158 | irq_set_chip_and_handler(IRQ_IPI_SMP_FUNCTION, &nlm_cpu_intr, | ||
159 | nlm_smp_function_ipi_handler); | ||
160 | irq_set_chip_and_handler(IRQ_IPI_SMP_RESCHEDULE, &nlm_cpu_intr, | ||
161 | nlm_smp_resched_ipi_handler); | ||
162 | nlm_irq_mask |= | ||
163 | ((1ULL << IRQ_IPI_SMP_FUNCTION) | (1ULL << IRQ_IPI_SMP_RESCHEDULE)); | ||
164 | #endif | ||
165 | /* unmask all PIC related interrupts. If no handler is installed by the | ||
166 | * drivers, it'll just ack the interrupt and return | ||
167 | */ | ||
168 | for (i = PIC_IRT_FIRST_IRQ; i <= PIC_IRT_LAST_IRQ; i++) | ||
169 | nlm_irq_mask |= (1ULL << i); | ||
170 | |||
171 | nlm_irq_mask |= (1ULL << IRQ_TIMER); | ||
172 | } | ||
173 | |||
174 | void __init arch_init_irq(void) | ||
175 | { | ||
176 | /* Initialize the irq descriptors */ | ||
177 | init_xlr_irqs(); | ||
178 | write_c0_eimr(nlm_irq_mask); | ||
179 | } | ||
180 | |||
181 | void __cpuinit nlm_smp_irq_init(void) | ||
182 | { | ||
183 | /* set interrupt mask for non-zero cpus */ | ||
184 | write_c0_eimr(nlm_irq_mask); | ||
185 | } | ||
186 | |||
187 | asmlinkage void plat_irq_dispatch(void) | ||
188 | { | ||
189 | uint64_t eirr; | ||
190 | int i; | ||
191 | |||
192 | eirr = read_c0_eirr() & read_c0_eimr(); | ||
193 | if (!eirr) | ||
194 | return; | ||
195 | |||
196 | /* no need of EIRR here, writing compare clears interrupt */ | ||
197 | if (eirr & (1 << IRQ_TIMER)) { | ||
198 | do_IRQ(IRQ_TIMER); | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | /* TODO use dcltz: optimize below code */ | ||
203 | for (i = 63; i != -1; i--) { | ||
204 | if (eirr & (1ULL << i)) | ||
205 | break; | ||
206 | } | ||
207 | if (i == -1) { | ||
208 | pr_err("no interrupt !!\n"); | ||
209 | return; | ||
210 | } | ||
211 | |||
212 | /* Ack eirr */ | ||
213 | write_c0_eirr(1ULL << i); | ||
214 | |||
215 | do_IRQ(i); | ||
216 | } | ||