blob: 4e6893f9e0da79533d5e7fdaf78e6cf21ef368c0 [file] [log] [blame]
Kuninori Morimoto4d22e562012-04-06 01:28:59 -07001/*
2 * armadillo 800 eva board support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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 */
21
22#include <linux/clk.h>
Kuninori Morimoto1c962932012-04-24 02:09:08 -070023#include <linux/delay.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070024#include <linux/err.h>
25#include <linux/kernel.h>
Kuninori Morimotof7e7d312012-04-06 01:31:33 -070026#include <linux/input.h>
Kuninori Morimoto1c962932012-04-24 02:09:08 -070027#include <linux/irq.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070028#include <linux/platform_device.h>
29#include <linux/gpio.h>
Kuninori Morimotof7e7d312012-04-06 01:31:33 -070030#include <linux/gpio_keys.h>
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -070031#include <linux/sh_eth.h>
Kuninori Morimotodad29d12012-04-06 01:30:09 -070032#include <linux/videodev2.h>
Kuninori Morimoto1c962932012-04-24 02:09:08 -070033#include <linux/usb/renesas_usbhs.h>
Kuninori Morimoto49c01112012-04-24 02:09:19 -070034#include <linux/mfd/tmio.h>
35#include <linux/mmc/host.h>
Kuninori Morimoto0a4266b2012-04-24 02:09:42 -070036#include <linux/mmc/sh_mmcif.h>
Kuninori Morimoto49c01112012-04-24 02:09:19 -070037#include <linux/mmc/sh_mobile_sdhi.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070038#include <mach/common.h>
39#include <mach/irqs.h>
40#include <asm/page.h>
41#include <asm/mach-types.h>
42#include <asm/mach/arch.h>
43#include <asm/mach/map.h>
44#include <asm/mach/time.h>
45#include <asm/hardware/cache-l2x0.h>
46#include <mach/r8a7740.h>
Kuninori Morimotodad29d12012-04-06 01:30:09 -070047#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto910c14d2012-06-12 02:39:11 -070048#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070049
50/*
51 * CON1 Camera Module
52 * CON2 Extension Bus
53 * CON3 HDMI Output
54 * CON4 Composite Video Output
55 * CON5 H-UDI JTAG
56 * CON6 ARM JTAG
57 * CON7 SD1
58 * CON8 SD2
59 * CON9 RTC BackUp
60 * CON10 Monaural Mic Input
61 * CON11 Stereo Headphone Output
62 * CON12 Audio Line Output(L)
63 * CON13 Audio Line Output(R)
64 * CON14 AWL13 Module
65 * CON15 Extension
66 * CON16 LCD1
67 * CON17 LCD2
68 * CON19 Power Input
69 * CON20 USB1
70 * CON21 USB2
71 * CON22 Serial
72 * CON23 LAN
73 * CON24 USB3
74 * LED1 Camera LED(Yellow)
75 * LED2 Power LED (Green)
76 * ED3-LED6 User LED(Yellow)
77 * LED7 LAN link LED(Green)
78 * LED8 LAN activity LED(Yellow)
79 */
80
81/*
82 * DipSwitch
83 *
84 * SW1
85 *
86 * -12345678-+---------------+----------------------------
87 * 1 | boot | hermit
88 * 0 | boot | OS auto boot
89 * -12345678-+---------------+----------------------------
90 * 00 | boot device | eMMC
91 * 10 | boot device | SDHI0 (CON7)
92 * 01 | boot device | -
93 * 11 | boot device | Extension Buss (CS0)
94 * -12345678-+---------------+----------------------------
95 * 0 | Extension Bus | D8-D15 disable, eMMC enable
96 * 1 | Extension Bus | D8-D15 enable, eMMC disable
97 * -12345678-+---------------+----------------------------
Kuninori Morimoto2e3a5ef2012-04-24 02:09:31 -070098 * 0 | SDHI1 | COM8 disable, COM14 enable
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070099 * 1 | SDHI1 | COM8 enable, COM14 disable
100 * -12345678-+---------------+----------------------------
Kuninori Morimoto1c962932012-04-24 02:09:08 -0700101 * 0 | USB0 | COM20 enable, COM24 disable
102 * 1 | USB0 | COM20 disable, COM24 enable
103 * -12345678-+---------------+----------------------------
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700104 * 00 | JTAG | SH-X2
105 * 10 | JTAG | ARM
106 * 01 | JTAG | -
107 * 11 | JTAG | Boundary Scan
108 *-----------+---------------+----------------------------
109 */
110
Kuninori Morimoto1c962932012-04-24 02:09:08 -0700111/*
112 * USB function
113 *
114 * When you use USB Function,
115 * set SW1.6 ON, and connect cable to CN24.
116 *
117 * USBF needs workaround on R8A7740 chip.
118 * These are a little bit complex.
119 * see
120 * usbhsf_power_ctrl()
121 *
122 * CAUTION
123 *
124 * It uses autonomy mode for USB hotplug at this point
125 * (= usbhs_private.platform_callback.get_vbus is NULL),
126 * since we don't know what's happen on PM control
127 * on this workaround.
128 */
129#define USBCR1 0xe605810a
130#define USBH 0xC6700000
131#define USBH_USBCTR 0x10834
132
133struct usbhsf_private {
134 struct clk *phy;
135 struct clk *usb24;
136 struct clk *pci;
137 struct clk *func;
138 struct clk *host;
139 void __iomem *usbh_base;
140 struct renesas_usbhs_platform_info info;
141};
142
143#define usbhsf_get_priv(pdev) \
144 container_of(renesas_usbhs_get_info(pdev), \
145 struct usbhsf_private, info)
146
147static int usbhsf_get_id(struct platform_device *pdev)
148{
149 return USBHS_GADGET;
150}
151
152static void usbhsf_power_ctrl(struct platform_device *pdev,
153 void __iomem *base, int enable)
154{
155 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
156
157 /*
158 * Work around for USB Function.
159 * It needs USB host clock, and settings
160 */
161 if (enable) {
162 /*
163 * enable all the related usb clocks
164 * for usb workaround
165 */
166 clk_enable(priv->usb24);
167 clk_enable(priv->pci);
168 clk_enable(priv->host);
169 clk_enable(priv->func);
170 clk_enable(priv->phy);
171
172 /*
173 * set USBCR1
174 *
175 * Port1 is driven by USB function,
176 * Port2 is driven by USB HOST
177 * One HOST (Port1 or Port2 is HOST)
178 * USB PLL input clock = 24MHz
179 */
180 __raw_writew(0xd750, USBCR1);
181 mdelay(1);
182
183 /*
184 * start USB Host
185 */
186 __raw_writel(0x0000000c, priv->usbh_base + USBH_USBCTR);
187 __raw_writel(0x00000008, priv->usbh_base + USBH_USBCTR);
188 mdelay(10);
189
190 /*
191 * USB PHY Power ON
192 */
193 __raw_writew(0xd770, USBCR1);
194 __raw_writew(0x4000, base + 0x102); /* USBF :: SUSPMODE */
195
196 } else {
197 __raw_writel(0x0000010f, priv->usbh_base + USBH_USBCTR);
198 __raw_writew(0xd7c0, USBCR1); /* GPIO */
199
200 clk_disable(priv->phy);
201 clk_disable(priv->func); /* usb work around */
202 clk_disable(priv->host); /* usb work around */
203 clk_disable(priv->pci); /* usb work around */
204 clk_disable(priv->usb24); /* usb work around */
205 }
206}
207
208static void usbhsf_hardware_exit(struct platform_device *pdev)
209{
210 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
211
212 if (!IS_ERR(priv->phy))
213 clk_put(priv->phy);
214 if (!IS_ERR(priv->usb24))
215 clk_put(priv->usb24);
216 if (!IS_ERR(priv->pci))
217 clk_put(priv->pci);
218 if (!IS_ERR(priv->host))
219 clk_put(priv->host);
220 if (!IS_ERR(priv->func))
221 clk_put(priv->func);
222 if (priv->usbh_base)
223 iounmap(priv->usbh_base);
224
225 priv->phy = NULL;
226 priv->usb24 = NULL;
227 priv->pci = NULL;
228 priv->host = NULL;
229 priv->func = NULL;
230 priv->usbh_base = NULL;
231}
232
233static int usbhsf_hardware_init(struct platform_device *pdev)
234{
235 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
236
237 priv->phy = clk_get(&pdev->dev, "phy");
238 priv->usb24 = clk_get(&pdev->dev, "usb24");
239 priv->pci = clk_get(&pdev->dev, "pci");
240 priv->func = clk_get(&pdev->dev, "func");
241 priv->host = clk_get(&pdev->dev, "host");
242 priv->usbh_base = ioremap_nocache(USBH, 0x20000);
243
244 if (IS_ERR(priv->phy) ||
245 IS_ERR(priv->usb24) ||
246 IS_ERR(priv->pci) ||
247 IS_ERR(priv->host) ||
248 IS_ERR(priv->func) ||
249 !priv->usbh_base) {
250 dev_err(&pdev->dev, "USB clock setting failed\n");
251 usbhsf_hardware_exit(pdev);
252 return -EIO;
253 }
254
255 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */
256 clk_set_rate(priv->usb24,
257 clk_get_rate(clk_get_parent(priv->usb24)));
258
259 return 0;
260}
261
262static struct usbhsf_private usbhsf_private = {
263 .info = {
264 .platform_callback = {
265 .get_id = usbhsf_get_id,
266 .hardware_init = usbhsf_hardware_init,
267 .hardware_exit = usbhsf_hardware_exit,
268 .power_ctrl = usbhsf_power_ctrl,
269 },
270 .driver_param = {
271 .buswait_bwait = 5,
272 .detection_delay = 5,
273 },
274 }
275};
276
277static struct resource usbhsf_resources[] = {
278 {
279 .name = "USBHS",
280 .start = 0xe6890000,
281 .end = 0xe6890104 - 1,
282 .flags = IORESOURCE_MEM,
283 },
284 {
285 .start = evt2irq(0x0A20),
286 .flags = IORESOURCE_IRQ,
287 },
288};
289
290static struct platform_device usbhsf_device = {
291 .name = "renesas_usbhs",
292 .dev = {
293 .platform_data = &usbhsf_private.info,
294 },
295 .id = -1,
296 .num_resources = ARRAY_SIZE(usbhsf_resources),
297 .resource = usbhsf_resources,
298};
299
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700300/* Ether */
301static struct sh_eth_plat_data sh_eth_platdata = {
302 .phy = 0x00, /* LAN8710A */
303 .edmac_endian = EDMAC_LITTLE_ENDIAN,
304 .register_type = SH_ETH_REG_GIGABIT,
305 .phy_interface = PHY_INTERFACE_MODE_MII,
306};
307
308static struct resource sh_eth_resources[] = {
309 {
310 .start = 0xe9a00000,
311 .end = 0xe9a00800 - 1,
312 .flags = IORESOURCE_MEM,
313 }, {
314 .start = 0xe9a01800,
315 .end = 0xe9a02000 - 1,
316 .flags = IORESOURCE_MEM,
317 }, {
318 .start = evt2irq(0x0500),
319 .flags = IORESOURCE_IRQ,
320 },
321};
322
323static struct platform_device sh_eth_device = {
324 .name = "sh-eth",
Kuninori Morimoto9c18f232012-05-06 22:58:41 -0700325 .id = -1,
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700326 .dev = {
327 .platform_data = &sh_eth_platdata,
328 },
329 .resource = sh_eth_resources,
330 .num_resources = ARRAY_SIZE(sh_eth_resources),
331};
332
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700333/* LCDC */
334static struct fb_videomode lcdc0_mode = {
335 .name = "AMPIER/AM-800480",
336 .xres = 800,
337 .yres = 480,
338 .left_margin = 88,
339 .right_margin = 40,
340 .hsync_len = 128,
341 .upper_margin = 20,
342 .lower_margin = 5,
343 .vsync_len = 5,
344 .sync = 0,
345};
346
347static struct sh_mobile_lcdc_info lcdc0_info = {
348 .clock_source = LCDC_CLK_BUS,
349 .ch[0] = {
350 .chan = LCDC_CHAN_MAINLCD,
351 .fourcc = V4L2_PIX_FMT_RGB565,
352 .interface_type = RGB24,
353 .clock_divider = 5,
354 .flags = 0,
355 .lcd_modes = &lcdc0_mode,
356 .num_modes = 1,
357 .panel_cfg = {
358 .width = 111,
359 .height = 68,
360 },
361 },
362};
363
364static struct resource lcdc0_resources[] = {
365 [0] = {
366 .name = "LCD0",
367 .start = 0xfe940000,
368 .end = 0xfe943fff,
369 .flags = IORESOURCE_MEM,
370 },
371 [1] = {
372 .start = intcs_evt2irq(0x580),
373 .flags = IORESOURCE_IRQ,
374 },
375};
376
377static struct platform_device lcdc0_device = {
378 .name = "sh_mobile_lcdc_fb",
379 .num_resources = ARRAY_SIZE(lcdc0_resources),
380 .resource = lcdc0_resources,
381 .id = 0,
382 .dev = {
383 .platform_data = &lcdc0_info,
384 .coherent_dma_mask = ~0,
385 },
386};
387
Kuninori Morimoto910c14d2012-06-12 02:39:11 -0700388/*
389 * LCDC1/HDMI
390 */
391static struct sh_mobile_hdmi_info hdmi_info = {
392 .flags = HDMI_OUTPUT_PUSH_PULL |
393 HDMI_OUTPUT_POLARITY_HI |
394 HDMI_32BIT_REG |
395 HDMI_HAS_HTOP1 |
396 HDMI_SND_SRC_SPDIF,
397};
398
399static struct resource hdmi_resources[] = {
400 [0] = {
401 .name = "HDMI",
402 .start = 0xe6be0000,
403 .end = 0xe6be03ff,
404 .flags = IORESOURCE_MEM,
405 },
406 [1] = {
407 .start = evt2irq(0x1700),
408 .flags = IORESOURCE_IRQ,
409 },
410 [2] = {
411 .name = "HDMI emma3pf",
412 .start = 0xe6be4000,
413 .end = 0xe6be43ff,
414 .flags = IORESOURCE_MEM,
415 },
416};
417
418static struct platform_device hdmi_device = {
419 .name = "sh-mobile-hdmi",
420 .num_resources = ARRAY_SIZE(hdmi_resources),
421 .resource = hdmi_resources,
422 .id = -1,
423 .dev = {
424 .platform_data = &hdmi_info,
425 },
426};
427
428static const struct fb_videomode lcdc1_mode = {
429 .name = "HDMI 720p",
430 .xres = 1280,
431 .yres = 720,
432 .pixclock = 13468,
433 .left_margin = 220,
434 .right_margin = 110,
435 .hsync_len = 40,
436 .upper_margin = 20,
437 .lower_margin = 5,
438 .vsync_len = 5,
439 .refresh = 60,
440 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
441};
442
443static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
444 .clock_source = LCDC_CLK_PERIPHERAL, /* HDMI clock */
445 .ch[0] = {
446 .chan = LCDC_CHAN_MAINLCD,
447 .fourcc = V4L2_PIX_FMT_RGB565,
448 .interface_type = RGB24,
449 .clock_divider = 1,
450 .flags = LCDC_FLAGS_DWPOL,
451 .lcd_modes = &lcdc1_mode,
452 .num_modes = 1,
453 .tx_dev = &hdmi_device,
454 .panel_cfg = {
455 .width = 1280,
456 .height = 720,
457 },
458 },
459};
460
461static struct resource hdmi_lcdc_resources[] = {
462 [0] = {
463 .name = "LCDC1",
464 .start = 0xfe944000,
465 .end = 0xfe948000 - 1,
466 .flags = IORESOURCE_MEM,
467 },
468 [1] = {
469 .start = intcs_evt2irq(0x1780),
470 .flags = IORESOURCE_IRQ,
471 },
472};
473
474static struct platform_device hdmi_lcdc_device = {
475 .name = "sh_mobile_lcdc_fb",
476 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
477 .resource = hdmi_lcdc_resources,
478 .id = 1,
479 .dev = {
480 .platform_data = &hdmi_lcdc_info,
481 .coherent_dma_mask = ~0,
482 },
483};
484
Kuninori Morimotof7e7d312012-04-06 01:31:33 -0700485/* GPIO KEY */
486#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
487
488static struct gpio_keys_button gpio_buttons[] = {
489 GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
490 GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
491 GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
492 GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
493};
494
495static struct gpio_keys_platform_data gpio_key_info = {
496 .buttons = gpio_buttons,
497 .nbuttons = ARRAY_SIZE(gpio_buttons),
498};
499
500static struct platform_device gpio_keys_device = {
501 .name = "gpio-keys",
502 .id = -1,
503 .dev = {
504 .platform_data = &gpio_key_info,
505 },
506};
507
Kuninori Morimoto49c01112012-04-24 02:09:19 -0700508/* SDHI0 */
509/*
510 * FIXME
511 *
512 * It use polling mode here, since
513 * CD (= Card Detect) pin is not connected to SDHI0_CD.
514 * We can use IRQ31 as card detect irq,
515 * but it needs chattering removal operation
516 */
517#define IRQ31 evt2irq(0x33E0)
518static struct sh_mobile_sdhi_info sdhi0_info = {
519 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\
520 MMC_CAP_NEEDS_POLL,
521 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
522 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
523};
524
525static struct resource sdhi0_resources[] = {
526 {
527 .name = "SDHI0",
528 .start = 0xe6850000,
529 .end = 0xe6850100 - 1,
530 .flags = IORESOURCE_MEM,
531 },
532 /*
533 * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here
534 */
535 {
536 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
537 .start = evt2irq(0x0E20),
538 .flags = IORESOURCE_IRQ,
539 },
540 {
541 .name = SH_MOBILE_SDHI_IRQ_SDIO,
542 .start = evt2irq(0x0E40),
543 .flags = IORESOURCE_IRQ,
544 },
545};
546
547static struct platform_device sdhi0_device = {
548 .name = "sh_mobile_sdhi",
549 .id = 0,
550 .dev = {
551 .platform_data = &sdhi0_info,
552 },
553 .num_resources = ARRAY_SIZE(sdhi0_resources),
554 .resource = sdhi0_resources,
555};
556
Kuninori Morimoto2e3a5ef2012-04-24 02:09:31 -0700557/* SDHI1 */
558static struct sh_mobile_sdhi_info sdhi1_info = {
559 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
560 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
561 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
562};
563
564static struct resource sdhi1_resources[] = {
565 [0] = {
566 .name = "SDHI1",
567 .start = 0xe6860000,
568 .end = 0xe6860100 - 1,
569 .flags = IORESOURCE_MEM,
570 },
571 [1] = {
572 .start = evt2irq(0x0E80),
573 .flags = IORESOURCE_IRQ,
574 },
575 [2] = {
576 .start = evt2irq(0x0EA0),
577 .flags = IORESOURCE_IRQ,
578 },
579 [3] = {
580 .start = evt2irq(0x0EC0),
581 .flags = IORESOURCE_IRQ,
582 },
583};
584
585static struct platform_device sdhi1_device = {
586 .name = "sh_mobile_sdhi",
587 .id = 1,
588 .dev = {
589 .platform_data = &sdhi1_info,
590 },
591 .num_resources = ARRAY_SIZE(sdhi1_resources),
592 .resource = sdhi1_resources,
593};
594
Kuninori Morimoto0a4266b2012-04-24 02:09:42 -0700595/* MMCIF */
596static struct sh_mmcif_plat_data sh_mmcif_plat = {
597 .sup_pclk = 0,
598 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
599 .caps = MMC_CAP_4_BIT_DATA |
600 MMC_CAP_8_BIT_DATA |
601 MMC_CAP_NONREMOVABLE,
602};
603
604static struct resource sh_mmcif_resources[] = {
605 [0] = {
606 .name = "MMCIF",
607 .start = 0xe6bd0000,
608 .end = 0xe6bd0100 - 1,
609 .flags = IORESOURCE_MEM,
610 },
611 [1] = {
612 /* MMC ERR */
613 .start = evt2irq(0x1AC0),
614 .flags = IORESOURCE_IRQ,
615 },
616 [2] = {
617 /* MMC NOR */
618 .start = evt2irq(0x1AE0),
619 .flags = IORESOURCE_IRQ,
620 },
621};
622
623static struct platform_device sh_mmcif_device = {
624 .name = "sh_mmcif",
625 .id = -1,
626 .dev = {
627 .platform_data = &sh_mmcif_plat,
628 },
629 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
630 .resource = sh_mmcif_resources,
631};
632
Kuninori Morimoto46cf6682012-04-06 01:30:42 -0700633/* I2C */
634static struct i2c_board_info i2c0_devices[] = {
635 {
636 I2C_BOARD_INFO("st1232-ts", 0x55),
637 .irq = evt2irq(0x0340),
638 },
639};
640
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700641/*
642 * board devices
643 */
644static struct platform_device *eva_devices[] __initdata = {
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700645 &lcdc0_device,
Kuninori Morimotof7e7d312012-04-06 01:31:33 -0700646 &gpio_keys_device,
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700647 &sh_eth_device,
Kuninori Morimoto49c01112012-04-24 02:09:19 -0700648 &sdhi0_device,
Kuninori Morimoto0a4266b2012-04-24 02:09:42 -0700649 &sh_mmcif_device,
Kuninori Morimoto910c14d2012-06-12 02:39:11 -0700650 &hdmi_device,
651 &hdmi_lcdc_device,
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700652};
653
Kuninori Morimoto1c962932012-04-24 02:09:08 -0700654static void __init eva_clock_init(void)
655{
656 struct clk *system = clk_get(NULL, "system_clk");
657 struct clk *xtal1 = clk_get(NULL, "extal1");
658 struct clk *usb24s = clk_get(NULL, "usb24s");
659
660 if (IS_ERR(system) ||
661 IS_ERR(xtal1) ||
662 IS_ERR(usb24s)) {
663 pr_err("armadillo800eva board clock init failed\n");
664 goto clock_error;
665 }
666
667 /* armadillo 800 eva extal1 is 24MHz */
668 clk_set_rate(xtal1, 24000000);
669
670 /* usb24s use extal1 (= system) clock (= 24MHz) */
671 clk_set_parent(usb24s, system);
672
673clock_error:
674 if (!IS_ERR(system))
675 clk_put(system);
676 if (!IS_ERR(xtal1))
677 clk_put(xtal1);
678 if (!IS_ERR(usb24s))
679 clk_put(usb24s);
680}
681
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700682/*
683 * board init
684 */
685static void __init eva_init(void)
686{
Kuninori Morimoto1c962932012-04-24 02:09:08 -0700687 eva_clock_init();
688
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700689 r8a7740_pinmux_init();
Kuninori Morimotod49679e2012-06-12 02:36:21 -0700690 r8a7740_meram_workaround();
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700691
692 /* SCIFA1 */
693 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
694 gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
695
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700696 /* LCDC0 */
697 gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
698 gpio_request(GPIO_FN_LCD0_D0, NULL);
699 gpio_request(GPIO_FN_LCD0_D1, NULL);
700 gpio_request(GPIO_FN_LCD0_D2, NULL);
701 gpio_request(GPIO_FN_LCD0_D3, NULL);
702 gpio_request(GPIO_FN_LCD0_D4, NULL);
703 gpio_request(GPIO_FN_LCD0_D5, NULL);
704 gpio_request(GPIO_FN_LCD0_D6, NULL);
705 gpio_request(GPIO_FN_LCD0_D7, NULL);
706 gpio_request(GPIO_FN_LCD0_D8, NULL);
707 gpio_request(GPIO_FN_LCD0_D9, NULL);
708 gpio_request(GPIO_FN_LCD0_D10, NULL);
709 gpio_request(GPIO_FN_LCD0_D11, NULL);
710 gpio_request(GPIO_FN_LCD0_D12, NULL);
711 gpio_request(GPIO_FN_LCD0_D13, NULL);
712 gpio_request(GPIO_FN_LCD0_D14, NULL);
713 gpio_request(GPIO_FN_LCD0_D15, NULL);
714 gpio_request(GPIO_FN_LCD0_D16, NULL);
715 gpio_request(GPIO_FN_LCD0_D17, NULL);
716 gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
717 gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
718 gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
719 gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
720 gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
721 gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
722 gpio_request(GPIO_FN_LCD0_DCK, NULL);
723 gpio_request(GPIO_FN_LCD0_VSYN, NULL);
724 gpio_request(GPIO_FN_LCD0_HSYN, NULL);
725 gpio_request(GPIO_FN_LCD0_DISP, NULL);
726 gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
727
728 gpio_request(GPIO_PORT61, NULL); /* LCDDON */
729 gpio_direction_output(GPIO_PORT61, 1);
730
731 gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
732 gpio_direction_output(GPIO_PORT202, 0);
733
Kuninori Morimoto46cf6682012-04-06 01:30:42 -0700734 /* Touchscreen */
735 gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */
736 gpio_request(GPIO_PORT166, NULL); /* TP_RST_B */
737 gpio_direction_output(GPIO_PORT166, 1);
738
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700739 /* GETHER */
740 gpio_request(GPIO_FN_ET_CRS, NULL);
741 gpio_request(GPIO_FN_ET_MDC, NULL);
742 gpio_request(GPIO_FN_ET_MDIO, NULL);
743 gpio_request(GPIO_FN_ET_TX_ER, NULL);
744 gpio_request(GPIO_FN_ET_RX_ER, NULL);
745 gpio_request(GPIO_FN_ET_ERXD0, NULL);
746 gpio_request(GPIO_FN_ET_ERXD1, NULL);
747 gpio_request(GPIO_FN_ET_ERXD2, NULL);
748 gpio_request(GPIO_FN_ET_ERXD3, NULL);
749 gpio_request(GPIO_FN_ET_TX_CLK, NULL);
750 gpio_request(GPIO_FN_ET_TX_EN, NULL);
751 gpio_request(GPIO_FN_ET_ETXD0, NULL);
752 gpio_request(GPIO_FN_ET_ETXD1, NULL);
753 gpio_request(GPIO_FN_ET_ETXD2, NULL);
754 gpio_request(GPIO_FN_ET_ETXD3, NULL);
755 gpio_request(GPIO_FN_ET_PHY_INT, NULL);
756 gpio_request(GPIO_FN_ET_COL, NULL);
757 gpio_request(GPIO_FN_ET_RX_DV, NULL);
758 gpio_request(GPIO_FN_ET_RX_CLK, NULL);
759
760 gpio_request(GPIO_PORT18, NULL); /* PHY_RST */
761 gpio_direction_output(GPIO_PORT18, 1);
762
Kuninori Morimoto1c962932012-04-24 02:09:08 -0700763 /* USB */
764 gpio_request(GPIO_PORT159, NULL); /* USB_DEVICE_MODE */
765 gpio_direction_input(GPIO_PORT159);
766
767 if (gpio_get_value(GPIO_PORT159)) {
768 /* USB Host */
769 } else {
770 /* USB Func */
771 gpio_request(GPIO_FN_VBUS, NULL);
772 platform_device_register(&usbhsf_device);
773 }
774
Kuninori Morimoto49c01112012-04-24 02:09:19 -0700775 /* SDHI0 */
776 gpio_request(GPIO_FN_SDHI0_CMD, NULL);
777 gpio_request(GPIO_FN_SDHI0_CLK, NULL);
778 gpio_request(GPIO_FN_SDHI0_D0, NULL);
779 gpio_request(GPIO_FN_SDHI0_D1, NULL);
780 gpio_request(GPIO_FN_SDHI0_D2, NULL);
781 gpio_request(GPIO_FN_SDHI0_D3, NULL);
782 gpio_request(GPIO_FN_SDHI0_WP, NULL);
783
784 gpio_request(GPIO_PORT17, NULL); /* SDHI0_18/33_B */
785 gpio_request(GPIO_PORT74, NULL); /* SDHI0_PON */
786 gpio_request(GPIO_PORT75, NULL); /* SDSLOT1_PON */
787 gpio_direction_output(GPIO_PORT17, 0);
788 gpio_direction_output(GPIO_PORT74, 1);
789 gpio_direction_output(GPIO_PORT75, 1);
790
791 /* we can use GPIO_FN_IRQ31_PORT167 here for SDHI0 CD irq */
792
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700793 /*
Kuninori Morimoto0a4266b2012-04-24 02:09:42 -0700794 * MMCIF
795 *
796 * Here doesn't care SW1.4 status,
797 * since CON2 is not mounted.
798 */
799 gpio_request(GPIO_FN_MMC1_CLK_PORT103, NULL);
800 gpio_request(GPIO_FN_MMC1_CMD_PORT104, NULL);
801 gpio_request(GPIO_FN_MMC1_D0_PORT149, NULL);
802 gpio_request(GPIO_FN_MMC1_D1_PORT148, NULL);
803 gpio_request(GPIO_FN_MMC1_D2_PORT147, NULL);
804 gpio_request(GPIO_FN_MMC1_D3_PORT146, NULL);
805 gpio_request(GPIO_FN_MMC1_D4_PORT145, NULL);
806 gpio_request(GPIO_FN_MMC1_D5_PORT144, NULL);
807 gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL);
808 gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL);
809
810 /*
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700811 * CAUTION
812 *
813 * DBGMD/LCDC0/FSIA MUX
814 * DBGMD_SELECT_B should be set after setting PFC Function.
815 */
816 gpio_request(GPIO_PORT176, NULL);
817 gpio_direction_output(GPIO_PORT176, 1);
818
Kuninori Morimoto2e3a5ef2012-04-24 02:09:31 -0700819 /*
820 * We can switch CON8/CON14 by SW1.5,
821 * but it needs after DBGMD_SELECT_B
822 */
823 gpio_request(GPIO_PORT6, NULL);
824 gpio_direction_input(GPIO_PORT6);
825 if (gpio_get_value(GPIO_PORT6)) {
826 /* CON14 enable */
827 } else {
828 /* CON8 (SDHI1) enable */
829 gpio_request(GPIO_FN_SDHI1_CLK, NULL);
830 gpio_request(GPIO_FN_SDHI1_CMD, NULL);
831 gpio_request(GPIO_FN_SDHI1_D0, NULL);
832 gpio_request(GPIO_FN_SDHI1_D1, NULL);
833 gpio_request(GPIO_FN_SDHI1_D2, NULL);
834 gpio_request(GPIO_FN_SDHI1_D3, NULL);
835 gpio_request(GPIO_FN_SDHI1_CD, NULL);
836 gpio_request(GPIO_FN_SDHI1_WP, NULL);
837
838 gpio_request(GPIO_PORT16, NULL); /* SDSLOT2_PON */
839 gpio_direction_output(GPIO_PORT16, 1);
840
841 platform_device_register(&sdhi1_device);
842 }
843
844
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700845#ifdef CONFIG_CACHE_L2X0
846 /* Early BRESP enable, Shared attribute override enable, 32K*8way */
847 l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
848#endif
849
Kuninori Morimoto46cf6682012-04-06 01:30:42 -0700850 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
851
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700852 r8a7740_add_standard_devices();
853
854 platform_add_devices(eva_devices,
855 ARRAY_SIZE(eva_devices));
856}
857
858static void __init eva_earlytimer_init(void)
859{
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700860 r8a7740_clock_init(MD_CK0 | MD_CK2);
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700861 shmobile_earlytimer_init();
862}
863
864static void __init eva_add_early_devices(void)
865{
866 r8a7740_add_early_devices();
867
868 /* override timer setup with board-specific code */
869 shmobile_timer.init = eva_earlytimer_init;
870}
871
Magnus Damme6bf7052012-05-14 19:54:41 +0900872static const char *eva_boards_compat_dt[] __initdata = {
873 "renesas,armadillo800eva",
874 NULL,
875};
876
877DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva")
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700878 .map_io = r8a7740_map_io,
879 .init_early = eva_add_early_devices,
880 .init_irq = r8a7740_init_irq,
881 .handle_irq = shmobile_handle_irq_intc,
882 .init_machine = eva_init,
883 .timer = &shmobile_timer,
Magnus Damme6bf7052012-05-14 19:54:41 +0900884 .dt_compat = eva_boards_compat_dt,
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700885MACHINE_END