blob: 27194bc6ee3c433e7c4d42b23958b0e00151d0dc [file] [log] [blame]
Kuninori Morimoto9b93e242012-04-10 20:57:31 -07001/*
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 */
Kuninori Morimoto26786112012-04-10 20:58:33 -070019
20#include <linux/delay.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070021#include <linux/gpio.h>
Kuninori Morimoto1e354642012-04-22 23:54:14 -070022#include <linux/gpio_keys.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070023#include <linux/io.h>
24#include <linux/irq.h>
Kuninori Morimoto407c0522012-04-10 20:58:45 -070025#include <linux/i2c.h>
Kuninori Morimoto1e354642012-04-22 23:54:14 -070026#include <linux/i2c/pcf857x.h>
27#include <linux/input.h>
Kuninori Morimotocc2512b2012-04-22 23:53:40 -070028#include <linux/mmc/host.h>
29#include <linux/mmc/sh_mmcif.h>
Kuninori Morimoto7775a932012-04-22 23:53:59 -070030#include <linux/mmc/sh_mobile_sdhi.h>
31#include <linux/mfd/tmio.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070032#include <linux/platform_device.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070033#include <linux/smsc911x.h>
Kuninori Morimotodd818182012-04-10 20:58:10 -070034#include <linux/usb/r8a66597.h>
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -070035#include <linux/usb/renesas_usbhs.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070036#include <linux/videodev2.h>
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -070037#include <sound/sh_fsi.h>
38#include <sound/simple_card.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070039#include <mach/irqs.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070040#include <mach/sh73a0.h>
41#include <mach/common.h>
42#include <asm/hardware/cache-l2x0.h>
43#include <asm/hardware/gic.h>
44#include <asm/mach-types.h>
45#include <asm/mach/arch.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070046#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070047
Kuninori Morimoto1e354642012-04-22 23:54:14 -070048/*
49 * external GPIO
50 */
51#define GPIO_PCF8575_BASE (GPIO_NR)
52#define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
53#define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
54#define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
55#define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
56#define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
57#define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
58#define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
59
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -070060/*
61 * FSI-AK4648
62 *
63 * this command is required when playback.
64 *
65 * # amixer set "LINEOUT Mixer DACL" on
66 */
67
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070068/* SMSC 9221 */
69static struct resource smsc9221_resources[] = {
70 [0] = {
71 .start = 0x10000000, /* CS4 */
72 .end = 0x100000ff,
73 .flags = IORESOURCE_MEM,
74 },
75 [1] = {
76 .start = intcs_evt2irq(0x260), /* IRQ3 */
77 .flags = IORESOURCE_IRQ,
78 },
79};
80
81static struct smsc911x_platform_config smsc9221_platdata = {
82 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
83 .phy_interface = PHY_INTERFACE_MODE_MII,
84 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
85 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
86};
87
88static struct platform_device smsc_device = {
89 .name = "smsc911x",
90 .dev = {
91 .platform_data = &smsc9221_platdata,
92 },
93 .resource = smsc9221_resources,
94 .num_resources = ARRAY_SIZE(smsc9221_resources),
95};
96
Kuninori Morimotodd818182012-04-10 20:58:10 -070097/* USB external chip */
98static struct r8a66597_platdata usb_host_data = {
99 .on_chip = 0,
100 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
101};
102
103static struct resource usb_resources[] = {
104 [0] = {
105 .start = 0x10010000,
106 .end = 0x1001ffff - 1,
107 .flags = IORESOURCE_MEM,
108 },
109 [1] = {
110 .start = intcs_evt2irq(0x220), /* IRQ1 */
111 .flags = IORESOURCE_IRQ,
112 },
113};
114
115static struct platform_device usb_host_device = {
116 .name = "r8a66597_hcd",
117 .dev = {
118 .platform_data = &usb_host_data,
119 .dma_mask = NULL,
120 .coherent_dma_mask = 0xffffffff,
121 },
122 .num_resources = ARRAY_SIZE(usb_resources),
123 .resource = usb_resources,
124};
125
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700126/* USB Func CN17 */
127struct usbhs_private {
128 unsigned int phy;
129 unsigned int cr2;
130 struct renesas_usbhs_platform_info info;
131};
132
133#define IRQ15 intcs_evt2irq(0x03e0)
134#define USB_PHY_MODE (1 << 4)
135#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
136#define USB_PHY_ON (1 << 1)
137#define USB_PHY_OFF (1 << 0)
138#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
139
140#define usbhs_get_priv(pdev) \
141 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
142
143static int usbhs_get_vbus(struct platform_device *pdev)
144{
145 struct usbhs_private *priv = usbhs_get_priv(pdev);
146
147 return !((1 << 7) & __raw_readw(priv->cr2));
148}
149
150static void usbhs_phy_reset(struct platform_device *pdev)
151{
152 struct usbhs_private *priv = usbhs_get_priv(pdev);
153
154 /* init phy */
155 __raw_writew(0x8a0a, priv->cr2);
156}
157
158static int usbhs_get_id(struct platform_device *pdev)
159{
160 return USBHS_GADGET;
161}
162
163static irqreturn_t usbhs_interrupt(int irq, void *data)
164{
165 struct platform_device *pdev = data;
166 struct usbhs_private *priv = usbhs_get_priv(pdev);
167
168 renesas_usbhs_call_notify_hotplug(pdev);
169
170 /* clear status */
171 __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
172
173 return IRQ_HANDLED;
174}
175
176static int usbhs_hardware_init(struct platform_device *pdev)
177{
178 struct usbhs_private *priv = usbhs_get_priv(pdev);
179 int ret;
180
181 /* clear interrupt status */
182 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
183
184 ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
185 dev_name(&pdev->dev), pdev);
186 if (ret) {
187 dev_err(&pdev->dev, "request_irq err\n");
188 return ret;
189 }
190
191 /* enable USB phy interrupt */
192 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
193
194 return 0;
195}
196
197static void usbhs_hardware_exit(struct platform_device *pdev)
198{
199 struct usbhs_private *priv = usbhs_get_priv(pdev);
200
201 /* clear interrupt status */
202 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
203
204 free_irq(IRQ15, pdev);
205}
206
207static u32 usbhs_pipe_cfg[] = {
208 USB_ENDPOINT_XFER_CONTROL,
209 USB_ENDPOINT_XFER_ISOC,
210 USB_ENDPOINT_XFER_ISOC,
211 USB_ENDPOINT_XFER_BULK,
212 USB_ENDPOINT_XFER_BULK,
213 USB_ENDPOINT_XFER_BULK,
214 USB_ENDPOINT_XFER_INT,
215 USB_ENDPOINT_XFER_INT,
216 USB_ENDPOINT_XFER_INT,
217 USB_ENDPOINT_XFER_BULK,
218 USB_ENDPOINT_XFER_BULK,
219 USB_ENDPOINT_XFER_BULK,
220 USB_ENDPOINT_XFER_BULK,
221 USB_ENDPOINT_XFER_BULK,
222 USB_ENDPOINT_XFER_BULK,
223 USB_ENDPOINT_XFER_BULK,
224};
225
226static struct usbhs_private usbhs_private = {
227 .phy = 0xe60781e0, /* USBPHYINT */
228 .cr2 = 0xe605810c, /* USBCR2 */
229 .info = {
230 .platform_callback = {
231 .hardware_init = usbhs_hardware_init,
232 .hardware_exit = usbhs_hardware_exit,
233 .get_id = usbhs_get_id,
234 .phy_reset = usbhs_phy_reset,
235 .get_vbus = usbhs_get_vbus,
236 },
237 .driver_param = {
238 .buswait_bwait = 4,
239 .has_otg = 1,
240 .pipe_type = usbhs_pipe_cfg,
241 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
242 },
243 },
244};
245
246static struct resource usbhs_resources[] = {
247 [0] = {
248 .start = 0xE6890000,
249 .end = 0xE68900e6 - 1,
250 .flags = IORESOURCE_MEM,
251 },
252 [1] = {
253 .start = gic_spi(62),
254 .end = gic_spi(62),
255 .flags = IORESOURCE_IRQ,
256 },
257};
258
259static struct platform_device usbhs_device = {
260 .name = "renesas_usbhs",
261 .id = -1,
262 .dev = {
263 .dma_mask = NULL,
264 .coherent_dma_mask = 0xffffffff,
265 .platform_data = &usbhs_private.info,
266 },
267 .num_resources = ARRAY_SIZE(usbhs_resources),
268 .resource = usbhs_resources,
269};
270
Kuninori Morimoto26786112012-04-10 20:58:33 -0700271/* LCDC */
272static struct fb_videomode kzm_lcdc_mode = {
273 .name = "WVGA Panel",
274 .xres = 800,
275 .yres = 480,
276 .left_margin = 220,
277 .right_margin = 110,
278 .hsync_len = 70,
279 .upper_margin = 20,
280 .lower_margin = 5,
281 .vsync_len = 5,
282 .sync = 0,
283};
284
285static struct sh_mobile_lcdc_info lcdc_info = {
286 .clock_source = LCDC_CLK_BUS,
287 .ch[0] = {
288 .chan = LCDC_CHAN_MAINLCD,
289 .fourcc = V4L2_PIX_FMT_RGB565,
290 .interface_type = RGB24,
291 .lcd_modes = &kzm_lcdc_mode,
292 .num_modes = 1,
293 .clock_divider = 5,
294 .flags = 0,
295 .panel_cfg = {
296 .width = 152,
297 .height = 91,
298 },
299 }
300};
301
302static struct resource lcdc_resources[] = {
303 [0] = {
304 .name = "LCDC",
305 .start = 0xfe940000,
306 .end = 0xfe943fff,
307 .flags = IORESOURCE_MEM,
308 },
309 [1] = {
310 .start = intcs_evt2irq(0x580),
311 .flags = IORESOURCE_IRQ,
312 },
313};
314
315static struct platform_device lcdc_device = {
316 .name = "sh_mobile_lcdc_fb",
317 .num_resources = ARRAY_SIZE(lcdc_resources),
318 .resource = lcdc_resources,
319 .dev = {
320 .platform_data = &lcdc_info,
321 .coherent_dma_mask = ~0,
322 },
323};
324
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700325/* MMCIF */
326static struct resource sh_mmcif_resources[] = {
327 [0] = {
328 .name = "MMCIF",
329 .start = 0xe6bd0000,
330 .end = 0xe6bd00ff,
331 .flags = IORESOURCE_MEM,
332 },
333 [1] = {
334 .start = gic_spi(141),
335 .flags = IORESOURCE_IRQ,
336 },
337 [2] = {
338 .start = gic_spi(140),
339 .flags = IORESOURCE_IRQ,
340 },
341};
342
343static struct sh_mmcif_plat_data sh_mmcif_platdata = {
344 .ocr = MMC_VDD_165_195,
345 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
346};
347
348static struct platform_device mmc_device = {
349 .name = "sh_mmcif",
350 .dev = {
351 .dma_mask = NULL,
352 .coherent_dma_mask = 0xffffffff,
353 .platform_data = &sh_mmcif_platdata,
354 },
355 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
356 .resource = sh_mmcif_resources,
357};
358
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700359/* SDHI */
360static struct sh_mobile_sdhi_info sdhi0_info = {
361 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
362 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
363 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
364};
365
366static struct resource sdhi0_resources[] = {
367 [0] = {
368 .name = "SDHI0",
369 .start = 0xee100000,
370 .end = 0xee1000ff,
371 .flags = IORESOURCE_MEM,
372 },
373 [1] = {
374 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
375 .start = gic_spi(83),
376 .flags = IORESOURCE_IRQ,
377 },
378 [2] = {
379 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
380 .start = gic_spi(84),
381 .flags = IORESOURCE_IRQ,
382 },
383 [3] = {
384 .name = SH_MOBILE_SDHI_IRQ_SDIO,
385 .start = gic_spi(85),
386 .flags = IORESOURCE_IRQ,
387 },
388};
389
390static struct platform_device sdhi0_device = {
391 .name = "sh_mobile_sdhi",
392 .num_resources = ARRAY_SIZE(sdhi0_resources),
393 .resource = sdhi0_resources,
394 .dev = {
395 .platform_data = &sdhi0_info,
396 },
397};
398
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700399/* KEY */
400#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
401
402static struct gpio_keys_button gpio_buttons[] = {
403 GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
404 GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
405 GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
406 GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
407 GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
408 GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
409 GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
410};
411
412static struct gpio_keys_platform_data gpio_key_info = {
413 .buttons = gpio_buttons,
414 .nbuttons = ARRAY_SIZE(gpio_buttons),
415 .poll_interval = 250, /* poling at this point */
416};
417
418static struct platform_device gpio_keys_device = {
419 /* gpio-pcf857x.c driver doesn't support gpio_to_irq() */
420 .name = "gpio-keys-polled",
421 .dev = {
422 .platform_data = &gpio_key_info,
423 },
424};
425
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700426/* FSI-AK4648 */
427static struct sh_fsi_platform_info fsi_info = {
428 .port_a = {
429 },
430};
431
432static struct resource fsi_resources[] = {
433 [0] = {
434 .name = "FSI",
435 .start = 0xEC230000,
436 .end = 0xEC230400 - 1,
437 .flags = IORESOURCE_MEM,
438 },
439 [1] = {
440 .start = gic_spi(146),
441 .flags = IORESOURCE_IRQ,
442 },
443};
444
445static struct platform_device fsi_device = {
446 .name = "sh_fsi2",
447 .id = -1,
448 .num_resources = ARRAY_SIZE(fsi_resources),
449 .resource = fsi_resources,
450 .dev = {
451 .platform_data = &fsi_info,
452 },
453};
454
455static struct asoc_simple_dai_init_info fsi2_ak4648_init_info = {
456 .fmt = SND_SOC_DAIFMT_LEFT_J,
457 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
458 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
459 .sysclk = 11289600,
460};
461
462static struct asoc_simple_card_info fsi2_ak4648_info = {
463 .name = "AK4648",
464 .card = "FSI2A-AK4648",
465 .cpu_dai = "fsia-dai",
466 .codec = "ak4642-codec.0-0012",
467 .platform = "sh_fsi2",
468 .codec_dai = "ak4642-hifi",
469 .init = &fsi2_ak4648_init_info,
470};
471
472static struct platform_device fsi_ak4648_device = {
473 .name = "asoc-simple-card",
474 .dev = {
475 .platform_data = &fsi2_ak4648_info,
476 },
477};
478
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700479/* I2C */
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700480static struct pcf857x_platform_data pcf8575_pdata = {
481 .gpio_base = GPIO_PCF8575_BASE,
482};
483
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700484static struct i2c_board_info i2c0_devices[] = {
485 {
486 I2C_BOARD_INFO("ak4648", 0x12),
Tetsuyuki Kobayashi080e0d12012-06-20 12:57:51 +0200487 },
488 {
489 I2C_BOARD_INFO("r2025sd", 0x32),
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700490 }
491};
492
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700493static struct i2c_board_info i2c1_devices[] = {
494 {
495 I2C_BOARD_INFO("st1232-ts", 0x55),
496 .irq = intcs_evt2irq(0x300), /* IRQ8 */
497 },
498};
499
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700500static struct i2c_board_info i2c3_devices[] = {
501 {
502 I2C_BOARD_INFO("pcf8575", 0x20),
503 .platform_data = &pcf8575_pdata,
504 },
505};
506
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700507static struct platform_device *kzm_devices[] __initdata = {
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700508 &smsc_device,
Kuninori Morimotodd818182012-04-10 20:58:10 -0700509 &usb_host_device,
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700510 &usbhs_device,
Kuninori Morimoto26786112012-04-10 20:58:33 -0700511 &lcdc_device,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700512 &mmc_device,
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700513 &sdhi0_device,
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700514 &gpio_keys_device,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700515 &fsi_device,
516 &fsi_ak4648_device,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700517};
518
Kuninori Morimoto26786112012-04-10 20:58:33 -0700519/*
520 * FIXME
521 *
522 * This is quick hack for enabling LCDC backlight
523 */
524static int __init as3711_enable_lcdc_backlight(void)
525{
526 struct i2c_adapter *a = i2c_get_adapter(0);
527 struct i2c_msg msg;
528 int i, ret;
529 __u8 magic[] = {
530 0x40, 0x2a,
531 0x43, 0x3c,
532 0x44, 0x3c,
533 0x45, 0x3c,
534 0x54, 0x03,
535 0x51, 0x00,
536 0x51, 0x01,
537 0xff, 0x00, /* wait */
538 0x43, 0xf0,
539 0x44, 0xf0,
540 0x45, 0xf0,
541 };
542
543 if (!machine_is_kzm9g())
544 return 0;
545
546 if (!a)
547 return 0;
548
549 msg.addr = 0x40;
550 msg.len = 2;
551 msg.flags = 0;
552
553 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
554 msg.buf = magic + i;
555
556 if (0xff == msg.buf[0]) {
557 udelay(500);
558 continue;
559 }
560
561 ret = i2c_transfer(a, &msg, 1);
562 if (ret < 0) {
563 pr_err("i2c transfer fail\n");
564 break;
565 }
566 }
567
568 return 0;
569}
570device_initcall(as3711_enable_lcdc_backlight);
571
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700572static void __init kzm_init(void)
573{
574 sh73a0_pinmux_init();
575
576 /* enable SCIFA4 */
577 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
578 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
579 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
580 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
581
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700582 /* CS4 for SMSC/USB */
583 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
584
585 /* SMSC */
586 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
587 gpio_direction_input(GPIO_PORT224);
588
Kuninori Morimoto26786112012-04-10 20:58:33 -0700589 /* LCDC */
590 gpio_request(GPIO_FN_LCDD23, NULL);
591 gpio_request(GPIO_FN_LCDD22, NULL);
592 gpio_request(GPIO_FN_LCDD21, NULL);
593 gpio_request(GPIO_FN_LCDD20, NULL);
594 gpio_request(GPIO_FN_LCDD19, NULL);
595 gpio_request(GPIO_FN_LCDD18, NULL);
596 gpio_request(GPIO_FN_LCDD17, NULL);
597 gpio_request(GPIO_FN_LCDD16, NULL);
598 gpio_request(GPIO_FN_LCDD15, NULL);
599 gpio_request(GPIO_FN_LCDD14, NULL);
600 gpio_request(GPIO_FN_LCDD13, NULL);
601 gpio_request(GPIO_FN_LCDD12, NULL);
602 gpio_request(GPIO_FN_LCDD11, NULL);
603 gpio_request(GPIO_FN_LCDD10, NULL);
604 gpio_request(GPIO_FN_LCDD9, NULL);
605 gpio_request(GPIO_FN_LCDD8, NULL);
606 gpio_request(GPIO_FN_LCDD7, NULL);
607 gpio_request(GPIO_FN_LCDD6, NULL);
608 gpio_request(GPIO_FN_LCDD5, NULL);
609 gpio_request(GPIO_FN_LCDD4, NULL);
610 gpio_request(GPIO_FN_LCDD3, NULL);
611 gpio_request(GPIO_FN_LCDD2, NULL);
612 gpio_request(GPIO_FN_LCDD1, NULL);
613 gpio_request(GPIO_FN_LCDD0, NULL);
614 gpio_request(GPIO_FN_LCDDISP, NULL);
615 gpio_request(GPIO_FN_LCDDCK, NULL);
616
Kuninori Morimoto601df612012-04-22 23:53:24 -0700617 gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
618 gpio_request(GPIO_PORT226, NULL); /* SC */
Kuninori Morimoto26786112012-04-10 20:58:33 -0700619 gpio_direction_output(GPIO_PORT222, 1);
Kuninori Morimoto601df612012-04-22 23:53:24 -0700620 gpio_direction_output(GPIO_PORT226, 1);
Kuninori Morimoto26786112012-04-10 20:58:33 -0700621
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700622 /* Touchscreen */
623 gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
624 gpio_direction_input(GPIO_PORT223);
625
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700626 /* enable MMCIF */
627 gpio_request(GPIO_FN_MMCCLK0, NULL);
628 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
629 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
630 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
631 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
632 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
633 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
634 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
635 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
636 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
637
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700638 /* enable SD */
639 gpio_request(GPIO_FN_SDHIWP0, NULL);
640 gpio_request(GPIO_FN_SDHICD0, NULL);
641 gpio_request(GPIO_FN_SDHICMD0, NULL);
642 gpio_request(GPIO_FN_SDHICLK0, NULL);
643 gpio_request(GPIO_FN_SDHID0_3, NULL);
644 gpio_request(GPIO_FN_SDHID0_2, NULL);
645 gpio_request(GPIO_FN_SDHID0_1, NULL);
646 gpio_request(GPIO_FN_SDHID0_0, NULL);
647 gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
648 gpio_request(GPIO_PORT15, NULL);
649 gpio_direction_output(GPIO_PORT15, 1); /* power */
650
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700651 /* I2C 3 */
652 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
653 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
654
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700655 /* enable FSI2 port A (ak4648) */
656 gpio_request(GPIO_FN_FSIACK, NULL);
657 gpio_request(GPIO_FN_FSIAILR, NULL);
658 gpio_request(GPIO_FN_FSIAIBT, NULL);
659 gpio_request(GPIO_FN_FSIAISLD, NULL);
660 gpio_request(GPIO_FN_FSIAOSLD, NULL);
661
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700662 /* enable USB */
663 gpio_request(GPIO_FN_VBUS_0, NULL);
664
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700665#ifdef CONFIG_CACHE_L2X0
666 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
667 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
668#endif
669
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700670 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700671 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700672 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700673
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700674 sh73a0_add_standard_devices();
675 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
676}
677
Magnus Damm7296d932012-05-14 23:22:28 +0200678static const char *kzm9g_boards_compat_dt[] __initdata = {
679 "renesas,kzm9g",
680 NULL,
681};
682
683DT_MACHINE_START(KZM9G_DT, "kzm9g")
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700684 .map_io = sh73a0_map_io,
685 .init_early = sh73a0_add_early_devices,
686 .nr_irqs = NR_IRQS_LEGACY,
687 .init_irq = sh73a0_init_irq,
688 .handle_irq = gic_handle_irq,
689 .init_machine = kzm_init,
690 .timer = &shmobile_timer,
Magnus Damm7296d932012-05-14 23:22:28 +0200691 .dt_compat = kzm9g_boards_compat_dt,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700692MACHINE_END