blob: 8e84819833a8158ad4814574a332951e7af60357 [file] [log] [blame]
Magnus Dammc793c1b2010-02-05 11:14:49 +00001/*
2 * sh7367 processor support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
Magnus Dammde328352011-04-28 03:16:32 +000025#include <linux/uio_driver.h>
Magnus Dammc793c1b2010-02-05 11:14:49 +000026#include <linux/delay.h>
27#include <linux/input.h>
28#include <linux/io.h>
29#include <linux/serial_sci.h>
Magnus Dammc793c1b2010-02-05 11:14:49 +000030#include <linux/sh_timer.h>
31#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060032#include <mach/irqs.h>
Magnus Dammc793c1b2010-02-05 11:14:49 +000033#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35
Magnus Damm74905092010-05-20 14:35:30 +000036/* SCIFA0 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000037static struct plat_sci_port scif0_platform_data = {
38 .mapbase = 0xe6c40000,
39 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090040 .scscr = SCSCR_RE | SCSCR_TE,
41 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090042 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000043 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
44 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000045};
46
47static struct platform_device scif0_device = {
48 .name = "sh-sci",
49 .id = 0,
50 .dev = {
51 .platform_data = &scif0_platform_data,
52 },
53};
54
Magnus Damm74905092010-05-20 14:35:30 +000055/* SCIFA1 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000056static struct plat_sci_port scif1_platform_data = {
57 .mapbase = 0xe6c50000,
58 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090059 .scscr = SCSCR_RE | SCSCR_TE,
60 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090061 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000062 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
63 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000064};
65
66static struct platform_device scif1_device = {
67 .name = "sh-sci",
68 .id = 1,
69 .dev = {
70 .platform_data = &scif1_platform_data,
71 },
72};
73
Magnus Damm74905092010-05-20 14:35:30 +000074/* SCIFA2 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000075static struct plat_sci_port scif2_platform_data = {
76 .mapbase = 0xe6c60000,
77 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090078 .scscr = SCSCR_RE | SCSCR_TE,
79 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090080 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000081 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
82 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000083};
84
85static struct platform_device scif2_device = {
86 .name = "sh-sci",
87 .id = 2,
88 .dev = {
89 .platform_data = &scif2_platform_data,
90 },
91};
92
Magnus Damm74905092010-05-20 14:35:30 +000093/* SCIFA3 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000094static struct plat_sci_port scif3_platform_data = {
95 .mapbase = 0xe6c70000,
96 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090097 .scscr = SCSCR_RE | SCSCR_TE,
98 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090099 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000100 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
101 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000102};
103
104static struct platform_device scif3_device = {
105 .name = "sh-sci",
106 .id = 3,
107 .dev = {
108 .platform_data = &scif3_platform_data,
109 },
110};
111
Magnus Damm74905092010-05-20 14:35:30 +0000112/* SCIFA4 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000113static struct plat_sci_port scif4_platform_data = {
114 .mapbase = 0xe6c80000,
115 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900116 .scscr = SCSCR_RE | SCSCR_TE,
117 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900118 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000119 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
120 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000121};
122
123static struct platform_device scif4_device = {
124 .name = "sh-sci",
125 .id = 4,
126 .dev = {
127 .platform_data = &scif4_platform_data,
128 },
129};
130
Magnus Damm74905092010-05-20 14:35:30 +0000131/* SCIFA5 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000132static struct plat_sci_port scif5_platform_data = {
133 .mapbase = 0xe6cb0000,
134 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900135 .scscr = SCSCR_RE | SCSCR_TE,
136 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900137 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000138 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
139 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000140};
141
142static struct platform_device scif5_device = {
143 .name = "sh-sci",
144 .id = 5,
145 .dev = {
146 .platform_data = &scif5_platform_data,
147 },
148};
149
Magnus Damm74905092010-05-20 14:35:30 +0000150/* SCIFB */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000151static struct plat_sci_port scif6_platform_data = {
152 .mapbase = 0xe6c30000,
153 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900154 .scscr = SCSCR_RE | SCSCR_TE,
155 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900156 .type = PORT_SCIFB,
Magnus Damm74905092010-05-20 14:35:30 +0000157 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
158 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000159};
160
161static struct platform_device scif6_device = {
162 .name = "sh-sci",
163 .id = 6,
164 .dev = {
165 .platform_data = &scif6_platform_data,
166 },
167};
168
169static struct sh_timer_config cmt10_platform_data = {
170 .name = "CMT10",
171 .channel_offset = 0x10,
172 .timer_bit = 0,
Magnus Dammc793c1b2010-02-05 11:14:49 +0000173 .clockevent_rating = 125,
174 .clocksource_rating = 125,
175};
176
177static struct resource cmt10_resources[] = {
178 [0] = {
179 .name = "CMT10",
180 .start = 0xe6138010,
181 .end = 0xe613801b,
182 .flags = IORESOURCE_MEM,
183 },
184 [1] = {
Magnus Damm74905092010-05-20 14:35:30 +0000185 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000186 .flags = IORESOURCE_IRQ,
187 },
188};
189
190static struct platform_device cmt10_device = {
191 .name = "sh_cmt",
192 .id = 10,
193 .dev = {
194 .platform_data = &cmt10_platform_data,
195 },
196 .resource = cmt10_resources,
197 .num_resources = ARRAY_SIZE(cmt10_resources),
198};
199
Magnus Dammde328352011-04-28 03:16:32 +0000200/* VPU */
201static struct uio_info vpu_platform_data = {
202 .name = "VPU5",
203 .version = "0",
204 .irq = intcs_evt2irq(0x980),
205};
206
207static struct resource vpu_resources[] = {
208 [0] = {
209 .name = "VPU",
210 .start = 0xfe900000,
211 .end = 0xfe902807,
212 .flags = IORESOURCE_MEM,
213 },
214};
215
216static struct platform_device vpu_device = {
217 .name = "uio_pdrv_genirq",
218 .id = 0,
219 .dev = {
220 .platform_data = &vpu_platform_data,
221 },
222 .resource = vpu_resources,
223 .num_resources = ARRAY_SIZE(vpu_resources),
224};
225
226/* VEU0 */
227static struct uio_info veu0_platform_data = {
228 .name = "VEU0",
229 .version = "0",
230 .irq = intcs_evt2irq(0x700),
231};
232
233static struct resource veu0_resources[] = {
234 [0] = {
235 .name = "VEU0",
236 .start = 0xfe920000,
237 .end = 0xfe9200b7,
238 .flags = IORESOURCE_MEM,
239 },
240};
241
242static struct platform_device veu0_device = {
243 .name = "uio_pdrv_genirq",
244 .id = 1,
245 .dev = {
246 .platform_data = &veu0_platform_data,
247 },
248 .resource = veu0_resources,
249 .num_resources = ARRAY_SIZE(veu0_resources),
250};
251
252/* VEU1 */
253static struct uio_info veu1_platform_data = {
254 .name = "VEU1",
255 .version = "0",
256 .irq = intcs_evt2irq(0x720),
257};
258
259static struct resource veu1_resources[] = {
260 [0] = {
261 .name = "VEU1",
262 .start = 0xfe924000,
263 .end = 0xfe9240b7,
264 .flags = IORESOURCE_MEM,
265 },
266};
267
268static struct platform_device veu1_device = {
269 .name = "uio_pdrv_genirq",
270 .id = 2,
271 .dev = {
272 .platform_data = &veu1_platform_data,
273 },
274 .resource = veu1_resources,
275 .num_resources = ARRAY_SIZE(veu1_resources),
276};
277
278/* VEU2 */
279static struct uio_info veu2_platform_data = {
280 .name = "VEU2",
281 .version = "0",
282 .irq = intcs_evt2irq(0x740),
283};
284
285static struct resource veu2_resources[] = {
286 [0] = {
287 .name = "VEU2",
288 .start = 0xfe928000,
289 .end = 0xfe9280b7,
290 .flags = IORESOURCE_MEM,
291 },
292};
293
294static struct platform_device veu2_device = {
295 .name = "uio_pdrv_genirq",
296 .id = 3,
297 .dev = {
298 .platform_data = &veu2_platform_data,
299 },
300 .resource = veu2_resources,
301 .num_resources = ARRAY_SIZE(veu2_resources),
302};
303
304/* VEU3 */
305static struct uio_info veu3_platform_data = {
306 .name = "VEU3",
307 .version = "0",
308 .irq = intcs_evt2irq(0x760),
309};
310
311static struct resource veu3_resources[] = {
312 [0] = {
313 .name = "VEU3",
314 .start = 0xfe92c000,
315 .end = 0xfe92c0b7,
316 .flags = IORESOURCE_MEM,
317 },
318};
319
320static struct platform_device veu3_device = {
321 .name = "uio_pdrv_genirq",
322 .id = 4,
323 .dev = {
324 .platform_data = &veu3_platform_data,
325 },
326 .resource = veu3_resources,
327 .num_resources = ARRAY_SIZE(veu3_resources),
328};
329
330/* VEU2H */
331static struct uio_info veu2h_platform_data = {
332 .name = "VEU2H",
333 .version = "0",
334 .irq = intcs_evt2irq(0x520),
335};
336
337static struct resource veu2h_resources[] = {
338 [0] = {
339 .name = "VEU2H",
340 .start = 0xfe93c000,
341 .end = 0xfe93c27b,
342 .flags = IORESOURCE_MEM,
343 },
344};
345
346static struct platform_device veu2h_device = {
347 .name = "uio_pdrv_genirq",
348 .id = 5,
349 .dev = {
350 .platform_data = &veu2h_platform_data,
351 },
352 .resource = veu2h_resources,
353 .num_resources = ARRAY_SIZE(veu2h_resources),
354};
355
356/* JPU */
357static struct uio_info jpu_platform_data = {
358 .name = "JPU",
359 .version = "0",
360 .irq = intcs_evt2irq(0x560),
361};
362
363static struct resource jpu_resources[] = {
364 [0] = {
365 .name = "JPU",
366 .start = 0xfe980000,
367 .end = 0xfe9902d3,
368 .flags = IORESOURCE_MEM,
369 },
370};
371
372static struct platform_device jpu_device = {
373 .name = "uio_pdrv_genirq",
374 .id = 6,
375 .dev = {
376 .platform_data = &jpu_platform_data,
377 },
378 .resource = jpu_resources,
379 .num_resources = ARRAY_SIZE(jpu_resources),
380};
381
382/* SPU1 */
383static struct uio_info spu1_platform_data = {
384 .name = "SPU1",
385 .version = "0",
386 .irq = evt2irq(0xfc0),
387};
388
389static struct resource spu1_resources[] = {
390 [0] = {
391 .name = "SPU1",
392 .start = 0xfe300000,
393 .end = 0xfe3fffff,
394 .flags = IORESOURCE_MEM,
395 },
396};
397
398static struct platform_device spu1_device = {
399 .name = "uio_pdrv_genirq",
400 .id = 7,
401 .dev = {
402 .platform_data = &spu1_platform_data,
403 },
404 .resource = spu1_resources,
405 .num_resources = ARRAY_SIZE(spu1_resources),
406};
407
Magnus Dammc793c1b2010-02-05 11:14:49 +0000408static struct platform_device *sh7367_early_devices[] __initdata = {
409 &scif0_device,
410 &scif1_device,
411 &scif2_device,
412 &scif3_device,
413 &scif4_device,
414 &scif5_device,
415 &scif6_device,
416 &cmt10_device,
417};
418
Magnus Dammde328352011-04-28 03:16:32 +0000419static struct platform_device *sh7367_devices[] __initdata = {
420 &vpu_device,
421 &veu0_device,
422 &veu1_device,
423 &veu2_device,
424 &veu3_device,
425 &veu2h_device,
426 &jpu_device,
427 &spu1_device,
428};
429
Magnus Dammc793c1b2010-02-05 11:14:49 +0000430void __init sh7367_add_standard_devices(void)
431{
432 platform_add_devices(sh7367_early_devices,
433 ARRAY_SIZE(sh7367_early_devices));
Magnus Dammde328352011-04-28 03:16:32 +0000434
435 platform_add_devices(sh7367_devices,
436 ARRAY_SIZE(sh7367_devices));
Magnus Dammc793c1b2010-02-05 11:14:49 +0000437}
438
439#define SYMSTPCR2 0xe6158048
440#define SYMSTPCR2_CMT1 (1 << 29)
441
442void __init sh7367_add_early_devices(void)
443{
444 /* enable clock to CMT1 */
445 __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2);
446
447 early_platform_add_devices(sh7367_early_devices,
448 ARRAY_SIZE(sh7367_early_devices));
449}