4 * Copyright (C) 2006 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>
14 #include <linux/uio_driver.h>
15 #include <linux/sh_timer.h>
16 #include <asm/clock.h>
18 static struct resource iic0_resources
[] = {
23 .flags
= IORESOURCE_MEM
,
28 .flags
= IORESOURCE_IRQ
,
32 static struct platform_device iic0_device
= {
33 .name
= "i2c-sh_mobile",
34 .id
= 0, /* "i2c0" clock */
35 .num_resources
= ARRAY_SIZE(iic0_resources
),
36 .resource
= iic0_resources
,
39 static struct resource iic1_resources
[] = {
44 .flags
= IORESOURCE_MEM
,
49 .flags
= IORESOURCE_IRQ
,
53 static struct platform_device iic1_device
= {
54 .name
= "i2c-sh_mobile",
55 .id
= 1, /* "i2c1" clock */
56 .num_resources
= ARRAY_SIZE(iic1_resources
),
57 .resource
= iic1_resources
,
60 static struct uio_info vpu_platform_data
= {
66 static struct resource vpu_resources
[] = {
71 .flags
= IORESOURCE_MEM
,
74 /* place holder for contiguous memory */
78 static struct platform_device vpu_device
= {
79 .name
= "uio_pdrv_genirq",
82 .platform_data
= &vpu_platform_data
,
84 .resource
= vpu_resources
,
85 .num_resources
= ARRAY_SIZE(vpu_resources
),
88 static struct uio_info veu_platform_data
= {
94 static struct resource veu_resources
[] = {
99 .flags
= IORESOURCE_MEM
,
102 /* place holder for contiguous memory */
106 static struct platform_device veu_device
= {
107 .name
= "uio_pdrv_genirq",
110 .platform_data
= &veu_platform_data
,
112 .resource
= veu_resources
,
113 .num_resources
= ARRAY_SIZE(veu_resources
),
116 static struct uio_info jpu_platform_data
= {
122 static struct resource jpu_resources
[] = {
127 .flags
= IORESOURCE_MEM
,
130 /* place holder for contiguous memory */
134 static struct platform_device jpu_device
= {
135 .name
= "uio_pdrv_genirq",
138 .platform_data
= &jpu_platform_data
,
140 .resource
= jpu_resources
,
141 .num_resources
= ARRAY_SIZE(jpu_resources
),
144 static struct sh_timer_config cmt_platform_data
= {
146 .channel_offset
= 0x60,
149 .clockevent_rating
= 125,
150 .clocksource_rating
= 200,
153 static struct resource cmt_resources
[] = {
158 .flags
= IORESOURCE_MEM
,
162 .flags
= IORESOURCE_IRQ
,
166 static struct platform_device cmt_device
= {
170 .platform_data
= &cmt_platform_data
,
172 .resource
= cmt_resources
,
173 .num_resources
= ARRAY_SIZE(cmt_resources
),
176 static struct sh_timer_config tmu0_platform_data
= {
178 .channel_offset
= 0x04,
181 .clockevent_rating
= 200,
184 static struct resource tmu0_resources
[] = {
189 .flags
= IORESOURCE_MEM
,
193 .flags
= IORESOURCE_IRQ
,
197 static struct platform_device tmu0_device
= {
201 .platform_data
= &tmu0_platform_data
,
203 .resource
= tmu0_resources
,
204 .num_resources
= ARRAY_SIZE(tmu0_resources
),
207 static struct sh_timer_config tmu1_platform_data
= {
209 .channel_offset
= 0x10,
212 .clocksource_rating
= 200,
215 static struct resource tmu1_resources
[] = {
220 .flags
= IORESOURCE_MEM
,
224 .flags
= IORESOURCE_IRQ
,
228 static struct platform_device tmu1_device
= {
232 .platform_data
= &tmu1_platform_data
,
234 .resource
= tmu1_resources
,
235 .num_resources
= ARRAY_SIZE(tmu1_resources
),
238 static struct sh_timer_config tmu2_platform_data
= {
240 .channel_offset
= 0x1c,
245 static struct resource tmu2_resources
[] = {
250 .flags
= IORESOURCE_MEM
,
254 .flags
= IORESOURCE_IRQ
,
258 static struct platform_device tmu2_device
= {
262 .platform_data
= &tmu2_platform_data
,
264 .resource
= tmu2_resources
,
265 .num_resources
= ARRAY_SIZE(tmu2_resources
),
268 static struct plat_sci_port sci_platform_data
[] = {
270 .mapbase
= 0xffe00000,
271 .flags
= UPF_BOOT_AUTOCONF
,
273 .irqs
= { 80, 80, 80, 80 },
276 .mapbase
= 0xffe10000,
277 .flags
= UPF_BOOT_AUTOCONF
,
279 .irqs
= { 81, 81, 81, 81 },
282 .mapbase
= 0xffe20000,
283 .flags
= UPF_BOOT_AUTOCONF
,
285 .irqs
= { 82, 82, 82, 82 },
288 .mapbase
= 0xffe30000,
289 .flags
= UPF_BOOT_AUTOCONF
,
291 .irqs
= { 83, 83, 83, 83 },
298 static struct platform_device sci_device
= {
302 .platform_data
= sci_platform_data
,
306 static struct platform_device
*sh7343_devices
[] __initdata
= {
319 static int __init
sh7343_devices_setup(void)
321 platform_resource_setup_memory(&vpu_device
, "vpu", 1 << 20);
322 platform_resource_setup_memory(&veu_device
, "veu", 2 << 20);
323 platform_resource_setup_memory(&jpu_device
, "jpu", 2 << 20);
325 return platform_add_devices(sh7343_devices
,
326 ARRAY_SIZE(sh7343_devices
));
328 arch_initcall(sh7343_devices_setup
);
330 static struct platform_device
*sh7343_early_devices
[] __initdata
= {
337 void __init
plat_early_device_setup(void)
339 early_platform_add_devices(sh7343_early_devices
,
340 ARRAY_SIZE(sh7343_early_devices
));
346 /* interrupt sources */
347 IRQ0
, IRQ1
, IRQ2
, IRQ3
, IRQ4
, IRQ5
, IRQ6
, IRQ7
,
348 DMAC0
, DMAC1
, DMAC2
, DMAC3
,
349 VIO_CEUI
, VIO_BEUI
, VIO_VEUI
, VOU
,
350 MFI
, VPU
, TPU
, Z3D4
, USBI0
, USBI1
,
351 MMC_ERR
, MMC_TRAN
, MMC_FSTAT
, MMC_FRDY
,
352 DMAC4
, DMAC5
, DMAC_DADERR
,
354 SCIF
, SCIF1
, SCIF2
, SCIF3
,
356 FLCTL_FLSTEI
, FLCTL_FLENDI
, FLCTL_FLTREQ0I
, FLCTL_FLTREQ1I
,
357 I2C0_ALI
, I2C0_TACKI
, I2C0_WAITI
, I2C0_DTEI
,
358 I2C1_ALI
, I2C1_TACKI
, I2C1_WAITI
, I2C1_DTEI
,
359 SIM_TEI
, SIM_TXI
, SIM_RXI
, SIM_ERI
,
361 SDHI0
, SDHI1
, SDHI2
, SDHI3
,
366 /* interrupt groups */
368 DMAC0123
, VIOVOU
, MMC
, DMAC45
, FLCTL
, I2C0
, I2C1
, SIM
, SDHI
, USB
,
371 static struct intc_vect vectors
[] __initdata
= {
372 INTC_VECT(IRQ0
, 0x600), INTC_VECT(IRQ1
, 0x620),
373 INTC_VECT(IRQ2
, 0x640), INTC_VECT(IRQ3
, 0x660),
374 INTC_VECT(IRQ4
, 0x680), INTC_VECT(IRQ5
, 0x6a0),
375 INTC_VECT(IRQ6
, 0x6c0), INTC_VECT(IRQ7
, 0x6e0),
376 INTC_VECT(I2C1_ALI
, 0x780), INTC_VECT(I2C1_TACKI
, 0x7a0),
377 INTC_VECT(I2C1_WAITI
, 0x7c0), INTC_VECT(I2C1_DTEI
, 0x7e0),
378 INTC_VECT(DMAC0
, 0x800), INTC_VECT(DMAC1
, 0x820),
379 INTC_VECT(DMAC2
, 0x840), INTC_VECT(DMAC3
, 0x860),
380 INTC_VECT(VIO_CEUI
, 0x880), INTC_VECT(VIO_BEUI
, 0x8a0),
381 INTC_VECT(VIO_VEUI
, 0x8c0), INTC_VECT(VOU
, 0x8e0),
382 INTC_VECT(MFI
, 0x900), INTC_VECT(VPU
, 0x980),
383 INTC_VECT(TPU
, 0x9a0), INTC_VECT(Z3D4
, 0x9e0),
384 INTC_VECT(USBI0
, 0xa20), INTC_VECT(USBI1
, 0xa40),
385 INTC_VECT(MMC_ERR
, 0xb00), INTC_VECT(MMC_TRAN
, 0xb20),
386 INTC_VECT(MMC_FSTAT
, 0xb40), INTC_VECT(MMC_FRDY
, 0xb60),
387 INTC_VECT(DMAC4
, 0xb80), INTC_VECT(DMAC5
, 0xba0),
388 INTC_VECT(DMAC_DADERR
, 0xbc0), INTC_VECT(KEYSC
, 0xbe0),
389 INTC_VECT(SCIF
, 0xc00), INTC_VECT(SCIF1
, 0xc20),
390 INTC_VECT(SCIF2
, 0xc40), INTC_VECT(SCIF3
, 0xc60),
391 INTC_VECT(SIOF0
, 0xc80), INTC_VECT(SIOF1
, 0xca0),
392 INTC_VECT(SIO
, 0xd00),
393 INTC_VECT(FLCTL_FLSTEI
, 0xd80), INTC_VECT(FLCTL_FLENDI
, 0xda0),
394 INTC_VECT(FLCTL_FLTREQ0I
, 0xdc0), INTC_VECT(FLCTL_FLTREQ1I
, 0xde0),
395 INTC_VECT(I2C0_ALI
, 0xe00), INTC_VECT(I2C0_TACKI
, 0xe20),
396 INTC_VECT(I2C0_WAITI
, 0xe40), INTC_VECT(I2C0_DTEI
, 0xe60),
397 INTC_VECT(SDHI0
, 0xe80), INTC_VECT(SDHI1
, 0xea0),
398 INTC_VECT(SDHI2
, 0xec0), INTC_VECT(SDHI3
, 0xee0),
399 INTC_VECT(CMT
, 0xf00), INTC_VECT(TSIF
, 0xf20),
400 INTC_VECT(SIU
, 0xf80),
401 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
402 INTC_VECT(TMU2
, 0x440),
403 INTC_VECT(JPU
, 0x560), INTC_VECT(LCDC
, 0x580),
406 static struct intc_group groups
[] __initdata
= {
407 INTC_GROUP(DMAC0123
, DMAC0
, DMAC1
, DMAC2
, DMAC3
),
408 INTC_GROUP(VIOVOU
, VIO_CEUI
, VIO_BEUI
, VIO_VEUI
, VOU
),
409 INTC_GROUP(MMC
, MMC_FRDY
, MMC_FSTAT
, MMC_TRAN
, MMC_ERR
),
410 INTC_GROUP(DMAC45
, DMAC4
, DMAC5
, DMAC_DADERR
),
411 INTC_GROUP(FLCTL
, FLCTL_FLSTEI
, FLCTL_FLENDI
,
412 FLCTL_FLTREQ0I
, FLCTL_FLTREQ1I
),
413 INTC_GROUP(I2C0
, I2C0_ALI
, I2C0_TACKI
, I2C0_WAITI
, I2C0_DTEI
),
414 INTC_GROUP(I2C1
, I2C1_ALI
, I2C1_TACKI
, I2C1_WAITI
, I2C1_DTEI
),
415 INTC_GROUP(SIM
, SIM_TEI
, SIM_TXI
, SIM_RXI
, SIM_ERI
),
416 INTC_GROUP(SDHI
, SDHI0
, SDHI1
, SDHI2
, SDHI3
),
417 INTC_GROUP(USB
, USBI0
, USBI1
),
420 static struct intc_mask_reg mask_registers
[] __initdata
= {
421 { 0xa4080084, 0xa40800c4, 8, /* IMR1 / IMCR1 */
422 { VOU
, VIO_VEUI
, VIO_BEUI
, VIO_CEUI
, DMAC3
, DMAC2
, DMAC1
, DMAC0
} },
423 { 0xa4080088, 0xa40800c8, 8, /* IMR2 / IMCR2 */
424 { 0, 0, 0, VPU
, 0, 0, 0, MFI
} },
425 { 0xa408008c, 0xa40800cc, 8, /* IMR3 / IMCR3 */
426 { SIM_TEI
, SIM_TXI
, SIM_RXI
, SIM_ERI
, 0, 0, 0, IRDA
} },
427 { 0xa4080090, 0xa40800d0, 8, /* IMR4 / IMCR4 */
428 { 0, TMU2
, TMU1
, TMU0
, JPU
, 0, 0, LCDC
} },
429 { 0xa4080094, 0xa40800d4, 8, /* IMR5 / IMCR5 */
430 { KEYSC
, DMAC_DADERR
, DMAC5
, DMAC4
, SCIF3
, SCIF2
, SCIF1
, SCIF
} },
431 { 0xa4080098, 0xa40800d8, 8, /* IMR6 / IMCR6 */
432 { 0, 0, 0, SIO
, Z3D4
, 0, SIOF1
, SIOF0
} },
433 { 0xa408009c, 0xa40800dc, 8, /* IMR7 / IMCR7 */
434 { I2C0_DTEI
, I2C0_WAITI
, I2C0_TACKI
, I2C0_ALI
,
435 FLCTL_FLTREQ1I
, FLCTL_FLTREQ0I
, FLCTL_FLENDI
, FLCTL_FLSTEI
} },
436 { 0xa40800a0, 0xa40800e0, 8, /* IMR8 / IMCR8 */
437 { SDHI3
, SDHI2
, SDHI1
, SDHI0
, 0, 0, 0, SIU
} },
438 { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */
439 { 0, 0, 0, CMT
, 0, USBI1
, USBI0
} },
440 { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
441 { MMC_FRDY
, MMC_FSTAT
, MMC_TRAN
, MMC_ERR
} },
442 { 0xa40800ac, 0xa40800ec, 8, /* IMR11 / IMCR11 */
443 { I2C1_DTEI
, I2C1_WAITI
, I2C1_TACKI
, I2C1_ALI
, TPU
, 0, 0, TSIF
} },
444 { 0xa4140044, 0xa4140064, 8, /* INTMSK00 / INTMSKCLR00 */
445 { IRQ0
, IRQ1
, IRQ2
, IRQ3
, IRQ4
, IRQ5
, IRQ6
, IRQ7
} },
448 static struct intc_prio_reg prio_registers
[] __initdata
= {
449 { 0xa4080000, 0, 16, 4, /* IPRA */ { TMU0
, TMU1
, TMU2
} },
450 { 0xa4080004, 0, 16, 4, /* IPRB */ { JPU
, LCDC
, SIM
} },
451 { 0xa4080010, 0, 16, 4, /* IPRE */ { DMAC0123
, VIOVOU
, MFI
, VPU
} },
452 { 0xa4080014, 0, 16, 4, /* IPRF */ { KEYSC
, DMAC45
, USB
, CMT
} },
453 { 0xa4080018, 0, 16, 4, /* IPRG */ { SCIF
, SCIF1
, SCIF2
, SCIF3
} },
454 { 0xa408001c, 0, 16, 4, /* IPRH */ { SIOF0
, SIOF1
, FLCTL
, I2C0
} },
455 { 0xa4080020, 0, 16, 4, /* IPRI */ { SIO
, 0, TSIF
, I2C1
} },
456 { 0xa4080024, 0, 16, 4, /* IPRJ */ { Z3D4
, 0, SIU
} },
457 { 0xa4080028, 0, 16, 4, /* IPRK */ { 0, MMC
, 0, SDHI
} },
458 { 0xa408002c, 0, 16, 4, /* IPRL */ { 0, 0, TPU
} },
459 { 0xa4140010, 0, 32, 4, /* INTPRI00 */
460 { IRQ0
, IRQ1
, IRQ2
, IRQ3
, IRQ4
, IRQ5
, IRQ6
, IRQ7
} },
463 static struct intc_sense_reg sense_registers
[] __initdata
= {
464 { 0xa414001c, 16, 2, /* ICR1 */
465 { IRQ0
, IRQ1
, IRQ2
, IRQ3
, IRQ4
, IRQ5
, IRQ6
, IRQ7
} },
468 static struct intc_mask_reg ack_registers
[] __initdata
= {
469 { 0xa4140024, 0, 8, /* INTREQ00 */
470 { IRQ0
, IRQ1
, IRQ2
, IRQ3
, IRQ4
, IRQ5
, IRQ6
, IRQ7
} },
473 static DECLARE_INTC_DESC_ACK(intc_desc
, "sh7343", vectors
, groups
,
474 mask_registers
, prio_registers
, sense_registers
,
477 void __init
plat_irq_setup(void)
479 register_intc_controller(&intc_desc
);