Commit | Line | Data |
---|---|---|
6d9598e2 MD |
1 | /* |
2 | * sh73a0 processor support | |
3 | * | |
4 | * Copyright (C) 2010 Takashi Yoshii | |
5 | * Copyright (C) 2010 Magnus Damm | |
6 | * Copyright (C) 2008 Yoshihiro Shimoda | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; version 2 of the License. | |
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | */ | |
21 | #include <linux/kernel.h> | |
22 | #include <linux/init.h> | |
23 | #include <linux/interrupt.h> | |
24 | #include <linux/irq.h> | |
25 | #include <linux/platform_device.h> | |
26 | #include <linux/delay.h> | |
27 | #include <linux/input.h> | |
28 | #include <linux/io.h> | |
29 | #include <linux/serial_sci.h> | |
30 | #include <linux/sh_intc.h> | |
31 | #include <linux/sh_timer.h> | |
32 | #include <mach/hardware.h> | |
33 | #include <asm/mach-types.h> | |
34 | #include <asm/mach/arch.h> | |
35 | ||
36 | static struct plat_sci_port scif0_platform_data = { | |
37 | .mapbase = 0xe6c40000, | |
38 | .flags = UPF_BOOT_AUTOCONF, | |
39 | .type = PORT_SCIFA, | |
40 | .irqs = { gic_spi(72), gic_spi(72), | |
41 | gic_spi(72), gic_spi(72) }, | |
42 | }; | |
43 | ||
44 | static struct platform_device scif0_device = { | |
45 | .name = "sh-sci", | |
46 | .id = 0, | |
47 | .dev = { | |
48 | .platform_data = &scif0_platform_data, | |
49 | }, | |
50 | }; | |
51 | ||
52 | static struct plat_sci_port scif1_platform_data = { | |
53 | .mapbase = 0xe6c50000, | |
54 | .flags = UPF_BOOT_AUTOCONF, | |
55 | .type = PORT_SCIFA, | |
56 | .irqs = { gic_spi(73), gic_spi(73), | |
57 | gic_spi(73), gic_spi(73) }, | |
58 | }; | |
59 | ||
60 | static struct platform_device scif1_device = { | |
61 | .name = "sh-sci", | |
62 | .id = 1, | |
63 | .dev = { | |
64 | .platform_data = &scif1_platform_data, | |
65 | }, | |
66 | }; | |
67 | ||
68 | static struct plat_sci_port scif2_platform_data = { | |
69 | .mapbase = 0xe6c60000, | |
70 | .flags = UPF_BOOT_AUTOCONF, | |
71 | .type = PORT_SCIFA, | |
72 | .irqs = { gic_spi(74), gic_spi(74), | |
73 | gic_spi(74), gic_spi(74) }, | |
74 | }; | |
75 | ||
76 | static struct platform_device scif2_device = { | |
77 | .name = "sh-sci", | |
78 | .id = 2, | |
79 | .dev = { | |
80 | .platform_data = &scif2_platform_data, | |
81 | }, | |
82 | }; | |
83 | ||
84 | static struct plat_sci_port scif3_platform_data = { | |
85 | .mapbase = 0xe6c70000, | |
86 | .flags = UPF_BOOT_AUTOCONF, | |
87 | .type = PORT_SCIFA, | |
88 | .irqs = { gic_spi(75), gic_spi(75), | |
89 | gic_spi(75), gic_spi(75) }, | |
90 | }; | |
91 | ||
92 | static struct platform_device scif3_device = { | |
93 | .name = "sh-sci", | |
94 | .id = 3, | |
95 | .dev = { | |
96 | .platform_data = &scif3_platform_data, | |
97 | }, | |
98 | }; | |
99 | ||
100 | static struct plat_sci_port scif4_platform_data = { | |
101 | .mapbase = 0xe6c80000, | |
102 | .flags = UPF_BOOT_AUTOCONF, | |
103 | .type = PORT_SCIFA, | |
104 | .irqs = { gic_spi(78), gic_spi(78), | |
105 | gic_spi(78), gic_spi(78) }, | |
106 | }; | |
107 | ||
108 | static struct platform_device scif4_device = { | |
109 | .name = "sh-sci", | |
110 | .id = 4, | |
111 | .dev = { | |
112 | .platform_data = &scif4_platform_data, | |
113 | }, | |
114 | }; | |
115 | ||
116 | static struct plat_sci_port scif5_platform_data = { | |
117 | .mapbase = 0xe6cb0000, | |
118 | .flags = UPF_BOOT_AUTOCONF, | |
119 | .type = PORT_SCIFA, | |
120 | .irqs = { gic_spi(79), gic_spi(79), | |
121 | gic_spi(79), gic_spi(79) }, | |
122 | }; | |
123 | ||
124 | static struct platform_device scif5_device = { | |
125 | .name = "sh-sci", | |
126 | .id = 5, | |
127 | .dev = { | |
128 | .platform_data = &scif5_platform_data, | |
129 | }, | |
130 | }; | |
131 | ||
132 | static struct plat_sci_port scif6_platform_data = { | |
133 | .mapbase = 0xe6cc0000, | |
134 | .flags = UPF_BOOT_AUTOCONF, | |
135 | .type = PORT_SCIFA, | |
136 | .irqs = { gic_spi(156), gic_spi(156), | |
137 | gic_spi(156), gic_spi(156) }, | |
138 | }; | |
139 | ||
140 | static struct platform_device scif6_device = { | |
141 | .name = "sh-sci", | |
142 | .id = 6, | |
143 | .dev = { | |
144 | .platform_data = &scif6_platform_data, | |
145 | }, | |
146 | }; | |
147 | ||
148 | static struct plat_sci_port scif7_platform_data = { | |
149 | .mapbase = 0xe6cd0000, | |
150 | .flags = UPF_BOOT_AUTOCONF, | |
151 | .type = PORT_SCIFA, | |
152 | .irqs = { gic_spi(143), gic_spi(143), | |
153 | gic_spi(143), gic_spi(143) }, | |
154 | }; | |
155 | ||
156 | static struct platform_device scif7_device = { | |
157 | .name = "sh-sci", | |
158 | .id = 7, | |
159 | .dev = { | |
160 | .platform_data = &scif7_platform_data, | |
161 | }, | |
162 | }; | |
163 | ||
164 | static struct plat_sci_port scif8_platform_data = { | |
165 | .mapbase = 0xe6c30000, | |
166 | .flags = UPF_BOOT_AUTOCONF, | |
167 | .type = PORT_SCIFB, | |
168 | .irqs = { gic_spi(80), gic_spi(80), | |
169 | gic_spi(80), gic_spi(80) }, | |
170 | }; | |
171 | ||
172 | static struct platform_device scif8_device = { | |
173 | .name = "sh-sci", | |
174 | .id = 8, | |
175 | .dev = { | |
176 | .platform_data = &scif8_platform_data, | |
177 | }, | |
178 | }; | |
179 | ||
180 | static struct sh_timer_config cmt10_platform_data = { | |
181 | .name = "CMT10", | |
182 | .channel_offset = 0x10, | |
183 | .timer_bit = 0, | |
184 | .clockevent_rating = 125, | |
185 | .clocksource_rating = 125, | |
186 | }; | |
187 | ||
188 | static struct resource cmt10_resources[] = { | |
189 | [0] = { | |
190 | .name = "CMT10", | |
191 | .start = 0xe6138010, | |
192 | .end = 0xe613801b, | |
193 | .flags = IORESOURCE_MEM, | |
194 | }, | |
195 | [1] = { | |
196 | .start = gic_spi(65), | |
197 | .flags = IORESOURCE_IRQ, | |
198 | }, | |
199 | }; | |
200 | ||
201 | static struct platform_device cmt10_device = { | |
202 | .name = "sh_cmt", | |
203 | .id = 10, | |
204 | .dev = { | |
205 | .platform_data = &cmt10_platform_data, | |
206 | }, | |
207 | .resource = cmt10_resources, | |
208 | .num_resources = ARRAY_SIZE(cmt10_resources), | |
209 | }; | |
210 | ||
5010f3db MD |
211 | /* TMU */ |
212 | static struct sh_timer_config tmu00_platform_data = { | |
213 | .name = "TMU00", | |
214 | .channel_offset = 0x4, | |
215 | .timer_bit = 0, | |
216 | .clockevent_rating = 200, | |
217 | }; | |
218 | ||
219 | static struct resource tmu00_resources[] = { | |
220 | [0] = { | |
221 | .name = "TMU00", | |
222 | .start = 0xfff60008, | |
223 | .end = 0xfff60013, | |
224 | .flags = IORESOURCE_MEM, | |
225 | }, | |
226 | [1] = { | |
227 | .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */ | |
228 | .flags = IORESOURCE_IRQ, | |
229 | }, | |
230 | }; | |
231 | ||
232 | static struct platform_device tmu00_device = { | |
233 | .name = "sh_tmu", | |
234 | .id = 0, | |
235 | .dev = { | |
236 | .platform_data = &tmu00_platform_data, | |
237 | }, | |
238 | .resource = tmu00_resources, | |
239 | .num_resources = ARRAY_SIZE(tmu00_resources), | |
240 | }; | |
241 | ||
242 | static struct sh_timer_config tmu01_platform_data = { | |
243 | .name = "TMU01", | |
244 | .channel_offset = 0x10, | |
245 | .timer_bit = 1, | |
246 | .clocksource_rating = 200, | |
247 | }; | |
248 | ||
249 | static struct resource tmu01_resources[] = { | |
250 | [0] = { | |
251 | .name = "TMU01", | |
252 | .start = 0xfff60014, | |
253 | .end = 0xfff6001f, | |
254 | .flags = IORESOURCE_MEM, | |
255 | }, | |
256 | [1] = { | |
257 | .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */ | |
258 | .flags = IORESOURCE_IRQ, | |
259 | }, | |
260 | }; | |
261 | ||
262 | static struct platform_device tmu01_device = { | |
263 | .name = "sh_tmu", | |
264 | .id = 1, | |
265 | .dev = { | |
266 | .platform_data = &tmu01_platform_data, | |
267 | }, | |
268 | .resource = tmu01_resources, | |
269 | .num_resources = ARRAY_SIZE(tmu01_resources), | |
270 | }; | |
271 | ||
b028f94b YT |
272 | static struct resource i2c0_resources[] = { |
273 | [0] = { | |
274 | .name = "IIC0", | |
275 | .start = 0xe6820000, | |
276 | .end = 0xe6820425 - 1, | |
277 | .flags = IORESOURCE_MEM, | |
278 | }, | |
279 | [1] = { | |
280 | .start = gic_spi(167), | |
281 | .end = gic_spi(170), | |
282 | .flags = IORESOURCE_IRQ, | |
283 | }, | |
284 | }; | |
285 | ||
286 | static struct resource i2c1_resources[] = { | |
287 | [0] = { | |
288 | .name = "IIC1", | |
289 | .start = 0xe6822000, | |
290 | .end = 0xe6822425 - 1, | |
291 | .flags = IORESOURCE_MEM, | |
292 | }, | |
293 | [1] = { | |
294 | .start = gic_spi(51), | |
295 | .end = gic_spi(54), | |
296 | .flags = IORESOURCE_IRQ, | |
297 | }, | |
298 | }; | |
299 | ||
300 | static struct resource i2c2_resources[] = { | |
301 | [0] = { | |
302 | .name = "IIC2", | |
303 | .start = 0xe6824000, | |
304 | .end = 0xe6824425 - 1, | |
305 | .flags = IORESOURCE_MEM, | |
306 | }, | |
307 | [1] = { | |
308 | .start = gic_spi(171), | |
309 | .end = gic_spi(174), | |
310 | .flags = IORESOURCE_IRQ, | |
311 | }, | |
312 | }; | |
313 | ||
314 | static struct resource i2c3_resources[] = { | |
315 | [0] = { | |
316 | .name = "IIC3", | |
317 | .start = 0xe6826000, | |
318 | .end = 0xe6826425 - 1, | |
319 | .flags = IORESOURCE_MEM, | |
320 | }, | |
321 | [1] = { | |
322 | .start = gic_spi(183), | |
323 | .end = gic_spi(186), | |
324 | .flags = IORESOURCE_IRQ, | |
325 | }, | |
326 | }; | |
327 | ||
328 | static struct resource i2c4_resources[] = { | |
329 | [0] = { | |
330 | .name = "IIC4", | |
331 | .start = 0xe6828000, | |
332 | .end = 0xe6828425 - 1, | |
333 | .flags = IORESOURCE_MEM, | |
334 | }, | |
335 | [1] = { | |
336 | .start = gic_spi(187), | |
337 | .end = gic_spi(190), | |
338 | .flags = IORESOURCE_IRQ, | |
339 | }, | |
340 | }; | |
341 | ||
342 | static struct platform_device i2c0_device = { | |
343 | .name = "i2c-sh_mobile", | |
344 | .id = 0, | |
345 | .resource = i2c0_resources, | |
346 | .num_resources = ARRAY_SIZE(i2c0_resources), | |
347 | }; | |
348 | ||
349 | static struct platform_device i2c1_device = { | |
350 | .name = "i2c-sh_mobile", | |
351 | .id = 1, | |
352 | .resource = i2c1_resources, | |
353 | .num_resources = ARRAY_SIZE(i2c1_resources), | |
354 | }; | |
355 | ||
356 | static struct platform_device i2c2_device = { | |
357 | .name = "i2c-sh_mobile", | |
358 | .id = 2, | |
359 | .resource = i2c2_resources, | |
360 | .num_resources = ARRAY_SIZE(i2c2_resources), | |
361 | }; | |
362 | ||
363 | static struct platform_device i2c3_device = { | |
364 | .name = "i2c-sh_mobile", | |
365 | .id = 3, | |
366 | .resource = i2c3_resources, | |
367 | .num_resources = ARRAY_SIZE(i2c3_resources), | |
368 | }; | |
369 | ||
370 | static struct platform_device i2c4_device = { | |
371 | .name = "i2c-sh_mobile", | |
372 | .id = 4, | |
373 | .resource = i2c4_resources, | |
374 | .num_resources = ARRAY_SIZE(i2c4_resources), | |
375 | }; | |
376 | ||
6d9598e2 MD |
377 | static struct platform_device *sh73a0_early_devices[] __initdata = { |
378 | &scif0_device, | |
379 | &scif1_device, | |
380 | &scif2_device, | |
381 | &scif3_device, | |
382 | &scif4_device, | |
383 | &scif5_device, | |
384 | &scif6_device, | |
385 | &scif7_device, | |
386 | &scif8_device, | |
387 | &cmt10_device, | |
5010f3db MD |
388 | &tmu00_device, |
389 | &tmu01_device, | |
6d9598e2 MD |
390 | }; |
391 | ||
b028f94b YT |
392 | static struct platform_device *sh73a0_late_devices[] __initdata = { |
393 | &i2c0_device, | |
394 | &i2c1_device, | |
395 | &i2c2_device, | |
396 | &i2c3_device, | |
397 | &i2c4_device, | |
398 | }; | |
399 | ||
6d9598e2 MD |
400 | void __init sh73a0_add_standard_devices(void) |
401 | { | |
402 | platform_add_devices(sh73a0_early_devices, | |
403 | ARRAY_SIZE(sh73a0_early_devices)); | |
b028f94b YT |
404 | platform_add_devices(sh73a0_late_devices, |
405 | ARRAY_SIZE(sh73a0_late_devices)); | |
6d9598e2 MD |
406 | } |
407 | ||
408 | void __init sh73a0_add_early_devices(void) | |
409 | { | |
410 | early_platform_add_devices(sh73a0_early_devices, | |
411 | ARRAY_SIZE(sh73a0_early_devices)); | |
412 | } |