2 * SH-X3 Prototype Setup
4 * Copyright (C) 2007 - 2009 Paul Mundt
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
10 #include <linux/platform_device.h>
11 #include <linux/init.h>
12 #include <linux/serial.h>
13 #include <linux/serial_sci.h>
15 #include <linux/sh_timer.h>
16 #include <asm/mmzone.h>
18 static struct plat_sci_port sci_platform_data
[] = {
20 .mapbase
= 0xffc30000,
21 .flags
= UPF_BOOT_AUTOCONF
,
23 .irqs
= { 40, 41, 43, 42 },
25 .mapbase
= 0xffc40000,
26 .flags
= UPF_BOOT_AUTOCONF
,
28 .irqs
= { 44, 45, 47, 46 },
30 .mapbase
= 0xffc50000,
31 .flags
= UPF_BOOT_AUTOCONF
,
33 .irqs
= { 48, 49, 51, 50 },
35 .mapbase
= 0xffc60000,
36 .flags
= UPF_BOOT_AUTOCONF
,
38 .irqs
= { 52, 53, 55, 54 },
44 static struct platform_device sci_device
= {
48 .platform_data
= sci_platform_data
,
52 static struct sh_timer_config tmu0_platform_data
= {
54 .channel_offset
= 0x04,
56 .clk
= "peripheral_clk",
57 .clockevent_rating
= 200,
60 static struct resource tmu0_resources
[] = {
65 .flags
= IORESOURCE_MEM
,
69 .flags
= IORESOURCE_IRQ
,
73 static struct platform_device tmu0_device
= {
77 .platform_data
= &tmu0_platform_data
,
79 .resource
= tmu0_resources
,
80 .num_resources
= ARRAY_SIZE(tmu0_resources
),
83 static struct sh_timer_config tmu1_platform_data
= {
85 .channel_offset
= 0x10,
87 .clk
= "peripheral_clk",
88 .clocksource_rating
= 200,
91 static struct resource tmu1_resources
[] = {
96 .flags
= IORESOURCE_MEM
,
100 .flags
= IORESOURCE_IRQ
,
104 static struct platform_device tmu1_device
= {
108 .platform_data
= &tmu1_platform_data
,
110 .resource
= tmu1_resources
,
111 .num_resources
= ARRAY_SIZE(tmu1_resources
),
114 static struct sh_timer_config tmu2_platform_data
= {
116 .channel_offset
= 0x1c,
118 .clk
= "peripheral_clk",
121 static struct resource tmu2_resources
[] = {
126 .flags
= IORESOURCE_MEM
,
130 .flags
= IORESOURCE_IRQ
,
134 static struct platform_device tmu2_device
= {
138 .platform_data
= &tmu2_platform_data
,
140 .resource
= tmu2_resources
,
141 .num_resources
= ARRAY_SIZE(tmu2_resources
),
144 static struct sh_timer_config tmu3_platform_data
= {
146 .channel_offset
= 0x04,
148 .clk
= "peripheral_clk",
151 static struct resource tmu3_resources
[] = {
156 .flags
= IORESOURCE_MEM
,
160 .flags
= IORESOURCE_IRQ
,
164 static struct platform_device tmu3_device
= {
168 .platform_data
= &tmu3_platform_data
,
170 .resource
= tmu3_resources
,
171 .num_resources
= ARRAY_SIZE(tmu3_resources
),
174 static struct sh_timer_config tmu4_platform_data
= {
176 .channel_offset
= 0x10,
178 .clk
= "peripheral_clk",
181 static struct resource tmu4_resources
[] = {
186 .flags
= IORESOURCE_MEM
,
190 .flags
= IORESOURCE_IRQ
,
194 static struct platform_device tmu4_device
= {
198 .platform_data
= &tmu4_platform_data
,
200 .resource
= tmu4_resources
,
201 .num_resources
= ARRAY_SIZE(tmu4_resources
),
204 static struct sh_timer_config tmu5_platform_data
= {
206 .channel_offset
= 0x1c,
208 .clk
= "peripheral_clk",
211 static struct resource tmu5_resources
[] = {
216 .flags
= IORESOURCE_MEM
,
220 .flags
= IORESOURCE_IRQ
,
224 static struct platform_device tmu5_device
= {
228 .platform_data
= &tmu5_platform_data
,
230 .resource
= tmu5_resources
,
231 .num_resources
= ARRAY_SIZE(tmu5_resources
),
234 static struct platform_device
*shx3_early_devices
[] __initdata
= {
243 static struct platform_device
*shx3_devices
[] __initdata
= {
247 static int __init
shx3_devices_setup(void)
251 ret
= platform_add_devices(shx3_early_devices
,
252 ARRAY_SIZE(shx3_early_devices
));
253 if (unlikely(ret
!= 0))
256 return platform_add_devices(shx3_devices
,
257 ARRAY_SIZE(shx3_devices
));
259 arch_initcall(shx3_devices_setup
);
261 void __init
plat_early_device_setup(void)
263 early_platform_add_devices(shx3_early_devices
,
264 ARRAY_SIZE(shx3_early_devices
));
270 /* interrupt sources */
271 IRL_LLLL
, IRL_LLLH
, IRL_LLHL
, IRL_LLHH
,
272 IRL_LHLL
, IRL_LHLH
, IRL_LHHL
, IRL_LHHH
,
273 IRL_HLLL
, IRL_HLLH
, IRL_HLHL
, IRL_HLHH
,
274 IRL_HHLL
, IRL_HHLH
, IRL_HHHL
,
275 IRQ0
, IRQ1
, IRQ2
, IRQ3
,
277 TMU0
, TMU1
, TMU2
, TMU3
, TMU4
, TMU5
,
278 PCII0
, PCII1
, PCII2
, PCII3
, PCII4
,
279 PCII5
, PCII6
, PCII7
, PCII8
, PCII9
,
280 SCIF0_ERI
, SCIF0_RXI
, SCIF0_BRI
, SCIF0_TXI
,
281 SCIF1_ERI
, SCIF1_RXI
, SCIF1_BRI
, SCIF1_TXI
,
282 SCIF2_ERI
, SCIF2_RXI
, SCIF2_BRI
, SCIF2_TXI
,
283 SCIF3_ERI
, SCIF3_RXI
, SCIF3_BRI
, SCIF3_TXI
,
284 DMAC0_DMINT0
, DMAC0_DMINT1
, DMAC0_DMINT2
, DMAC0_DMINT3
,
285 DMAC0_DMINT4
, DMAC0_DMINT5
, DMAC0_DMAE
,
287 DMAC1_DMINT6
, DMAC1_DMINT7
, DMAC1_DMINT8
, DMAC1_DMINT9
,
288 DMAC1_DMINT10
, DMAC1_DMINT11
, DMAC1_DMAE
,
289 IIC
, VIN0
, VIN1
, VCORE0
, ATAPI
,
290 DTU0_TEND
, DTU0_AE
, DTU0_TMISS
,
291 DTU1_TEND
, DTU1_AE
, DTU1_TMISS
,
292 DTU2_TEND
, DTU2_AE
, DTU2_TMISS
,
293 DTU3_TEND
, DTU3_AE
, DTU3_TMISS
,
295 GPIO0
, GPIO1
, GPIO2
, GPIO3
,
297 INTICI0
, INTICI1
, INTICI2
, INTICI3
,
298 INTICI4
, INTICI5
, INTICI6
, INTICI7
,
300 /* interrupt groups */
301 IRL
, PCII56789
, SCIF0
, SCIF1
, SCIF2
, SCIF3
,
302 DMAC0
, DMAC1
, DTU0
, DTU1
, DTU2
, DTU3
,
305 static struct intc_vect vectors
[] __initdata
= {
306 INTC_VECT(HUDII
, 0x3e0),
307 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
308 INTC_VECT(TMU2
, 0x440), INTC_VECT(TMU3
, 0x460),
309 INTC_VECT(TMU4
, 0x480), INTC_VECT(TMU5
, 0x4a0),
310 INTC_VECT(PCII0
, 0x500), INTC_VECT(PCII1
, 0x520),
311 INTC_VECT(PCII2
, 0x540), INTC_VECT(PCII3
, 0x560),
312 INTC_VECT(PCII4
, 0x580), INTC_VECT(PCII5
, 0x5a0),
313 INTC_VECT(PCII6
, 0x5c0), INTC_VECT(PCII7
, 0x5e0),
314 INTC_VECT(PCII8
, 0x600), INTC_VECT(PCII9
, 0x620),
315 INTC_VECT(SCIF0_ERI
, 0x700), INTC_VECT(SCIF0_RXI
, 0x720),
316 INTC_VECT(SCIF0_BRI
, 0x740), INTC_VECT(SCIF0_TXI
, 0x760),
317 INTC_VECT(SCIF1_ERI
, 0x780), INTC_VECT(SCIF1_RXI
, 0x7a0),
318 INTC_VECT(SCIF1_BRI
, 0x7c0), INTC_VECT(SCIF1_TXI
, 0x7e0),
319 INTC_VECT(SCIF2_ERI
, 0x800), INTC_VECT(SCIF2_RXI
, 0x820),
320 INTC_VECT(SCIF2_BRI
, 0x840), INTC_VECT(SCIF2_TXI
, 0x860),
321 INTC_VECT(SCIF3_ERI
, 0x880), INTC_VECT(SCIF3_RXI
, 0x8a0),
322 INTC_VECT(SCIF3_BRI
, 0x8c0), INTC_VECT(SCIF3_TXI
, 0x8e0),
323 INTC_VECT(DMAC0_DMINT0
, 0x900), INTC_VECT(DMAC0_DMINT1
, 0x920),
324 INTC_VECT(DMAC0_DMINT2
, 0x940), INTC_VECT(DMAC0_DMINT3
, 0x960),
325 INTC_VECT(DMAC0_DMINT4
, 0x980), INTC_VECT(DMAC0_DMINT5
, 0x9a0),
326 INTC_VECT(DMAC0_DMAE
, 0x9c0),
327 INTC_VECT(DU
, 0x9e0),
328 INTC_VECT(DMAC1_DMINT6
, 0xa00), INTC_VECT(DMAC1_DMINT7
, 0xa20),
329 INTC_VECT(DMAC1_DMINT8
, 0xa40), INTC_VECT(DMAC1_DMINT9
, 0xa60),
330 INTC_VECT(DMAC1_DMINT10
, 0xa80), INTC_VECT(DMAC1_DMINT11
, 0xaa0),
331 INTC_VECT(DMAC1_DMAE
, 0xac0),
332 INTC_VECT(IIC
, 0xae0),
333 INTC_VECT(VIN0
, 0xb00), INTC_VECT(VIN1
, 0xb20),
334 INTC_VECT(VCORE0
, 0xb00), INTC_VECT(ATAPI
, 0xb60),
335 INTC_VECT(DTU0_TEND
, 0xc00), INTC_VECT(DTU0_AE
, 0xc20),
336 INTC_VECT(DTU0_TMISS
, 0xc40),
337 INTC_VECT(DTU1_TEND
, 0xc60), INTC_VECT(DTU1_AE
, 0xc80),
338 INTC_VECT(DTU1_TMISS
, 0xca0),
339 INTC_VECT(DTU2_TEND
, 0xcc0), INTC_VECT(DTU2_AE
, 0xce0),
340 INTC_VECT(DTU2_TMISS
, 0xd00),
341 INTC_VECT(DTU3_TEND
, 0xd20), INTC_VECT(DTU3_AE
, 0xd40),
342 INTC_VECT(DTU3_TMISS
, 0xd60),
343 INTC_VECT(FE0
, 0xe00), INTC_VECT(FE1
, 0xe20),
344 INTC_VECT(GPIO0
, 0xe40), INTC_VECT(GPIO1
, 0xe60),
345 INTC_VECT(GPIO2
, 0xe80), INTC_VECT(GPIO3
, 0xea0),
346 INTC_VECT(PAM
, 0xec0), INTC_VECT(IRM
, 0xee0),
347 INTC_VECT(INTICI0
, 0xf00), INTC_VECT(INTICI1
, 0xf20),
348 INTC_VECT(INTICI2
, 0xf40), INTC_VECT(INTICI3
, 0xf60),
349 INTC_VECT(INTICI4
, 0xf80), INTC_VECT(INTICI5
, 0xfa0),
350 INTC_VECT(INTICI6
, 0xfc0), INTC_VECT(INTICI7
, 0xfe0),
353 static struct intc_group groups
[] __initdata
= {
354 INTC_GROUP(IRL
, IRL_LLLL
, IRL_LLLH
, IRL_LLHL
, IRL_LLHH
,
355 IRL_LHLL
, IRL_LHLH
, IRL_LHHL
, IRL_LHHH
,
356 IRL_HLLL
, IRL_HLLH
, IRL_HLHL
, IRL_HLHH
,
357 IRL_HHLL
, IRL_HHLH
, IRL_HHHL
),
358 INTC_GROUP(PCII56789
, PCII5
, PCII6
, PCII7
, PCII8
, PCII9
),
359 INTC_GROUP(SCIF0
, SCIF0_ERI
, SCIF0_RXI
, SCIF0_BRI
, SCIF0_TXI
),
360 INTC_GROUP(SCIF1
, SCIF1_ERI
, SCIF1_RXI
, SCIF1_BRI
, SCIF1_TXI
),
361 INTC_GROUP(SCIF2
, SCIF2_ERI
, SCIF2_RXI
, SCIF2_BRI
, SCIF2_TXI
),
362 INTC_GROUP(SCIF3
, SCIF3_ERI
, SCIF3_RXI
, SCIF3_BRI
, SCIF3_TXI
),
363 INTC_GROUP(DMAC0
, DMAC0_DMINT0
, DMAC0_DMINT1
, DMAC0_DMINT2
,
364 DMAC0_DMINT3
, DMAC0_DMINT4
, DMAC0_DMINT5
, DMAC0_DMAE
),
365 INTC_GROUP(DMAC1
, DMAC1_DMINT6
, DMAC1_DMINT7
, DMAC1_DMINT8
,
366 DMAC1_DMINT9
, DMAC1_DMINT10
, DMAC1_DMINT11
),
367 INTC_GROUP(DTU0
, DTU0_TEND
, DTU0_AE
, DTU0_TMISS
),
368 INTC_GROUP(DTU1
, DTU1_TEND
, DTU1_AE
, DTU1_TMISS
),
369 INTC_GROUP(DTU2
, DTU2_TEND
, DTU2_AE
, DTU2_TMISS
),
370 INTC_GROUP(DTU3
, DTU3_TEND
, DTU3_AE
, DTU3_TMISS
),
373 static struct intc_mask_reg mask_registers
[] __initdata
= {
374 { 0xfe410030, 0xfe410050, 32, /* CnINTMSK0 / CnINTMSKCLR0 */
375 { IRQ0
, IRQ1
, IRQ2
, IRQ3
} },
376 { 0xfe410040, 0xfe410060, 32, /* CnINTMSK1 / CnINTMSKCLR1 */
378 { 0xfe410820, 0xfe410850, 32, /* CnINT2MSK0 / CnINT2MSKCLR0 */
379 { FE1
, FE0
, 0, ATAPI
, VCORE0
, VIN1
, VIN0
, IIC
,
380 DU
, GPIO3
, GPIO2
, GPIO1
, GPIO0
, PAM
, 0, 0,
381 0, 0, 0, 0, 0, 0, 0, 0, /* HUDI bits ignored */
382 0, TMU5
, TMU4
, TMU3
, TMU2
, TMU1
, TMU0
, 0, } },
383 { 0xfe410830, 0xfe410860, 32, /* CnINT2MSK1 / CnINT2MSKCLR1 */
384 { 0, 0, 0, 0, DTU3
, DTU2
, DTU1
, DTU0
, /* IRM bits ignored */
385 PCII9
, PCII8
, PCII7
, PCII6
, PCII5
, PCII4
, PCII3
, PCII2
,
386 PCII1
, PCII0
, DMAC1_DMAE
, DMAC1_DMINT11
,
387 DMAC1_DMINT10
, DMAC1_DMINT9
, DMAC1_DMINT8
, DMAC1_DMINT7
,
388 DMAC1_DMINT6
, DMAC0_DMAE
, DMAC0_DMINT5
, DMAC0_DMINT4
,
389 DMAC0_DMINT3
, DMAC0_DMINT2
, DMAC0_DMINT1
, DMAC0_DMINT0
} },
390 { 0xfe410840, 0xfe410870, 32, /* CnINT2MSK2 / CnINT2MSKCLR2 */
391 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
392 SCIF3_TXI
, SCIF3_BRI
, SCIF3_RXI
, SCIF3_ERI
,
393 SCIF2_TXI
, SCIF2_BRI
, SCIF2_RXI
, SCIF2_ERI
,
394 SCIF1_TXI
, SCIF1_BRI
, SCIF1_RXI
, SCIF1_ERI
,
395 SCIF0_TXI
, SCIF0_BRI
, SCIF0_RXI
, SCIF0_ERI
} },
398 static struct intc_prio_reg prio_registers
[] __initdata
= {
399 { 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0
, IRQ1
, IRQ2
, IRQ3
} },
401 { 0xfe410800, 0, 32, 4, /* INT2PRI0 */ { 0, HUDII
, TMU5
, TMU4
,
402 TMU3
, TMU2
, TMU1
, TMU0
} },
403 { 0xfe410804, 0, 32, 4, /* INT2PRI1 */ { DTU3
, DTU2
, DTU1
, DTU0
,
406 { 0xfe410808, 0, 32, 4, /* INT2PRI2 */ { DMAC1
, DMAC0
,
410 { 0xfe41080c, 0, 32, 4, /* INT2PRI3 */ { FE1
, FE0
, ATAPI
, VCORE0
,
411 VIN1
, VIN0
, IIC
, DU
} },
412 { 0xfe410810, 0, 32, 4, /* INT2PRI4 */ { 0, 0, PAM
, GPIO3
,
413 GPIO2
, GPIO1
, GPIO0
, IRM
} },
414 { 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */
415 { INTICI7
, INTICI6
, INTICI5
, INTICI4
,
416 INTICI3
, INTICI2
, INTICI1
, INTICI0
}, INTC_SMP(4, 4) },
419 static DECLARE_INTC_DESC(intc_desc
, "shx3", vectors
, groups
,
420 mask_registers
, prio_registers
, NULL
);
422 /* Support for external interrupt pins in IRQ mode */
423 static struct intc_vect vectors_irq
[] __initdata
= {
424 INTC_VECT(IRQ0
, 0x240), INTC_VECT(IRQ1
, 0x280),
425 INTC_VECT(IRQ2
, 0x2c0), INTC_VECT(IRQ3
, 0x300),
428 static struct intc_sense_reg sense_registers
[] __initdata
= {
429 { 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0
, IRQ1
, IRQ2
, IRQ3
} },
432 static DECLARE_INTC_DESC(intc_desc_irq
, "shx3-irq", vectors_irq
, groups
,
433 mask_registers
, prio_registers
, sense_registers
);
435 /* External interrupt pins in IRL mode */
436 static struct intc_vect vectors_irl
[] __initdata
= {
437 INTC_VECT(IRL_LLLL
, 0x200), INTC_VECT(IRL_LLLH
, 0x220),
438 INTC_VECT(IRL_LLHL
, 0x240), INTC_VECT(IRL_LLHH
, 0x260),
439 INTC_VECT(IRL_LHLL
, 0x280), INTC_VECT(IRL_LHLH
, 0x2a0),
440 INTC_VECT(IRL_LHHL
, 0x2c0), INTC_VECT(IRL_LHHH
, 0x2e0),
441 INTC_VECT(IRL_HLLL
, 0x300), INTC_VECT(IRL_HLLH
, 0x320),
442 INTC_VECT(IRL_HLHL
, 0x340), INTC_VECT(IRL_HLHH
, 0x360),
443 INTC_VECT(IRL_HHLL
, 0x380), INTC_VECT(IRL_HHLH
, 0x3a0),
444 INTC_VECT(IRL_HHHL
, 0x3c0),
447 static DECLARE_INTC_DESC(intc_desc_irl
, "shx3-irl", vectors_irl
, groups
,
448 mask_registers
, prio_registers
, NULL
);
450 void __init
plat_irq_setup_pins(int mode
)
454 register_intc_controller(&intc_desc_irq
);
456 case IRQ_MODE_IRL3210
:
457 register_intc_controller(&intc_desc_irl
);
464 void __init
plat_irq_setup(void)
466 register_intc_controller(&intc_desc
);
469 void __init
plat_mem_setup(void)
471 unsigned int nid
= 1;
473 /* Register CPU#0 URAM space as Node 1 */
474 setup_bootmem_node(nid
++, 0x145f0000, 0x14610000); /* CPU0 */
478 setup_bootmem_node(nid
++, 0x14df0000, 0x14e10000); /* CPU1 */
479 setup_bootmem_node(nid
++, 0x155f0000, 0x15610000); /* CPU2 */
480 setup_bootmem_node(nid
++, 0x15df0000, 0x15e10000); /* CPU3 */
483 setup_bootmem_node(nid
++, 0x16000000, 0x16020000); /* CSM */