blob: c1c0401ff6a46fd4ec25dfbcf29fa0e68a148d6f [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>
Rob Herring520f7bd2012-12-27 13:10:24 -060028#include <linux/irqchip/arm-gic.h>
Kuninori Morimotocc2512b2012-04-22 23:53:40 -070029#include <linux/mmc/host.h>
30#include <linux/mmc/sh_mmcif.h>
Kuninori Morimoto7775a932012-04-22 23:53:59 -070031#include <linux/mmc/sh_mobile_sdhi.h>
32#include <linux/mfd/tmio.h>
Laurent Pinchartf3202e12013-01-03 12:54:28 +010033#include <linux/pinctrl/machine.h>
Laurent Pinchart83aeac92013-03-13 03:23:50 +010034#include <linux/pinctrl/pinconf-generic.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070035#include <linux/platform_device.h>
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +020036#include <linux/regulator/fixed.h>
37#include <linux/regulator/machine.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070038#include <linux/smsc911x.h>
Kuninori Morimotodd818182012-04-10 20:58:10 -070039#include <linux/usb/r8a66597.h>
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -070040#include <linux/usb/renesas_usbhs.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070041#include <linux/videodev2.h>
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -070042#include <sound/sh_fsi.h>
43#include <sound/simple_card.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070044#include <mach/irqs.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070045#include <mach/sh73a0.h>
46#include <mach/common.h>
47#include <asm/hardware/cache-l2x0.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070048#include <asm/mach-types.h>
49#include <asm/mach/arch.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070050#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070051
Kuninori Morimoto1e354642012-04-22 23:54:14 -070052/*
53 * external GPIO
54 */
55#define GPIO_PCF8575_BASE (GPIO_NR)
56#define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
57#define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
58#define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
59#define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
60#define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
61#define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
62#define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
63
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +020064/* Dummy supplies, where voltage doesn't matter */
65static struct regulator_consumer_supply dummy_supplies[] = {
66 REGULATOR_SUPPLY("vddvario", "smsc911x"),
67 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
68};
69
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -070070/*
71 * FSI-AK4648
72 *
73 * this command is required when playback.
74 *
75 * # amixer set "LINEOUT Mixer DACL" on
76 */
77
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070078/* SMSC 9221 */
79static struct resource smsc9221_resources[] = {
80 [0] = {
81 .start = 0x10000000, /* CS4 */
82 .end = 0x100000ff,
83 .flags = IORESOURCE_MEM,
84 },
85 [1] = {
86 .start = intcs_evt2irq(0x260), /* IRQ3 */
87 .flags = IORESOURCE_IRQ,
88 },
89};
90
91static struct smsc911x_platform_config smsc9221_platdata = {
92 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
93 .phy_interface = PHY_INTERFACE_MODE_MII,
94 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
95 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
96};
97
98static struct platform_device smsc_device = {
99 .name = "smsc911x",
100 .dev = {
101 .platform_data = &smsc9221_platdata,
102 },
103 .resource = smsc9221_resources,
104 .num_resources = ARRAY_SIZE(smsc9221_resources),
105};
106
Kuninori Morimotodd818182012-04-10 20:58:10 -0700107/* USB external chip */
108static struct r8a66597_platdata usb_host_data = {
109 .on_chip = 0,
110 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
111};
112
113static struct resource usb_resources[] = {
114 [0] = {
115 .start = 0x10010000,
116 .end = 0x1001ffff - 1,
117 .flags = IORESOURCE_MEM,
118 },
119 [1] = {
120 .start = intcs_evt2irq(0x220), /* IRQ1 */
121 .flags = IORESOURCE_IRQ,
122 },
123};
124
125static struct platform_device usb_host_device = {
126 .name = "r8a66597_hcd",
127 .dev = {
128 .platform_data = &usb_host_data,
129 .dma_mask = NULL,
130 .coherent_dma_mask = 0xffffffff,
131 },
132 .num_resources = ARRAY_SIZE(usb_resources),
133 .resource = usb_resources,
134};
135
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700136/* USB Func CN17 */
137struct usbhs_private {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000138 void __iomem *phy;
139 void __iomem *cr2;
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700140 struct renesas_usbhs_platform_info info;
141};
142
143#define IRQ15 intcs_evt2irq(0x03e0)
144#define USB_PHY_MODE (1 << 4)
145#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
146#define USB_PHY_ON (1 << 1)
147#define USB_PHY_OFF (1 << 0)
148#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
149
150#define usbhs_get_priv(pdev) \
151 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
152
153static int usbhs_get_vbus(struct platform_device *pdev)
154{
155 struct usbhs_private *priv = usbhs_get_priv(pdev);
156
157 return !((1 << 7) & __raw_readw(priv->cr2));
158}
159
160static void usbhs_phy_reset(struct platform_device *pdev)
161{
162 struct usbhs_private *priv = usbhs_get_priv(pdev);
163
164 /* init phy */
165 __raw_writew(0x8a0a, priv->cr2);
166}
167
168static int usbhs_get_id(struct platform_device *pdev)
169{
170 return USBHS_GADGET;
171}
172
173static 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
186static 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
207static void 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
217static u32 usbhs_pipe_cfg[] = {
218 USB_ENDPOINT_XFER_CONTROL,
219 USB_ENDPOINT_XFER_ISOC,
220 USB_ENDPOINT_XFER_ISOC,
221 USB_ENDPOINT_XFER_BULK,
222 USB_ENDPOINT_XFER_BULK,
223 USB_ENDPOINT_XFER_BULK,
224 USB_ENDPOINT_XFER_INT,
225 USB_ENDPOINT_XFER_INT,
226 USB_ENDPOINT_XFER_INT,
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 USB_ENDPOINT_XFER_BULK,
233 USB_ENDPOINT_XFER_BULK,
234};
235
236static struct usbhs_private usbhs_private = {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000237 .phy = IOMEM(0xe60781e0), /* USBPHYINT */
238 .cr2 = IOMEM(0xe605810c), /* USBCR2 */
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700239 .info = {
240 .platform_callback = {
241 .hardware_init = usbhs_hardware_init,
242 .hardware_exit = usbhs_hardware_exit,
243 .get_id = usbhs_get_id,
244 .phy_reset = usbhs_phy_reset,
245 .get_vbus = usbhs_get_vbus,
246 },
247 .driver_param = {
248 .buswait_bwait = 4,
249 .has_otg = 1,
250 .pipe_type = usbhs_pipe_cfg,
251 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
252 },
253 },
254};
255
256static struct resource usbhs_resources[] = {
257 [0] = {
258 .start = 0xE6890000,
259 .end = 0xE68900e6 - 1,
260 .flags = IORESOURCE_MEM,
261 },
262 [1] = {
263 .start = gic_spi(62),
264 .end = gic_spi(62),
265 .flags = IORESOURCE_IRQ,
266 },
267};
268
269static struct platform_device usbhs_device = {
270 .name = "renesas_usbhs",
271 .id = -1,
272 .dev = {
273 .dma_mask = NULL,
274 .coherent_dma_mask = 0xffffffff,
275 .platform_data = &usbhs_private.info,
276 },
277 .num_resources = ARRAY_SIZE(usbhs_resources),
278 .resource = usbhs_resources,
279};
280
Kuninori Morimoto26786112012-04-10 20:58:33 -0700281/* LCDC */
282static struct fb_videomode kzm_lcdc_mode = {
283 .name = "WVGA Panel",
284 .xres = 800,
285 .yres = 480,
286 .left_margin = 220,
287 .right_margin = 110,
288 .hsync_len = 70,
289 .upper_margin = 20,
290 .lower_margin = 5,
291 .vsync_len = 5,
292 .sync = 0,
293};
294
295static struct sh_mobile_lcdc_info lcdc_info = {
296 .clock_source = LCDC_CLK_BUS,
297 .ch[0] = {
298 .chan = LCDC_CHAN_MAINLCD,
299 .fourcc = V4L2_PIX_FMT_RGB565,
300 .interface_type = RGB24,
301 .lcd_modes = &kzm_lcdc_mode,
302 .num_modes = 1,
303 .clock_divider = 5,
304 .flags = 0,
305 .panel_cfg = {
306 .width = 152,
307 .height = 91,
308 },
309 }
310};
311
312static struct resource lcdc_resources[] = {
313 [0] = {
314 .name = "LCDC",
315 .start = 0xfe940000,
316 .end = 0xfe943fff,
317 .flags = IORESOURCE_MEM,
318 },
319 [1] = {
320 .start = intcs_evt2irq(0x580),
321 .flags = IORESOURCE_IRQ,
322 },
323};
324
325static struct platform_device lcdc_device = {
326 .name = "sh_mobile_lcdc_fb",
327 .num_resources = ARRAY_SIZE(lcdc_resources),
328 .resource = lcdc_resources,
329 .dev = {
330 .platform_data = &lcdc_info,
331 .coherent_dma_mask = ~0,
332 },
333};
334
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200335/* Fixed 1.8V regulator to be used by MMCIF */
336static struct regulator_consumer_supply fixed1v8_power_consumers[] =
337{
338 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
339 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
340};
341
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700342/* MMCIF */
343static struct resource sh_mmcif_resources[] = {
344 [0] = {
345 .name = "MMCIF",
346 .start = 0xe6bd0000,
347 .end = 0xe6bd00ff,
348 .flags = IORESOURCE_MEM,
349 },
350 [1] = {
Tetsuyuki Kobayashia7048352012-09-06 07:19:36 +0000351 .start = gic_spi(140),
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700352 .flags = IORESOURCE_IRQ,
353 },
354 [2] = {
Tetsuyuki Kobayashia7048352012-09-06 07:19:36 +0000355 .start = gic_spi(141),
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700356 .flags = IORESOURCE_IRQ,
357 },
358};
359
360static struct sh_mmcif_plat_data sh_mmcif_platdata = {
361 .ocr = MMC_VDD_165_195,
362 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Kuninori Morimotoa1ca8f42012-06-25 03:39:39 -0700363 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
364 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700365};
366
367static struct platform_device mmc_device = {
368 .name = "sh_mmcif",
369 .dev = {
370 .dma_mask = NULL,
371 .coherent_dma_mask = 0xffffffff,
372 .platform_data = &sh_mmcif_platdata,
373 },
374 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
375 .resource = sh_mmcif_resources,
376};
377
Guennadi Liakhovetski11b8e452012-07-01 01:12:04 +0200378/* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200379static struct regulator_consumer_supply fixed2v8_power_consumers[] =
380{
381 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
382 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
Guennadi Liakhovetski11b8e452012-07-01 01:12:04 +0200383 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
384 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200385};
386
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700387/* SDHI */
388static struct sh_mobile_sdhi_info sdhi0_info = {
Tetsuyuki Kobayashibd9e2e72012-09-06 09:09:31 +0000389 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
390 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700391 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
392 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
393 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
394};
395
396static struct resource sdhi0_resources[] = {
397 [0] = {
398 .name = "SDHI0",
399 .start = 0xee100000,
400 .end = 0xee1000ff,
401 .flags = IORESOURCE_MEM,
402 },
403 [1] = {
404 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
405 .start = gic_spi(83),
406 .flags = IORESOURCE_IRQ,
407 },
408 [2] = {
409 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
410 .start = gic_spi(84),
411 .flags = IORESOURCE_IRQ,
412 },
413 [3] = {
414 .name = SH_MOBILE_SDHI_IRQ_SDIO,
415 .start = gic_spi(85),
416 .flags = IORESOURCE_IRQ,
417 },
418};
419
420static struct platform_device sdhi0_device = {
421 .name = "sh_mobile_sdhi",
422 .num_resources = ARRAY_SIZE(sdhi0_resources),
423 .resource = sdhi0_resources,
424 .dev = {
425 .platform_data = &sdhi0_info,
426 },
427};
428
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700429/* Micro SD */
430static struct sh_mobile_sdhi_info sdhi2_info = {
Tetsuyuki Kobayashibd9e2e72012-09-06 09:09:31 +0000431 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
432 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700433 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
434 TMIO_MMC_USE_GPIO_CD |
435 TMIO_MMC_WRPROTECT_DISABLE,
436 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
437 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100438 .cd_gpio = 13,
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700439};
440
441static struct resource sdhi2_resources[] = {
442 [0] = {
443 .name = "SDHI2",
444 .start = 0xee140000,
445 .end = 0xee1400ff,
446 .flags = IORESOURCE_MEM,
447 },
448 [1] = {
449 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
450 .start = gic_spi(103),
451 .flags = IORESOURCE_IRQ,
452 },
453 [2] = {
454 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
455 .start = gic_spi(104),
456 .flags = IORESOURCE_IRQ,
457 },
458 [3] = {
459 .name = SH_MOBILE_SDHI_IRQ_SDIO,
460 .start = gic_spi(105),
461 .flags = IORESOURCE_IRQ,
462 },
463};
464
465static struct platform_device sdhi2_device = {
466 .name = "sh_mobile_sdhi",
467 .id = 2,
468 .num_resources = ARRAY_SIZE(sdhi2_resources),
469 .resource = sdhi2_resources,
470 .dev = {
471 .platform_data = &sdhi2_info,
472 },
473};
474
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700475/* KEY */
476#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
477
478static struct gpio_keys_button gpio_buttons[] = {
479 GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
480 GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
481 GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
482 GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
483 GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
484 GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
485 GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
486};
487
488static struct gpio_keys_platform_data gpio_key_info = {
489 .buttons = gpio_buttons,
490 .nbuttons = ARRAY_SIZE(gpio_buttons),
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700491};
492
493static struct platform_device gpio_keys_device = {
Kuninori Morimotoee6691d2012-09-11 14:26:05 +0900494 .name = "gpio-keys",
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700495 .dev = {
496 .platform_data = &gpio_key_info,
497 },
498};
499
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700500/* FSI-AK4648 */
501static struct sh_fsi_platform_info fsi_info = {
502 .port_a = {
Kuninori Morimoto76b80322012-06-25 03:39:30 -0700503 .tx_id = SHDMA_SLAVE_FSI2A_TX,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700504 },
505};
506
507static struct resource fsi_resources[] = {
508 [0] = {
509 .name = "FSI",
510 .start = 0xEC230000,
511 .end = 0xEC230400 - 1,
512 .flags = IORESOURCE_MEM,
513 },
514 [1] = {
515 .start = gic_spi(146),
516 .flags = IORESOURCE_IRQ,
517 },
518};
519
520static struct platform_device fsi_device = {
521 .name = "sh_fsi2",
522 .id = -1,
523 .num_resources = ARRAY_SIZE(fsi_resources),
524 .resource = fsi_resources,
525 .dev = {
526 .platform_data = &fsi_info,
527 },
528};
529
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700530static struct asoc_simple_card_info fsi2_ak4648_info = {
531 .name = "AK4648",
532 .card = "FSI2A-AK4648",
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700533 .codec = "ak4642-codec.0-0012",
534 .platform = "sh_fsi2",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800535 .daifmt = SND_SOC_DAIFMT_LEFT_J,
536 .cpu_dai = {
537 .name = "fsia-dai",
538 .fmt = SND_SOC_DAIFMT_CBS_CFS,
539 },
540 .codec_dai = {
541 .name = "ak4642-hifi",
542 .fmt = SND_SOC_DAIFMT_CBM_CFM,
543 .sysclk = 11289600,
544 },
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700545};
546
547static struct platform_device fsi_ak4648_device = {
548 .name = "asoc-simple-card",
549 .dev = {
550 .platform_data = &fsi2_ak4648_info,
551 },
552};
553
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700554/* I2C */
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700555static struct pcf857x_platform_data pcf8575_pdata = {
556 .gpio_base = GPIO_PCF8575_BASE,
557};
558
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700559static struct i2c_board_info i2c0_devices[] = {
560 {
561 I2C_BOARD_INFO("ak4648", 0x12),
Tetsuyuki Kobayashi080e0d12012-06-20 12:57:51 +0200562 },
563 {
564 I2C_BOARD_INFO("r2025sd", 0x32),
Tetsuyuki Kobayashi8cec0122012-09-14 18:14:28 +0900565 },
566 {
567 I2C_BOARD_INFO("ak8975", 0x0c),
568 .irq = intcs_evt2irq(0x3380), /* IRQ28 */
569 },
Tetsuyuki Kobayashi608c5622012-09-14 18:14:29 +0900570 {
571 I2C_BOARD_INFO("adxl34x", 0x1d),
572 .irq = intcs_evt2irq(0x3340), /* IRQ26 */
573 },
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700574};
575
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700576static struct i2c_board_info i2c1_devices[] = {
577 {
578 I2C_BOARD_INFO("st1232-ts", 0x55),
579 .irq = intcs_evt2irq(0x300), /* IRQ8 */
580 },
581};
582
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700583static struct i2c_board_info i2c3_devices[] = {
584 {
585 I2C_BOARD_INFO("pcf8575", 0x20),
Kuninori Morimoto805f8642012-12-06 01:10:28 -0800586 .irq = intcs_evt2irq(0x3260), /* IRQ19 */
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700587 .platform_data = &pcf8575_pdata,
588 },
589};
590
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700591static struct platform_device *kzm_devices[] __initdata = {
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700592 &smsc_device,
Kuninori Morimotodd818182012-04-10 20:58:10 -0700593 &usb_host_device,
Kuninori Morimoto77bcefd2012-06-25 03:35:01 -0700594 &usbhs_device,
Kuninori Morimoto26786112012-04-10 20:58:33 -0700595 &lcdc_device,
Kuninori Morimotocc2512b2012-04-22 23:53:40 -0700596 &mmc_device,
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700597 &sdhi0_device,
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700598 &sdhi2_device,
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700599 &gpio_keys_device,
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700600 &fsi_device,
601 &fsi_ak4648_device,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700602};
603
Laurent Pinchart83aeac92013-03-13 03:23:50 +0100604static unsigned long pin_pullup_conf[] = {
605 PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_UP, 0),
606};
607
Laurent Pinchartf3202e12013-01-03 12:54:28 +0100608static const struct pinctrl_map kzm_pinctrl_map[] = {
Laurent Pinchartee9f8da2013-01-03 12:54:28 +0100609 /* FSIA (AK4648) */
610 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
611 "fsia_mclk_in", "fsia"),
612 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
613 "fsia_sclk_in", "fsia"),
614 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
615 "fsia_data_in", "fsia"),
616 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
617 "fsia_data_out", "fsia"),
Laurent Pinchart118b6732013-01-03 12:54:28 +0100618 /* I2C3 */
619 PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
620 "i2c3_1", "i2c3"),
Laurent Pinchartf3202e12013-01-03 12:54:28 +0100621 /* LCD */
622 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
623 "lcd_data24", "lcd"),
624 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
625 "lcd_sync", "lcd"),
Laurent Pinchart83aeac92013-03-13 03:23:50 +0100626 /* MMCIF */
627 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
628 "mmc0_data8_0", "mmc0"),
629 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
630 "mmc0_ctrl_0", "mmc0"),
631 PIN_MAP_CONFIGS_PIN_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
632 "PORT279", pin_pullup_conf),
633 PIN_MAP_CONFIGS_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
634 "mmc0_data8_0", pin_pullup_conf),
Laurent Pinchart5606ed92013-01-03 12:54:28 +0100635 /* SCIFA4 */
636 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
637 "scifa4_data", "scifa4"),
638 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
639 "scifa4_ctrl", "scifa4"),
Laurent Pinchart83aeac92013-03-13 03:23:50 +0100640 /* SDHI0 */
641 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
642 "sdhi0_data4", "sdhi0"),
643 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
644 "sdhi0_ctrl", "sdhi0"),
645 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
646 "sdhi0_cd", "sdhi0"),
647 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
648 "sdhi0_wp", "sdhi0"),
649 /* SDHI2 */
650 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
651 "sdhi2_data4", "sdhi2"),
652 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
653 "sdhi2_ctrl", "sdhi2"),
Laurent Pinchartfed94cf2013-03-13 03:21:36 +0100654 /* SMSC */
655 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x.0", "pfc-sh73a0",
656 "bsc_cs4", "bsc"),
Laurent Pinchartf4243862013-03-13 03:23:50 +0100657 /* USB */
658 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-sh73a0",
659 "usb_vbus", "usb"),
Laurent Pinchartf3202e12013-01-03 12:54:28 +0100660};
661
Kuninori Morimoto26786112012-04-10 20:58:33 -0700662/*
663 * FIXME
664 *
665 * This is quick hack for enabling LCDC backlight
666 */
667static int __init as3711_enable_lcdc_backlight(void)
668{
669 struct i2c_adapter *a = i2c_get_adapter(0);
670 struct i2c_msg msg;
671 int i, ret;
672 __u8 magic[] = {
673 0x40, 0x2a,
674 0x43, 0x3c,
675 0x44, 0x3c,
676 0x45, 0x3c,
677 0x54, 0x03,
678 0x51, 0x00,
679 0x51, 0x01,
680 0xff, 0x00, /* wait */
681 0x43, 0xf0,
682 0x44, 0xf0,
683 0x45, 0xf0,
684 };
685
Laurent Pinchartcf244502013-01-09 01:52:42 +0100686 if (!of_machine_is_compatible("renesas,kzm9g"))
Kuninori Morimoto26786112012-04-10 20:58:33 -0700687 return 0;
688
689 if (!a)
690 return 0;
691
692 msg.addr = 0x40;
693 msg.len = 2;
694 msg.flags = 0;
695
696 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
697 msg.buf = magic + i;
698
699 if (0xff == msg.buf[0]) {
700 udelay(500);
701 continue;
702 }
703
704 ret = i2c_transfer(a, &msg, 1);
705 if (ret < 0) {
706 pr_err("i2c transfer fail\n");
707 break;
708 }
709 }
710
711 return 0;
712}
713device_initcall(as3711_enable_lcdc_backlight);
714
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700715static void __init kzm_init(void)
716{
Guennadi Liakhovetski44a42442012-06-27 00:32:31 +0200717 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
718 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
719 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
720 ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
721 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
722
Laurent Pinchartf3202e12013-01-03 12:54:28 +0100723 pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
724
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700725 sh73a0_pinmux_init();
726
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700727 /* SMSC */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100728 gpio_request_one(224, GPIOF_IN, NULL); /* IRQ3 */
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700729
Kuninori Morimoto26786112012-04-10 20:58:33 -0700730 /* LCDC */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100731 gpio_request_one(222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */
732 gpio_request_one(226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */
Kuninori Morimoto26786112012-04-10 20:58:33 -0700733
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700734 /* Touchscreen */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100735 gpio_request_one(223, GPIOF_IN, NULL); /* IRQ8 */
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700736
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700737 /* enable SD */
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700738 gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100739 gpio_request_one(15, GPIOF_OUT_INIT_HIGH, NULL); /* power */
Kuninori Morimoto7775a932012-04-22 23:53:59 -0700740
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700741 /* enable Micro SD */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100742 gpio_request_one(14, GPIOF_OUT_INIT_HIGH, NULL); /* power */
Kuninori Morimoto425d6942012-06-25 03:35:11 -0700743
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700744#ifdef CONFIG_CACHE_L2X0
745 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
746 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
747#endif
748
Kuninori Morimotoaccb90c2012-06-12 02:44:03 -0700749 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700750 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto1e354642012-04-22 23:54:14 -0700751 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
Kuninori Morimoto407c0522012-04-10 20:58:45 -0700752
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700753 sh73a0_add_standard_devices();
754 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
Bastian Hecht13baf882012-12-05 12:13:06 +0000755
756 sh73a0_pm_init();
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700757}
758
Tetsuyuki Kobayashi79527172012-07-20 15:16:30 +0900759static void kzm9g_restart(char mode, const char *cmd)
760{
Arnd Bergmann28901c12012-09-23 22:41:21 +0000761#define RESCNT2 IOMEM(0xe6188020)
Tetsuyuki Kobayashi79527172012-07-20 15:16:30 +0900762 /* Do soft power on reset */
763 writel((1 << 31), RESCNT2);
764}
765
Magnus Damm7296d932012-05-14 23:22:28 +0200766static const char *kzm9g_boards_compat_dt[] __initdata = {
767 "renesas,kzm9g",
768 NULL,
769};
770
771DT_MACHINE_START(KZM9G_DT, "kzm9g")
Marc Zyngiera62580e2011-09-08 13:15:22 +0100772 .smp = smp_ops(sh73a0_smp_ops),
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700773 .map_io = sh73a0_map_io,
774 .init_early = sh73a0_add_early_devices,
775 .nr_irqs = NR_IRQS_LEGACY,
776 .init_irq = sh73a0_init_irq,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700777 .init_machine = kzm_init,
Kuninori Morimoto14dd52f2012-06-20 22:40:08 -0700778 .init_late = shmobile_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700779 .init_time = sh73a0_earlytimer_init,
Tetsuyuki Kobayashi79527172012-07-20 15:16:30 +0900780 .restart = kzm9g_restart,
Magnus Damm7296d932012-05-14 23:22:28 +0200781 .dt_compat = kzm9g_boards_compat_dt,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700782MACHINE_END