blob: 256aa8dce66b2cca06840bbc169721c7584715bf [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>
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +020033#include <linux/regulator/fixed.h>
34#include <linux/regulator/machine.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070035#include <linux/smsc911x.h>
Kuninori Morimotodd818182012-04-10 20:58:10 -070036#include <linux/usb/r8a66597.h>
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -070037#include <linux/usb/renesas_usbhs.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070038#include <linux/videodev2.h>
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -070039#include <sound/sh_fsi.h>
40#include <sound/simple_card.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070041#include <mach/irqs.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070042#include <mach/sh73a0.h>
43#include <mach/common.h>
44#include <asm/hardware/cache-l2x0.h>
45#include <asm/hardware/gic.h>
46#include <asm/mach-types.h>
47#include <asm/mach/arch.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070048#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070049
Kuninori Morimoto1e354642012-04-22 23:54:14 -070050/*
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
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +020062/* Dummy supplies, where voltage doesn't matter */
63static struct regulator_consumer_supply dummy_supplies[] = {
64 REGULATOR_SUPPLY("vddvario", "smsc911x"),
65 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
66};
67
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -070068/*
69 * FSI-AK4648
70 *
71 * this command is required when playback.
72 *
73 * # amixer set "LINEOUT Mixer DACL" on
74 */
75
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070076/* SMSC 9221 */
77static struct resource smsc9221_resources[] = {
78 [0] = {
79 .start = 0x10000000, /* CS4 */
80 .end = 0x100000ff,
81 .flags = IORESOURCE_MEM,
82 },
83 [1] = {
84 .start = intcs_evt2irq(0x260), /* IRQ3 */
85 .flags = IORESOURCE_IRQ,
86 },
87};
88
89static 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
96static 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
Kuninori Morimotodd818182012-04-10 20:58:10 -0700105/* USB external chip */
106static struct r8a66597_platdata usb_host_data = {
107 .on_chip = 0,
108 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
109};
110
111static struct resource usb_resources[] = {
112 [0] = {
113 .start = 0x10010000,
114 .end = 0x1001ffff - 1,
115 .flags = IORESOURCE_MEM,
116 },
117 [1] = {
118 .start = intcs_evt2irq(0x220), /* IRQ1 */
119 .flags = IORESOURCE_IRQ,
120 },
121};
122
123static 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
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700134/* USB Func CN17 */
135struct usbhs_private {
136 unsigned int phy;
137 unsigned int cr2;
138 struct renesas_usbhs_platform_info info;
139};
140
141#define IRQ15 intcs_evt2irq(0x03e0)
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
151static 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
158static void 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
166static int usbhs_get_id(struct platform_device *pdev)
167{
168 return USBHS_GADGET;
169}
170
171static irqreturn_t usbhs_interrupt(int irq, void *data)
172{
173 struct platform_device *pdev = data;
174 struct usbhs_private *priv = usbhs_get_priv(pdev);
175
176 renesas_usbhs_call_notify_hotplug(pdev);
177
178 /* clear status */
179 __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
180
181 return IRQ_HANDLED;
182}
183
184static int usbhs_hardware_init(struct platform_device *pdev)
185{
186 struct usbhs_private *priv = usbhs_get_priv(pdev);
187 int ret;
188
189 /* clear interrupt status */
190 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
191
192 ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
193 dev_name(&pdev->dev), pdev);
194 if (ret) {
195 dev_err(&pdev->dev, "request_irq err\n");
196 return ret;
197 }
198
199 /* enable USB phy interrupt */
200 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
201
202 return 0;
203}
204
205static void usbhs_hardware_exit(struct platform_device *pdev)
206{
207 struct usbhs_private *priv = usbhs_get_priv(pdev);
208
209 /* clear interrupt status */
210 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
211
212 free_irq(IRQ15, pdev);
213}
214
215static u32 usbhs_pipe_cfg[] = {
216 USB_ENDPOINT_XFER_CONTROL,
217 USB_ENDPOINT_XFER_ISOC,
218 USB_ENDPOINT_XFER_ISOC,
219 USB_ENDPOINT_XFER_BULK,
220 USB_ENDPOINT_XFER_BULK,
221 USB_ENDPOINT_XFER_BULK,
222 USB_ENDPOINT_XFER_INT,
223 USB_ENDPOINT_XFER_INT,
224 USB_ENDPOINT_XFER_INT,
225 USB_ENDPOINT_XFER_BULK,
226 USB_ENDPOINT_XFER_BULK,
227 USB_ENDPOINT_XFER_BULK,
228 USB_ENDPOINT_XFER_BULK,
229 USB_ENDPOINT_XFER_BULK,
230 USB_ENDPOINT_XFER_BULK,
231 USB_ENDPOINT_XFER_BULK,
232};
233
234static struct usbhs_private usbhs_private = {
235 .phy = 0xe60781e0, /* USBPHYINT */
236 .cr2 = 0xe605810c, /* USBCR2 */
237 .info = {
238 .platform_callback = {
239 .hardware_init = usbhs_hardware_init,
240 .hardware_exit = usbhs_hardware_exit,
241 .get_id = usbhs_get_id,
242 .phy_reset = usbhs_phy_reset,
243 .get_vbus = usbhs_get_vbus,
244 },
245 .driver_param = {
246 .buswait_bwait = 4,
247 .has_otg = 1,
248 .pipe_type = usbhs_pipe_cfg,
249 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
250 },
251 },
252};
253
254static struct resource usbhs_resources[] = {
255 [0] = {
256 .start = 0xE6890000,
257 .end = 0xE68900e6 - 1,
258 .flags = IORESOURCE_MEM,
259 },
260 [1] = {
261 .start = gic_spi(62),
262 .end = gic_spi(62),
263 .flags = IORESOURCE_IRQ,
264 },
265};
266
267static struct platform_device usbhs_device = {
268 .name = "renesas_usbhs",
269 .id = -1,
270 .dev = {
271 .dma_mask = NULL,
272 .coherent_dma_mask = 0xffffffff,
273 .platform_data = &usbhs_private.info,
274 },
275 .num_resources = ARRAY_SIZE(usbhs_resources),
276 .resource = usbhs_resources,
277};
278
Kuninori Morimoto26786112012-04-10 20:58:33 -0700279/* LCDC */
280static struct fb_videomode kzm_lcdc_mode = {
281 .name = "WVGA Panel",
282 .xres = 800,
283 .yres = 480,
284 .left_margin = 220,
285 .right_margin = 110,
286 .hsync_len = 70,
287 .upper_margin = 20,
288 .lower_margin = 5,
289 .vsync_len = 5,
290 .sync = 0,
291};
292
293static struct sh_mobile_lcdc_info lcdc_info = {
294 .clock_source = LCDC_CLK_BUS,
295 .ch[0] = {
296 .chan = LCDC_CHAN_MAINLCD,
297 .fourcc = V4L2_PIX_FMT_RGB565,
298 .interface_type = RGB24,
299 .lcd_modes = &kzm_lcdc_mode,
300 .num_modes = 1,
301 .clock_divider = 5,
302 .flags = 0,
303 .panel_cfg = {
304 .width = 152,
305 .height = 91,
306 },
307 }
308};
309
310static struct resource lcdc_resources[] = {
311 [0] = {
312 .name = "LCDC",
313 .start = 0xfe940000,
314 .end = 0xfe943fff,
315 .flags = IORESOURCE_MEM,
316 },
317 [1] = {
318 .start = intcs_evt2irq(0x580),
319 .flags = IORESOURCE_IRQ,
320 },
321};
322
323static struct platform_device lcdc_device = {
324 .name = "sh_mobile_lcdc_fb",
325 .num_resources = ARRAY_SIZE(lcdc_resources),
326 .resource = lcdc_resources,
327 .dev = {
328 .platform_data = &lcdc_info,
329 .coherent_dma_mask = ~0,
330 },
331};
332
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200333/* Fixed 1.8V regulator to be used by MMCIF */
334static struct regulator_consumer_supply fixed1v8_power_consumers[] =
335{
336 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
337 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
338};
339
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700340/* MMCIF */
341static struct resource sh_mmcif_resources[] = {
342 [0] = {
343 .name = "MMCIF",
344 .start = 0xe6bd0000,
345 .end = 0xe6bd00ff,
346 .flags = IORESOURCE_MEM,
347 },
348 [1] = {
349 .start = gic_spi(141),
350 .flags = IORESOURCE_IRQ,
351 },
352 [2] = {
353 .start = gic_spi(140),
354 .flags = IORESOURCE_IRQ,
355 },
356};
357
358static struct sh_mmcif_plat_data sh_mmcif_platdata = {
359 .ocr = MMC_VDD_165_195,
360 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Kuninori Morimotoa1ca8f42012-06-25 03:39:39 -0700361 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
362 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700363};
364
365static struct platform_device mmc_device = {
366 .name = "sh_mmcif",
367 .dev = {
368 .dma_mask = NULL,
369 .coherent_dma_mask = 0xffffffff,
370 .platform_data = &sh_mmcif_platdata,
371 },
372 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
373 .resource = sh_mmcif_resources,
374};
375
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200376/* Fixed 2.8V regulators to be used by SDHI0 */
377static struct regulator_consumer_supply fixed2v8_power_consumers[] =
378{
379 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
380 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
381};
382
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700383/* SDHI */
384static struct sh_mobile_sdhi_info sdhi0_info = {
385 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
386 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
387 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
388};
389
390static struct resource sdhi0_resources[] = {
391 [0] = {
392 .name = "SDHI0",
393 .start = 0xee100000,
394 .end = 0xee1000ff,
395 .flags = IORESOURCE_MEM,
396 },
397 [1] = {
398 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
399 .start = gic_spi(83),
400 .flags = IORESOURCE_IRQ,
401 },
402 [2] = {
403 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
404 .start = gic_spi(84),
405 .flags = IORESOURCE_IRQ,
406 },
407 [3] = {
408 .name = SH_MOBILE_SDHI_IRQ_SDIO,
409 .start = gic_spi(85),
410 .flags = IORESOURCE_IRQ,
411 },
412};
413
414static struct platform_device sdhi0_device = {
415 .name = "sh_mobile_sdhi",
416 .num_resources = ARRAY_SIZE(sdhi0_resources),
417 .resource = sdhi0_resources,
418 .dev = {
419 .platform_data = &sdhi0_info,
420 },
421};
422
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700423/* Micro SD */
424static struct sh_mobile_sdhi_info sdhi2_info = {
425 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
426 TMIO_MMC_USE_GPIO_CD |
427 TMIO_MMC_WRPROTECT_DISABLE,
428 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
429 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
430 .cd_gpio = GPIO_PORT13,
431};
432
433static struct resource sdhi2_resources[] = {
434 [0] = {
435 .name = "SDHI2",
436 .start = 0xee140000,
437 .end = 0xee1400ff,
438 .flags = IORESOURCE_MEM,
439 },
440 [1] = {
441 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
442 .start = gic_spi(103),
443 .flags = IORESOURCE_IRQ,
444 },
445 [2] = {
446 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
447 .start = gic_spi(104),
448 .flags = IORESOURCE_IRQ,
449 },
450 [3] = {
451 .name = SH_MOBILE_SDHI_IRQ_SDIO,
452 .start = gic_spi(105),
453 .flags = IORESOURCE_IRQ,
454 },
455};
456
457static struct platform_device sdhi2_device = {
458 .name = "sh_mobile_sdhi",
459 .id = 2,
460 .num_resources = ARRAY_SIZE(sdhi2_resources),
461 .resource = sdhi2_resources,
462 .dev = {
463 .platform_data = &sdhi2_info,
464 },
465};
466
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700467/* KEY */
468#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
469
470static struct gpio_keys_button gpio_buttons[] = {
471 GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
472 GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
473 GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
474 GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
475 GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
476 GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
477 GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
478};
479
480static struct gpio_keys_platform_data gpio_key_info = {
481 .buttons = gpio_buttons,
482 .nbuttons = ARRAY_SIZE(gpio_buttons),
483 .poll_interval = 250, /* poling at this point */
484};
485
486static struct platform_device gpio_keys_device = {
487 /* gpio-pcf857x.c driver doesn't support gpio_to_irq() */
488 .name = "gpio-keys-polled",
489 .dev = {
490 .platform_data = &gpio_key_info,
491 },
492};
493
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700494/* FSI-AK4648 */
495static struct sh_fsi_platform_info fsi_info = {
496 .port_a = {
Kuninori Morimoto76b80322012-06-25 03:39:30 -0700497 .tx_id = SHDMA_SLAVE_FSI2A_TX,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700498 },
499};
500
501static struct resource fsi_resources[] = {
502 [0] = {
503 .name = "FSI",
504 .start = 0xEC230000,
505 .end = 0xEC230400 - 1,
506 .flags = IORESOURCE_MEM,
507 },
508 [1] = {
509 .start = gic_spi(146),
510 .flags = IORESOURCE_IRQ,
511 },
512};
513
514static struct platform_device fsi_device = {
515 .name = "sh_fsi2",
516 .id = -1,
517 .num_resources = ARRAY_SIZE(fsi_resources),
518 .resource = fsi_resources,
519 .dev = {
520 .platform_data = &fsi_info,
521 },
522};
523
524static struct asoc_simple_dai_init_info fsi2_ak4648_init_info = {
525 .fmt = SND_SOC_DAIFMT_LEFT_J,
526 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
527 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
528 .sysclk = 11289600,
529};
530
531static struct asoc_simple_card_info fsi2_ak4648_info = {
532 .name = "AK4648",
533 .card = "FSI2A-AK4648",
534 .cpu_dai = "fsia-dai",
535 .codec = "ak4642-codec.0-0012",
536 .platform = "sh_fsi2",
537 .codec_dai = "ak4642-hifi",
538 .init = &fsi2_ak4648_init_info,
539};
540
541static struct platform_device fsi_ak4648_device = {
542 .name = "asoc-simple-card",
543 .dev = {
544 .platform_data = &fsi2_ak4648_info,
545 },
546};
547
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700548/* I2C */
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700549static struct pcf857x_platform_data pcf8575_pdata = {
550 .gpio_base = GPIO_PCF8575_BASE,
551};
552
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700553static struct i2c_board_info i2c0_devices[] = {
554 {
555 I2C_BOARD_INFO("ak4648", 0x12),
Tetsuyuki Kobayashi080e0d12012-06-20 12:57:51 +0200556 },
557 {
558 I2C_BOARD_INFO("r2025sd", 0x32),
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700559 }
560};
561
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700562static struct i2c_board_info i2c1_devices[] = {
563 {
564 I2C_BOARD_INFO("st1232-ts", 0x55),
565 .irq = intcs_evt2irq(0x300), /* IRQ8 */
566 },
567};
568
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700569static struct i2c_board_info i2c3_devices[] = {
570 {
571 I2C_BOARD_INFO("pcf8575", 0x20),
572 .platform_data = &pcf8575_pdata,
573 },
574};
575
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700576static struct platform_device *kzm_devices[] __initdata = {
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700577 &smsc_device,
Kuninori Morimotodd818182012-04-10 20:58:10 -0700578 &usb_host_device,
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700579 &usbhs_device,
Kuninori Morimoto26786112012-04-10 20:58:33 -0700580 &lcdc_device,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700581 &mmc_device,
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700582 &sdhi0_device,
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700583 &sdhi2_device,
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700584 &gpio_keys_device,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700585 &fsi_device,
586 &fsi_ak4648_device,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700587};
588
Kuninori Morimoto26786112012-04-10 20:58:33 -0700589/*
590 * FIXME
591 *
592 * This is quick hack for enabling LCDC backlight
593 */
594static int __init as3711_enable_lcdc_backlight(void)
595{
596 struct i2c_adapter *a = i2c_get_adapter(0);
597 struct i2c_msg msg;
598 int i, ret;
599 __u8 magic[] = {
600 0x40, 0x2a,
601 0x43, 0x3c,
602 0x44, 0x3c,
603 0x45, 0x3c,
604 0x54, 0x03,
605 0x51, 0x00,
606 0x51, 0x01,
607 0xff, 0x00, /* wait */
608 0x43, 0xf0,
609 0x44, 0xf0,
610 0x45, 0xf0,
611 };
612
613 if (!machine_is_kzm9g())
614 return 0;
615
616 if (!a)
617 return 0;
618
619 msg.addr = 0x40;
620 msg.len = 2;
621 msg.flags = 0;
622
623 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
624 msg.buf = magic + i;
625
626 if (0xff == msg.buf[0]) {
627 udelay(500);
628 continue;
629 }
630
631 ret = i2c_transfer(a, &msg, 1);
632 if (ret < 0) {
633 pr_err("i2c transfer fail\n");
634 break;
635 }
636 }
637
638 return 0;
639}
640device_initcall(as3711_enable_lcdc_backlight);
641
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700642static void __init kzm_init(void)
643{
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200644 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
645 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
646 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
647 ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
648 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
649
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700650 sh73a0_pinmux_init();
651
652 /* enable SCIFA4 */
653 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
654 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
655 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
656 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
657
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700658 /* CS4 for SMSC/USB */
659 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
660
661 /* SMSC */
662 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
663 gpio_direction_input(GPIO_PORT224);
664
Kuninori Morimoto26786112012-04-10 20:58:33 -0700665 /* LCDC */
666 gpio_request(GPIO_FN_LCDD23, NULL);
667 gpio_request(GPIO_FN_LCDD22, NULL);
668 gpio_request(GPIO_FN_LCDD21, NULL);
669 gpio_request(GPIO_FN_LCDD20, NULL);
670 gpio_request(GPIO_FN_LCDD19, NULL);
671 gpio_request(GPIO_FN_LCDD18, NULL);
672 gpio_request(GPIO_FN_LCDD17, NULL);
673 gpio_request(GPIO_FN_LCDD16, NULL);
674 gpio_request(GPIO_FN_LCDD15, NULL);
675 gpio_request(GPIO_FN_LCDD14, NULL);
676 gpio_request(GPIO_FN_LCDD13, NULL);
677 gpio_request(GPIO_FN_LCDD12, NULL);
678 gpio_request(GPIO_FN_LCDD11, NULL);
679 gpio_request(GPIO_FN_LCDD10, NULL);
680 gpio_request(GPIO_FN_LCDD9, NULL);
681 gpio_request(GPIO_FN_LCDD8, NULL);
682 gpio_request(GPIO_FN_LCDD7, NULL);
683 gpio_request(GPIO_FN_LCDD6, NULL);
684 gpio_request(GPIO_FN_LCDD5, NULL);
685 gpio_request(GPIO_FN_LCDD4, NULL);
686 gpio_request(GPIO_FN_LCDD3, NULL);
687 gpio_request(GPIO_FN_LCDD2, NULL);
688 gpio_request(GPIO_FN_LCDD1, NULL);
689 gpio_request(GPIO_FN_LCDD0, NULL);
690 gpio_request(GPIO_FN_LCDDISP, NULL);
691 gpio_request(GPIO_FN_LCDDCK, NULL);
692
Kuninori Morimoto601df612012-04-22 23:53:24 -0700693 gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
694 gpio_request(GPIO_PORT226, NULL); /* SC */
Kuninori Morimoto26786112012-04-10 20:58:33 -0700695 gpio_direction_output(GPIO_PORT222, 1);
Kuninori Morimoto601df612012-04-22 23:53:24 -0700696 gpio_direction_output(GPIO_PORT226, 1);
Kuninori Morimoto26786112012-04-10 20:58:33 -0700697
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700698 /* Touchscreen */
699 gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
700 gpio_direction_input(GPIO_PORT223);
701
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700702 /* enable MMCIF */
703 gpio_request(GPIO_FN_MMCCLK0, NULL);
704 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
705 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
706 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
707 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
708 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
709 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
710 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
711 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
712 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
713
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700714 /* enable SD */
715 gpio_request(GPIO_FN_SDHIWP0, NULL);
716 gpio_request(GPIO_FN_SDHICD0, NULL);
717 gpio_request(GPIO_FN_SDHICMD0, NULL);
718 gpio_request(GPIO_FN_SDHICLK0, NULL);
719 gpio_request(GPIO_FN_SDHID0_3, NULL);
720 gpio_request(GPIO_FN_SDHID0_2, NULL);
721 gpio_request(GPIO_FN_SDHID0_1, NULL);
722 gpio_request(GPIO_FN_SDHID0_0, NULL);
723 gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
724 gpio_request(GPIO_PORT15, NULL);
725 gpio_direction_output(GPIO_PORT15, 1); /* power */
726
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700727 /* enable Micro SD */
728 gpio_request(GPIO_FN_SDHID2_0, NULL);
729 gpio_request(GPIO_FN_SDHID2_1, NULL);
730 gpio_request(GPIO_FN_SDHID2_2, NULL);
731 gpio_request(GPIO_FN_SDHID2_3, NULL);
732 gpio_request(GPIO_FN_SDHICMD2, NULL);
733 gpio_request(GPIO_FN_SDHICLK2, NULL);
734 gpio_request(GPIO_PORT14, NULL);
735 gpio_direction_output(GPIO_PORT14, 1); /* power */
736
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700737 /* I2C 3 */
738 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
739 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
740
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700741 /* enable FSI2 port A (ak4648) */
742 gpio_request(GPIO_FN_FSIACK, NULL);
743 gpio_request(GPIO_FN_FSIAILR, NULL);
744 gpio_request(GPIO_FN_FSIAIBT, NULL);
745 gpio_request(GPIO_FN_FSIAISLD, NULL);
746 gpio_request(GPIO_FN_FSIAOSLD, NULL);
747
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700748 /* enable USB */
749 gpio_request(GPIO_FN_VBUS_0, NULL);
750
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700751#ifdef CONFIG_CACHE_L2X0
752 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
753 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
754#endif
755
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700756 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700757 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700758 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700759
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700760 sh73a0_add_standard_devices();
761 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
762}
763
Magnus Damm7296d932012-05-14 23:22:28 +0200764static const char *kzm9g_boards_compat_dt[] __initdata = {
765 "renesas,kzm9g",
766 NULL,
767};
768
769DT_MACHINE_START(KZM9G_DT, "kzm9g")
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700770 .map_io = sh73a0_map_io,
771 .init_early = sh73a0_add_early_devices,
772 .nr_irqs = NR_IRQS_LEGACY,
773 .init_irq = sh73a0_init_irq,
774 .handle_irq = gic_handle_irq,
775 .init_machine = kzm_init,
776 .timer = &shmobile_timer,
Magnus Damm7296d932012-05-14 23:22:28 +0200777 .dt_compat = kzm9g_boards_compat_dt,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700778MACHINE_END