Merge tag 'drivers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-shmobile / board-kzm9g.c
1 /*
2 * KZM-A9-GT board support
3 *
4 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include <linux/delay.h>
21 #include <linux/gpio.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/io.h>
24 #include <linux/irq.h>
25 #include <linux/i2c.h>
26 #include <linux/i2c/pcf857x.h>
27 #include <linux/input.h>
28 #include <linux/irqchip/arm-gic.h>
29 #include <linux/mmc/host.h>
30 #include <linux/mmc/sh_mmcif.h>
31 #include <linux/mmc/sh_mobile_sdhi.h>
32 #include <linux/mfd/tmio.h>
33 #include <linux/platform_device.h>
34 #include <linux/regulator/fixed.h>
35 #include <linux/regulator/machine.h>
36 #include <linux/smsc911x.h>
37 #include <linux/usb/r8a66597.h>
38 #include <linux/usb/renesas_usbhs.h>
39 #include <linux/videodev2.h>
40 #include <sound/sh_fsi.h>
41 #include <sound/simple_card.h>
42 #include <mach/irqs.h>
43 #include <mach/sh73a0.h>
44 #include <mach/common.h>
45 #include <asm/hardware/cache-l2x0.h>
46 #include <asm/mach-types.h>
47 #include <asm/mach/arch.h>
48 #include <video/sh_mobile_lcdc.h>
49
50 /*
51 * external GPIO
52 */
53 #define GPIO_PCF8575_BASE (GPIO_NR)
54 #define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
55 #define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
56 #define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
57 #define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
58 #define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
59 #define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
60 #define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
61
62 /* Dummy supplies, where voltage doesn't matter */
63 static struct regulator_consumer_supply dummy_supplies[] = {
64 REGULATOR_SUPPLY("vddvario", "smsc911x"),
65 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
66 };
67
68 /*
69 * FSI-AK4648
70 *
71 * this command is required when playback.
72 *
73 * # amixer set "LINEOUT Mixer DACL" on
74 */
75
76 /* SMSC 9221 */
77 static struct resource smsc9221_resources[] = {
78 [0] = {
79 .start = 0x10000000, /* CS4 */
80 .end = 0x100000ff,
81 .flags = IORESOURCE_MEM,
82 },
83 [1] = {
84 .start = irq_pin(3), /* IRQ3 */
85 .flags = IORESOURCE_IRQ,
86 },
87 };
88
89 static struct smsc911x_platform_config smsc9221_platdata = {
90 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
91 .phy_interface = PHY_INTERFACE_MODE_MII,
92 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
93 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
94 };
95
96 static struct platform_device smsc_device = {
97 .name = "smsc911x",
98 .dev = {
99 .platform_data = &smsc9221_platdata,
100 },
101 .resource = smsc9221_resources,
102 .num_resources = ARRAY_SIZE(smsc9221_resources),
103 };
104
105 /* USB external chip */
106 static struct r8a66597_platdata usb_host_data = {
107 .on_chip = 0,
108 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
109 };
110
111 static struct resource usb_resources[] = {
112 [0] = {
113 .start = 0x10010000,
114 .end = 0x1001ffff - 1,
115 .flags = IORESOURCE_MEM,
116 },
117 [1] = {
118 .start = irq_pin(1), /* IRQ1 */
119 .flags = IORESOURCE_IRQ,
120 },
121 };
122
123 static struct platform_device usb_host_device = {
124 .name = "r8a66597_hcd",
125 .dev = {
126 .platform_data = &usb_host_data,
127 .dma_mask = NULL,
128 .coherent_dma_mask = 0xffffffff,
129 },
130 .num_resources = ARRAY_SIZE(usb_resources),
131 .resource = usb_resources,
132 };
133
134 /* USB Func CN17 */
135 struct usbhs_private {
136 void __iomem *phy;
137 void __iomem *cr2;
138 struct renesas_usbhs_platform_info info;
139 };
140
141 #define IRQ15 irq_pin(15)
142 #define USB_PHY_MODE (1 << 4)
143 #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
144 #define USB_PHY_ON (1 << 1)
145 #define USB_PHY_OFF (1 << 0)
146 #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
147
148 #define usbhs_get_priv(pdev) \
149 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
150
151 static int usbhs_get_vbus(struct platform_device *pdev)
152 {
153 struct usbhs_private *priv = usbhs_get_priv(pdev);
154
155 return !((1 << 7) & __raw_readw(priv->cr2));
156 }
157
158 static int usbhs_phy_reset(struct platform_device *pdev)
159 {
160 struct usbhs_private *priv = usbhs_get_priv(pdev);
161
162 /* init phy */
163 __raw_writew(0x8a0a, priv->cr2);
164
165 return 0;
166 }
167
168 static int usbhs_get_id(struct platform_device *pdev)
169 {
170 return USBHS_GADGET;
171 }
172
173 static irqreturn_t usbhs_interrupt(int irq, void *data)
174 {
175 struct platform_device *pdev = data;
176 struct usbhs_private *priv = usbhs_get_priv(pdev);
177
178 renesas_usbhs_call_notify_hotplug(pdev);
179
180 /* clear status */
181 __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
182
183 return IRQ_HANDLED;
184 }
185
186 static int usbhs_hardware_init(struct platform_device *pdev)
187 {
188 struct usbhs_private *priv = usbhs_get_priv(pdev);
189 int ret;
190
191 /* clear interrupt status */
192 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
193
194 ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
195 dev_name(&pdev->dev), pdev);
196 if (ret) {
197 dev_err(&pdev->dev, "request_irq err\n");
198 return ret;
199 }
200
201 /* enable USB phy interrupt */
202 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
203
204 return 0;
205 }
206
207 static int usbhs_hardware_exit(struct platform_device *pdev)
208 {
209 struct usbhs_private *priv = usbhs_get_priv(pdev);
210
211 /* clear interrupt status */
212 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
213
214 free_irq(IRQ15, pdev);
215
216 return 0;
217 }
218
219 static u32 usbhs_pipe_cfg[] = {
220 USB_ENDPOINT_XFER_CONTROL,
221 USB_ENDPOINT_XFER_ISOC,
222 USB_ENDPOINT_XFER_ISOC,
223 USB_ENDPOINT_XFER_BULK,
224 USB_ENDPOINT_XFER_BULK,
225 USB_ENDPOINT_XFER_BULK,
226 USB_ENDPOINT_XFER_INT,
227 USB_ENDPOINT_XFER_INT,
228 USB_ENDPOINT_XFER_INT,
229 USB_ENDPOINT_XFER_BULK,
230 USB_ENDPOINT_XFER_BULK,
231 USB_ENDPOINT_XFER_BULK,
232 USB_ENDPOINT_XFER_BULK,
233 USB_ENDPOINT_XFER_BULK,
234 USB_ENDPOINT_XFER_BULK,
235 USB_ENDPOINT_XFER_BULK,
236 };
237
238 static struct usbhs_private usbhs_private = {
239 .phy = IOMEM(0xe60781e0), /* USBPHYINT */
240 .cr2 = IOMEM(0xe605810c), /* USBCR2 */
241 .info = {
242 .platform_callback = {
243 .hardware_init = usbhs_hardware_init,
244 .hardware_exit = usbhs_hardware_exit,
245 .get_id = usbhs_get_id,
246 .phy_reset = usbhs_phy_reset,
247 .get_vbus = usbhs_get_vbus,
248 },
249 .driver_param = {
250 .buswait_bwait = 4,
251 .has_otg = 1,
252 .pipe_type = usbhs_pipe_cfg,
253 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
254 },
255 },
256 };
257
258 static struct resource usbhs_resources[] = {
259 [0] = {
260 .start = 0xE6890000,
261 .end = 0xE68900e6 - 1,
262 .flags = IORESOURCE_MEM,
263 },
264 [1] = {
265 .start = gic_spi(62),
266 .end = gic_spi(62),
267 .flags = IORESOURCE_IRQ,
268 },
269 };
270
271 static struct platform_device usbhs_device = {
272 .name = "renesas_usbhs",
273 .id = -1,
274 .dev = {
275 .dma_mask = NULL,
276 .coherent_dma_mask = 0xffffffff,
277 .platform_data = &usbhs_private.info,
278 },
279 .num_resources = ARRAY_SIZE(usbhs_resources),
280 .resource = usbhs_resources,
281 };
282
283 /* LCDC */
284 static struct fb_videomode kzm_lcdc_mode = {
285 .name = "WVGA Panel",
286 .xres = 800,
287 .yres = 480,
288 .left_margin = 220,
289 .right_margin = 110,
290 .hsync_len = 70,
291 .upper_margin = 20,
292 .lower_margin = 5,
293 .vsync_len = 5,
294 .sync = 0,
295 };
296
297 static struct sh_mobile_lcdc_info lcdc_info = {
298 .clock_source = LCDC_CLK_BUS,
299 .ch[0] = {
300 .chan = LCDC_CHAN_MAINLCD,
301 .fourcc = V4L2_PIX_FMT_RGB565,
302 .interface_type = RGB24,
303 .lcd_modes = &kzm_lcdc_mode,
304 .num_modes = 1,
305 .clock_divider = 5,
306 .flags = 0,
307 .panel_cfg = {
308 .width = 152,
309 .height = 91,
310 },
311 }
312 };
313
314 static struct resource lcdc_resources[] = {
315 [0] = {
316 .name = "LCDC",
317 .start = 0xfe940000,
318 .end = 0xfe943fff,
319 .flags = IORESOURCE_MEM,
320 },
321 [1] = {
322 .start = intcs_evt2irq(0x580),
323 .flags = IORESOURCE_IRQ,
324 },
325 };
326
327 static struct platform_device lcdc_device = {
328 .name = "sh_mobile_lcdc_fb",
329 .num_resources = ARRAY_SIZE(lcdc_resources),
330 .resource = lcdc_resources,
331 .dev = {
332 .platform_data = &lcdc_info,
333 .coherent_dma_mask = ~0,
334 },
335 };
336
337 /* Fixed 1.8V regulator to be used by MMCIF */
338 static struct regulator_consumer_supply fixed1v8_power_consumers[] =
339 {
340 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
341 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
342 };
343
344 /* MMCIF */
345 static struct resource sh_mmcif_resources[] = {
346 [0] = {
347 .name = "MMCIF",
348 .start = 0xe6bd0000,
349 .end = 0xe6bd00ff,
350 .flags = IORESOURCE_MEM,
351 },
352 [1] = {
353 .start = gic_spi(140),
354 .flags = IORESOURCE_IRQ,
355 },
356 [2] = {
357 .start = gic_spi(141),
358 .flags = IORESOURCE_IRQ,
359 },
360 };
361
362 static struct sh_mmcif_plat_data sh_mmcif_platdata = {
363 .ocr = MMC_VDD_165_195,
364 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
365 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
366 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
367 };
368
369 static struct platform_device mmc_device = {
370 .name = "sh_mmcif",
371 .dev = {
372 .dma_mask = NULL,
373 .coherent_dma_mask = 0xffffffff,
374 .platform_data = &sh_mmcif_platdata,
375 },
376 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
377 .resource = sh_mmcif_resources,
378 };
379
380 /* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */
381 static struct regulator_consumer_supply fixed2v8_power_consumers[] =
382 {
383 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
384 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
385 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
386 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
387 };
388
389 /* SDHI */
390 static struct sh_mobile_sdhi_info sdhi0_info = {
391 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
392 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
393 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
394 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
395 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
396 };
397
398 static struct resource sdhi0_resources[] = {
399 [0] = {
400 .name = "SDHI0",
401 .start = 0xee100000,
402 .end = 0xee1000ff,
403 .flags = IORESOURCE_MEM,
404 },
405 [1] = {
406 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
407 .start = gic_spi(83),
408 .flags = IORESOURCE_IRQ,
409 },
410 [2] = {
411 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
412 .start = gic_spi(84),
413 .flags = IORESOURCE_IRQ,
414 },
415 [3] = {
416 .name = SH_MOBILE_SDHI_IRQ_SDIO,
417 .start = gic_spi(85),
418 .flags = IORESOURCE_IRQ,
419 },
420 };
421
422 static struct platform_device sdhi0_device = {
423 .name = "sh_mobile_sdhi",
424 .num_resources = ARRAY_SIZE(sdhi0_resources),
425 .resource = sdhi0_resources,
426 .dev = {
427 .platform_data = &sdhi0_info,
428 },
429 };
430
431 /* Micro SD */
432 static struct sh_mobile_sdhi_info sdhi2_info = {
433 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
434 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
435 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
436 TMIO_MMC_USE_GPIO_CD |
437 TMIO_MMC_WRPROTECT_DISABLE,
438 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
439 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
440 .cd_gpio = GPIO_PORT13,
441 };
442
443 static struct resource sdhi2_resources[] = {
444 [0] = {
445 .name = "SDHI2",
446 .start = 0xee140000,
447 .end = 0xee1400ff,
448 .flags = IORESOURCE_MEM,
449 },
450 [1] = {
451 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
452 .start = gic_spi(103),
453 .flags = IORESOURCE_IRQ,
454 },
455 [2] = {
456 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
457 .start = gic_spi(104),
458 .flags = IORESOURCE_IRQ,
459 },
460 [3] = {
461 .name = SH_MOBILE_SDHI_IRQ_SDIO,
462 .start = gic_spi(105),
463 .flags = IORESOURCE_IRQ,
464 },
465 };
466
467 static struct platform_device sdhi2_device = {
468 .name = "sh_mobile_sdhi",
469 .id = 2,
470 .num_resources = ARRAY_SIZE(sdhi2_resources),
471 .resource = sdhi2_resources,
472 .dev = {
473 .platform_data = &sdhi2_info,
474 },
475 };
476
477 /* KEY */
478 #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
479
480 static struct gpio_keys_button gpio_buttons[] = {
481 GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
482 GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
483 GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
484 GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
485 GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
486 GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
487 GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
488 };
489
490 static struct gpio_keys_platform_data gpio_key_info = {
491 .buttons = gpio_buttons,
492 .nbuttons = ARRAY_SIZE(gpio_buttons),
493 };
494
495 static struct platform_device gpio_keys_device = {
496 .name = "gpio-keys",
497 .dev = {
498 .platform_data = &gpio_key_info,
499 },
500 };
501
502 /* FSI-AK4648 */
503 static struct sh_fsi_platform_info fsi_info = {
504 .port_a = {
505 .tx_id = SHDMA_SLAVE_FSI2A_TX,
506 },
507 };
508
509 static struct resource fsi_resources[] = {
510 [0] = {
511 .name = "FSI",
512 .start = 0xEC230000,
513 .end = 0xEC230400 - 1,
514 .flags = IORESOURCE_MEM,
515 },
516 [1] = {
517 .start = gic_spi(146),
518 .flags = IORESOURCE_IRQ,
519 },
520 };
521
522 static struct platform_device fsi_device = {
523 .name = "sh_fsi2",
524 .id = -1,
525 .num_resources = ARRAY_SIZE(fsi_resources),
526 .resource = fsi_resources,
527 .dev = {
528 .platform_data = &fsi_info,
529 },
530 };
531
532 static struct asoc_simple_card_info fsi2_ak4648_info = {
533 .name = "AK4648",
534 .card = "FSI2A-AK4648",
535 .codec = "ak4642-codec.0-0012",
536 .platform = "sh_fsi2",
537 .daifmt = SND_SOC_DAIFMT_LEFT_J,
538 .cpu_dai = {
539 .name = "fsia-dai",
540 .fmt = SND_SOC_DAIFMT_CBS_CFS,
541 },
542 .codec_dai = {
543 .name = "ak4642-hifi",
544 .fmt = SND_SOC_DAIFMT_CBM_CFM,
545 .sysclk = 11289600,
546 },
547 };
548
549 static struct platform_device fsi_ak4648_device = {
550 .name = "asoc-simple-card",
551 .dev = {
552 .platform_data = &fsi2_ak4648_info,
553 },
554 };
555
556 /* I2C */
557 static struct pcf857x_platform_data pcf8575_pdata = {
558 .gpio_base = GPIO_PCF8575_BASE,
559 };
560
561 static struct i2c_board_info i2c0_devices[] = {
562 {
563 I2C_BOARD_INFO("ak4648", 0x12),
564 },
565 {
566 I2C_BOARD_INFO("r2025sd", 0x32),
567 },
568 {
569 I2C_BOARD_INFO("ak8975", 0x0c),
570 .irq = irq_pin(28), /* IRQ28 */
571 },
572 {
573 I2C_BOARD_INFO("adxl34x", 0x1d),
574 .irq = irq_pin(26), /* IRQ26 */
575 },
576 };
577
578 static struct i2c_board_info i2c1_devices[] = {
579 {
580 I2C_BOARD_INFO("st1232-ts", 0x55),
581 .irq = irq_pin(8), /* IRQ8 */
582 },
583 };
584
585 static struct i2c_board_info i2c3_devices[] = {
586 {
587 I2C_BOARD_INFO("pcf8575", 0x20),
588 .irq = irq_pin(19), /* IRQ19 */
589 .platform_data = &pcf8575_pdata,
590 },
591 };
592
593 static struct platform_device *kzm_devices[] __initdata = {
594 &smsc_device,
595 &usb_host_device,
596 &usbhs_device,
597 &lcdc_device,
598 &mmc_device,
599 &sdhi0_device,
600 &sdhi2_device,
601 &gpio_keys_device,
602 &fsi_device,
603 &fsi_ak4648_device,
604 };
605
606 /*
607 * FIXME
608 *
609 * This is quick hack for enabling LCDC backlight
610 */
611 static int __init as3711_enable_lcdc_backlight(void)
612 {
613 struct i2c_adapter *a = i2c_get_adapter(0);
614 struct i2c_msg msg;
615 int i, ret;
616 __u8 magic[] = {
617 0x40, 0x2a,
618 0x43, 0x3c,
619 0x44, 0x3c,
620 0x45, 0x3c,
621 0x54, 0x03,
622 0x51, 0x00,
623 0x51, 0x01,
624 0xff, 0x00, /* wait */
625 0x43, 0xf0,
626 0x44, 0xf0,
627 0x45, 0xf0,
628 };
629
630 if (!of_machine_is_compatible("renesas,kzm9g"))
631 return 0;
632
633 if (!a)
634 return 0;
635
636 msg.addr = 0x40;
637 msg.len = 2;
638 msg.flags = 0;
639
640 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
641 msg.buf = magic + i;
642
643 if (0xff == msg.buf[0]) {
644 udelay(500);
645 continue;
646 }
647
648 ret = i2c_transfer(a, &msg, 1);
649 if (ret < 0) {
650 pr_err("i2c transfer fail\n");
651 break;
652 }
653 }
654
655 return 0;
656 }
657 device_initcall(as3711_enable_lcdc_backlight);
658
659 static void __init kzm_init(void)
660 {
661 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
662 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
663 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
664 ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
665 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
666
667 sh73a0_pinmux_init();
668
669 /* enable SCIFA4 */
670 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
671 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
672 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
673 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
674
675 /* CS4 for SMSC/USB */
676 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
677
678 /* SMSC */
679 gpio_request_one(GPIO_PORT224, GPIOF_IN, NULL); /* IRQ3 */
680
681 /* LCDC */
682 gpio_request(GPIO_FN_LCDD23, NULL);
683 gpio_request(GPIO_FN_LCDD22, NULL);
684 gpio_request(GPIO_FN_LCDD21, NULL);
685 gpio_request(GPIO_FN_LCDD20, NULL);
686 gpio_request(GPIO_FN_LCDD19, NULL);
687 gpio_request(GPIO_FN_LCDD18, NULL);
688 gpio_request(GPIO_FN_LCDD17, NULL);
689 gpio_request(GPIO_FN_LCDD16, NULL);
690 gpio_request(GPIO_FN_LCDD15, NULL);
691 gpio_request(GPIO_FN_LCDD14, NULL);
692 gpio_request(GPIO_FN_LCDD13, NULL);
693 gpio_request(GPIO_FN_LCDD12, NULL);
694 gpio_request(GPIO_FN_LCDD11, NULL);
695 gpio_request(GPIO_FN_LCDD10, NULL);
696 gpio_request(GPIO_FN_LCDD9, NULL);
697 gpio_request(GPIO_FN_LCDD8, NULL);
698 gpio_request(GPIO_FN_LCDD7, NULL);
699 gpio_request(GPIO_FN_LCDD6, NULL);
700 gpio_request(GPIO_FN_LCDD5, NULL);
701 gpio_request(GPIO_FN_LCDD4, NULL);
702 gpio_request(GPIO_FN_LCDD3, NULL);
703 gpio_request(GPIO_FN_LCDD2, NULL);
704 gpio_request(GPIO_FN_LCDD1, NULL);
705 gpio_request(GPIO_FN_LCDD0, NULL);
706 gpio_request(GPIO_FN_LCDDISP, NULL);
707 gpio_request(GPIO_FN_LCDDCK, NULL);
708
709 gpio_request_one(GPIO_PORT222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */
710 gpio_request_one(GPIO_PORT226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */
711
712 /* Touchscreen */
713 gpio_request_one(GPIO_PORT223, GPIOF_IN, NULL); /* IRQ8 */
714
715 /* enable MMCIF */
716 gpio_request(GPIO_FN_MMCCLK0, NULL);
717 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
718 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
719 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
720 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
721 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
722 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
723 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
724 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
725 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
726
727 /* enable SD */
728 gpio_request(GPIO_FN_SDHIWP0, NULL);
729 gpio_request(GPIO_FN_SDHICD0, NULL);
730 gpio_request(GPIO_FN_SDHICMD0, NULL);
731 gpio_request(GPIO_FN_SDHICLK0, NULL);
732 gpio_request(GPIO_FN_SDHID0_3, NULL);
733 gpio_request(GPIO_FN_SDHID0_2, NULL);
734 gpio_request(GPIO_FN_SDHID0_1, NULL);
735 gpio_request(GPIO_FN_SDHID0_0, NULL);
736 gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
737 gpio_request_one(GPIO_PORT15, GPIOF_OUT_INIT_HIGH, NULL); /* power */
738
739 /* enable Micro SD */
740 gpio_request(GPIO_FN_SDHID2_0, NULL);
741 gpio_request(GPIO_FN_SDHID2_1, NULL);
742 gpio_request(GPIO_FN_SDHID2_2, NULL);
743 gpio_request(GPIO_FN_SDHID2_3, NULL);
744 gpio_request(GPIO_FN_SDHICMD2, NULL);
745 gpio_request(GPIO_FN_SDHICLK2, NULL);
746 gpio_request_one(GPIO_PORT14, GPIOF_OUT_INIT_HIGH, NULL); /* power */
747
748 /* I2C 3 */
749 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
750 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
751
752 /* enable FSI2 port A (ak4648) */
753 gpio_request(GPIO_FN_FSIACK, NULL);
754 gpio_request(GPIO_FN_FSIAILR, NULL);
755 gpio_request(GPIO_FN_FSIAIBT, NULL);
756 gpio_request(GPIO_FN_FSIAISLD, NULL);
757 gpio_request(GPIO_FN_FSIAOSLD, NULL);
758
759 /* enable USB */
760 gpio_request(GPIO_FN_VBUS_0, NULL);
761
762 #ifdef CONFIG_CACHE_L2X0
763 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
764 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
765 #endif
766
767 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
768 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
769 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
770
771 sh73a0_add_standard_devices();
772 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
773
774 sh73a0_pm_init();
775 }
776
777 static void kzm9g_restart(char mode, const char *cmd)
778 {
779 #define RESCNT2 IOMEM(0xe6188020)
780 /* Do soft power on reset */
781 writel((1 << 31), RESCNT2);
782 }
783
784 static const char *kzm9g_boards_compat_dt[] __initdata = {
785 "renesas,kzm9g",
786 NULL,
787 };
788
789 DT_MACHINE_START(KZM9G_DT, "kzm9g")
790 .smp = smp_ops(sh73a0_smp_ops),
791 .map_io = sh73a0_map_io,
792 .init_early = sh73a0_add_early_devices,
793 .nr_irqs = NR_IRQS_LEGACY,
794 .init_irq = sh73a0_init_irq,
795 .init_machine = kzm_init,
796 .init_late = shmobile_init_late,
797 .init_time = sh73a0_earlytimer_init,
798 .restart = kzm9g_restart,
799 .dt_compat = kzm9g_boards_compat_dt,
800 MACHINE_END