ARM: shmobile: kzm9g: Remove the VCCQ MC0 function GPIO
[deliverable/linux.git] / arch / arm / mach-shmobile / board-kzm9g.c
CommitLineData
9b93e244
KM
1/*
2 * KZM-A9-GT board support
3 *
4 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
26786111
KM
19
20#include <linux/delay.h>
9b93e244 21#include <linux/gpio.h>
1e354641 22#include <linux/gpio_keys.h>
9b93e244
KM
23#include <linux/io.h>
24#include <linux/irq.h>
407c0526 25#include <linux/i2c.h>
1e354641
KM
26#include <linux/i2c/pcf857x.h>
27#include <linux/input.h>
520f7bd7 28#include <linux/irqchip/arm-gic.h>
cc2512bc
KM
29#include <linux/mmc/host.h>
30#include <linux/mmc/sh_mmcif.h>
7775a933
KM
31#include <linux/mmc/sh_mobile_sdhi.h>
32#include <linux/mfd/tmio.h>
f3202e1b 33#include <linux/pinctrl/machine.h>
83aeac98 34#include <linux/pinctrl/pinconf-generic.h>
9b93e244 35#include <linux/platform_device.h>
44a4244e
GL
36#include <linux/regulator/fixed.h>
37#include <linux/regulator/machine.h>
c15c4257 38#include <linux/smsc911x.h>
dd818180 39#include <linux/usb/r8a66597.h>
77bcefd9 40#include <linux/usb/renesas_usbhs.h>
26786111 41#include <linux/videodev2.h>
accb90c8
KM
42#include <sound/sh_fsi.h>
43#include <sound/simple_card.h>
c15c4257 44#include <mach/irqs.h>
9b93e244
KM
45#include <mach/sh73a0.h>
46#include <mach/common.h>
47#include <asm/hardware/cache-l2x0.h>
9b93e244
KM
48#include <asm/mach-types.h>
49#include <asm/mach/arch.h>
26786111 50#include <video/sh_mobile_lcdc.h>
9b93e244 51
1e354641
KM
52/*
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
44a4244e
GL
64/* Dummy supplies, where voltage doesn't matter */
65static struct regulator_consumer_supply dummy_supplies[] = {
48296a13
SH
66 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
67 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
44a4244e
GL
68};
69
accb90c8
KM
70/*
71 * FSI-AK4648
72 *
73 * this command is required when playback.
74 *
75 * # amixer set "LINEOUT Mixer DACL" on
76 */
77
c15c4257
KM
78/* SMSC 9221 */
79static struct resource smsc9221_resources[] = {
80 [0] = {
81 .start = 0x10000000, /* CS4 */
82 .end = 0x100000ff,
83 .flags = IORESOURCE_MEM,
84 },
85 [1] = {
341eb546 86 .start = irq_pin(3), /* IRQ3 */
c15c4257
KM
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
dd818180
KM
107/* 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] = {
341eb546 120 .start = irq_pin(1), /* IRQ1 */
dd818180
KM
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
77bcefd9
KM
136/* USB Func CN17 */
137struct usbhs_private {
0a4b04dc
AB
138 void __iomem *phy;
139 void __iomem *cr2;
77bcefd9
KM
140 struct renesas_usbhs_platform_info info;
141};
142
341eb546 143#define IRQ15 irq_pin(15)
77bcefd9
KM
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
225da3e3 160static int usbhs_phy_reset(struct platform_device *pdev)
77bcefd9
KM
161{
162 struct usbhs_private *priv = usbhs_get_priv(pdev);
163
164 /* init phy */
165 __raw_writew(0x8a0a, priv->cr2);
225da3e3
KM
166
167 return 0;
77bcefd9
KM
168}
169
170static int usbhs_get_id(struct platform_device *pdev)
171{
172 return USBHS_GADGET;
173}
174
175static irqreturn_t usbhs_interrupt(int irq, void *data)
176{
177 struct platform_device *pdev = data;
178 struct usbhs_private *priv = usbhs_get_priv(pdev);
179
180 renesas_usbhs_call_notify_hotplug(pdev);
181
182 /* clear status */
183 __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
184
185 return IRQ_HANDLED;
186}
187
188static int usbhs_hardware_init(struct platform_device *pdev)
189{
190 struct usbhs_private *priv = usbhs_get_priv(pdev);
191 int ret;
192
193 /* clear interrupt status */
194 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
195
196 ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
197 dev_name(&pdev->dev), pdev);
198 if (ret) {
199 dev_err(&pdev->dev, "request_irq err\n");
200 return ret;
201 }
202
203 /* enable USB phy interrupt */
204 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
205
206 return 0;
207}
208
225da3e3 209static int usbhs_hardware_exit(struct platform_device *pdev)
77bcefd9
KM
210{
211 struct usbhs_private *priv = usbhs_get_priv(pdev);
212
213 /* clear interrupt status */
214 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
215
216 free_irq(IRQ15, pdev);
225da3e3
KM
217
218 return 0;
77bcefd9
KM
219}
220
221static u32 usbhs_pipe_cfg[] = {
222 USB_ENDPOINT_XFER_CONTROL,
223 USB_ENDPOINT_XFER_ISOC,
224 USB_ENDPOINT_XFER_ISOC,
225 USB_ENDPOINT_XFER_BULK,
226 USB_ENDPOINT_XFER_BULK,
227 USB_ENDPOINT_XFER_BULK,
228 USB_ENDPOINT_XFER_INT,
229 USB_ENDPOINT_XFER_INT,
230 USB_ENDPOINT_XFER_INT,
231 USB_ENDPOINT_XFER_BULK,
232 USB_ENDPOINT_XFER_BULK,
233 USB_ENDPOINT_XFER_BULK,
234 USB_ENDPOINT_XFER_BULK,
235 USB_ENDPOINT_XFER_BULK,
236 USB_ENDPOINT_XFER_BULK,
237 USB_ENDPOINT_XFER_BULK,
238};
239
240static struct usbhs_private usbhs_private = {
0a4b04dc
AB
241 .phy = IOMEM(0xe60781e0), /* USBPHYINT */
242 .cr2 = IOMEM(0xe605810c), /* USBCR2 */
77bcefd9
KM
243 .info = {
244 .platform_callback = {
245 .hardware_init = usbhs_hardware_init,
246 .hardware_exit = usbhs_hardware_exit,
247 .get_id = usbhs_get_id,
248 .phy_reset = usbhs_phy_reset,
249 .get_vbus = usbhs_get_vbus,
250 },
251 .driver_param = {
252 .buswait_bwait = 4,
253 .has_otg = 1,
254 .pipe_type = usbhs_pipe_cfg,
255 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
256 },
257 },
258};
259
260static struct resource usbhs_resources[] = {
261 [0] = {
262 .start = 0xE6890000,
263 .end = 0xE68900e6 - 1,
264 .flags = IORESOURCE_MEM,
265 },
266 [1] = {
267 .start = gic_spi(62),
268 .end = gic_spi(62),
269 .flags = IORESOURCE_IRQ,
270 },
271};
272
273static struct platform_device usbhs_device = {
274 .name = "renesas_usbhs",
275 .id = -1,
276 .dev = {
277 .dma_mask = NULL,
278 .coherent_dma_mask = 0xffffffff,
279 .platform_data = &usbhs_private.info,
280 },
281 .num_resources = ARRAY_SIZE(usbhs_resources),
282 .resource = usbhs_resources,
283};
284
26786111
KM
285/* LCDC */
286static struct fb_videomode kzm_lcdc_mode = {
287 .name = "WVGA Panel",
288 .xres = 800,
289 .yres = 480,
290 .left_margin = 220,
291 .right_margin = 110,
292 .hsync_len = 70,
293 .upper_margin = 20,
294 .lower_margin = 5,
295 .vsync_len = 5,
296 .sync = 0,
297};
298
299static struct sh_mobile_lcdc_info lcdc_info = {
300 .clock_source = LCDC_CLK_BUS,
301 .ch[0] = {
302 .chan = LCDC_CHAN_MAINLCD,
303 .fourcc = V4L2_PIX_FMT_RGB565,
304 .interface_type = RGB24,
305 .lcd_modes = &kzm_lcdc_mode,
306 .num_modes = 1,
307 .clock_divider = 5,
308 .flags = 0,
309 .panel_cfg = {
310 .width = 152,
311 .height = 91,
312 },
313 }
314};
315
316static struct resource lcdc_resources[] = {
317 [0] = {
318 .name = "LCDC",
319 .start = 0xfe940000,
320 .end = 0xfe943fff,
321 .flags = IORESOURCE_MEM,
322 },
323 [1] = {
324 .start = intcs_evt2irq(0x580),
325 .flags = IORESOURCE_IRQ,
326 },
327};
328
329static struct platform_device lcdc_device = {
330 .name = "sh_mobile_lcdc_fb",
331 .num_resources = ARRAY_SIZE(lcdc_resources),
332 .resource = lcdc_resources,
333 .dev = {
334 .platform_data = &lcdc_info,
335 .coherent_dma_mask = ~0,
336 },
337};
338
44a4244e
GL
339/* Fixed 1.8V regulator to be used by MMCIF */
340static struct regulator_consumer_supply fixed1v8_power_consumers[] =
341{
342 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
343 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
344};
345
cc2512bc
KM
346/* MMCIF */
347static struct resource sh_mmcif_resources[] = {
348 [0] = {
349 .name = "MMCIF",
350 .start = 0xe6bd0000,
351 .end = 0xe6bd00ff,
352 .flags = IORESOURCE_MEM,
353 },
354 [1] = {
a704835d 355 .start = gic_spi(140),
cc2512bc
KM
356 .flags = IORESOURCE_IRQ,
357 },
358 [2] = {
a704835d 359 .start = gic_spi(141),
cc2512bc
KM
360 .flags = IORESOURCE_IRQ,
361 },
362};
363
364static struct sh_mmcif_plat_data sh_mmcif_platdata = {
365 .ocr = MMC_VDD_165_195,
366 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
a1ca8f49
KM
367 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
368 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
cc2512bc
KM
369};
370
371static struct platform_device mmc_device = {
372 .name = "sh_mmcif",
373 .dev = {
374 .dma_mask = NULL,
375 .coherent_dma_mask = 0xffffffff,
376 .platform_data = &sh_mmcif_platdata,
377 },
378 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
379 .resource = sh_mmcif_resources,
380};
381
54ca74ef
GL
382/* Fixed 3.3V regulators to be used by SDHI0 */
383static struct regulator_consumer_supply vcc_sdhi0_consumers[] =
44a4244e
GL
384{
385 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
54ca74ef
GL
386};
387
388static struct regulator_init_data vcc_sdhi0_init_data = {
389 .constraints = {
390 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
391 },
392 .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi0_consumers),
393 .consumer_supplies = vcc_sdhi0_consumers,
394};
395
396static struct fixed_voltage_config vcc_sdhi0_info = {
397 .supply_name = "SDHI0 Vcc",
398 .microvolts = 3300000,
399 .gpio = 15,
400 .enable_high = 1,
401 .init_data = &vcc_sdhi0_init_data,
402};
403
404static struct platform_device vcc_sdhi0 = {
405 .name = "reg-fixed-voltage",
406 .id = 0,
407 .dev = {
408 .platform_data = &vcc_sdhi0_info,
409 },
410};
411
412/* Fixed 3.3V regulators to be used by SDHI2 */
413static struct regulator_consumer_supply vcc_sdhi2_consumers[] =
414{
11b8e452 415 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
54ca74ef
GL
416};
417
418static struct regulator_init_data vcc_sdhi2_init_data = {
419 .constraints = {
420 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
421 },
422 .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi2_consumers),
423 .consumer_supplies = vcc_sdhi2_consumers,
424};
425
426static struct fixed_voltage_config vcc_sdhi2_info = {
427 .supply_name = "SDHI2 Vcc",
428 .microvolts = 3300000,
429 .gpio = 14,
430 .enable_high = 1,
431 .init_data = &vcc_sdhi2_init_data,
432};
433
434static struct platform_device vcc_sdhi2 = {
435 .name = "reg-fixed-voltage",
436 .id = 1,
437 .dev = {
438 .platform_data = &vcc_sdhi2_info,
439 },
44a4244e
GL
440};
441
7775a933
KM
442/* SDHI */
443static struct sh_mobile_sdhi_info sdhi0_info = {
bd9e2e71
TK
444 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
445 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
7775a933 446 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
54ca74ef
GL
447 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
448 MMC_CAP_POWER_OFF_CARD,
7775a933
KM
449};
450
451static struct resource sdhi0_resources[] = {
452 [0] = {
453 .name = "SDHI0",
454 .start = 0xee100000,
455 .end = 0xee1000ff,
456 .flags = IORESOURCE_MEM,
457 },
458 [1] = {
459 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
460 .start = gic_spi(83),
461 .flags = IORESOURCE_IRQ,
462 },
463 [2] = {
464 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
465 .start = gic_spi(84),
466 .flags = IORESOURCE_IRQ,
467 },
468 [3] = {
469 .name = SH_MOBILE_SDHI_IRQ_SDIO,
470 .start = gic_spi(85),
471 .flags = IORESOURCE_IRQ,
472 },
473};
474
475static struct platform_device sdhi0_device = {
476 .name = "sh_mobile_sdhi",
477 .num_resources = ARRAY_SIZE(sdhi0_resources),
478 .resource = sdhi0_resources,
479 .dev = {
480 .platform_data = &sdhi0_info,
481 },
482};
483
425d6940
KM
484/* Micro SD */
485static struct sh_mobile_sdhi_info sdhi2_info = {
bd9e2e71
TK
486 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
487 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
425d6940
KM
488 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
489 TMIO_MMC_USE_GPIO_CD |
490 TMIO_MMC_WRPROTECT_DISABLE,
54ca74ef 491 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_POWER_OFF_CARD,
b58e5fac 492 .cd_gpio = 13,
425d6940
KM
493};
494
495static struct resource sdhi2_resources[] = {
496 [0] = {
497 .name = "SDHI2",
498 .start = 0xee140000,
499 .end = 0xee1400ff,
500 .flags = IORESOURCE_MEM,
501 },
502 [1] = {
503 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
504 .start = gic_spi(103),
505 .flags = IORESOURCE_IRQ,
506 },
507 [2] = {
508 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
509 .start = gic_spi(104),
510 .flags = IORESOURCE_IRQ,
511 },
512 [3] = {
513 .name = SH_MOBILE_SDHI_IRQ_SDIO,
514 .start = gic_spi(105),
515 .flags = IORESOURCE_IRQ,
516 },
517};
518
519static struct platform_device sdhi2_device = {
520 .name = "sh_mobile_sdhi",
521 .id = 2,
522 .num_resources = ARRAY_SIZE(sdhi2_resources),
523 .resource = sdhi2_resources,
524 .dev = {
525 .platform_data = &sdhi2_info,
526 },
527};
528
1e354641
KM
529/* KEY */
530#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
531
532static struct gpio_keys_button gpio_buttons[] = {
533 GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
534 GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
535 GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
536 GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
537 GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
538 GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
539 GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
540};
541
542static struct gpio_keys_platform_data gpio_key_info = {
543 .buttons = gpio_buttons,
544 .nbuttons = ARRAY_SIZE(gpio_buttons),
1e354641
KM
545};
546
547static struct platform_device gpio_keys_device = {
ee6691d7 548 .name = "gpio-keys",
1e354641
KM
549 .dev = {
550 .platform_data = &gpio_key_info,
551 },
552};
553
accb90c8
KM
554/* FSI-AK4648 */
555static struct sh_fsi_platform_info fsi_info = {
556 .port_a = {
76b80329 557 .tx_id = SHDMA_SLAVE_FSI2A_TX,
accb90c8
KM
558 },
559};
560
561static struct resource fsi_resources[] = {
562 [0] = {
563 .name = "FSI",
564 .start = 0xEC230000,
565 .end = 0xEC230400 - 1,
566 .flags = IORESOURCE_MEM,
567 },
568 [1] = {
569 .start = gic_spi(146),
570 .flags = IORESOURCE_IRQ,
571 },
572};
573
574static struct platform_device fsi_device = {
575 .name = "sh_fsi2",
576 .id = -1,
577 .num_resources = ARRAY_SIZE(fsi_resources),
578 .resource = fsi_resources,
579 .dev = {
580 .platform_data = &fsi_info,
581 },
582};
583
accb90c8
KM
584static struct asoc_simple_card_info fsi2_ak4648_info = {
585 .name = "AK4648",
586 .card = "FSI2A-AK4648",
accb90c8
KM
587 .codec = "ak4642-codec.0-0012",
588 .platform = "sh_fsi2",
a4a2992c
KM
589 .daifmt = SND_SOC_DAIFMT_LEFT_J,
590 .cpu_dai = {
591 .name = "fsia-dai",
592 .fmt = SND_SOC_DAIFMT_CBS_CFS,
593 },
594 .codec_dai = {
595 .name = "ak4642-hifi",
596 .fmt = SND_SOC_DAIFMT_CBM_CFM,
597 .sysclk = 11289600,
598 },
accb90c8
KM
599};
600
601static struct platform_device fsi_ak4648_device = {
602 .name = "asoc-simple-card",
603 .dev = {
604 .platform_data = &fsi2_ak4648_info,
605 },
606};
607
7775a933 608/* I2C */
1e354641
KM
609static struct pcf857x_platform_data pcf8575_pdata = {
610 .gpio_base = GPIO_PCF8575_BASE,
611};
612
accb90c8
KM
613static struct i2c_board_info i2c0_devices[] = {
614 {
615 I2C_BOARD_INFO("ak4648", 0x12),
080e0d13
TK
616 },
617 {
618 I2C_BOARD_INFO("r2025sd", 0x32),
8cec0123
TK
619 },
620 {
621 I2C_BOARD_INFO("ak8975", 0x0c),
341eb546 622 .irq = irq_pin(28), /* IRQ28 */
8cec0123 623 },
608c5620
TK
624 {
625 I2C_BOARD_INFO("adxl34x", 0x1d),
341eb546 626 .irq = irq_pin(26), /* IRQ26 */
608c5620 627 },
accb90c8
KM
628};
629
407c0526
KM
630static struct i2c_board_info i2c1_devices[] = {
631 {
632 I2C_BOARD_INFO("st1232-ts", 0x55),
341eb546 633 .irq = irq_pin(8), /* IRQ8 */
407c0526
KM
634 },
635};
636
1e354641
KM
637static struct i2c_board_info i2c3_devices[] = {
638 {
639 I2C_BOARD_INFO("pcf8575", 0x20),
341eb546 640 .irq = irq_pin(19), /* IRQ19 */
1e354641
KM
641 .platform_data = &pcf8575_pdata,
642 },
643};
644
9b93e244 645static struct platform_device *kzm_devices[] __initdata = {
c15c4257 646 &smsc_device,
dd818180 647 &usb_host_device,
77bcefd9 648 &usbhs_device,
26786111 649 &lcdc_device,
cc2512bc 650 &mmc_device,
54ca74ef
GL
651 &vcc_sdhi0,
652 &vcc_sdhi2,
7775a933 653 &sdhi0_device,
425d6940 654 &sdhi2_device,
1e354641 655 &gpio_keys_device,
accb90c8
KM
656 &fsi_device,
657 &fsi_ak4648_device,
9b93e244
KM
658};
659
83aeac98
LP
660static unsigned long pin_pullup_conf[] = {
661 PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_UP, 0),
662};
663
f3202e1b 664static const struct pinctrl_map kzm_pinctrl_map[] = {
ee9f8da7
LP
665 /* FSIA (AK4648) */
666 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
667 "fsia_mclk_in", "fsia"),
668 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
669 "fsia_sclk_in", "fsia"),
670 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
671 "fsia_data_in", "fsia"),
672 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
673 "fsia_data_out", "fsia"),
118b673e
LP
674 /* I2C3 */
675 PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
676 "i2c3_1", "i2c3"),
f3202e1b
LP
677 /* LCD */
678 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
679 "lcd_data24", "lcd"),
680 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
681 "lcd_sync", "lcd"),
83aeac98
LP
682 /* MMCIF */
683 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
684 "mmc0_data8_0", "mmc0"),
685 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
686 "mmc0_ctrl_0", "mmc0"),
687 PIN_MAP_CONFIGS_PIN_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
688 "PORT279", pin_pullup_conf),
689 PIN_MAP_CONFIGS_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
690 "mmc0_data8_0", pin_pullup_conf),
5606ed9c
LP
691 /* SCIFA4 */
692 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
693 "scifa4_data", "scifa4"),
694 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
695 "scifa4_ctrl", "scifa4"),
83aeac98
LP
696 /* SDHI0 */
697 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
698 "sdhi0_data4", "sdhi0"),
699 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
700 "sdhi0_ctrl", "sdhi0"),
701 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
702 "sdhi0_cd", "sdhi0"),
703 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
704 "sdhi0_wp", "sdhi0"),
705 /* SDHI2 */
706 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
707 "sdhi2_data4", "sdhi2"),
708 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
709 "sdhi2_ctrl", "sdhi2"),
fed94cf8
LP
710 /* SMSC */
711 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x.0", "pfc-sh73a0",
712 "bsc_cs4", "bsc"),
f4243860
LP
713 /* USB */
714 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-sh73a0",
715 "usb_vbus", "usb"),
f3202e1b
LP
716};
717
26786111
KM
718/*
719 * FIXME
720 *
721 * This is quick hack for enabling LCDC backlight
722 */
723static int __init as3711_enable_lcdc_backlight(void)
724{
725 struct i2c_adapter *a = i2c_get_adapter(0);
726 struct i2c_msg msg;
727 int i, ret;
728 __u8 magic[] = {
729 0x40, 0x2a,
730 0x43, 0x3c,
731 0x44, 0x3c,
732 0x45, 0x3c,
733 0x54, 0x03,
734 0x51, 0x00,
735 0x51, 0x01,
736 0xff, 0x00, /* wait */
737 0x43, 0xf0,
738 0x44, 0xf0,
739 0x45, 0xf0,
740 };
741
cf244505 742 if (!of_machine_is_compatible("renesas,kzm9g"))
26786111
KM
743 return 0;
744
745 if (!a)
746 return 0;
747
748 msg.addr = 0x40;
749 msg.len = 2;
750 msg.flags = 0;
751
752 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
753 msg.buf = magic + i;
754
755 if (0xff == msg.buf[0]) {
756 udelay(500);
757 continue;
758 }
759
760 ret = i2c_transfer(a, &msg, 1);
761 if (ret < 0) {
762 pr_err("i2c transfer fail\n");
763 break;
764 }
765 }
766
767 return 0;
768}
769device_initcall(as3711_enable_lcdc_backlight);
770
9b93e244
KM
771static void __init kzm_init(void)
772{
54ca74ef 773 regulator_register_always_on(2, "fixed-1.8V", fixed1v8_power_consumers,
44a4244e 774 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
54ca74ef 775 regulator_register_fixed(3, dummy_supplies, ARRAY_SIZE(dummy_supplies));
44a4244e 776
f3202e1b 777 pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
9b93e244 778
9b93e244 779 sh73a0_pinmux_init();
c15c4257
KM
780
781 /* SMSC */
b58e5fac 782 gpio_request_one(224, GPIOF_IN, NULL); /* IRQ3 */
c15c4257 783
26786111 784 /* LCDC */
b58e5fac
GL
785 gpio_request_one(222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */
786 gpio_request_one(226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */
26786111 787
407c0526 788 /* Touchscreen */
b58e5fac 789 gpio_request_one(223, GPIOF_IN, NULL); /* IRQ8 */
cc2512bc 790
9b93e244
KM
791#ifdef CONFIG_CACHE_L2X0
792 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
793 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
794#endif
795
accb90c8 796 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
407c0526 797 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
1e354641 798 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
407c0526 799
9b93e244
KM
800 sh73a0_add_standard_devices();
801 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
13baf88b
BH
802
803 sh73a0_pm_init();
9b93e244
KM
804}
805
7952717a
TK
806static void kzm9g_restart(char mode, const char *cmd)
807{
28901c1f 808#define RESCNT2 IOMEM(0xe6188020)
7952717a
TK
809 /* Do soft power on reset */
810 writel((1 << 31), RESCNT2);
811}
812
7296d932
MD
813static const char *kzm9g_boards_compat_dt[] __initdata = {
814 "renesas,kzm9g",
815 NULL,
816};
817
818DT_MACHINE_START(KZM9G_DT, "kzm9g")
a62580e5 819 .smp = smp_ops(sh73a0_smp_ops),
9b93e244
KM
820 .map_io = sh73a0_map_io,
821 .init_early = sh73a0_add_early_devices,
822 .nr_irqs = NR_IRQS_LEGACY,
823 .init_irq = sh73a0_init_irq,
9b93e244 824 .init_machine = kzm_init,
14dd52f4 825 .init_late = shmobile_init_late,
6bb27d73 826 .init_time = sh73a0_earlytimer_init,
7952717a 827 .restart = kzm9g_restart,
7296d932 828 .dt_compat = kzm9g_boards_compat_dt,
9b93e244 829MACHINE_END
This page took 0.135653 seconds and 5 git commands to generate.