1
2
3
4
5
6
7
8#include <linux/platform_device.h>
9#include <linux/init.h>
10#include <linux/irq.h>
11#include <linux/serial.h>
12#include <linux/serial_sci.h>
13#include <linux/sh_timer.h>
14#include <linux/sh_intc.h>
15#include <asm/rtc.h>
16#include <cpu/serial.h>
17
18enum {
19 UNUSED = 0,
20
21
22 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
23 PINT07, PINT815,
24
25 DMAC, SCIF0, SCIF2, ADC_ADI, USB,
26
27 TPU0, TPU1, TPU2, TPU3,
28 TMU0, TMU1, TMU2,
29
30 RTC, WDT, REF_RCMI,
31};
32
33static struct intc_vect vectors[] __initdata = {
34
35 INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
36 INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
37 INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
38 INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
39 INTC_VECT(SCIF0, 0x8e0),
40 INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
41 INTC_VECT(SCIF2, 0x960),
42 INTC_VECT(ADC_ADI, 0x980),
43 INTC_VECT(USB, 0xa20), INTC_VECT(USB, 0xa40),
44 INTC_VECT(TPU0, 0xc00), INTC_VECT(TPU1, 0xc20),
45 INTC_VECT(TPU2, 0xc80), INTC_VECT(TPU3, 0xca0),
46 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
47 INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
48 INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
49 INTC_VECT(RTC, 0x4c0),
50 INTC_VECT(WDT, 0x560),
51 INTC_VECT(REF_RCMI, 0x580),
52};
53
54static struct intc_prio_reg prio_registers[] __initdata = {
55 { 0xfffffee2, 0, 16, 4, { TMU0, TMU1, TMU2, RTC } },
56 { 0xfffffee4, 0, 16, 4, { WDT, REF_RCMI, 0, 0 } },
57 { 0xa4000016, 0, 16, 4, { IRQ3, IRQ2, IRQ1, IRQ0 } },
58 { 0xa4000018, 0, 16, 4, { PINT07, PINT815, IRQ5, IRQ4 } },
59 { 0xa400001a, 0, 16, 4, { DMAC, SCIF0, SCIF2, ADC_ADI } },
60 { 0xa4080000, 0, 16, 4, { 0, 0, USB } },
61 { 0xa4080002, 0, 16, 4, { TPU0, TPU1 } },
62 { 0xa4080004, 0, 16, 4, { TPU2, TPU3 } },
63
64};
65
66static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, NULL,
67 NULL, prio_registers, NULL);
68
69static struct plat_sci_port scif0_platform_data = {
70 .scscr = SCSCR_CKE1,
71 .type = PORT_SCIF,
72 .ops = &sh770x_sci_port_ops,
73 .regtype = SCIx_SH7705_SCIF_REGTYPE,
74};
75
76static struct resource scif0_resources[] = {
77 DEFINE_RES_MEM(0xa4410000, 0x100),
78 DEFINE_RES_IRQ(evt2irq(0x900)),
79};
80
81static struct platform_device scif0_device = {
82 .name = "sh-sci",
83 .id = 0,
84 .resource = scif0_resources,
85 .num_resources = ARRAY_SIZE(scif0_resources),
86 .dev = {
87 .platform_data = &scif0_platform_data,
88 },
89};
90
91static struct plat_sci_port scif1_platform_data = {
92 .type = PORT_SCIF,
93 .ops = &sh770x_sci_port_ops,
94 .regtype = SCIx_SH7705_SCIF_REGTYPE,
95};
96
97static struct resource scif1_resources[] = {
98 DEFINE_RES_MEM(0xa4400000, 0x100),
99 DEFINE_RES_IRQ(evt2irq(0x880)),
100};
101
102static struct platform_device scif1_device = {
103 .name = "sh-sci",
104 .id = 1,
105 .resource = scif1_resources,
106 .num_resources = ARRAY_SIZE(scif1_resources),
107 .dev = {
108 .platform_data = &scif1_platform_data,
109 },
110};
111
112static struct resource rtc_resources[] = {
113 [0] = {
114 .start = 0xfffffec0,
115 .end = 0xfffffec0 + 0x1e,
116 .flags = IORESOURCE_IO,
117 },
118 [1] = {
119 .start = evt2irq(0x480),
120 .flags = IORESOURCE_IRQ,
121 },
122};
123
124static struct sh_rtc_platform_info rtc_info = {
125 .capabilities = RTC_CAP_4_DIGIT_YEAR,
126};
127
128static struct platform_device rtc_device = {
129 .name = "sh-rtc",
130 .id = -1,
131 .num_resources = ARRAY_SIZE(rtc_resources),
132 .resource = rtc_resources,
133 .dev = {
134 .platform_data = &rtc_info,
135 },
136};
137
138static struct sh_timer_config tmu0_platform_data = {
139 .channels_mask = 7,
140};
141
142static struct resource tmu0_resources[] = {
143 DEFINE_RES_MEM(0xfffffe90, 0x2c),
144 DEFINE_RES_IRQ(evt2irq(0x400)),
145 DEFINE_RES_IRQ(evt2irq(0x420)),
146 DEFINE_RES_IRQ(evt2irq(0x440)),
147};
148
149static struct platform_device tmu0_device = {
150 .name = "sh-tmu-sh3",
151 .id = 0,
152 .dev = {
153 .platform_data = &tmu0_platform_data,
154 },
155 .resource = tmu0_resources,
156 .num_resources = ARRAY_SIZE(tmu0_resources),
157};
158
159static struct platform_device *sh7705_devices[] __initdata = {
160 &scif0_device,
161 &scif1_device,
162 &tmu0_device,
163 &rtc_device,
164};
165
166static int __init sh7705_devices_setup(void)
167{
168 return platform_add_devices(sh7705_devices,
169 ARRAY_SIZE(sh7705_devices));
170}
171arch_initcall(sh7705_devices_setup);
172
173static struct platform_device *sh7705_early_devices[] __initdata = {
174 &scif0_device,
175 &scif1_device,
176 &tmu0_device,
177};
178
179void __init plat_early_device_setup(void)
180{
181 early_platform_add_devices(sh7705_early_devices,
182 ARRAY_SIZE(sh7705_early_devices));
183}
184
185void __init plat_irq_setup(void)
186{
187 register_intc_controller(&intc_desc);
188 plat_irq_setup_sh3();
189}
190