blob: 065e9600fae68ea14c6a1e895cc9a9d447cb7e79 [file] [log] [blame]
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001/*
2 * Copyright (C) 2009 Renesas Solutions Corp.
3 *
4 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/platform_device.h>
Yusuke Goda1238c682010-04-27 10:15:32 +000014#include <linux/mmc/host.h>
15#include <linux/mmc/sh_mmcif.h>
Guennadi Liakhovetski960b9e72011-03-09 11:29:48 +010016#include <linux/mmc/sh_mobile_sdhi.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000017#include <linux/mtd/physmap.h>
18#include <linux/gpio.h>
19#include <linux/interrupt.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000020#include <linux/io.h>
21#include <linux/delay.h>
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +020022#include <linux/regulator/fixed.h>
23#include <linux/regulator/machine.h>
Kuninori Morimoto907050a2009-08-26 11:04:31 +000024#include <linux/usb/r8a66597.h>
Kuninori Morimotofb2e7392011-06-15 06:08:18 +000025#include <linux/usb/renesas_usbhs.h>
Kuninori Morimoto4907d572009-09-10 01:39:58 +000026#include <linux/i2c.h>
Kuninori Morimoto8810e052009-09-28 08:21:41 +000027#include <linux/i2c/tsc2007.h>
Magnus Damm1ce4da72009-12-07 14:05:45 +000028#include <linux/spi/spi.h>
29#include <linux/spi/sh_msiof.h>
30#include <linux/spi/mmc_spi.h>
Kuninori Morimotoe9103e72009-09-14 11:23:00 +000031#include <linux/input.h>
Magnus Dammfc1d0032009-11-27 07:32:24 +000032#include <linux/input/sh_keysc.h>
Yoshihiro Shimodacf8e56b2011-09-28 16:49:14 +090033#include <linux/sh_eth.h>
Paul Mundt9307d112012-05-18 15:49:38 +090034#include <linux/sh_intc.h>
Guennadi Liakhovetskia1ad8032012-01-25 22:07:05 +010035#include <linux/videodev2.h>
Kuninori Morimotofa3ba512009-08-26 11:04:34 +000036#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +000037#include <sound/sh_fsi.h>
Kuninori Morimoto064bfad2012-04-08 21:19:25 -070038#include <sound/simple_card.h>
Kuninori Morimoto2153ad32009-08-26 11:04:36 +000039#include <media/sh_mobile_ceu.h>
Guennadi Liakhovetskia1ad8032012-01-25 22:07:05 +010040#include <media/soc_camera.h>
Kuninori Morimoto207efd02009-12-15 05:37:16 +000041#include <media/tw9910.h>
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +000042#include <media/mt9t112.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000043#include <asm/heartbeat.h>
Kuninori Morimotoa9918012009-09-14 11:23:16 +000044#include <asm/clock.h>
Magnus Dammeb0cd9e2009-10-30 04:23:59 +000045#include <asm/suspend.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000046#include <cpu/sh7724.h>
47
48/*
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000049 * Address Interface BusWidth
50 *-----------------------------------------
51 * 0x0000_0000 uboot 16bit
52 * 0x0004_0000 Linux romImage 16bit
53 * 0x0014_0000 MTD for Linux 16bit
54 * 0x0400_0000 Internal I/O 16/32bit
55 * 0x0800_0000 DRAM 32bit
56 * 0x1800_0000 MFI 16bit
Kuninori Morimoto4138b742009-08-19 12:08:33 +000057 */
58
Kuninori Morimoto9c472c42009-10-02 07:52:20 +000059/* SWITCH
60 *------------------------------
61 * DS2[1] = FlashROM write protect ON : write protect
62 * OFF : No write protect
63 * DS2[2] = RMII / TS, SCIF ON : RMII
64 * OFF : TS, SCIF3
65 * DS2[3] = Camera / Video ON : Camera
66 * OFF : NTSC/PAL (IN)
67 * DS2[5] = NTSC_OUT Clock ON : On board OSC
68 * OFF : SH7724 DV_CLK
69 * DS2[6-7] = MMC / SD ON-OFF : SD
70 * OFF-ON : MMC
71 */
72
Kuninori Morimoto4138b742009-08-19 12:08:33 +000073/* Heartbeat */
74static unsigned char led_pos[] = { 0, 1, 2, 3 };
Paul Mundta09d2832010-01-15 12:24:34 +090075
Kuninori Morimoto4138b742009-08-19 12:08:33 +000076static struct heartbeat_data heartbeat_data = {
Kuninori Morimoto4138b742009-08-19 12:08:33 +000077 .nr_bits = 4,
78 .bit_pos = led_pos,
79};
80
Paul Mundta09d2832010-01-15 12:24:34 +090081static struct resource heartbeat_resource = {
82 .start = 0xA405012C, /* PTG */
83 .end = 0xA405012E - 1,
84 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
Kuninori Morimoto4138b742009-08-19 12:08:33 +000085};
86
87static struct platform_device heartbeat_device = {
88 .name = "heartbeat",
89 .id = -1,
90 .dev = {
91 .platform_data = &heartbeat_data,
92 },
Paul Mundta09d2832010-01-15 12:24:34 +090093 .num_resources = 1,
94 .resource = &heartbeat_resource,
Kuninori Morimoto4138b742009-08-19 12:08:33 +000095};
96
97/* MTD */
98static struct mtd_partition nor_flash_partitions[] = {
99 {
Kuninori Morimotob7056bc2009-08-26 11:04:22 +0000100 .name = "boot loader",
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000101 .offset = 0,
Kuninori Morimotob7056bc2009-08-26 11:04:22 +0000102 .size = (5 * 1024 * 1024),
Kuninori Morimotod5ce0102009-09-30 00:50:30 +0000103 .mask_flags = MTD_WRITEABLE, /* force read-only */
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000104 }, {
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000105 .name = "free-area",
106 .offset = MTDPART_OFS_APPEND,
107 .size = MTDPART_SIZ_FULL,
108 },
109};
110
111static struct physmap_flash_data nor_flash_data = {
112 .width = 2,
113 .parts = nor_flash_partitions,
114 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
115};
116
117static struct resource nor_flash_resources[] = {
118 [0] = {
119 .name = "NOR Flash",
120 .start = 0x00000000,
121 .end = 0x03ffffff,
122 .flags = IORESOURCE_MEM,
123 }
124};
125
126static struct platform_device nor_flash_device = {
127 .name = "physmap-flash",
128 .resource = nor_flash_resources,
129 .num_resources = ARRAY_SIZE(nor_flash_resources),
130 .dev = {
131 .platform_data = &nor_flash_data,
132 },
133};
134
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000135/* SH Eth */
136#define SH_ETH_ADDR (0xA4600000)
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000137static struct resource sh_eth_resources[] = {
138 [0] = {
139 .start = SH_ETH_ADDR,
140 .end = SH_ETH_ADDR + 0x1FC,
141 .flags = IORESOURCE_MEM,
142 },
143 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900144 .start = evt2irq(0xd60),
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000145 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
146 },
147};
148
Kuninori Morimoto3ce09332010-06-02 00:27:31 +0000149static struct sh_eth_plat_data sh_eth_plat = {
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000150 .phy = 0x1f, /* SMSC LAN8700 */
151 .edmac_endian = EDMAC_LITTLE_ENDIAN,
Yoshihiro Shimoda9055f892011-03-08 08:00:04 +0000152 .register_type = SH_ETH_REG_FAST_SH4,
153 .phy_interface = PHY_INTERFACE_MODE_MII,
Kuninori Morimotoacf3cc22009-09-24 06:28:27 +0000154 .ether_link_active_low = 1
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000155};
156
157static struct platform_device sh_eth_device = {
158 .name = "sh-eth",
159 .id = 0,
160 .dev = {
161 .platform_data = &sh_eth_plat,
162 },
163 .num_resources = ARRAY_SIZE(sh_eth_resources),
164 .resource = sh_eth_resources,
165};
166
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000167/* USB0 host */
Kuninori Morimoto3ce09332010-06-02 00:27:31 +0000168static void usb0_port_power(int port, int power)
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000169{
170 gpio_set_value(GPIO_PTB4, power);
171}
172
173static struct r8a66597_platdata usb0_host_data = {
174 .on_chip = 1,
175 .port_power = usb0_port_power,
176};
177
178static struct resource usb0_host_resources[] = {
179 [0] = {
180 .start = 0xa4d80000,
181 .end = 0xa4d80124 - 1,
182 .flags = IORESOURCE_MEM,
183 },
184 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900185 .start = evt2irq(0xa20),
186 .end = evt2irq(0xa20),
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000187 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
188 },
189};
190
191static struct platform_device usb0_host_device = {
192 .name = "r8a66597_hcd",
193 .id = 0,
194 .dev = {
195 .dma_mask = NULL, /* not use dma */
196 .coherent_dma_mask = 0xffffffff,
197 .platform_data = &usb0_host_data,
198 },
199 .num_resources = ARRAY_SIZE(usb0_host_resources),
200 .resource = usb0_host_resources,
201};
202
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000203/* USB1 host/function */
Kuninori Morimoto3ce09332010-06-02 00:27:31 +0000204static void usb1_port_power(int port, int power)
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000205{
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000206 gpio_set_value(GPIO_PTB5, power);
207}
208
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000209static struct r8a66597_platdata usb1_common_data = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000210 .on_chip = 1,
211 .port_power = usb1_port_power,
212};
213
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000214static struct resource usb1_common_resources[] = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000215 [0] = {
216 .start = 0xa4d90000,
217 .end = 0xa4d90124 - 1,
218 .flags = IORESOURCE_MEM,
219 },
220 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900221 .start = evt2irq(0xa40),
222 .end = evt2irq(0xa40),
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000223 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
224 },
225};
226
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000227static struct platform_device usb1_common_device = {
228 /* .name will be added in arch_setup */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000229 .id = 1,
230 .dev = {
231 .dma_mask = NULL, /* not use dma */
232 .coherent_dma_mask = 0xffffffff,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000233 .platform_data = &usb1_common_data,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000234 },
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000235 .num_resources = ARRAY_SIZE(usb1_common_resources),
236 .resource = usb1_common_resources,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000237};
238
Kuninori Morimotofb2e7392011-06-15 06:08:18 +0000239/*
240 * USBHS
241 */
242static int usbhs_get_id(struct platform_device *pdev)
243{
244 return gpio_get_value(GPIO_PTB3);
245}
246
Kuninori Morimoto1ca8fe32012-08-01 00:54:58 -0700247static void usbhs_phy_reset(struct platform_device *pdev)
248{
249 /* enable vbus if HOST */
250 if (!gpio_get_value(GPIO_PTB3))
251 gpio_set_value(GPIO_PTB5, 1);
252}
253
Kuninori Morimotofb2e7392011-06-15 06:08:18 +0000254static struct renesas_usbhs_platform_info usbhs_info = {
255 .platform_callback = {
256 .get_id = usbhs_get_id,
Kuninori Morimoto1ca8fe32012-08-01 00:54:58 -0700257 .phy_reset = usbhs_phy_reset,
Kuninori Morimotofb2e7392011-06-15 06:08:18 +0000258 },
259 .driver_param = {
260 .buswait_bwait = 4,
261 .detection_delay = 5,
Kuninori Morimoto9f0fa792011-06-15 06:08:32 +0000262 .d0_tx_id = SHDMA_SLAVE_USB1D0_TX,
263 .d0_rx_id = SHDMA_SLAVE_USB1D0_RX,
264 .d1_tx_id = SHDMA_SLAVE_USB1D1_TX,
265 .d1_rx_id = SHDMA_SLAVE_USB1D1_RX,
Kuninori Morimotofb2e7392011-06-15 06:08:18 +0000266 },
267};
268
269static struct resource usbhs_resources[] = {
270 [0] = {
271 .start = 0xa4d90000,
272 .end = 0xa4d90124 - 1,
273 .flags = IORESOURCE_MEM,
274 },
275 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900276 .start = evt2irq(0xa40),
277 .end = evt2irq(0xa40),
Kuninori Morimotofb2e7392011-06-15 06:08:18 +0000278 .flags = IORESOURCE_IRQ,
279 },
280};
281
282static struct platform_device usbhs_device = {
283 .name = "renesas_usbhs",
284 .id = 1,
285 .dev = {
286 .dma_mask = NULL, /* not use dma */
287 .coherent_dma_mask = 0xffffffff,
288 .platform_data = &usbhs_info,
289 },
290 .num_resources = ARRAY_SIZE(usbhs_resources),
291 .resource = usbhs_resources,
Kuninori Morimotofb2e7392011-06-15 06:08:18 +0000292};
293
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000294/* LCDC */
Jesper Juhle04008e2011-07-09 23:16:22 +0200295static const struct fb_videomode ecovec_lcd_modes[] = {
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000296 {
297 .name = "Panel",
298 .xres = 800,
299 .yres = 480,
300 .left_margin = 220,
301 .right_margin = 110,
302 .hsync_len = 70,
303 .upper_margin = 20,
304 .lower_margin = 5,
305 .vsync_len = 5,
306 .sync = 0, /* hsync and vsync are active low */
307 },
308};
309
Jesper Juhle04008e2011-07-09 23:16:22 +0200310static const struct fb_videomode ecovec_dvi_modes[] = {
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000311 {
312 .name = "DVI",
313 .xres = 1280,
314 .yres = 720,
315 .left_margin = 220,
316 .right_margin = 110,
317 .hsync_len = 40,
318 .upper_margin = 20,
319 .lower_margin = 5,
320 .vsync_len = 5,
321 .sync = 0, /* hsync and vsync are active low */
322 },
323};
324
Laurent Pinchart018882a2011-09-11 22:59:04 +0200325static int ecovec24_set_brightness(int brightness)
Alexandre Courbot0839d682011-02-16 03:49:02 +0000326{
327 gpio_set_value(GPIO_PTR1, brightness);
328
329 return 0;
330}
331
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000332static struct sh_mobile_lcdc_info lcdc_info = {
333 .ch[0] = {
334 .interface_type = RGB18,
335 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100336 .fourcc = V4L2_PIX_FMT_RGB565,
Laurent Pinchartafaad832011-09-11 22:59:04 +0200337 .panel_cfg = { /* 7.0 inch */
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000338 .width = 152,
339 .height = 91,
340 },
Alexandre Courbot0839d682011-02-16 03:49:02 +0000341 .bl_info = {
342 .name = "sh_mobile_lcdc_bl",
343 .max_brightness = 1,
Laurent Pinchart43059b02011-09-11 22:59:04 +0200344 .set_brightness = ecovec24_set_brightness,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000345 },
346 }
347};
348
349static struct resource lcdc_resources[] = {
350 [0] = {
351 .name = "LCDC",
352 .start = 0xfe940000,
Phil Edworthya6f15ad2009-09-15 12:00:30 +0000353 .end = 0xfe942fff,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000354 .flags = IORESOURCE_MEM,
355 },
356 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900357 .start = evt2irq(0xf40),
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000358 .flags = IORESOURCE_IRQ,
359 },
360};
361
362static struct platform_device lcdc_device = {
363 .name = "sh_mobile_lcdc_fb",
364 .num_resources = ARRAY_SIZE(lcdc_resources),
365 .resource = lcdc_resources,
366 .dev = {
367 .platform_data = &lcdc_info,
368 },
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000369};
370
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000371/* CEU0 */
372static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
373 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
374};
375
376static struct resource ceu0_resources[] = {
377 [0] = {
378 .name = "CEU0",
379 .start = 0xfe910000,
380 .end = 0xfe91009f,
381 .flags = IORESOURCE_MEM,
382 },
383 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900384 .start = evt2irq(0x880),
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000385 .flags = IORESOURCE_IRQ,
386 },
387 [2] = {
388 /* place holder for contiguous memory */
389 },
390};
391
392static struct platform_device ceu0_device = {
393 .name = "sh_mobile_ceu",
394 .id = 0, /* "ceu0" clock */
395 .num_resources = ARRAY_SIZE(ceu0_resources),
396 .resource = ceu0_resources,
397 .dev = {
398 .platform_data = &sh_mobile_ceu0_info,
399 },
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000400};
401
402/* CEU1 */
403static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
404 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
405};
406
407static struct resource ceu1_resources[] = {
408 [0] = {
409 .name = "CEU1",
410 .start = 0xfe914000,
411 .end = 0xfe91409f,
412 .flags = IORESOURCE_MEM,
413 },
414 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900415 .start = evt2irq(0x9e0),
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000416 .flags = IORESOURCE_IRQ,
417 },
418 [2] = {
419 /* place holder for contiguous memory */
420 },
421};
422
423static struct platform_device ceu1_device = {
424 .name = "sh_mobile_ceu",
425 .id = 1, /* "ceu1" clock */
426 .num_resources = ARRAY_SIZE(ceu1_resources),
427 .resource = ceu1_resources,
428 .dev = {
429 .platform_data = &sh_mobile_ceu1_info,
430 },
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000431};
432
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000433/* I2C device */
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +0000434static struct i2c_board_info i2c0_devices[] = {
435 {
436 I2C_BOARD_INFO("da7210", 0x1a),
437 },
438};
439
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000440static struct i2c_board_info i2c1_devices[] = {
441 {
442 I2C_BOARD_INFO("r2025sd", 0x32),
443 },
NISHIMOTO Hirokiea440782010-01-15 08:25:00 +0900444 {
445 I2C_BOARD_INFO("lis3lv02d", 0x1c),
Paul Mundt9307d112012-05-18 15:49:38 +0900446 .irq = evt2irq(0x620),
NISHIMOTO Hirokiea440782010-01-15 08:25:00 +0900447 }
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000448};
449
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000450/* KEYSC */
451static struct sh_keysc_info keysc_info = {
452 .mode = SH_KEYSC_MODE_1,
453 .scan_timing = 3,
454 .delay = 50,
455 .kycr2_delay = 100,
456 .keycodes = { KEY_1, 0, 0, 0, 0,
457 KEY_2, 0, 0, 0, 0,
458 KEY_3, 0, 0, 0, 0,
459 KEY_4, 0, 0, 0, 0,
460 KEY_5, 0, 0, 0, 0,
461 KEY_6, 0, 0, 0, 0, },
462};
463
464static struct resource keysc_resources[] = {
465 [0] = {
466 .name = "KEYSC",
467 .start = 0x044b0000,
468 .end = 0x044b000f,
469 .flags = IORESOURCE_MEM,
470 },
471 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900472 .start = evt2irq(0xbe0),
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000473 .flags = IORESOURCE_IRQ,
474 },
475};
476
477static struct platform_device keysc_device = {
478 .name = "sh_keysc",
479 .id = 0, /* keysc0 clock */
480 .num_resources = ARRAY_SIZE(keysc_resources),
481 .resource = keysc_resources,
482 .dev = {
483 .platform_data = &keysc_info,
484 },
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000485};
486
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000487/* TouchScreen */
Paul Mundt9307d112012-05-18 15:49:38 +0900488#define IRQ0 evt2irq(0x600)
489
Paul Mundt5d75b3a2010-09-14 18:26:38 +0900490static int ts_get_pendown_state(void)
491{
492 int val = 0;
493 gpio_free(GPIO_FN_INTC_IRQ0);
494 gpio_request(GPIO_PTZ0, NULL);
495 gpio_direction_input(GPIO_PTZ0);
496
497 val = gpio_get_value(GPIO_PTZ0);
498
499 gpio_free(GPIO_PTZ0);
500 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
501
502 return val ? 0 : 1;
503}
504
505static int ts_init(void)
506{
507 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
508 return 0;
509}
510
Kuninori Morimoto3ce09332010-06-02 00:27:31 +0000511static struct tsc2007_platform_data tsc2007_info = {
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000512 .model = 2007,
Paul Mundt5d75b3a2010-09-14 18:26:38 +0900513 .x_plate_ohms = 180,
514 .get_pendown_state = ts_get_pendown_state,
515 .init_platform_hw = ts_init,
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000516};
517
518static struct i2c_board_info ts_i2c_clients = {
519 I2C_BOARD_INFO("tsc2007", 0x48),
520 .type = "tsc2007",
521 .platform_data = &tsc2007_info,
522 .irq = IRQ0,
523};
524
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200525static struct regulator_consumer_supply cn12_power_consumers[] =
526{
527 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
528 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
529 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
530 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
531};
532
533static struct regulator_init_data cn12_power_init_data = {
534 .constraints = {
535 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
536 },
537 .num_consumer_supplies = ARRAY_SIZE(cn12_power_consumers),
538 .consumer_supplies = cn12_power_consumers,
539};
540
541static struct fixed_voltage_config cn12_power_info = {
542 .supply_name = "CN12 SD/MMC Vdd",
543 .microvolts = 3300000,
544 .gpio = GPIO_PTB7,
545 .enable_high = 1,
546 .init_data = &cn12_power_init_data,
547};
548
549static struct platform_device cn12_power = {
550 .name = "reg-fixed-voltage",
551 .id = 0,
552 .dev = {
553 .platform_data = &cn12_power_info,
554 },
555};
556
Guennadi Liakhovetski5744c882011-04-15 20:03:17 +0200557#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
Yusuke Goda1238c682010-04-27 10:15:32 +0000558/* SDHI0 */
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200559static struct regulator_consumer_supply sdhi0_power_consumers[] =
560{
561 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
562 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
563};
564
565static struct regulator_init_data sdhi0_power_init_data = {
566 .constraints = {
567 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
568 },
569 .num_consumer_supplies = ARRAY_SIZE(sdhi0_power_consumers),
570 .consumer_supplies = sdhi0_power_consumers,
571};
572
573static struct fixed_voltage_config sdhi0_power_info = {
574 .supply_name = "CN11 SD/MMC Vdd",
575 .microvolts = 3300000,
576 .gpio = GPIO_PTB6,
577 .enable_high = 1,
578 .init_data = &sdhi0_power_init_data,
579};
580
581static struct platform_device sdhi0_power = {
582 .name = "reg-fixed-voltage",
583 .id = 1,
584 .dev = {
585 .platform_data = &sdhi0_power_info,
586 },
587};
588
Magnus Damm98779ad2009-11-27 04:36:58 +0000589static void sdhi0_set_pwr(struct platform_device *pdev, int state)
590{
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200591 static int power_gpio = -EINVAL;
592
593 if (power_gpio < 0) {
594 int ret = gpio_request(GPIO_PTB6, NULL);
595 if (!ret) {
596 power_gpio = GPIO_PTB6;
597 gpio_direction_output(power_gpio, 0);
598 }
599 }
600
601 /*
602 * Toggle the GPIO regardless, whether we managed to grab it above or
603 * the fixed regulator driver did.
604 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000605 gpio_set_value(GPIO_PTB6, state);
606}
607
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +0100608static int sdhi0_get_cd(struct platform_device *pdev)
609{
610 return !gpio_get_value(GPIO_PTY7);
611}
612
Magnus Damm98779ad2009-11-27 04:36:58 +0000613static struct sh_mobile_sdhi_info sdhi0_info = {
Guennadi Liakhovetski815f1992010-05-19 18:34:27 +0000614 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
615 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
616 .set_pwr = sdhi0_set_pwr,
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +0100617 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
618 MMC_CAP_NEEDS_POLL,
619 .get_cd = sdhi0_get_cd,
Magnus Damm98779ad2009-11-27 04:36:58 +0000620};
621
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000622static struct resource sdhi0_resources[] = {
623 [0] = {
624 .name = "SDHI0",
625 .start = 0x04ce0000,
Guennadi Liakhovetskid80e9222011-03-09 13:42:42 +0100626 .end = 0x04ce00ff,
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000627 .flags = IORESOURCE_MEM,
628 },
629 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900630 .start = evt2irq(0xe80),
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000631 .flags = IORESOURCE_IRQ,
632 },
633};
634
635static struct platform_device sdhi0_device = {
636 .name = "sh_mobile_sdhi",
637 .num_resources = ARRAY_SIZE(sdhi0_resources),
638 .resource = sdhi0_resources,
639 .id = 0,
Magnus Damm98779ad2009-11-27 04:36:58 +0000640 .dev = {
641 .platform_data = &sdhi0_info,
642 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000643};
644
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200645static void cn12_set_pwr(struct platform_device *pdev, int state)
Magnus Damm98779ad2009-11-27 04:36:58 +0000646{
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200647 static int power_gpio = -EINVAL;
648
649 if (power_gpio < 0) {
650 int ret = gpio_request(GPIO_PTB7, NULL);
651 if (!ret) {
652 power_gpio = GPIO_PTB7;
653 gpio_direction_output(power_gpio, 0);
654 }
655 }
656
657 /*
658 * Toggle the GPIO regardless, whether we managed to grab it above or
659 * the fixed regulator driver did.
660 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000661 gpio_set_value(GPIO_PTB7, state);
662}
663
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200664#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
665/* SDHI1 */
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +0100666static int sdhi1_get_cd(struct platform_device *pdev)
667{
668 return !gpio_get_value(GPIO_PTW7);
669}
670
Magnus Damm98779ad2009-11-27 04:36:58 +0000671static struct sh_mobile_sdhi_info sdhi1_info = {
Guennadi Liakhovetski815f1992010-05-19 18:34:27 +0000672 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
673 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +0100674 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
675 MMC_CAP_NEEDS_POLL,
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200676 .set_pwr = cn12_set_pwr,
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +0100677 .get_cd = sdhi1_get_cd,
Magnus Damm98779ad2009-11-27 04:36:58 +0000678};
679
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000680static struct resource sdhi1_resources[] = {
681 [0] = {
682 .name = "SDHI1",
683 .start = 0x04cf0000,
Guennadi Liakhovetskid80e9222011-03-09 13:42:42 +0100684 .end = 0x04cf00ff,
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000685 .flags = IORESOURCE_MEM,
686 },
687 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900688 .start = evt2irq(0x4e0),
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000689 .flags = IORESOURCE_IRQ,
690 },
691};
692
693static struct platform_device sdhi1_device = {
694 .name = "sh_mobile_sdhi",
695 .num_resources = ARRAY_SIZE(sdhi1_resources),
696 .resource = sdhi1_resources,
697 .id = 1,
Magnus Damm98779ad2009-11-27 04:36:58 +0000698 .dev = {
699 .platform_data = &sdhi1_info,
700 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000701};
Yusuke Goda1238c682010-04-27 10:15:32 +0000702#endif /* CONFIG_MMC_SH_MMCIF */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000703
Magnus Damm1ce4da72009-12-07 14:05:45 +0000704#else
705
Kuninori Morimoto9503e892009-12-24 05:27:47 +0000706/* MMC SPI */
Magnus Damm1ce4da72009-12-07 14:05:45 +0000707static int mmc_spi_get_ro(struct device *dev)
708{
709 return gpio_get_value(GPIO_PTY6);
710}
711
712static int mmc_spi_get_cd(struct device *dev)
713{
714 return !gpio_get_value(GPIO_PTY7);
715}
716
717static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
718{
719 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
720}
721
722static struct mmc_spi_platform_data mmc_spi_info = {
723 .get_ro = mmc_spi_get_ro,
724 .get_cd = mmc_spi_get_cd,
725 .caps = MMC_CAP_NEEDS_POLL,
726 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
727 .setpower = mmc_spi_setpower,
728};
729
730static struct spi_board_info spi_bus[] = {
731 {
732 .modalias = "mmc_spi",
733 .platform_data = &mmc_spi_info,
734 .max_speed_hz = 5000000,
735 .mode = SPI_MODE_0,
736 .controller_data = (void *) GPIO_PTM4,
737 },
738};
739
Kuninori Morimoto9503e892009-12-24 05:27:47 +0000740/* MSIOF0 */
Magnus Damm1ce4da72009-12-07 14:05:45 +0000741static struct sh_msiof_spi_info msiof0_data = {
742 .num_chipselect = 1,
743};
744
745static struct resource msiof0_resources[] = {
746 [0] = {
747 .name = "MSIOF0",
748 .start = 0xa4c40000,
749 .end = 0xa4c40063,
750 .flags = IORESOURCE_MEM,
751 },
752 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900753 .start = evt2irq(0xc80),
Magnus Damm1ce4da72009-12-07 14:05:45 +0000754 .flags = IORESOURCE_IRQ,
755 },
756};
757
758static struct platform_device msiof0_device = {
759 .name = "spi_sh_msiof",
760 .id = 0, /* MSIOF0 */
761 .dev = {
762 .platform_data = &msiof0_data,
763 },
764 .num_resources = ARRAY_SIZE(msiof0_resources),
765 .resource = msiof0_resources,
Magnus Damm1ce4da72009-12-07 14:05:45 +0000766};
767
768#endif
769
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000770/* I2C Video/Camera */
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000771static struct i2c_board_info i2c_camera[] = {
772 {
773 I2C_BOARD_INFO("tw9910", 0x45),
774 },
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000775 {
776 /* 1st camera */
777 I2C_BOARD_INFO("mt9t112", 0x3c),
778 },
779 {
780 /* 2nd camera */
781 I2C_BOARD_INFO("mt9t112", 0x3c),
782 },
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000783};
784
785/* tw9910 */
786static int tw9910_power(struct device *dev, int mode)
787{
788 int val = mode ? 0 : 1;
789
790 gpio_set_value(GPIO_PTU2, val);
791 if (mode)
792 mdelay(100);
793
794 return 0;
795}
796
797static struct tw9910_video_info tw9910_info = {
798 .buswidth = SOCAM_DATAWIDTH_8,
799 .mpout = TW9910_MPO_FIELD,
800};
801
802static struct soc_camera_link tw9910_link = {
803 .i2c_adapter_id = 0,
804 .bus_id = 1,
805 .power = tw9910_power,
806 .board_info = &i2c_camera[0],
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000807 .priv = &tw9910_info,
808};
809
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000810/* mt9t112 */
811static int mt9t112_power1(struct device *dev, int mode)
812{
813 gpio_set_value(GPIO_PTA3, mode);
814 if (mode)
815 mdelay(100);
816
817 return 0;
818}
819
820static struct mt9t112_camera_info mt9t112_info1 = {
821 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
822 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
823};
824
825static struct soc_camera_link mt9t112_link1 = {
826 .i2c_adapter_id = 0,
827 .power = mt9t112_power1,
828 .bus_id = 0,
829 .board_info = &i2c_camera[1],
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000830 .priv = &mt9t112_info1,
831};
832
833static int mt9t112_power2(struct device *dev, int mode)
834{
835 gpio_set_value(GPIO_PTA4, mode);
836 if (mode)
837 mdelay(100);
838
839 return 0;
840}
841
842static struct mt9t112_camera_info mt9t112_info2 = {
843 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
844 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
845};
846
847static struct soc_camera_link mt9t112_link2 = {
848 .i2c_adapter_id = 1,
849 .power = mt9t112_power2,
850 .bus_id = 1,
851 .board_info = &i2c_camera[2],
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000852 .priv = &mt9t112_info2,
853};
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000854
855static struct platform_device camera_devices[] = {
856 {
857 .name = "soc-camera-pdrv",
858 .id = 0,
859 .dev = {
860 .platform_data = &tw9910_link,
861 },
862 },
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000863 {
864 .name = "soc-camera-pdrv",
865 .id = 1,
866 .dev = {
867 .platform_data = &mt9t112_link1,
868 },
869 },
870 {
871 .name = "soc-camera-pdrv",
872 .id = 2,
873 .dev = {
874 .platform_data = &mt9t112_link2,
875 },
876 },
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000877};
878
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +0000879/* FSI */
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +0000880static struct resource fsi_resources[] = {
881 [0] = {
882 .name = "FSI",
883 .start = 0xFE3C0000,
884 .end = 0xFE3C021d,
885 .flags = IORESOURCE_MEM,
886 },
887 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900888 .start = evt2irq(0xf80),
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +0000889 .flags = IORESOURCE_IRQ,
890 },
891};
892
893static struct platform_device fsi_device = {
894 .name = "sh_fsi",
895 .id = 0,
896 .num_resources = ARRAY_SIZE(fsi_resources),
897 .resource = fsi_resources,
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +0000898};
899
Kuninori Morimoto064bfad2012-04-08 21:19:25 -0700900static struct asoc_simple_card_info fsi_da7210_info = {
901 .name = "DA7210",
902 .card = "FSIB-DA7210",
Kuninori Morimoto064bfad2012-04-08 21:19:25 -0700903 .codec = "da7210.0-001a",
904 .platform = "sh_fsi.0",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800905 .daifmt = SND_SOC_DAIFMT_I2S,
906 .cpu_dai = {
907 .name = "fsib-dai",
908 .fmt = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
909 },
910 .codec_dai = {
911 .name = "da7210-hifi",
912 .fmt = SND_SOC_DAIFMT_CBM_CFM,
913 },
Kuninori Morimoto064bfad2012-04-08 21:19:25 -0700914};
915
916static struct platform_device fsi_da7210_device = {
917 .name = "asoc-simple-card",
918 .dev = {
919 .platform_data = &fsi_da7210_info,
920 },
921};
922
923
Kuninori Morimoto26365712010-02-24 00:32:28 +0000924/* IrDA */
925static struct resource irda_resources[] = {
926 [0] = {
927 .name = "IrDA",
928 .start = 0xA45D0000,
929 .end = 0xA45D0049,
930 .flags = IORESOURCE_MEM,
931 },
932 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900933 .start = evt2irq(0x480),
Kuninori Morimoto26365712010-02-24 00:32:28 +0000934 .flags = IORESOURCE_IRQ,
935 },
936};
937
938static struct platform_device irda_device = {
939 .name = "sh_sir",
940 .num_resources = ARRAY_SIZE(irda_resources),
941 .resource = irda_resources,
942};
943
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +0000944#include <media/ak881x.h>
945#include <media/sh_vou.h>
946
Kuninori Morimoto3ce09332010-06-02 00:27:31 +0000947static struct ak881x_pdata ak881x_pdata = {
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +0000948 .flags = AK881X_IF_MODE_SLAVE,
949};
950
951static struct i2c_board_info ak8813 = {
952 I2C_BOARD_INFO("ak8813", 0x20),
953 .platform_data = &ak881x_pdata,
954};
955
Kuninori Morimoto3ce09332010-06-02 00:27:31 +0000956static struct sh_vou_pdata sh_vou_pdata = {
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +0000957 .bus_fmt = SH_VOU_BUS_8BIT,
958 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
959 .board_info = &ak8813,
960 .i2c_adap = 0,
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +0000961};
962
963static struct resource sh_vou_resources[] = {
964 [0] = {
965 .start = 0xfe960000,
966 .end = 0xfe962043,
967 .flags = IORESOURCE_MEM,
968 },
969 [1] = {
Paul Mundt9307d112012-05-18 15:49:38 +0900970 .start = evt2irq(0x8e0),
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +0000971 .flags = IORESOURCE_IRQ,
972 },
973};
974
975static struct platform_device vou_device = {
976 .name = "sh-vou",
977 .id = -1,
978 .num_resources = ARRAY_SIZE(sh_vou_resources),
979 .resource = sh_vou_resources,
980 .dev = {
981 .platform_data = &sh_vou_pdata,
982 },
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +0000983};
984
Guennadi Liakhovetski5744c882011-04-15 20:03:17 +0200985#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda1238c682010-04-27 10:15:32 +0000986/* SH_MMCIF */
Yusuke Goda1238c682010-04-27 10:15:32 +0000987static void mmcif_down_pwr(struct platform_device *pdev)
988{
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +0200989 cn12_set_pwr(pdev, 0);
Yusuke Goda1238c682010-04-27 10:15:32 +0000990}
991
992static struct resource sh_mmcif_resources[] = {
993 [0] = {
994 .name = "SH_MMCIF",
995 .start = 0xA4CA0000,
996 .end = 0xA4CA00FF,
997 .flags = IORESOURCE_MEM,
998 },
999 [1] = {
1000 /* MMC2I */
Paul Mundt9307d112012-05-18 15:49:38 +09001001 .start = evt2irq(0x5a0),
Yusuke Goda1238c682010-04-27 10:15:32 +00001002 .flags = IORESOURCE_IRQ,
1003 },
1004 [2] = {
1005 /* MMC3I */
Paul Mundt9307d112012-05-18 15:49:38 +09001006 .start = evt2irq(0x5c0),
Yusuke Goda1238c682010-04-27 10:15:32 +00001007 .flags = IORESOURCE_IRQ,
1008 },
1009};
1010
Kuninori Morimoto3ce09332010-06-02 00:27:31 +00001011static struct sh_mmcif_plat_data sh_mmcif_plat = {
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +02001012 .set_pwr = cn12_set_pwr,
Yusuke Goda1238c682010-04-27 10:15:32 +00001013 .down_pwr = mmcif_down_pwr,
1014 .sup_pclk = 0, /* SH7724: Max Pclk/2 */
1015 .caps = MMC_CAP_4_BIT_DATA |
1016 MMC_CAP_8_BIT_DATA |
1017 MMC_CAP_NEEDS_POLL,
1018 .ocr = MMC_VDD_32_33 | MMC_VDD_33_34,
1019};
1020
1021static struct platform_device sh_mmcif_device = {
1022 .name = "sh_mmcif",
1023 .id = 0,
1024 .dev = {
1025 .platform_data = &sh_mmcif_plat,
1026 },
1027 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
1028 .resource = sh_mmcif_resources,
1029};
1030#endif
1031
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001032static struct platform_device *ecovec_devices[] __initdata = {
1033 &heartbeat_device,
1034 &nor_flash_device,
Kuninori Morimoto35a35402009-08-26 11:04:26 +00001035 &sh_eth_device,
Kuninori Morimoto907050a2009-08-26 11:04:31 +00001036 &usb0_host_device,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +00001037 &usb1_common_device,
Kuninori Morimotofb2e7392011-06-15 06:08:18 +00001038 &usbhs_device,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001039 &lcdc_device,
Kuninori Morimoto2153ad32009-08-26 11:04:36 +00001040 &ceu0_device,
1041 &ceu1_device,
Kuninori Morimotoe9103e72009-09-14 11:23:00 +00001042 &keysc_device,
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +02001043 &cn12_power,
Guennadi Liakhovetski5744c882011-04-15 20:03:17 +02001044#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
Guennadi Liakhovetskid4c191d2012-06-28 12:29:46 +02001045 &sdhi0_power,
Kuninori Morimoto96987d92009-10-02 07:54:42 +00001046 &sdhi0_device,
Guennadi Liakhovetski5744c882011-04-15 20:03:17 +02001047#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Kuninori Morimoto96987d92009-10-02 07:54:42 +00001048 &sdhi1_device,
Yusuke Goda1238c682010-04-27 10:15:32 +00001049#endif
Magnus Damm1ce4da72009-12-07 14:05:45 +00001050#else
1051 &msiof0_device,
1052#endif
Kuninori Morimoto207efd02009-12-15 05:37:16 +00001053 &camera_devices[0],
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +00001054 &camera_devices[1],
1055 &camera_devices[2],
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001056 &fsi_device,
Kuninori Morimoto064bfad2012-04-08 21:19:25 -07001057 &fsi_da7210_device,
Kuninori Morimoto26365712010-02-24 00:32:28 +00001058 &irda_device,
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +00001059 &vou_device,
Guennadi Liakhovetski5744c882011-04-15 20:03:17 +02001060#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda1238c682010-04-27 10:15:32 +00001061 &sh_mmcif_device,
1062#endif
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001063};
1064
Magnus Damm6b3b5572010-02-25 11:10:54 +00001065#ifdef CONFIG_I2C
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001066#define EEPROM_ADDR 0x50
1067static u8 mac_read(struct i2c_adapter *a, u8 command)
1068{
1069 struct i2c_msg msg[2];
1070 u8 buf;
1071 int ret;
1072
1073 msg[0].addr = EEPROM_ADDR;
1074 msg[0].flags = 0;
1075 msg[0].len = 1;
1076 msg[0].buf = &command;
1077
1078 msg[1].addr = EEPROM_ADDR;
1079 msg[1].flags = I2C_M_RD;
1080 msg[1].len = 1;
1081 msg[1].buf = &buf;
1082
1083 ret = i2c_transfer(a, msg, 2);
1084 if (ret < 0) {
1085 printk(KERN_ERR "error %d\n", ret);
1086 buf = 0xff;
1087 }
1088
1089 return buf;
1090}
1091
Magnus Damm376abbb2009-10-26 10:44:37 +00001092static void __init sh_eth_init(struct sh_eth_plat_data *pd)
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001093{
1094 struct i2c_adapter *a = i2c_get_adapter(1);
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001095 int i;
1096
1097 if (!a) {
1098 pr_err("can not get I2C 1\n");
1099 return;
1100 }
1101
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001102 /* read MAC address from EEPROM */
Magnus Damm376abbb2009-10-26 10:44:37 +00001103 for (i = 0; i < sizeof(pd->mac_addr); i++) {
1104 pd->mac_addr[i] = mac_read(a, 0x10 + i);
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001105 msleep(10);
1106 }
Kuninori Morimotob230eb32010-03-16 02:01:33 +00001107
1108 i2c_put_adapter(a);
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001109}
Magnus Damm6b3b5572010-02-25 11:10:54 +00001110#else
1111static void __init sh_eth_init(struct sh_eth_plat_data *pd)
1112{
1113 pr_err("unable to read sh_eth MAC address\n");
1114}
1115#endif
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001116
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001117#define PORT_HIZA 0xA4050158
Kuninori Morimotoea15edb2009-08-26 11:04:39 +00001118#define IODRIVEA 0xA405018A
Magnus Dammeb0cd9e2009-10-30 04:23:59 +00001119
1120extern char ecovec24_sdram_enter_start;
1121extern char ecovec24_sdram_enter_end;
1122extern char ecovec24_sdram_leave_start;
1123extern char ecovec24_sdram_leave_end;
1124
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001125static int __init arch_setup(void)
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001126{
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001127 struct clk *clk;
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +01001128 bool cn12_enabled = false;
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001129
Magnus Dammeb0cd9e2009-10-30 04:23:59 +00001130 /* register board specific self-refresh code */
Magnus Damm2839bd62010-02-25 11:07:52 +00001131 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
1132 SUSP_SH_RSTANDBY,
Magnus Dammeb0cd9e2009-10-30 04:23:59 +00001133 &ecovec24_sdram_enter_start,
1134 &ecovec24_sdram_enter_end,
1135 &ecovec24_sdram_leave_start,
1136 &ecovec24_sdram_leave_end);
1137
Magnus Dammf78bab32009-10-07 09:00:06 +00001138 /* enable STATUS0, STATUS2 and PDSTATUS */
1139 gpio_request(GPIO_FN_STATUS0, NULL);
1140 gpio_request(GPIO_FN_STATUS2, NULL);
1141 gpio_request(GPIO_FN_PDSTATUS, NULL);
1142
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001143 /* enable SCIFA0 */
1144 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
1145 gpio_request(GPIO_FN_SCIF0_RXD, NULL);
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001146
1147 /* enable debug LED */
1148 gpio_request(GPIO_PTG0, NULL);
1149 gpio_request(GPIO_PTG1, NULL);
1150 gpio_request(GPIO_PTG2, NULL);
1151 gpio_request(GPIO_PTG3, NULL);
Kuninori Morimotob7056bc2009-08-26 11:04:22 +00001152 gpio_direction_output(GPIO_PTG0, 0);
1153 gpio_direction_output(GPIO_PTG1, 0);
1154 gpio_direction_output(GPIO_PTG2, 0);
1155 gpio_direction_output(GPIO_PTG3, 0);
Paul Mundt9d56dd32010-01-26 12:58:40 +09001156 __raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001157
Kuninori Morimoto35a35402009-08-26 11:04:26 +00001158 /* enable SH-Eth */
1159 gpio_request(GPIO_PTA1, NULL);
1160 gpio_direction_output(GPIO_PTA1, 1);
1161 mdelay(20);
1162
1163 gpio_request(GPIO_FN_RMII_RXD0, NULL);
1164 gpio_request(GPIO_FN_RMII_RXD1, NULL);
1165 gpio_request(GPIO_FN_RMII_TXD0, NULL);
1166 gpio_request(GPIO_FN_RMII_TXD1, NULL);
1167 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
1168 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
1169 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
1170 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
1171 gpio_request(GPIO_FN_MDIO, NULL);
1172 gpio_request(GPIO_FN_MDC, NULL);
1173 gpio_request(GPIO_FN_LNKSTA, NULL);
1174
Kuninori Morimoto907050a2009-08-26 11:04:31 +00001175 /* enable USB */
Paul Mundt9d56dd32010-01-26 12:58:40 +09001176 __raw_writew(0x0000, 0xA4D80000);
1177 __raw_writew(0x0000, 0xA4D90000);
Kuninori Morimoto907050a2009-08-26 11:04:31 +00001178 gpio_request(GPIO_PTB3, NULL);
1179 gpio_request(GPIO_PTB4, NULL);
1180 gpio_request(GPIO_PTB5, NULL);
1181 gpio_direction_input(GPIO_PTB3);
1182 gpio_direction_output(GPIO_PTB4, 0);
1183 gpio_direction_output(GPIO_PTB5, 0);
Paul Mundt9d56dd32010-01-26 12:58:40 +09001184 __raw_writew(0x0600, 0xa40501d4);
1185 __raw_writew(0x0600, 0xa4050192);
Kuninori Morimoto907050a2009-08-26 11:04:31 +00001186
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +00001187 if (gpio_get_value(GPIO_PTB3)) {
1188 printk(KERN_INFO "USB1 function is selected\n");
1189 usb1_common_device.name = "r8a66597_udc";
1190 } else {
1191 printk(KERN_INFO "USB1 host is selected\n");
1192 usb1_common_device.name = "r8a66597_hcd";
1193 }
1194
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001195 /* enable LCDC */
1196 gpio_request(GPIO_FN_LCDD23, NULL);
1197 gpio_request(GPIO_FN_LCDD22, NULL);
1198 gpio_request(GPIO_FN_LCDD21, NULL);
1199 gpio_request(GPIO_FN_LCDD20, NULL);
1200 gpio_request(GPIO_FN_LCDD19, NULL);
1201 gpio_request(GPIO_FN_LCDD18, NULL);
1202 gpio_request(GPIO_FN_LCDD17, NULL);
1203 gpio_request(GPIO_FN_LCDD16, NULL);
1204 gpio_request(GPIO_FN_LCDD15, NULL);
1205 gpio_request(GPIO_FN_LCDD14, NULL);
1206 gpio_request(GPIO_FN_LCDD13, NULL);
1207 gpio_request(GPIO_FN_LCDD12, NULL);
1208 gpio_request(GPIO_FN_LCDD11, NULL);
1209 gpio_request(GPIO_FN_LCDD10, NULL);
1210 gpio_request(GPIO_FN_LCDD9, NULL);
1211 gpio_request(GPIO_FN_LCDD8, NULL);
1212 gpio_request(GPIO_FN_LCDD7, NULL);
1213 gpio_request(GPIO_FN_LCDD6, NULL);
1214 gpio_request(GPIO_FN_LCDD5, NULL);
1215 gpio_request(GPIO_FN_LCDD4, NULL);
1216 gpio_request(GPIO_FN_LCDD3, NULL);
1217 gpio_request(GPIO_FN_LCDD2, NULL);
1218 gpio_request(GPIO_FN_LCDD1, NULL);
1219 gpio_request(GPIO_FN_LCDD0, NULL);
1220 gpio_request(GPIO_FN_LCDDISP, NULL);
1221 gpio_request(GPIO_FN_LCDHSYN, NULL);
1222 gpio_request(GPIO_FN_LCDDCK, NULL);
1223 gpio_request(GPIO_FN_LCDVSYN, NULL);
1224 gpio_request(GPIO_FN_LCDDON, NULL);
1225 gpio_request(GPIO_FN_LCDLCLK, NULL);
Paul Mundt9d56dd32010-01-26 12:58:40 +09001226 __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001227
1228 gpio_request(GPIO_PTE6, NULL);
1229 gpio_request(GPIO_PTU1, NULL);
1230 gpio_request(GPIO_PTR1, NULL);
1231 gpio_request(GPIO_PTA2, NULL);
1232 gpio_direction_input(GPIO_PTE6);
1233 gpio_direction_output(GPIO_PTU1, 0);
1234 gpio_direction_output(GPIO_PTR1, 0);
1235 gpio_direction_output(GPIO_PTA2, 0);
1236
Kuninori Morimoto82b33222009-12-02 09:35:42 +00001237 /* I/O buffer drive ability is high */
Paul Mundt9d56dd32010-01-26 12:58:40 +09001238 __raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
Kuninori Morimotoea15edb2009-08-26 11:04:39 +00001239
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001240 if (gpio_get_value(GPIO_PTE6)) {
1241 /* DVI */
1242 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
Guennadi Liakhovetski44432402010-09-03 07:20:04 +00001243 lcdc_info.ch[0].clock_divider = 1;
Laurent Pinchart93ff2592011-11-29 14:33:41 +01001244 lcdc_info.ch[0].lcd_modes = ecovec_dvi_modes;
1245 lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_dvi_modes);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001246
1247 gpio_set_value(GPIO_PTA2, 1);
1248 gpio_set_value(GPIO_PTU1, 1);
1249 } else {
1250 /* Panel */
Kuninori Morimotoea15edb2009-08-26 11:04:39 +00001251 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
Guennadi Liakhovetski44432402010-09-03 07:20:04 +00001252 lcdc_info.ch[0].clock_divider = 2;
Laurent Pinchart93ff2592011-11-29 14:33:41 +01001253 lcdc_info.ch[0].lcd_modes = ecovec_lcd_modes;
1254 lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_lcd_modes);
Kuninori Morimotoea15edb2009-08-26 11:04:39 +00001255
1256 gpio_set_value(GPIO_PTR1, 1);
1257
1258 /* FIXME
1259 *
1260 * LCDDON control is needed for Panel,
1261 * but current sh_mobile_lcdc driver doesn't control it.
1262 * It is temporary correspondence
1263 */
1264 gpio_request(GPIO_PTF4, NULL);
1265 gpio_direction_output(GPIO_PTF4, 1);
Kuninori Morimoto8810e052009-09-28 08:21:41 +00001266
1267 /* enable TouchScreen */
1268 i2c_register_board_info(0, &ts_i2c_clients, 1);
Thomas Gleixnerfcb89182011-03-24 16:31:17 +01001269 irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +00001270 }
1271
Kuninori Morimoto2153ad32009-08-26 11:04:36 +00001272 /* enable CEU0 */
1273 gpio_request(GPIO_FN_VIO0_D15, NULL);
1274 gpio_request(GPIO_FN_VIO0_D14, NULL);
1275 gpio_request(GPIO_FN_VIO0_D13, NULL);
1276 gpio_request(GPIO_FN_VIO0_D12, NULL);
1277 gpio_request(GPIO_FN_VIO0_D11, NULL);
1278 gpio_request(GPIO_FN_VIO0_D10, NULL);
1279 gpio_request(GPIO_FN_VIO0_D9, NULL);
1280 gpio_request(GPIO_FN_VIO0_D8, NULL);
1281 gpio_request(GPIO_FN_VIO0_D7, NULL);
1282 gpio_request(GPIO_FN_VIO0_D6, NULL);
1283 gpio_request(GPIO_FN_VIO0_D5, NULL);
1284 gpio_request(GPIO_FN_VIO0_D4, NULL);
1285 gpio_request(GPIO_FN_VIO0_D3, NULL);
1286 gpio_request(GPIO_FN_VIO0_D2, NULL);
1287 gpio_request(GPIO_FN_VIO0_D1, NULL);
1288 gpio_request(GPIO_FN_VIO0_D0, NULL);
1289 gpio_request(GPIO_FN_VIO0_VD, NULL);
1290 gpio_request(GPIO_FN_VIO0_CLK, NULL);
1291 gpio_request(GPIO_FN_VIO0_FLD, NULL);
1292 gpio_request(GPIO_FN_VIO0_HD, NULL);
1293 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
1294
1295 /* enable CEU1 */
1296 gpio_request(GPIO_FN_VIO1_D7, NULL);
1297 gpio_request(GPIO_FN_VIO1_D6, NULL);
1298 gpio_request(GPIO_FN_VIO1_D5, NULL);
1299 gpio_request(GPIO_FN_VIO1_D4, NULL);
1300 gpio_request(GPIO_FN_VIO1_D3, NULL);
1301 gpio_request(GPIO_FN_VIO1_D2, NULL);
1302 gpio_request(GPIO_FN_VIO1_D1, NULL);
1303 gpio_request(GPIO_FN_VIO1_D0, NULL);
1304 gpio_request(GPIO_FN_VIO1_FLD, NULL);
1305 gpio_request(GPIO_FN_VIO1_HD, NULL);
1306 gpio_request(GPIO_FN_VIO1_VD, NULL);
1307 gpio_request(GPIO_FN_VIO1_CLK, NULL);
1308 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
1309
Kuninori Morimotoe9103e72009-09-14 11:23:00 +00001310 /* enable KEYSC */
1311 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
1312 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
1313 gpio_request(GPIO_FN_KEYOUT3, NULL);
1314 gpio_request(GPIO_FN_KEYOUT2, NULL);
1315 gpio_request(GPIO_FN_KEYOUT1, NULL);
1316 gpio_request(GPIO_FN_KEYOUT0, NULL);
1317 gpio_request(GPIO_FN_KEYIN0, NULL);
1318
Kuninori Morimoto064a16d2009-09-16 11:34:34 +00001319 /* enable user debug switch */
1320 gpio_request(GPIO_PTR0, NULL);
1321 gpio_request(GPIO_PTR4, NULL);
1322 gpio_request(GPIO_PTR5, NULL);
1323 gpio_request(GPIO_PTR6, NULL);
1324 gpio_direction_input(GPIO_PTR0);
1325 gpio_direction_input(GPIO_PTR4);
1326 gpio_direction_input(GPIO_PTR5);
1327 gpio_direction_input(GPIO_PTR6);
1328
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +01001329 /* SD-card slot CN11 */
1330 /* Card-detect, used on CN11, either with SDHI0 or with SPI */
1331 gpio_request(GPIO_PTY7, NULL);
1332 gpio_direction_input(GPIO_PTY7);
1333
Guennadi Liakhovetski5744c882011-04-15 20:03:17 +02001334#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
Magnus Damm1ce4da72009-12-07 14:05:45 +00001335 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +00001336 gpio_request(GPIO_FN_SDHI0WP, NULL);
1337 gpio_request(GPIO_FN_SDHI0CMD, NULL);
1338 gpio_request(GPIO_FN_SDHI0CLK, NULL);
1339 gpio_request(GPIO_FN_SDHI0D3, NULL);
1340 gpio_request(GPIO_FN_SDHI0D2, NULL);
1341 gpio_request(GPIO_FN_SDHI0D1, NULL);
1342 gpio_request(GPIO_FN_SDHI0D0, NULL);
Magnus Damm1ce4da72009-12-07 14:05:45 +00001343#else
1344 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
1345 gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
1346 gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
1347 gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
1348 gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
1349 gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
1350 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
1351 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
1352 gpio_request(GPIO_PTY6, NULL); /* write protect */
1353 gpio_direction_input(GPIO_PTY6);
Magnus Damm1ce4da72009-12-07 14:05:45 +00001354
1355 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
1356#endif
Kuninori Morimoto96987d92009-10-02 07:54:42 +00001357
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +01001358 /* MMC/SD-card slot CN12 */
1359#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
1360 /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
1361 gpio_request(GPIO_FN_MMC_D7, NULL);
1362 gpio_request(GPIO_FN_MMC_D6, NULL);
1363 gpio_request(GPIO_FN_MMC_D5, NULL);
1364 gpio_request(GPIO_FN_MMC_D4, NULL);
1365 gpio_request(GPIO_FN_MMC_D3, NULL);
1366 gpio_request(GPIO_FN_MMC_D2, NULL);
1367 gpio_request(GPIO_FN_MMC_D1, NULL);
1368 gpio_request(GPIO_FN_MMC_D0, NULL);
1369 gpio_request(GPIO_FN_MMC_CLK, NULL);
1370 gpio_request(GPIO_FN_MMC_CMD, NULL);
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +01001371
1372 cn12_enabled = true;
1373#elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1374 /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
1375 gpio_request(GPIO_FN_SDHI1WP, NULL);
1376 gpio_request(GPIO_FN_SDHI1CMD, NULL);
1377 gpio_request(GPIO_FN_SDHI1CLK, NULL);
1378 gpio_request(GPIO_FN_SDHI1D3, NULL);
1379 gpio_request(GPIO_FN_SDHI1D2, NULL);
1380 gpio_request(GPIO_FN_SDHI1D1, NULL);
1381 gpio_request(GPIO_FN_SDHI1D0, NULL);
Guennadi Liakhovetski4eb80142012-01-28 19:36:24 +01001382
1383 /* Card-detect, used on CN12 with SDHI1 */
1384 gpio_request(GPIO_PTW7, NULL);
1385 gpio_direction_input(GPIO_PTW7);
1386
1387 cn12_enabled = true;
1388#endif
1389
1390 if (cn12_enabled)
1391 /* I/O buffer drive ability is high for CN12 */
1392 __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000,
1393 IODRIVEA);
1394
Kuninori Morimoto207efd02009-12-15 05:37:16 +00001395 /* enable Video */
1396 gpio_request(GPIO_PTU2, NULL);
1397 gpio_direction_output(GPIO_PTU2, 1);
1398
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +00001399 /* enable Camera */
1400 gpio_request(GPIO_PTA3, NULL);
1401 gpio_request(GPIO_PTA4, NULL);
1402 gpio_direction_output(GPIO_PTA3, 0);
1403 gpio_direction_output(GPIO_PTA4, 0);
1404
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001405 /* enable FSI */
1406 gpio_request(GPIO_FN_FSIMCKB, NULL);
1407 gpio_request(GPIO_FN_FSIIBSD, NULL);
1408 gpio_request(GPIO_FN_FSIOBSD, NULL);
1409 gpio_request(GPIO_FN_FSIIBBCK, NULL);
1410 gpio_request(GPIO_FN_FSIIBLRCK, NULL);
1411 gpio_request(GPIO_FN_FSIOBBCK, NULL);
1412 gpio_request(GPIO_FN_FSIOBLRCK, NULL);
1413 gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
1414
Kuninori Morimoto16afc9f2010-02-22 05:18:10 +00001415 /* set SPU2 clock to 83.4 MHz */
1416 clk = clk_get(NULL, "spu_clk");
Guennadi Liakhovetski56ea5102010-10-15 14:37:24 +00001417 if (!IS_ERR(clk)) {
Kuninori Morimoto10305852010-05-13 01:08:33 +00001418 clk_set_rate(clk, clk_round_rate(clk, 83333333));
1419 clk_put(clk);
1420 }
Kuninori Morimoto16afc9f2010-02-22 05:18:10 +00001421
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001422 /* change parent of FSI B */
1423 clk = clk_get(NULL, "fsib_clk");
Guennadi Liakhovetski56ea5102010-10-15 14:37:24 +00001424 if (!IS_ERR(clk)) {
Kuninori Morimoto4bd5d252010-11-26 09:40:22 +00001425 /* 48kHz dummy clock was used to make sure 1/1 divide */
1426 clk_set_rate(&sh7724_fsimckb_clk, 48000);
1427 clk_set_parent(clk, &sh7724_fsimckb_clk);
1428 clk_set_rate(clk, 48000);
Kuninori Morimoto10305852010-05-13 01:08:33 +00001429 clk_put(clk);
1430 }
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001431
1432 gpio_request(GPIO_PTU0, NULL);
1433 gpio_direction_output(GPIO_PTU0, 0);
1434 mdelay(20);
1435
NISHIMOTO Hirokiea440782010-01-15 08:25:00 +09001436 /* enable motion sensor */
1437 gpio_request(GPIO_FN_INTC_IRQ1, NULL);
1438 gpio_direction_input(GPIO_FN_INTC_IRQ1);
1439
Magnus Damm6f26d192010-02-19 09:33:47 +00001440 /* set VPU clock to 166 MHz */
1441 clk = clk_get(NULL, "vpu_clk");
Guennadi Liakhovetski56ea5102010-10-15 14:37:24 +00001442 if (!IS_ERR(clk)) {
Kuninori Morimoto10305852010-05-13 01:08:33 +00001443 clk_set_rate(clk, clk_round_rate(clk, 166000000));
1444 clk_put(clk);
1445 }
Magnus Damm6f26d192010-02-19 09:33:47 +00001446
Kuninori Morimoto26365712010-02-24 00:32:28 +00001447 /* enable IrDA */
1448 gpio_request(GPIO_FN_IRDA_OUT, NULL);
1449 gpio_request(GPIO_FN_IRDA_IN, NULL);
1450 gpio_request(GPIO_PTU5, NULL);
1451 gpio_direction_output(GPIO_PTU5, 0);
1452
Kuninori Morimoto125ecce2009-09-10 01:39:37 +00001453 /* enable I2C device */
Kuninori Morimoto1980fdc2009-12-15 05:37:39 +00001454 i2c_register_board_info(0, i2c0_devices,
1455 ARRAY_SIZE(i2c0_devices));
1456
Kuninori Morimoto125ecce2009-09-10 01:39:37 +00001457 i2c_register_board_info(1, i2c1_devices,
1458 ARRAY_SIZE(i2c1_devices));
1459
Guennadi Liakhovetski92359a72011-01-17 08:02:53 +00001460#if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +00001461 /* VOU */
1462 gpio_request(GPIO_FN_DV_D15, NULL);
1463 gpio_request(GPIO_FN_DV_D14, NULL);
1464 gpio_request(GPIO_FN_DV_D13, NULL);
1465 gpio_request(GPIO_FN_DV_D12, NULL);
1466 gpio_request(GPIO_FN_DV_D11, NULL);
1467 gpio_request(GPIO_FN_DV_D10, NULL);
1468 gpio_request(GPIO_FN_DV_D9, NULL);
1469 gpio_request(GPIO_FN_DV_D8, NULL);
1470 gpio_request(GPIO_FN_DV_CLKI, NULL);
1471 gpio_request(GPIO_FN_DV_CLK, NULL);
1472 gpio_request(GPIO_FN_DV_VSYNC, NULL);
1473 gpio_request(GPIO_FN_DV_HSYNC, NULL);
1474
1475 /* AK8813 power / reset sequence */
1476 gpio_request(GPIO_PTG4, NULL);
1477 gpio_request(GPIO_PTU3, NULL);
1478 /* Reset */
1479 gpio_direction_output(GPIO_PTG4, 0);
1480 /* Power down */
1481 gpio_direction_output(GPIO_PTU3, 1);
1482
1483 udelay(10);
1484
1485 /* Power up, reset */
1486 gpio_set_value(GPIO_PTU3, 0);
1487
1488 udelay(10);
1489
1490 /* Remove reset */
1491 gpio_set_value(GPIO_PTG4, 1);
Guennadi Liakhovetski92359a72011-01-17 08:02:53 +00001492#endif
Guennadi Liakhovetskiaee5ab02010-04-21 08:45:25 +00001493
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001494 return platform_add_devices(ecovec_devices,
1495 ARRAY_SIZE(ecovec_devices));
1496}
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001497arch_initcall(arch_setup);
1498
1499static int __init devices_setup(void)
1500{
Magnus Damm376abbb2009-10-26 10:44:37 +00001501 sh_eth_init(&sh_eth_plat);
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001502 return 0;
1503}
1504device_initcall(devices_setup);
1505
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001506static struct sh_machine_vector mv_ecovec __initmv = {
1507 .mv_name = "R0P7724 (EcoVec)",
1508};