blob: a00283fe528ce1d7c24ba44f3644c1755971b114 [file] [log] [blame]
Magnus Dammf411fad2011-12-14 01:36:12 +09001/*
2 * r8a7779 processor support
3 *
Sergei Shtylyovdace48d2013-04-04 18:53:50 +00004 * Copyright (C) 2011, 2013 Renesas Solutions Corp.
Magnus Dammf411fad2011-12-14 01:36:12 +09005 * Copyright (C) 2011 Magnus Damm
Sergei Shtylyovdace48d2013-04-04 18:53:50 +00006 * Copyright (C) 2013 Cogent Embedded, Inc.
Magnus Dammf411fad2011-12-14 01:36:12 +09007 *
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>
Simon Horman10e8d4f2012-11-21 22:00:15 +090025#include <linux/of_platform.h>
Laurent Pinchart37a72d02013-03-10 03:31:51 +010026#include <linux/platform_data/gpio-rcar.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090027#include <linux/platform_device.h>
28#include <linux/delay.h>
29#include <linux/input.h>
30#include <linux/io.h>
31#include <linux/serial_sci.h>
32#include <linux/sh_intc.h>
33#include <linux/sh_timer.h>
Vladimir Barinova7b98372013-02-27 23:39:14 +030034#include <linux/dma-mapping.h>
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +040035#include <linux/usb/otg.h>
Sergei Shtylyov84a812d2013-06-02 01:37:01 +040036#include <linux/usb/hcd.h>
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +040037#include <linux/usb/ehci_pdriver.h>
38#include <linux/usb/ohci_pdriver.h>
39#include <linux/pm_runtime.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090040#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060041#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090042#include <mach/r8a7779.h>
Magnus Damma662c082012-01-10 15:50:01 +090043#include <mach/common.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090044#include <asm/mach-types.h>
45#include <asm/mach/arch.h>
Magnus Dammdf27a2d2012-03-06 17:37:01 +090046#include <asm/mach/time.h>
Magnus Damm3e353b872012-02-29 21:37:43 +090047#include <asm/mach/map.h>
Magnus Damm8bac13f2012-03-01 12:48:03 +090048#include <asm/hardware/cache-l2x0.h>
Magnus Damm3e353b872012-02-29 21:37:43 +090049
50static struct map_desc r8a7779_io_desc[] __initdata = {
51 /* 2M entity map for 0xf0000000 (MPCORE) */
52 {
53 .virtual = 0xf0000000,
54 .pfn = __phys_to_pfn(0xf0000000),
55 .length = SZ_2M,
56 .type = MT_DEVICE_NONSHARED
57 },
58 /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
59 {
60 .virtual = 0xfe000000,
61 .pfn = __phys_to_pfn(0xfe000000),
62 .length = SZ_16M,
63 .type = MT_DEVICE_NONSHARED
64 },
65};
66
67void __init r8a7779_map_io(void)
68{
69 iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
70}
Magnus Dammf411fad2011-12-14 01:36:12 +090071
Laurent Pinchart8b6edf32012-12-15 23:51:26 +010072static struct resource r8a7779_pfc_resources[] = {
Magnus Damm0ccaf5b2013-04-12 14:21:29 +020073 DEFINE_RES_MEM(0xfffc0000, 0x023c),
Laurent Pinchart8b6edf32012-12-15 23:51:26 +010074};
75
76static struct platform_device r8a7779_pfc_device = {
77 .name = "pfc-r8a7779",
78 .id = -1,
79 .resource = r8a7779_pfc_resources,
80 .num_resources = ARRAY_SIZE(r8a7779_pfc_resources),
81};
82
Laurent Pinchart37a72d02013-03-10 03:31:51 +010083#define R8A7779_GPIO(idx, npins) \
84static struct resource r8a7779_gpio##idx##_resources[] = { \
Magnus Damm0ccaf5b2013-04-12 14:21:29 +020085 DEFINE_RES_MEM(0xffc40000 + (0x1000 * (idx)), 0x002c), \
86 DEFINE_RES_IRQ(gic_iid(0xad + (idx))), \
Laurent Pinchart37a72d02013-03-10 03:31:51 +010087}; \
88 \
89static struct gpio_rcar_config r8a7779_gpio##idx##_platform_data = { \
90 .gpio_base = 32 * (idx), \
91 .irq_base = 0, \
92 .number_of_pins = npins, \
93 .pctl_name = "pfc-r8a7779", \
94}; \
95 \
96static struct platform_device r8a7779_gpio##idx##_device = { \
97 .name = "gpio_rcar", \
98 .id = idx, \
99 .resource = r8a7779_gpio##idx##_resources, \
100 .num_resources = ARRAY_SIZE(r8a7779_gpio##idx##_resources), \
101 .dev = { \
102 .platform_data = &r8a7779_gpio##idx##_platform_data, \
103 }, \
104}
105
106R8A7779_GPIO(0, 32);
107R8A7779_GPIO(1, 32);
108R8A7779_GPIO(2, 32);
109R8A7779_GPIO(3, 32);
110R8A7779_GPIO(4, 32);
111R8A7779_GPIO(5, 32);
112R8A7779_GPIO(6, 9);
113
114static struct platform_device *r8a7779_pinctrl_devices[] __initdata = {
115 &r8a7779_pfc_device,
116 &r8a7779_gpio0_device,
117 &r8a7779_gpio1_device,
118 &r8a7779_gpio2_device,
119 &r8a7779_gpio3_device,
120 &r8a7779_gpio4_device,
121 &r8a7779_gpio5_device,
122 &r8a7779_gpio6_device,
123};
124
Laurent Pinchart8b6edf32012-12-15 23:51:26 +0100125void __init r8a7779_pinmux_init(void)
126{
Laurent Pinchart37a72d02013-03-10 03:31:51 +0100127 platform_add_devices(r8a7779_pinctrl_devices,
128 ARRAY_SIZE(r8a7779_pinctrl_devices));
Laurent Pinchart8b6edf32012-12-15 23:51:26 +0100129}
130
Magnus Dammf411fad2011-12-14 01:36:12 +0900131static struct plat_sci_port scif0_platform_data = {
132 .mapbase = 0xffe40000,
133 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
134 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
135 .scbrr_algo_id = SCBRR_ALGO_2,
136 .type = PORT_SCIF,
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800137 .irqs = SCIx_IRQ_MUXED(gic_iid(0x78)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900138};
139
140static struct platform_device scif0_device = {
141 .name = "sh-sci",
142 .id = 0,
143 .dev = {
144 .platform_data = &scif0_platform_data,
145 },
146};
147
148static struct plat_sci_port scif1_platform_data = {
149 .mapbase = 0xffe41000,
150 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
151 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
152 .scbrr_algo_id = SCBRR_ALGO_2,
153 .type = PORT_SCIF,
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800154 .irqs = SCIx_IRQ_MUXED(gic_iid(0x79)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900155};
156
157static struct platform_device scif1_device = {
158 .name = "sh-sci",
159 .id = 1,
160 .dev = {
161 .platform_data = &scif1_platform_data,
162 },
163};
164
165static struct plat_sci_port scif2_platform_data = {
166 .mapbase = 0xffe42000,
167 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
168 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
169 .scbrr_algo_id = SCBRR_ALGO_2,
170 .type = PORT_SCIF,
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800171 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7a)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900172};
173
174static struct platform_device scif2_device = {
175 .name = "sh-sci",
176 .id = 2,
177 .dev = {
178 .platform_data = &scif2_platform_data,
179 },
180};
181
182static struct plat_sci_port scif3_platform_data = {
183 .mapbase = 0xffe43000,
184 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
185 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
186 .scbrr_algo_id = SCBRR_ALGO_2,
187 .type = PORT_SCIF,
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800188 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7b)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900189};
190
191static struct platform_device scif3_device = {
192 .name = "sh-sci",
193 .id = 3,
194 .dev = {
195 .platform_data = &scif3_platform_data,
196 },
197};
198
199static struct plat_sci_port scif4_platform_data = {
200 .mapbase = 0xffe44000,
201 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
202 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
203 .scbrr_algo_id = SCBRR_ALGO_2,
204 .type = PORT_SCIF,
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800205 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7c)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900206};
207
208static struct platform_device scif4_device = {
209 .name = "sh-sci",
210 .id = 4,
211 .dev = {
212 .platform_data = &scif4_platform_data,
213 },
214};
215
216static struct plat_sci_port scif5_platform_data = {
217 .mapbase = 0xffe45000,
218 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
219 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
220 .scbrr_algo_id = SCBRR_ALGO_2,
221 .type = PORT_SCIF,
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800222 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7d)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900223};
224
225static struct platform_device scif5_device = {
226 .name = "sh-sci",
227 .id = 5,
228 .dev = {
229 .platform_data = &scif5_platform_data,
230 },
231};
232
233/* TMU */
234static struct sh_timer_config tmu00_platform_data = {
235 .name = "TMU00",
236 .channel_offset = 0x4,
237 .timer_bit = 0,
238 .clockevent_rating = 200,
239};
240
241static struct resource tmu00_resources[] = {
242 [0] = {
243 .name = "TMU00",
244 .start = 0xffd80008,
245 .end = 0xffd80013,
246 .flags = IORESOURCE_MEM,
247 },
248 [1] = {
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800249 .start = gic_iid(0x40),
Magnus Dammf411fad2011-12-14 01:36:12 +0900250 .flags = IORESOURCE_IRQ,
251 },
252};
253
254static struct platform_device tmu00_device = {
255 .name = "sh_tmu",
256 .id = 0,
257 .dev = {
258 .platform_data = &tmu00_platform_data,
259 },
260 .resource = tmu00_resources,
261 .num_resources = ARRAY_SIZE(tmu00_resources),
262};
263
264static struct sh_timer_config tmu01_platform_data = {
265 .name = "TMU01",
266 .channel_offset = 0x10,
267 .timer_bit = 1,
268 .clocksource_rating = 200,
269};
270
271static struct resource tmu01_resources[] = {
272 [0] = {
273 .name = "TMU01",
274 .start = 0xffd80014,
275 .end = 0xffd8001f,
276 .flags = IORESOURCE_MEM,
277 },
278 [1] = {
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800279 .start = gic_iid(0x41),
Magnus Dammf411fad2011-12-14 01:36:12 +0900280 .flags = IORESOURCE_IRQ,
281 },
282};
283
284static struct platform_device tmu01_device = {
285 .name = "sh_tmu",
286 .id = 1,
287 .dev = {
288 .platform_data = &tmu01_platform_data,
289 },
290 .resource = tmu01_resources,
291 .num_resources = ARRAY_SIZE(tmu01_resources),
292};
293
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700294/* I2C */
295static struct resource rcar_i2c0_res[] = {
296 {
297 .start = 0xffc70000,
298 .end = 0xffc70fff,
299 .flags = IORESOURCE_MEM,
300 }, {
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800301 .start = gic_iid(0x6f),
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700302 .flags = IORESOURCE_IRQ,
303 },
304};
305
306static struct platform_device i2c0_device = {
307 .name = "i2c-rcar",
308 .id = 0,
309 .resource = rcar_i2c0_res,
310 .num_resources = ARRAY_SIZE(rcar_i2c0_res),
311};
312
313static struct resource rcar_i2c1_res[] = {
314 {
315 .start = 0xffc71000,
316 .end = 0xffc71fff,
317 .flags = IORESOURCE_MEM,
318 }, {
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800319 .start = gic_iid(0x72),
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700320 .flags = IORESOURCE_IRQ,
321 },
322};
323
324static struct platform_device i2c1_device = {
325 .name = "i2c-rcar",
326 .id = 1,
327 .resource = rcar_i2c1_res,
328 .num_resources = ARRAY_SIZE(rcar_i2c1_res),
329};
330
331static struct resource rcar_i2c2_res[] = {
332 {
333 .start = 0xffc72000,
334 .end = 0xffc72fff,
335 .flags = IORESOURCE_MEM,
336 }, {
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800337 .start = gic_iid(0x70),
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700338 .flags = IORESOURCE_IRQ,
339 },
340};
341
342static struct platform_device i2c2_device = {
343 .name = "i2c-rcar",
344 .id = 2,
345 .resource = rcar_i2c2_res,
346 .num_resources = ARRAY_SIZE(rcar_i2c2_res),
347};
348
349static struct resource rcar_i2c3_res[] = {
350 {
351 .start = 0xffc73000,
352 .end = 0xffc73fff,
353 .flags = IORESOURCE_MEM,
354 }, {
Kuninori Morimotodbe95ad2013-03-03 23:11:41 -0800355 .start = gic_iid(0x71),
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700356 .flags = IORESOURCE_IRQ,
357 },
358};
359
360static struct platform_device i2c3_device = {
361 .name = "i2c-rcar",
362 .id = 3,
363 .resource = rcar_i2c3_res,
364 .num_resources = ARRAY_SIZE(rcar_i2c3_res),
365};
366
Vladimir Barinova7b98372013-02-27 23:39:14 +0300367static struct resource sata_resources[] = {
368 [0] = {
369 .name = "rcar-sata",
370 .start = 0xfc600000,
371 .end = 0xfc601fff,
372 .flags = IORESOURCE_MEM,
373 },
374 [1] = {
Sergei Shtylyovd60cd5f2013-03-08 02:31:03 +0300375 .start = gic_iid(0x84),
Vladimir Barinova7b98372013-02-27 23:39:14 +0300376 .flags = IORESOURCE_IRQ,
377 },
378};
379
380static struct platform_device sata_device = {
381 .name = "sata_rcar",
382 .id = -1,
383 .resource = sata_resources,
384 .num_resources = ARRAY_SIZE(sata_resources),
385 .dev = {
386 .dma_mask = &sata_device.dev.coherent_dma_mask,
387 .coherent_dma_mask = DMA_BIT_MASK(32),
388 },
389};
390
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400391/* USB PHY */
392static struct resource usb_phy_resources[] = {
393 [0] = {
Sergei Shtylyov725bf9d2013-06-02 01:50:25 +0400394 .start = 0xffe70800,
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400395 .end = 0xffe70900 - 1,
396 .flags = IORESOURCE_MEM,
397 },
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400398};
399
400static struct platform_device usb_phy_device = {
401 .name = "rcar_usb_phy",
402 .id = -1,
403 .resource = usb_phy_resources,
404 .num_resources = ARRAY_SIZE(usb_phy_resources),
405};
406
407/* USB */
408static struct usb_phy *phy;
409
410static int usb_power_on(struct platform_device *pdev)
411{
412 if (IS_ERR(phy))
413 return PTR_ERR(phy);
414
415 pm_runtime_enable(&pdev->dev);
416 pm_runtime_get_sync(&pdev->dev);
417
418 usb_phy_init(phy);
419
420 return 0;
421}
422
423static void usb_power_off(struct platform_device *pdev)
424{
425 if (IS_ERR(phy))
426 return;
427
428 usb_phy_shutdown(phy);
429
430 pm_runtime_put_sync(&pdev->dev);
431 pm_runtime_disable(&pdev->dev);
432}
433
Sergei Shtylyov84a812d2013-06-02 01:37:01 +0400434static int ehci_init_internal_buffer(struct usb_hcd *hcd)
435{
436 /*
437 * Below are recommended values from the datasheet;
438 * see [USB :: Setting of EHCI Internal Buffer].
439 */
440 /* EHCI IP internal buffer setting */
441 iowrite32(0x00ff0040, hcd->regs + 0x0094);
442 /* EHCI IP internal buffer enable */
443 iowrite32(0x00000001, hcd->regs + 0x009C);
444
445 return 0;
446}
447
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400448static struct usb_ehci_pdata ehcix_pdata = {
449 .power_on = usb_power_on,
450 .power_off = usb_power_off,
451 .power_suspend = usb_power_off,
Sergei Shtylyov84a812d2013-06-02 01:37:01 +0400452 .pre_setup = ehci_init_internal_buffer,
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400453};
454
455static struct resource ehci0_resources[] = {
456 [0] = {
457 .start = 0xffe70000,
458 .end = 0xffe70400 - 1,
459 .flags = IORESOURCE_MEM,
460 },
461 [1] = {
462 .start = gic_iid(0x4c),
463 .flags = IORESOURCE_IRQ,
464 },
465};
466
467static struct platform_device ehci0_device = {
468 .name = "ehci-platform",
469 .id = 0,
470 .dev = {
471 .dma_mask = &ehci0_device.dev.coherent_dma_mask,
472 .coherent_dma_mask = 0xffffffff,
473 .platform_data = &ehcix_pdata,
474 },
475 .num_resources = ARRAY_SIZE(ehci0_resources),
476 .resource = ehci0_resources,
477};
478
479static struct resource ehci1_resources[] = {
480 [0] = {
481 .start = 0xfff70000,
482 .end = 0xfff70400 - 1,
483 .flags = IORESOURCE_MEM,
484 },
485 [1] = {
486 .start = gic_iid(0x4d),
487 .flags = IORESOURCE_IRQ,
488 },
489};
490
491static struct platform_device ehci1_device = {
492 .name = "ehci-platform",
493 .id = 1,
494 .dev = {
495 .dma_mask = &ehci1_device.dev.coherent_dma_mask,
496 .coherent_dma_mask = 0xffffffff,
497 .platform_data = &ehcix_pdata,
498 },
499 .num_resources = ARRAY_SIZE(ehci1_resources),
500 .resource = ehci1_resources,
501};
502
503static struct usb_ohci_pdata ohcix_pdata = {
504 .power_on = usb_power_on,
505 .power_off = usb_power_off,
506 .power_suspend = usb_power_off,
507};
508
509static struct resource ohci0_resources[] = {
510 [0] = {
511 .start = 0xffe70400,
512 .end = 0xffe70800 - 1,
513 .flags = IORESOURCE_MEM,
514 },
515 [1] = {
516 .start = gic_iid(0x4c),
517 .flags = IORESOURCE_IRQ,
518 },
519};
520
521static struct platform_device ohci0_device = {
522 .name = "ohci-platform",
523 .id = 0,
524 .dev = {
525 .dma_mask = &ohci0_device.dev.coherent_dma_mask,
526 .coherent_dma_mask = 0xffffffff,
527 .platform_data = &ohcix_pdata,
528 },
529 .num_resources = ARRAY_SIZE(ohci0_resources),
530 .resource = ohci0_resources,
531};
532
533static struct resource ohci1_resources[] = {
534 [0] = {
535 .start = 0xfff70400,
536 .end = 0xfff70800 - 1,
537 .flags = IORESOURCE_MEM,
538 },
539 [1] = {
540 .start = gic_iid(0x4d),
541 .flags = IORESOURCE_IRQ,
542 },
543};
544
545static struct platform_device ohci1_device = {
546 .name = "ohci-platform",
547 .id = 1,
548 .dev = {
549 .dma_mask = &ohci1_device.dev.coherent_dma_mask,
550 .coherent_dma_mask = 0xffffffff,
551 .platform_data = &ohcix_pdata,
552 },
553 .num_resources = ARRAY_SIZE(ohci1_resources),
554 .resource = ohci1_resources,
555};
556
Sergei Shtylyovdace48d2013-04-04 18:53:50 +0000557/* Ether */
558static struct resource ether_resources[] = {
559 {
560 .start = 0xfde00000,
561 .end = 0xfde003ff,
562 .flags = IORESOURCE_MEM,
563 }, {
564 .start = gic_iid(0xb4),
565 .flags = IORESOURCE_IRQ,
566 },
567};
568
Simon Horman916ddc32013-02-19 10:53:05 +0900569static struct platform_device *r8a7779_devices_dt[] __initdata = {
Magnus Dammf411fad2011-12-14 01:36:12 +0900570 &scif0_device,
571 &scif1_device,
572 &scif2_device,
573 &scif3_device,
574 &scif4_device,
575 &scif5_device,
576 &tmu00_device,
577 &tmu01_device,
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400578 &usb_phy_device,
Simon Horman10e8d4f2012-11-21 22:00:15 +0900579};
580
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400581static struct platform_device *r8a7779_standard_devices[] __initdata = {
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700582 &i2c0_device,
583 &i2c1_device,
584 &i2c2_device,
585 &i2c3_device,
Vladimir Barinova7b98372013-02-27 23:39:14 +0300586 &sata_device,
Magnus Dammf411fad2011-12-14 01:36:12 +0900587};
588
Magnus Dammf411fad2011-12-14 01:36:12 +0900589void __init r8a7779_add_standard_devices(void)
590{
Magnus Damm8bac13f2012-03-01 12:48:03 +0900591#ifdef CONFIG_CACHE_L2X0
592 /* Early BRESP enable, Shared attribute override enable, 64K*16way */
Kuninori Morimotoed7d1322012-10-14 23:35:24 -0700593 l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff);
Magnus Damm8bac13f2012-03-01 12:48:03 +0900594#endif
Magnus Damma662c082012-01-10 15:50:01 +0900595 r8a7779_pm_init();
596
Rafael J. Wysocki45e5ca52012-08-07 01:14:14 +0200597 r8a7779_init_pm_domains();
Magnus Damma662c082012-01-10 15:50:01 +0900598
Simon Horman916ddc32013-02-19 10:53:05 +0900599 platform_add_devices(r8a7779_devices_dt,
600 ARRAY_SIZE(r8a7779_devices_dt));
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400601 platform_add_devices(r8a7779_standard_devices,
602 ARRAY_SIZE(r8a7779_standard_devices));
Magnus Dammf411fad2011-12-14 01:36:12 +0900603}
604
Sergei Shtylyovdace48d2013-04-04 18:53:50 +0000605void __init r8a7779_add_ether_device(struct sh_eth_plat_data *pdata)
606{
607 platform_device_register_resndata(&platform_bus, "sh_eth", -1,
608 ether_resources,
609 ARRAY_SIZE(ether_resources),
610 pdata, sizeof(*pdata));
611}
612
Magnus Dammb759bd12012-05-10 14:57:22 +0900613/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
614void __init __weak r8a7779_register_twd(void) { }
615
Stephen Warren6bb27d72012-11-08 12:40:59 -0700616void __init r8a7779_earlytimer_init(void)
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900617{
618 r8a7779_clock_init();
619 shmobile_earlytimer_init();
Magnus Dammb759bd12012-05-10 14:57:22 +0900620 r8a7779_register_twd();
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900621}
622
Magnus Dammf411fad2011-12-14 01:36:12 +0900623void __init r8a7779_add_early_devices(void)
624{
Simon Horman916ddc32013-02-19 10:53:05 +0900625 early_platform_add_devices(r8a7779_devices_dt,
626 ARRAY_SIZE(r8a7779_devices_dt));
Magnus Damm3e353b872012-02-29 21:37:43 +0900627
628 /* Early serial console setup is not included here due to
629 * memory map collisions. The SCIF serial ports in r8a7779
630 * are difficult to entity map 1:1 due to collision with the
631 * virtual memory range used by the coherent DMA code on ARM.
632 *
633 * Anyone wanting to debug early can remove UPF_IOREMAP from
634 * the sh-sci serial console platform data, adjust mapbase
635 * to a static M:N virt:phys mapping that needs to be added to
636 * the mappings passed with iotable_init() above.
637 *
638 * Then add a call to shmobile_setup_console() from this function.
639 *
640 * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
641 * command line in case of the marzen board.
642 */
Magnus Dammf411fad2011-12-14 01:36:12 +0900643}
Simon Horman10e8d4f2012-11-21 22:00:15 +0900644
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400645static struct platform_device *r8a7779_late_devices[] __initdata = {
646 &ehci0_device,
647 &ehci1_device,
648 &ohci0_device,
649 &ohci1_device,
650};
651
652void __init r8a7779_init_late(void)
653{
654 /* get USB PHY */
655 phy = usb_get_phy(USB_PHY_TYPE_USB2);
656
657 shmobile_init_late();
658 platform_add_devices(r8a7779_late_devices,
659 ARRAY_SIZE(r8a7779_late_devices));
660}
661
Simon Horman10e8d4f2012-11-21 22:00:15 +0900662#ifdef CONFIG_USE_OF
Simon Horman916ddc32013-02-19 10:53:05 +0900663void __init r8a7779_init_delay(void)
Simon Horman10e8d4f2012-11-21 22:00:15 +0900664{
665 shmobile_setup_delay(1000, 2, 4); /* Cortex-A9 @ 1000MHz */
Simon Horman10e8d4f2012-11-21 22:00:15 +0900666}
667
668static const struct of_dev_auxdata r8a7779_auxdata_lookup[] __initconst = {
669 {},
670};
671
672void __init r8a7779_add_standard_devices_dt(void)
673{
674 /* clocks are setup late during boot in the case of DT */
675 r8a7779_clock_init();
676
Simon Horman916ddc32013-02-19 10:53:05 +0900677 platform_add_devices(r8a7779_devices_dt,
678 ARRAY_SIZE(r8a7779_devices_dt));
Simon Horman10e8d4f2012-11-21 22:00:15 +0900679 of_platform_populate(NULL, of_default_bus_match_table,
680 r8a7779_auxdata_lookup, NULL);
681}
682
683static const char *r8a7779_compat_dt[] __initdata = {
684 "renesas,r8a7779",
685 NULL,
686};
687
Kuninori Morimotoabe0e142013-03-03 23:11:20 -0800688DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
Simon Horman10e8d4f2012-11-21 22:00:15 +0900689 .map_io = r8a7779_map_io,
Simon Horman916ddc32013-02-19 10:53:05 +0900690 .init_early = r8a7779_init_delay,
Simon Horman10e8d4f2012-11-21 22:00:15 +0900691 .nr_irqs = NR_IRQS_LEGACY,
692 .init_irq = r8a7779_init_irq_dt,
693 .init_machine = r8a7779_add_standard_devices_dt,
694 .init_time = shmobile_timer_init,
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400695 .init_late = r8a7779_init_late,
Simon Horman10e8d4f2012-11-21 22:00:15 +0900696 .dt_compat = r8a7779_compat_dt,
697MACHINE_END
698#endif /* CONFIG_USE_OF */