blob: a16c970ee37737a14b2c36bfb42b667e9609b68a [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,
Kuninori Morimotoa1ca8f42012-06-25 03:39:39 -0700346 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
347 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700348};
349
350static struct platform_device mmc_device = {
351 .name = "sh_mmcif",
352 .dev = {
353 .dma_mask = NULL,
354 .coherent_dma_mask = 0xffffffff,
355 .platform_data = &sh_mmcif_platdata,
356 },
357 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
358 .resource = sh_mmcif_resources,
359};
360
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700361/* SDHI */
362static struct sh_mobile_sdhi_info sdhi0_info = {
363 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
364 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
365 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
366};
367
368static struct resource sdhi0_resources[] = {
369 [0] = {
370 .name = "SDHI0",
371 .start = 0xee100000,
372 .end = 0xee1000ff,
373 .flags = IORESOURCE_MEM,
374 },
375 [1] = {
376 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
377 .start = gic_spi(83),
378 .flags = IORESOURCE_IRQ,
379 },
380 [2] = {
381 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
382 .start = gic_spi(84),
383 .flags = IORESOURCE_IRQ,
384 },
385 [3] = {
386 .name = SH_MOBILE_SDHI_IRQ_SDIO,
387 .start = gic_spi(85),
388 .flags = IORESOURCE_IRQ,
389 },
390};
391
392static struct platform_device sdhi0_device = {
393 .name = "sh_mobile_sdhi",
394 .num_resources = ARRAY_SIZE(sdhi0_resources),
395 .resource = sdhi0_resources,
396 .dev = {
397 .platform_data = &sdhi0_info,
398 },
399};
400
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700401/* Micro SD */
402static struct sh_mobile_sdhi_info sdhi2_info = {
403 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
404 TMIO_MMC_USE_GPIO_CD |
405 TMIO_MMC_WRPROTECT_DISABLE,
406 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
407 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
408 .cd_gpio = GPIO_PORT13,
409};
410
411static struct resource sdhi2_resources[] = {
412 [0] = {
413 .name = "SDHI2",
414 .start = 0xee140000,
415 .end = 0xee1400ff,
416 .flags = IORESOURCE_MEM,
417 },
418 [1] = {
419 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
420 .start = gic_spi(103),
421 .flags = IORESOURCE_IRQ,
422 },
423 [2] = {
424 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
425 .start = gic_spi(104),
426 .flags = IORESOURCE_IRQ,
427 },
428 [3] = {
429 .name = SH_MOBILE_SDHI_IRQ_SDIO,
430 .start = gic_spi(105),
431 .flags = IORESOURCE_IRQ,
432 },
433};
434
435static struct platform_device sdhi2_device = {
436 .name = "sh_mobile_sdhi",
437 .id = 2,
438 .num_resources = ARRAY_SIZE(sdhi2_resources),
439 .resource = sdhi2_resources,
440 .dev = {
441 .platform_data = &sdhi2_info,
442 },
443};
444
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700445/* KEY */
446#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
447
448static struct gpio_keys_button gpio_buttons[] = {
449 GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
450 GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
451 GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
452 GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
453 GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
454 GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
455 GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
456};
457
458static struct gpio_keys_platform_data gpio_key_info = {
459 .buttons = gpio_buttons,
460 .nbuttons = ARRAY_SIZE(gpio_buttons),
461 .poll_interval = 250, /* poling at this point */
462};
463
464static struct platform_device gpio_keys_device = {
465 /* gpio-pcf857x.c driver doesn't support gpio_to_irq() */
466 .name = "gpio-keys-polled",
467 .dev = {
468 .platform_data = &gpio_key_info,
469 },
470};
471
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700472/* FSI-AK4648 */
473static struct sh_fsi_platform_info fsi_info = {
474 .port_a = {
Kuninori Morimoto76b80322012-06-25 03:39:30 -0700475 .tx_id = SHDMA_SLAVE_FSI2A_TX,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700476 },
477};
478
479static struct resource fsi_resources[] = {
480 [0] = {
481 .name = "FSI",
482 .start = 0xEC230000,
483 .end = 0xEC230400 - 1,
484 .flags = IORESOURCE_MEM,
485 },
486 [1] = {
487 .start = gic_spi(146),
488 .flags = IORESOURCE_IRQ,
489 },
490};
491
492static struct platform_device fsi_device = {
493 .name = "sh_fsi2",
494 .id = -1,
495 .num_resources = ARRAY_SIZE(fsi_resources),
496 .resource = fsi_resources,
497 .dev = {
498 .platform_data = &fsi_info,
499 },
500};
501
502static struct asoc_simple_dai_init_info fsi2_ak4648_init_info = {
503 .fmt = SND_SOC_DAIFMT_LEFT_J,
504 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
505 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
506 .sysclk = 11289600,
507};
508
509static struct asoc_simple_card_info fsi2_ak4648_info = {
510 .name = "AK4648",
511 .card = "FSI2A-AK4648",
512 .cpu_dai = "fsia-dai",
513 .codec = "ak4642-codec.0-0012",
514 .platform = "sh_fsi2",
515 .codec_dai = "ak4642-hifi",
516 .init = &fsi2_ak4648_init_info,
517};
518
519static struct platform_device fsi_ak4648_device = {
520 .name = "asoc-simple-card",
521 .dev = {
522 .platform_data = &fsi2_ak4648_info,
523 },
524};
525
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700526/* I2C */
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700527static struct pcf857x_platform_data pcf8575_pdata = {
528 .gpio_base = GPIO_PCF8575_BASE,
529};
530
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700531static struct i2c_board_info i2c0_devices[] = {
532 {
533 I2C_BOARD_INFO("ak4648", 0x12),
Tetsuyuki Kobayashi080e0d12012-06-20 12:57:51 +0200534 },
535 {
536 I2C_BOARD_INFO("r2025sd", 0x32),
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700537 }
538};
539
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700540static struct i2c_board_info i2c1_devices[] = {
541 {
542 I2C_BOARD_INFO("st1232-ts", 0x55),
543 .irq = intcs_evt2irq(0x300), /* IRQ8 */
544 },
545};
546
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700547static struct i2c_board_info i2c3_devices[] = {
548 {
549 I2C_BOARD_INFO("pcf8575", 0x20),
550 .platform_data = &pcf8575_pdata,
551 },
552};
553
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700554static struct platform_device *kzm_devices[] __initdata = {
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700555 &smsc_device,
Kuninori Morimotodd818182012-04-10 20:58:10 -0700556 &usb_host_device,
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700557 &usbhs_device,
Kuninori Morimoto26786112012-04-10 20:58:33 -0700558 &lcdc_device,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700559 &mmc_device,
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700560 &sdhi0_device,
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700561 &sdhi2_device,
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700562 &gpio_keys_device,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700563 &fsi_device,
564 &fsi_ak4648_device,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700565};
566
Kuninori Morimoto26786112012-04-10 20:58:33 -0700567/*
568 * FIXME
569 *
570 * This is quick hack for enabling LCDC backlight
571 */
572static int __init as3711_enable_lcdc_backlight(void)
573{
574 struct i2c_adapter *a = i2c_get_adapter(0);
575 struct i2c_msg msg;
576 int i, ret;
577 __u8 magic[] = {
578 0x40, 0x2a,
579 0x43, 0x3c,
580 0x44, 0x3c,
581 0x45, 0x3c,
582 0x54, 0x03,
583 0x51, 0x00,
584 0x51, 0x01,
585 0xff, 0x00, /* wait */
586 0x43, 0xf0,
587 0x44, 0xf0,
588 0x45, 0xf0,
589 };
590
591 if (!machine_is_kzm9g())
592 return 0;
593
594 if (!a)
595 return 0;
596
597 msg.addr = 0x40;
598 msg.len = 2;
599 msg.flags = 0;
600
601 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
602 msg.buf = magic + i;
603
604 if (0xff == msg.buf[0]) {
605 udelay(500);
606 continue;
607 }
608
609 ret = i2c_transfer(a, &msg, 1);
610 if (ret < 0) {
611 pr_err("i2c transfer fail\n");
612 break;
613 }
614 }
615
616 return 0;
617}
618device_initcall(as3711_enable_lcdc_backlight);
619
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700620static void __init kzm_init(void)
621{
622 sh73a0_pinmux_init();
623
624 /* enable SCIFA4 */
625 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
626 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
627 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
628 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
629
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700630 /* CS4 for SMSC/USB */
631 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
632
633 /* SMSC */
634 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
635 gpio_direction_input(GPIO_PORT224);
636
Kuninori Morimoto26786112012-04-10 20:58:33 -0700637 /* LCDC */
638 gpio_request(GPIO_FN_LCDD23, NULL);
639 gpio_request(GPIO_FN_LCDD22, NULL);
640 gpio_request(GPIO_FN_LCDD21, NULL);
641 gpio_request(GPIO_FN_LCDD20, NULL);
642 gpio_request(GPIO_FN_LCDD19, NULL);
643 gpio_request(GPIO_FN_LCDD18, NULL);
644 gpio_request(GPIO_FN_LCDD17, NULL);
645 gpio_request(GPIO_FN_LCDD16, NULL);
646 gpio_request(GPIO_FN_LCDD15, NULL);
647 gpio_request(GPIO_FN_LCDD14, NULL);
648 gpio_request(GPIO_FN_LCDD13, NULL);
649 gpio_request(GPIO_FN_LCDD12, NULL);
650 gpio_request(GPIO_FN_LCDD11, NULL);
651 gpio_request(GPIO_FN_LCDD10, NULL);
652 gpio_request(GPIO_FN_LCDD9, NULL);
653 gpio_request(GPIO_FN_LCDD8, NULL);
654 gpio_request(GPIO_FN_LCDD7, NULL);
655 gpio_request(GPIO_FN_LCDD6, NULL);
656 gpio_request(GPIO_FN_LCDD5, NULL);
657 gpio_request(GPIO_FN_LCDD4, NULL);
658 gpio_request(GPIO_FN_LCDD3, NULL);
659 gpio_request(GPIO_FN_LCDD2, NULL);
660 gpio_request(GPIO_FN_LCDD1, NULL);
661 gpio_request(GPIO_FN_LCDD0, NULL);
662 gpio_request(GPIO_FN_LCDDISP, NULL);
663 gpio_request(GPIO_FN_LCDDCK, NULL);
664
Kuninori Morimoto601df612012-04-22 23:53:24 -0700665 gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
666 gpio_request(GPIO_PORT226, NULL); /* SC */
Kuninori Morimoto26786112012-04-10 20:58:33 -0700667 gpio_direction_output(GPIO_PORT222, 1);
Kuninori Morimoto601df612012-04-22 23:53:24 -0700668 gpio_direction_output(GPIO_PORT226, 1);
Kuninori Morimoto26786112012-04-10 20:58:33 -0700669
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700670 /* Touchscreen */
671 gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
672 gpio_direction_input(GPIO_PORT223);
673
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700674 /* enable MMCIF */
675 gpio_request(GPIO_FN_MMCCLK0, NULL);
676 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
677 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
678 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
679 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
680 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
681 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
682 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
683 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
684 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
685
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700686 /* enable SD */
687 gpio_request(GPIO_FN_SDHIWP0, NULL);
688 gpio_request(GPIO_FN_SDHICD0, NULL);
689 gpio_request(GPIO_FN_SDHICMD0, NULL);
690 gpio_request(GPIO_FN_SDHICLK0, NULL);
691 gpio_request(GPIO_FN_SDHID0_3, NULL);
692 gpio_request(GPIO_FN_SDHID0_2, NULL);
693 gpio_request(GPIO_FN_SDHID0_1, NULL);
694 gpio_request(GPIO_FN_SDHID0_0, NULL);
695 gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
696 gpio_request(GPIO_PORT15, NULL);
697 gpio_direction_output(GPIO_PORT15, 1); /* power */
698
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700699 /* enable Micro SD */
700 gpio_request(GPIO_FN_SDHID2_0, NULL);
701 gpio_request(GPIO_FN_SDHID2_1, NULL);
702 gpio_request(GPIO_FN_SDHID2_2, NULL);
703 gpio_request(GPIO_FN_SDHID2_3, NULL);
704 gpio_request(GPIO_FN_SDHICMD2, NULL);
705 gpio_request(GPIO_FN_SDHICLK2, NULL);
706 gpio_request(GPIO_PORT14, NULL);
707 gpio_direction_output(GPIO_PORT14, 1); /* power */
708
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700709 /* I2C 3 */
710 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
711 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
712
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700713 /* enable FSI2 port A (ak4648) */
714 gpio_request(GPIO_FN_FSIACK, NULL);
715 gpio_request(GPIO_FN_FSIAILR, NULL);
716 gpio_request(GPIO_FN_FSIAIBT, NULL);
717 gpio_request(GPIO_FN_FSIAISLD, NULL);
718 gpio_request(GPIO_FN_FSIAOSLD, NULL);
719
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700720 /* enable USB */
721 gpio_request(GPIO_FN_VBUS_0, NULL);
722
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700723#ifdef CONFIG_CACHE_L2X0
724 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
725 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
726#endif
727
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700728 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700729 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700730 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700731
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700732 sh73a0_add_standard_devices();
733 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
734}
735
Magnus Damm7296d932012-05-14 23:22:28 +0200736static const char *kzm9g_boards_compat_dt[] __initdata = {
737 "renesas,kzm9g",
738 NULL,
739};
740
741DT_MACHINE_START(KZM9G_DT, "kzm9g")
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700742 .map_io = sh73a0_map_io,
743 .init_early = sh73a0_add_early_devices,
744 .nr_irqs = NR_IRQS_LEGACY,
745 .init_irq = sh73a0_init_irq,
746 .handle_irq = gic_handle_irq,
747 .init_machine = kzm_init,
748 .timer = &shmobile_timer,
Magnus Damm7296d932012-05-14 23:22:28 +0200749 .dt_compat = kzm9g_boards_compat_dt,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700750MACHINE_END