diff options
Diffstat (limited to 'arch/mips/emma')
-rw-r--r-- | arch/mips/emma/Kconfig | 29 | ||||
-rw-r--r-- | arch/mips/emma/common/Makefile | 13 | ||||
-rw-r--r-- | arch/mips/emma/common/prom.c | 72 | ||||
-rw-r--r-- | arch/mips/emma/markeins/Makefile | 13 | ||||
-rw-r--r-- | arch/mips/emma/markeins/irq.c | 331 | ||||
-rw-r--r-- | arch/mips/emma/markeins/led.c | 60 | ||||
-rw-r--r-- | arch/mips/emma/markeins/platform.c | 191 | ||||
-rw-r--r-- | arch/mips/emma/markeins/setup.c | 135 |
8 files changed, 844 insertions, 0 deletions
diff --git a/arch/mips/emma/Kconfig b/arch/mips/emma/Kconfig new file mode 100644 index 000000000000..9669c72123c9 --- /dev/null +++ b/arch/mips/emma/Kconfig | |||
@@ -0,0 +1,29 @@ | |||
1 | choice | ||
2 | prompt "Machine type" | ||
3 | depends on MACH_EMMA | ||
4 | default NEC_MARKEINS | ||
5 | |||
6 | config NEC_MARKEINS | ||
7 | bool "NEC EMMA2RH Mark-eins board" | ||
8 | select SOC_EMMA2RH | ||
9 | select HW_HAS_PCI | ||
10 | help | ||
11 | This enables support for the NEC Electronics Mark-eins boards. | ||
12 | |||
13 | endchoice | ||
14 | |||
15 | config SOC_EMMA2RH | ||
16 | bool | ||
17 | select SOC_EMMA | ||
18 | select SYS_HAS_CPU_R5500 | ||
19 | select SYS_SUPPORTS_32BIT_KERNEL | ||
20 | select SYS_SUPPORTS_64BIT_KERNEL | ||
21 | |||
22 | config SOC_EMMA | ||
23 | bool | ||
24 | select CEVT_R4K | ||
25 | select CSRC_R4K | ||
26 | select DMA_NONCOHERENT | ||
27 | select IRQ_CPU | ||
28 | select SWAP_IO_SPACE | ||
29 | select SYS_SUPPORTS_BIG_ENDIAN | ||
diff --git a/arch/mips/emma/common/Makefile b/arch/mips/emma/common/Makefile new file mode 100644 index 000000000000..c392d28c1ef1 --- /dev/null +++ b/arch/mips/emma/common/Makefile | |||
@@ -0,0 +1,13 @@ | |||
1 | # | ||
2 | # arch/mips/emma2rh/common/Makefile | ||
3 | # Makefile for the common code of NEC EMMA2RH based board. | ||
4 | # | ||
5 | # Copyright (C) NEC Electronics Corporation 2005-2006 | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License as published by | ||
9 | # the Free Software Foundation; either version 2 of the License, or | ||
10 | # (at your option) any later version. | ||
11 | # | ||
12 | |||
13 | obj-$(CONFIG_NEC_MARKEINS) += prom.o | ||
diff --git a/arch/mips/emma/common/prom.c b/arch/mips/emma/common/prom.c new file mode 100644 index 000000000000..120f53fbdb45 --- /dev/null +++ b/arch/mips/emma/common/prom.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/common/prom.c | ||
3 | * This file is prom file. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2004-2006 | ||
6 | * | ||
7 | * This file is based on the arch/mips/ddb5xxx/common/prom.c | ||
8 | * | ||
9 | * Copyright 2001 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/mm.h> | ||
27 | #include <linux/sched.h> | ||
28 | #include <linux/bootmem.h> | ||
29 | |||
30 | #include <asm/addrspace.h> | ||
31 | #include <asm/bootinfo.h> | ||
32 | #include <asm/emma/emma2rh.h> | ||
33 | |||
34 | const char *get_system_type(void) | ||
35 | { | ||
36 | #ifdef CONFIG_NEC_MARKEINS | ||
37 | return "NEC EMMA2RH Mark-eins"; | ||
38 | #else | ||
39 | #error Unknown NEC board | ||
40 | #endif | ||
41 | } | ||
42 | |||
43 | /* [jsun@junsun.net] PMON passes arguments in C main() style */ | ||
44 | void __init prom_init(void) | ||
45 | { | ||
46 | int argc = fw_arg0; | ||
47 | char **arg = (char **)fw_arg1; | ||
48 | int i; | ||
49 | |||
50 | /* if user passes kernel args, ignore the default one */ | ||
51 | if (argc > 1) | ||
52 | arcs_cmdline[0] = '\0'; | ||
53 | |||
54 | /* arg[0] is "g", the rest is boot parameters */ | ||
55 | for (i = 1; i < argc; i++) { | ||
56 | if (strlen(arcs_cmdline) + strlen(arg[i] + 1) | ||
57 | >= sizeof(arcs_cmdline)) | ||
58 | break; | ||
59 | strcat(arcs_cmdline, arg[i]); | ||
60 | strcat(arcs_cmdline, " "); | ||
61 | } | ||
62 | |||
63 | #ifdef CONFIG_NEC_MARKEINS | ||
64 | add_memory_region(0, EMMA2RH_RAM_SIZE, BOOT_MEM_RAM); | ||
65 | #else | ||
66 | #error Unknown NEC board | ||
67 | #endif | ||
68 | } | ||
69 | |||
70 | void __init prom_free_prom_memory(void) | ||
71 | { | ||
72 | } | ||
diff --git a/arch/mips/emma/markeins/Makefile b/arch/mips/emma/markeins/Makefile new file mode 100644 index 000000000000..16e0017ba919 --- /dev/null +++ b/arch/mips/emma/markeins/Makefile | |||
@@ -0,0 +1,13 @@ | |||
1 | # | ||
2 | # arch/mips/emma2rh/markeins/Makefile | ||
3 | # Makefile for the common code of NEC EMMA2RH based board. | ||
4 | # | ||
5 | # Copyright (C) NEC Electronics Corporation 2005-2006 | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License as published by | ||
9 | # the Free Software Foundation; either version 2 of the License, or | ||
10 | # (at your option) any later version. | ||
11 | # | ||
12 | |||
13 | obj-$(CONFIG_NEC_MARKEINS) += irq.o setup.o led.o platform.o | ||
diff --git a/arch/mips/emma/markeins/irq.c b/arch/mips/emma/markeins/irq.c new file mode 100644 index 000000000000..c2583ecc93cf --- /dev/null +++ b/arch/mips/emma/markeins/irq.c | |||
@@ -0,0 +1,331 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/markeins/irq.c | ||
3 | * This file defines the irq handler for EMMA2RH. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2004-2006 | ||
6 | * | ||
7 | * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c | ||
8 | * | ||
9 | * Copyright 2001 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/irq.h> | ||
28 | #include <linux/types.h> | ||
29 | #include <linux/ptrace.h> | ||
30 | #include <linux/delay.h> | ||
31 | |||
32 | #include <asm/irq_cpu.h> | ||
33 | #include <asm/system.h> | ||
34 | #include <asm/mipsregs.h> | ||
35 | #include <asm/addrspace.h> | ||
36 | #include <asm/bootinfo.h> | ||
37 | |||
38 | #include <asm/emma/emma2rh.h> | ||
39 | |||
40 | static void emma2rh_irq_enable(unsigned int irq) | ||
41 | { | ||
42 | u32 reg_value; | ||
43 | u32 reg_bitmask; | ||
44 | u32 reg_index; | ||
45 | |||
46 | irq -= EMMA2RH_IRQ_BASE; | ||
47 | |||
48 | reg_index = EMMA2RH_BHIF_INT_EN_0 + | ||
49 | (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0) * (irq / 32); | ||
50 | reg_value = emma2rh_in32(reg_index); | ||
51 | reg_bitmask = 0x1 << (irq % 32); | ||
52 | emma2rh_out32(reg_index, reg_value | reg_bitmask); | ||
53 | } | ||
54 | |||
55 | static void emma2rh_irq_disable(unsigned int irq) | ||
56 | { | ||
57 | u32 reg_value; | ||
58 | u32 reg_bitmask; | ||
59 | u32 reg_index; | ||
60 | |||
61 | irq -= EMMA2RH_IRQ_BASE; | ||
62 | |||
63 | reg_index = EMMA2RH_BHIF_INT_EN_0 + | ||
64 | (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0) * (irq / 32); | ||
65 | reg_value = emma2rh_in32(reg_index); | ||
66 | reg_bitmask = 0x1 << (irq % 32); | ||
67 | emma2rh_out32(reg_index, reg_value & ~reg_bitmask); | ||
68 | } | ||
69 | |||
70 | struct irq_chip emma2rh_irq_controller = { | ||
71 | .name = "emma2rh_irq", | ||
72 | .ack = emma2rh_irq_disable, | ||
73 | .mask = emma2rh_irq_disable, | ||
74 | .mask_ack = emma2rh_irq_disable, | ||
75 | .unmask = emma2rh_irq_enable, | ||
76 | }; | ||
77 | |||
78 | void emma2rh_irq_init(void) | ||
79 | { | ||
80 | u32 i; | ||
81 | |||
82 | for (i = 0; i < NUM_EMMA2RH_IRQ; i++) | ||
83 | set_irq_chip_and_handler(EMMA2RH_IRQ_BASE + i, | ||
84 | &emma2rh_irq_controller, | ||
85 | handle_level_irq); | ||
86 | } | ||
87 | |||
88 | static void emma2rh_sw_irq_enable(unsigned int irq) | ||
89 | { | ||
90 | u32 reg; | ||
91 | |||
92 | irq -= EMMA2RH_SW_IRQ_BASE; | ||
93 | |||
94 | reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN); | ||
95 | reg |= 1 << irq; | ||
96 | emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg); | ||
97 | } | ||
98 | |||
99 | static void emma2rh_sw_irq_disable(unsigned int irq) | ||
100 | { | ||
101 | u32 reg; | ||
102 | |||
103 | irq -= EMMA2RH_SW_IRQ_BASE; | ||
104 | |||
105 | reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN); | ||
106 | reg &= ~(1 << irq); | ||
107 | emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg); | ||
108 | } | ||
109 | |||
110 | struct irq_chip emma2rh_sw_irq_controller = { | ||
111 | .name = "emma2rh_sw_irq", | ||
112 | .ack = emma2rh_sw_irq_disable, | ||
113 | .mask = emma2rh_sw_irq_disable, | ||
114 | .mask_ack = emma2rh_sw_irq_disable, | ||
115 | .unmask = emma2rh_sw_irq_enable, | ||
116 | }; | ||
117 | |||
118 | void emma2rh_sw_irq_init(void) | ||
119 | { | ||
120 | u32 i; | ||
121 | |||
122 | for (i = 0; i < NUM_EMMA2RH_IRQ_SW; i++) | ||
123 | set_irq_chip_and_handler(EMMA2RH_SW_IRQ_BASE + i, | ||
124 | &emma2rh_sw_irq_controller, | ||
125 | handle_level_irq); | ||
126 | } | ||
127 | |||
128 | static void emma2rh_gpio_irq_enable(unsigned int irq) | ||
129 | { | ||
130 | u32 reg; | ||
131 | |||
132 | irq -= EMMA2RH_GPIO_IRQ_BASE; | ||
133 | |||
134 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
135 | reg |= 1 << irq; | ||
136 | emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg); | ||
137 | } | ||
138 | |||
139 | static void emma2rh_gpio_irq_disable(unsigned int irq) | ||
140 | { | ||
141 | u32 reg; | ||
142 | |||
143 | irq -= EMMA2RH_GPIO_IRQ_BASE; | ||
144 | |||
145 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
146 | reg &= ~(1 << irq); | ||
147 | emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg); | ||
148 | } | ||
149 | |||
150 | static void emma2rh_gpio_irq_ack(unsigned int irq) | ||
151 | { | ||
152 | u32 reg; | ||
153 | |||
154 | irq -= EMMA2RH_GPIO_IRQ_BASE; | ||
155 | emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~(1 << irq)); | ||
156 | |||
157 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
158 | reg &= ~(1 << irq); | ||
159 | emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg); | ||
160 | } | ||
161 | |||
162 | static void emma2rh_gpio_irq_end(unsigned int irq) | ||
163 | { | ||
164 | u32 reg; | ||
165 | |||
166 | if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) { | ||
167 | |||
168 | irq -= EMMA2RH_GPIO_IRQ_BASE; | ||
169 | |||
170 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
171 | reg |= 1 << irq; | ||
172 | emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | struct irq_chip emma2rh_gpio_irq_controller = { | ||
177 | .name = "emma2rh_gpio_irq", | ||
178 | .ack = emma2rh_gpio_irq_ack, | ||
179 | .mask = emma2rh_gpio_irq_disable, | ||
180 | .mask_ack = emma2rh_gpio_irq_ack, | ||
181 | .unmask = emma2rh_gpio_irq_enable, | ||
182 | .end = emma2rh_gpio_irq_end, | ||
183 | }; | ||
184 | |||
185 | void emma2rh_gpio_irq_init(void) | ||
186 | { | ||
187 | u32 i; | ||
188 | |||
189 | for (i = 0; i < NUM_EMMA2RH_IRQ_GPIO; i++) | ||
190 | set_irq_chip(EMMA2RH_GPIO_IRQ_BASE + i, | ||
191 | &emma2rh_gpio_irq_controller); | ||
192 | } | ||
193 | |||
194 | static struct irqaction irq_cascade = { | ||
195 | .handler = no_action, | ||
196 | .flags = 0, | ||
197 | .mask = CPU_MASK_NONE, | ||
198 | .name = "cascade", | ||
199 | .dev_id = NULL, | ||
200 | .next = NULL, | ||
201 | }; | ||
202 | |||
203 | /* | ||
204 | * the first level int-handler will jump here if it is a emma2rh irq | ||
205 | */ | ||
206 | void emma2rh_irq_dispatch(void) | ||
207 | { | ||
208 | u32 intStatus; | ||
209 | u32 bitmask; | ||
210 | u32 i; | ||
211 | |||
212 | intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_0) & | ||
213 | emma2rh_in32(EMMA2RH_BHIF_INT_EN_0); | ||
214 | |||
215 | #ifdef EMMA2RH_SW_CASCADE | ||
216 | if (intStatus & | ||
217 | (1 << ((EMMA2RH_SW_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) { | ||
218 | u32 swIntStatus; | ||
219 | swIntStatus = emma2rh_in32(EMMA2RH_BHIF_SW_INT) | ||
220 | & emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN); | ||
221 | for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) { | ||
222 | if (swIntStatus & bitmask) { | ||
223 | do_IRQ(EMMA2RH_SW_IRQ_BASE + i); | ||
224 | return; | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | #endif | ||
229 | |||
230 | for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) { | ||
231 | if (intStatus & bitmask) { | ||
232 | do_IRQ(EMMA2RH_IRQ_BASE + i); | ||
233 | return; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_1) & | ||
238 | emma2rh_in32(EMMA2RH_BHIF_INT_EN_1); | ||
239 | |||
240 | #ifdef EMMA2RH_GPIO_CASCADE | ||
241 | if (intStatus & | ||
242 | (1 << ((EMMA2RH_GPIO_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) { | ||
243 | u32 gpioIntStatus; | ||
244 | gpioIntStatus = emma2rh_in32(EMMA2RH_GPIO_INT_ST) | ||
245 | & emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
246 | for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) { | ||
247 | if (gpioIntStatus & bitmask) { | ||
248 | do_IRQ(EMMA2RH_GPIO_IRQ_BASE + i); | ||
249 | return; | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | #endif | ||
254 | |||
255 | for (i = 32, bitmask = 1; i < 64; i++, bitmask <<= 1) { | ||
256 | if (intStatus & bitmask) { | ||
257 | do_IRQ(EMMA2RH_IRQ_BASE + i); | ||
258 | return; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_2) & | ||
263 | emma2rh_in32(EMMA2RH_BHIF_INT_EN_2); | ||
264 | |||
265 | for (i = 64, bitmask = 1; i < 96; i++, bitmask <<= 1) { | ||
266 | if (intStatus & bitmask) { | ||
267 | do_IRQ(EMMA2RH_IRQ_BASE + i); | ||
268 | return; | ||
269 | } | ||
270 | } | ||
271 | } | ||
272 | |||
273 | void __init arch_init_irq(void) | ||
274 | { | ||
275 | u32 reg; | ||
276 | |||
277 | /* by default, interrupts are disabled. */ | ||
278 | emma2rh_out32(EMMA2RH_BHIF_INT_EN_0, 0); | ||
279 | emma2rh_out32(EMMA2RH_BHIF_INT_EN_1, 0); | ||
280 | emma2rh_out32(EMMA2RH_BHIF_INT_EN_2, 0); | ||
281 | emma2rh_out32(EMMA2RH_BHIF_INT1_EN_0, 0); | ||
282 | emma2rh_out32(EMMA2RH_BHIF_INT1_EN_1, 0); | ||
283 | emma2rh_out32(EMMA2RH_BHIF_INT1_EN_2, 0); | ||
284 | emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, 0); | ||
285 | |||
286 | clear_c0_status(0xff00); | ||
287 | set_c0_status(0x0400); | ||
288 | |||
289 | #define GPIO_PCI (0xf<<15) | ||
290 | /* setup GPIO interrupt for PCI interface */ | ||
291 | /* direction input */ | ||
292 | reg = emma2rh_in32(EMMA2RH_GPIO_DIR); | ||
293 | emma2rh_out32(EMMA2RH_GPIO_DIR, reg & ~GPIO_PCI); | ||
294 | /* disable interrupt */ | ||
295 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
296 | emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg & ~GPIO_PCI); | ||
297 | /* level triggerd */ | ||
298 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_MODE); | ||
299 | emma2rh_out32(EMMA2RH_GPIO_INT_MODE, reg | GPIO_PCI); | ||
300 | reg = emma2rh_in32(EMMA2RH_GPIO_INT_CND_A); | ||
301 | emma2rh_out32(EMMA2RH_GPIO_INT_CND_A, reg & (~GPIO_PCI)); | ||
302 | /* interrupt clear */ | ||
303 | emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~GPIO_PCI); | ||
304 | |||
305 | /* init all controllers */ | ||
306 | emma2rh_irq_init(); | ||
307 | emma2rh_sw_irq_init(); | ||
308 | emma2rh_gpio_irq_init(); | ||
309 | mips_cpu_irq_init(); | ||
310 | |||
311 | /* setup cascade interrupts */ | ||
312 | setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_SW_CASCADE, &irq_cascade); | ||
313 | setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_GPIO_CASCADE, &irq_cascade); | ||
314 | setup_irq(CPU_IRQ_BASE + CPU_EMMA2RH_CASCADE, &irq_cascade); | ||
315 | } | ||
316 | |||
317 | asmlinkage void plat_irq_dispatch(void) | ||
318 | { | ||
319 | unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM; | ||
320 | |||
321 | if (pending & STATUSF_IP7) | ||
322 | do_IRQ(CPU_IRQ_BASE + 7); | ||
323 | else if (pending & STATUSF_IP2) | ||
324 | emma2rh_irq_dispatch(); | ||
325 | else if (pending & STATUSF_IP1) | ||
326 | do_IRQ(CPU_IRQ_BASE + 1); | ||
327 | else if (pending & STATUSF_IP0) | ||
328 | do_IRQ(CPU_IRQ_BASE + 0); | ||
329 | else | ||
330 | spurious_interrupt(); | ||
331 | } | ||
diff --git a/arch/mips/emma/markeins/led.c b/arch/mips/emma/markeins/led.c new file mode 100644 index 000000000000..377a181b6561 --- /dev/null +++ b/arch/mips/emma/markeins/led.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/markeins/led.c | ||
3 | * This file defines the led display for Mark-eins. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2004-2006 | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/types.h> | ||
23 | #include <linux/string.h> | ||
24 | #include <asm/emma/emma2rh.h> | ||
25 | |||
26 | const unsigned long clear = 0x20202020; | ||
27 | |||
28 | #define LED_BASE 0xb1400038 | ||
29 | |||
30 | void markeins_led_clear(void) | ||
31 | { | ||
32 | emma2rh_out32(LED_BASE, clear); | ||
33 | emma2rh_out32(LED_BASE + 4, clear); | ||
34 | } | ||
35 | |||
36 | void markeins_led(const char *str) | ||
37 | { | ||
38 | int i; | ||
39 | int len = strlen(str); | ||
40 | |||
41 | markeins_led_clear(); | ||
42 | if (len > 8) | ||
43 | len = 8; | ||
44 | |||
45 | if (emma2rh_in32(0xb0000800) & (0x1 << 18)) | ||
46 | for (i = 0; i < len; i++) | ||
47 | emma2rh_out8(LED_BASE + i, str[i]); | ||
48 | else | ||
49 | for (i = 0; i < len; i++) | ||
50 | emma2rh_out8(LED_BASE + (i & 4) + (3 - (i & 3)), | ||
51 | str[i]); | ||
52 | } | ||
53 | |||
54 | void markeins_led_hex(u32 val) | ||
55 | { | ||
56 | char str[10]; | ||
57 | |||
58 | sprintf(str, "%08x", val); | ||
59 | markeins_led(str); | ||
60 | } | ||
diff --git a/arch/mips/emma/markeins/platform.c b/arch/mips/emma/markeins/platform.c new file mode 100644 index 000000000000..88e87f6b3442 --- /dev/null +++ b/arch/mips/emma/markeins/platform.c | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/markeins/platofrm.c | ||
3 | * This file sets up platform devices for EMMA2RH Mark-eins. | ||
4 | * | ||
5 | * Copyright(C) MontaVista Software Inc, 2006 | ||
6 | * | ||
7 | * Author: dmitry pervushin <dpervushin@ru.mvista.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/ioport.h> | ||
27 | #include <linux/serial_8250.h> | ||
28 | #include <linux/mtd/physmap.h> | ||
29 | |||
30 | #include <asm/cpu.h> | ||
31 | #include <asm/bootinfo.h> | ||
32 | #include <asm/addrspace.h> | ||
33 | #include <asm/time.h> | ||
34 | #include <asm/bcache.h> | ||
35 | #include <asm/irq.h> | ||
36 | #include <asm/reboot.h> | ||
37 | #include <asm/traps.h> | ||
38 | |||
39 | #include <asm/emma/emma2rh.h> | ||
40 | |||
41 | |||
42 | #define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */ | ||
43 | |||
44 | static struct resource i2c_emma_resources_0[] = { | ||
45 | { | ||
46 | .name = NULL, | ||
47 | .start = EMMA2RH_IRQ_PIIC0, | ||
48 | .end = EMMA2RH_IRQ_PIIC0, | ||
49 | .flags = IORESOURCE_IRQ | ||
50 | }, { | ||
51 | .name = NULL, | ||
52 | .start = EMMA2RH_PIIC0_BASE, | ||
53 | .end = EMMA2RH_PIIC0_BASE + 0x1000, | ||
54 | .flags = 0 | ||
55 | }, | ||
56 | }; | ||
57 | |||
58 | struct resource i2c_emma_resources_1[] = { | ||
59 | { | ||
60 | .name = NULL, | ||
61 | .start = EMMA2RH_IRQ_PIIC1, | ||
62 | .end = EMMA2RH_IRQ_PIIC1, | ||
63 | .flags = IORESOURCE_IRQ | ||
64 | }, { | ||
65 | .name = NULL, | ||
66 | .start = EMMA2RH_PIIC1_BASE, | ||
67 | .end = EMMA2RH_PIIC1_BASE + 0x1000, | ||
68 | .flags = 0 | ||
69 | }, | ||
70 | }; | ||
71 | |||
72 | struct resource i2c_emma_resources_2[] = { | ||
73 | { | ||
74 | .name = NULL, | ||
75 | .start = EMMA2RH_IRQ_PIIC2, | ||
76 | .end = EMMA2RH_IRQ_PIIC2, | ||
77 | .flags = IORESOURCE_IRQ | ||
78 | }, { | ||
79 | .name = NULL, | ||
80 | .start = EMMA2RH_PIIC2_BASE, | ||
81 | .end = EMMA2RH_PIIC2_BASE + 0x1000, | ||
82 | .flags = 0 | ||
83 | }, | ||
84 | }; | ||
85 | |||
86 | struct platform_device i2c_emma_devices[] = { | ||
87 | [0] = { | ||
88 | .name = I2C_EMMA2RH, | ||
89 | .id = 0, | ||
90 | .resource = i2c_emma_resources_0, | ||
91 | .num_resources = ARRAY_SIZE(i2c_emma_resources_0), | ||
92 | }, | ||
93 | [1] = { | ||
94 | .name = I2C_EMMA2RH, | ||
95 | .id = 1, | ||
96 | .resource = i2c_emma_resources_1, | ||
97 | .num_resources = ARRAY_SIZE(i2c_emma_resources_1), | ||
98 | }, | ||
99 | [2] = { | ||
100 | .name = I2C_EMMA2RH, | ||
101 | .id = 2, | ||
102 | .resource = i2c_emma_resources_2, | ||
103 | .num_resources = ARRAY_SIZE(i2c_emma_resources_2), | ||
104 | }, | ||
105 | }; | ||
106 | |||
107 | #define EMMA2RH_SERIAL_CLOCK 18544000 | ||
108 | #define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | ||
109 | |||
110 | static struct plat_serial8250_port platform_serial_ports[] = { | ||
111 | [0] = { | ||
112 | .membase= (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3), | ||
113 | .irq = EMMA2RH_IRQ_PFUR0, | ||
114 | .uartclk = EMMA2RH_SERIAL_CLOCK, | ||
115 | .regshift = 4, | ||
116 | .iotype = UPIO_MEM, | ||
117 | .flags = EMMA2RH_SERIAL_FLAGS, | ||
118 | }, [1] = { | ||
119 | .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3), | ||
120 | .irq = EMMA2RH_IRQ_PFUR1, | ||
121 | .uartclk = EMMA2RH_SERIAL_CLOCK, | ||
122 | .regshift = 4, | ||
123 | .iotype = UPIO_MEM, | ||
124 | .flags = EMMA2RH_SERIAL_FLAGS, | ||
125 | }, [2] = { | ||
126 | .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3), | ||
127 | .irq = EMMA2RH_IRQ_PFUR2, | ||
128 | .uartclk = EMMA2RH_SERIAL_CLOCK, | ||
129 | .regshift = 4, | ||
130 | .iotype = UPIO_MEM, | ||
131 | .flags = EMMA2RH_SERIAL_FLAGS, | ||
132 | }, [3] = { | ||
133 | .flags = 0, | ||
134 | }, | ||
135 | }; | ||
136 | |||
137 | static struct platform_device serial_emma = { | ||
138 | .name = "serial8250", | ||
139 | .dev = { | ||
140 | .platform_data = &platform_serial_ports, | ||
141 | }, | ||
142 | }; | ||
143 | |||
144 | static struct platform_device *devices[] = { | ||
145 | &i2c_emma_devices[0], | ||
146 | &i2c_emma_devices[1], | ||
147 | &i2c_emma_devices[2], | ||
148 | &serial_emma, | ||
149 | }; | ||
150 | |||
151 | static struct mtd_partition markeins_parts[] = { | ||
152 | [0] = { | ||
153 | .name = "RootFS", | ||
154 | .offset = 0x00000000, | ||
155 | .size = 0x00c00000, | ||
156 | }, | ||
157 | [1] = { | ||
158 | .name = "boot code area", | ||
159 | .offset = MTDPART_OFS_APPEND, | ||
160 | .size = 0x00100000, | ||
161 | }, | ||
162 | [2] = { | ||
163 | .name = "kernel image", | ||
164 | .offset = MTDPART_OFS_APPEND, | ||
165 | .size = 0x00300000, | ||
166 | }, | ||
167 | [3] = { | ||
168 | .name = "RootFS2", | ||
169 | .offset = MTDPART_OFS_APPEND, | ||
170 | .size = 0x00c00000, | ||
171 | }, | ||
172 | [4] = { | ||
173 | .name = "boot code area2", | ||
174 | .offset = MTDPART_OFS_APPEND, | ||
175 | .size = 0x00100000, | ||
176 | }, | ||
177 | [5] = { | ||
178 | .name = "kernel image2", | ||
179 | .offset = MTDPART_OFS_APPEND, | ||
180 | .size = MTDPART_SIZ_FULL, | ||
181 | }, | ||
182 | }; | ||
183 | |||
184 | static int __init platform_devices_setup(void) | ||
185 | { | ||
186 | physmap_set_partitions(markeins_parts, ARRAY_SIZE(markeins_parts)); | ||
187 | return platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
188 | } | ||
189 | |||
190 | arch_initcall(platform_devices_setup); | ||
191 | |||
diff --git a/arch/mips/emma/markeins/setup.c b/arch/mips/emma/markeins/setup.c new file mode 100644 index 000000000000..67f456500084 --- /dev/null +++ b/arch/mips/emma/markeins/setup.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/markeins/setup.c | ||
3 | * This file is setup for EMMA2RH Mark-eins. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2004-2006 | ||
6 | * | ||
7 | * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c. | ||
8 | * | ||
9 | * Copyright 2001 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/types.h> | ||
28 | |||
29 | #include <asm/time.h> | ||
30 | #include <asm/reboot.h> | ||
31 | |||
32 | #include <asm/emma/emma2rh.h> | ||
33 | |||
34 | #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */ | ||
35 | |||
36 | extern void markeins_led(const char *); | ||
37 | |||
38 | static int bus_frequency = 0; | ||
39 | |||
40 | static void markeins_machine_restart(char *command) | ||
41 | { | ||
42 | static void (*back_to_prom) (void) = (void (*)(void))0xbfc00000; | ||
43 | |||
44 | printk("cannot EMMA2RH Mark-eins restart.\n"); | ||
45 | markeins_led("restart."); | ||
46 | back_to_prom(); | ||
47 | } | ||
48 | |||
49 | static void markeins_machine_halt(void) | ||
50 | { | ||
51 | printk("EMMA2RH Mark-eins halted.\n"); | ||
52 | markeins_led("halted."); | ||
53 | while (1) ; | ||
54 | } | ||
55 | |||
56 | static void markeins_machine_power_off(void) | ||
57 | { | ||
58 | printk("EMMA2RH Mark-eins halted. Please turn off the power.\n"); | ||
59 | markeins_led("poweroff."); | ||
60 | while (1) ; | ||
61 | } | ||
62 | |||
63 | static unsigned long __initdata emma2rh_clock[4] = { | ||
64 | 166500000, 187312500, 199800000, 210600000 | ||
65 | }; | ||
66 | |||
67 | static unsigned int __init detect_bus_frequency(unsigned long rtc_base) | ||
68 | { | ||
69 | u32 reg; | ||
70 | |||
71 | /* detect from boot strap */ | ||
72 | reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); | ||
73 | reg = (reg >> 4) & 0x3; | ||
74 | |||
75 | return emma2rh_clock[reg]; | ||
76 | } | ||
77 | |||
78 | void __init plat_time_init(void) | ||
79 | { | ||
80 | u32 reg; | ||
81 | if (bus_frequency == 0) | ||
82 | bus_frequency = detect_bus_frequency(0); | ||
83 | |||
84 | reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); | ||
85 | if ((reg & 0x3) == 0) | ||
86 | reg = (reg >> 6) & 0x3; | ||
87 | else { | ||
88 | reg = emma2rh_in32(EMMA2RH_BHIF_MAIN_CTRL); | ||
89 | reg = (reg >> 4) & 0x3; | ||
90 | } | ||
91 | mips_hpt_frequency = (bus_frequency * (4 + reg)) / 4 / 2; | ||
92 | } | ||
93 | |||
94 | static void markeins_board_init(void); | ||
95 | extern void markeins_irq_setup(void); | ||
96 | |||
97 | static void inline __init markeins_sio_setup(void) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | void __init plat_mem_setup(void) | ||
102 | { | ||
103 | /* initialize board - we don't trust the loader */ | ||
104 | markeins_board_init(); | ||
105 | |||
106 | set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE)); | ||
107 | |||
108 | _machine_restart = markeins_machine_restart; | ||
109 | _machine_halt = markeins_machine_halt; | ||
110 | pm_power_off = markeins_machine_power_off; | ||
111 | |||
112 | /* setup resource limits */ | ||
113 | ioport_resource.start = EMMA2RH_PCI_IO_BASE; | ||
114 | ioport_resource.end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1; | ||
115 | iomem_resource.start = EMMA2RH_IO_BASE; | ||
116 | iomem_resource.end = EMMA2RH_ROM_BASE - 1; | ||
117 | |||
118 | /* Reboot on panic */ | ||
119 | panic_timeout = 180; | ||
120 | |||
121 | markeins_sio_setup(); | ||
122 | } | ||
123 | |||
124 | static void __init markeins_board_init(void) | ||
125 | { | ||
126 | u32 val; | ||
127 | |||
128 | val = emma2rh_in32(EMMA2RH_PBRD_INT_EN); /* open serial interrupts. */ | ||
129 | emma2rh_out32(EMMA2RH_PBRD_INT_EN, val | 0xaa); | ||
130 | val = emma2rh_in32(EMMA2RH_PBRD_CLKSEL); /* set serial clocks. */ | ||
131 | emma2rh_out32(EMMA2RH_PBRD_CLKSEL, val | 0x5); /* 18MHz */ | ||
132 | emma2rh_out32(EMMA2RH_PCI_CONTROL, 0); | ||
133 | |||
134 | markeins_led("MVL E2RH"); | ||
135 | } | ||