xref: /openbmc/linux/arch/sh/boards/mach-ecovec24/setup.c (revision f240ec09bb8a08003a6e2cb51682705ab19b78cd)
1aaf9128aSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
24138b740SKuninori Morimoto /*
34138b740SKuninori Morimoto  * Copyright (C) 2009 Renesas Solutions Corp.
44138b740SKuninori Morimoto  *
54138b740SKuninori Morimoto  * Kuninori Morimoto <morimoto.kuninori@renesas.com>
64138b740SKuninori Morimoto  */
7c2f9b05fSJacopo Mondi #include <asm/clock.h>
8c2f9b05fSJacopo Mondi #include <asm/heartbeat.h>
9c2f9b05fSJacopo Mondi #include <asm/suspend.h>
10c2f9b05fSJacopo Mondi #include <cpu/sh7724.h>
11c2f9b05fSJacopo Mondi #include <linux/delay.h>
124138b740SKuninori Morimoto #include <linux/device.h>
13c2f9b05fSJacopo Mondi #include <linux/i2c.h>
14c2f9b05fSJacopo Mondi #include <linux/io.h>
15c2f9b05fSJacopo Mondi #include <linux/init.h>
16c2f9b05fSJacopo Mondi #include <linux/input.h>
17c2f9b05fSJacopo Mondi #include <linux/input/sh_keysc.h>
18c2f9b05fSJacopo Mondi #include <linux/interrupt.h>
19c2f9b05fSJacopo Mondi #include <linux/memblock.h>
20c2f9b05fSJacopo Mondi #include <linux/mfd/tmio.h>
211238c684SYusuke Goda #include <linux/mmc/host.h>
221238c684SYusuke Goda #include <linux/mmc/sh_mmcif.h>
234138b740SKuninori Morimoto #include <linux/mtd/physmap.h>
244138b740SKuninori Morimoto #include <linux/gpio.h>
25c2f9b05fSJacopo Mondi #include <linux/gpio/machine.h>
26c2f9b05fSJacopo Mondi #include <linux/platform_data/gpio_backlight.h>
27c2f9b05fSJacopo Mondi #include <linux/platform_data/tsc2007.h>
28c2f9b05fSJacopo Mondi #include <linux/platform_device.h>
29d4c191dfSGuennadi Liakhovetski #include <linux/regulator/fixed.h>
30d4c191dfSGuennadi Liakhovetski #include <linux/regulator/machine.h>
31cf8e56bfSYoshihiro Shimoda #include <linux/sh_eth.h>
329307d115SPaul Mundt #include <linux/sh_intc.h>
33c2f9b05fSJacopo Mondi #include <linux/spi/mmc_spi.h>
34c2f9b05fSJacopo Mondi #include <linux/spi/sh_msiof.h>
35c2f9b05fSJacopo Mondi #include <linux/spi/spi.h>
36c2f9b05fSJacopo Mondi #include <linux/usb/r8a66597.h>
37c2f9b05fSJacopo Mondi #include <linux/usb/renesas_usbhs.h>
38a1ad8033SGuennadi Liakhovetski #include <linux/videodev2.h>
39c2f9b05fSJacopo Mondi 
40c2f9b05fSJacopo Mondi #include <media/drv-intf/renesas-ceu.h>
41c2f9b05fSJacopo Mondi #include <media/i2c/mt9t112.h>
42c2f9b05fSJacopo Mondi #include <media/i2c/tw9910.h>
43c2f9b05fSJacopo Mondi 
441980fdc4SKuninori Morimoto #include <sound/sh_fsi.h>
45064bfadaSKuninori Morimoto #include <sound/simple_card.h>
46c2f9b05fSJacopo Mondi 
47c2f9b05fSJacopo Mondi #include <video/sh_mobile_lcdc.h>
484138b740SKuninori Morimoto 
494138b740SKuninori Morimoto /*
50b7056bc1SKuninori Morimoto  *  Address      Interface        BusWidth
51b7056bc1SKuninori Morimoto  *-----------------------------------------
52b7056bc1SKuninori Morimoto  *  0x0000_0000  uboot            16bit
53b7056bc1SKuninori Morimoto  *  0x0004_0000  Linux romImage   16bit
54b7056bc1SKuninori Morimoto  *  0x0014_0000  MTD for Linux    16bit
55b7056bc1SKuninori Morimoto  *  0x0400_0000  Internal I/O     16/32bit
56b7056bc1SKuninori Morimoto  *  0x0800_0000  DRAM             32bit
57b7056bc1SKuninori Morimoto  *  0x1800_0000  MFI              16bit
584138b740SKuninori Morimoto  */
594138b740SKuninori Morimoto 
609c472c4dSKuninori Morimoto /* SWITCH
619c472c4dSKuninori Morimoto  *------------------------------
629c472c4dSKuninori Morimoto  * DS2[1] = FlashROM write protect  ON     : write protect
639c472c4dSKuninori Morimoto  *                                  OFF    : No write protect
649c472c4dSKuninori Morimoto  * DS2[2] = RMII / TS, SCIF         ON     : RMII
659c472c4dSKuninori Morimoto  *                                  OFF    : TS, SCIF3
669c472c4dSKuninori Morimoto  * DS2[3] = Camera / Video          ON     : Camera
679c472c4dSKuninori Morimoto  *                                  OFF    : NTSC/PAL (IN)
689c472c4dSKuninori Morimoto  * DS2[5] = NTSC_OUT Clock          ON     : On board OSC
699c472c4dSKuninori Morimoto  *                                  OFF    : SH7724 DV_CLK
709c472c4dSKuninori Morimoto  * DS2[6-7] = MMC / SD              ON-OFF : SD
719c472c4dSKuninori Morimoto  *                                  OFF-ON : MMC
729c472c4dSKuninori Morimoto  */
739c472c4dSKuninori Morimoto 
74035688d9SKuninori Morimoto /*
75035688d9SKuninori Morimoto  * FSI - DA7210
76035688d9SKuninori Morimoto  *
77035688d9SKuninori Morimoto  * it needs amixer settings for playing
78035688d9SKuninori Morimoto  *
79035688d9SKuninori Morimoto  * amixer set 'HeadPhone' 80
80035688d9SKuninori Morimoto  * amixer set 'Out Mixer Left DAC Left' on
81035688d9SKuninori Morimoto  * amixer set 'Out Mixer Right DAC Right' on
82035688d9SKuninori Morimoto  */
83035688d9SKuninori Morimoto 
84c2f9b05fSJacopo Mondi #define CEU_BUFFER_MEMORY_SIZE		(4 << 20)
85c2f9b05fSJacopo Mondi static phys_addr_t ceu0_dma_membase;
86c2f9b05fSJacopo Mondi static phys_addr_t ceu1_dma_membase;
87c2f9b05fSJacopo Mondi 
884138b740SKuninori Morimoto /* Heartbeat */
894138b740SKuninori Morimoto static unsigned char led_pos[] = { 0, 1, 2, 3 };
90a09d2831SPaul Mundt 
914138b740SKuninori Morimoto static struct heartbeat_data heartbeat_data = {
924138b740SKuninori Morimoto 	.nr_bits = 4,
934138b740SKuninori Morimoto 	.bit_pos = led_pos,
944138b740SKuninori Morimoto };
954138b740SKuninori Morimoto 
96a09d2831SPaul Mundt static struct resource heartbeat_resource = {
974138b740SKuninori Morimoto 	.start  = 0xA405012C, /* PTG */
984138b740SKuninori Morimoto 	.end    = 0xA405012E - 1,
99a09d2831SPaul Mundt 	.flags  = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
1004138b740SKuninori Morimoto };
1014138b740SKuninori Morimoto 
1024138b740SKuninori Morimoto static struct platform_device heartbeat_device = {
1034138b740SKuninori Morimoto 	.name           = "heartbeat",
1044138b740SKuninori Morimoto 	.id             = -1,
1054138b740SKuninori Morimoto 	.dev = {
1064138b740SKuninori Morimoto 		.platform_data = &heartbeat_data,
1074138b740SKuninori Morimoto 	},
108a09d2831SPaul Mundt 	.num_resources  = 1,
109a09d2831SPaul Mundt 	.resource       = &heartbeat_resource,
1104138b740SKuninori Morimoto };
1114138b740SKuninori Morimoto 
1124138b740SKuninori Morimoto /* MTD */
1134138b740SKuninori Morimoto static struct mtd_partition nor_flash_partitions[] = {
1144138b740SKuninori Morimoto 	{
115b7056bc1SKuninori Morimoto 		.name = "boot loader",
1164138b740SKuninori Morimoto 		.offset = 0,
117b7056bc1SKuninori Morimoto 		.size = (5 * 1024 * 1024),
118d5ce010cSKuninori Morimoto 		.mask_flags = MTD_WRITEABLE,  /* force read-only */
1194138b740SKuninori Morimoto 	}, {
1204138b740SKuninori Morimoto 		.name = "free-area",
1214138b740SKuninori Morimoto 		.offset = MTDPART_OFS_APPEND,
1224138b740SKuninori Morimoto 		.size = MTDPART_SIZ_FULL,
1234138b740SKuninori Morimoto 	},
1244138b740SKuninori Morimoto };
1254138b740SKuninori Morimoto 
1264138b740SKuninori Morimoto static struct physmap_flash_data nor_flash_data = {
1274138b740SKuninori Morimoto 	.width		= 2,
1284138b740SKuninori Morimoto 	.parts		= nor_flash_partitions,
1294138b740SKuninori Morimoto 	.nr_parts	= ARRAY_SIZE(nor_flash_partitions),
1304138b740SKuninori Morimoto };
1314138b740SKuninori Morimoto 
1324138b740SKuninori Morimoto static struct resource nor_flash_resources[] = {
1334138b740SKuninori Morimoto 	[0] = {
1344138b740SKuninori Morimoto 		.name	= "NOR Flash",
1354138b740SKuninori Morimoto 		.start	= 0x00000000,
1364138b740SKuninori Morimoto 		.end	= 0x03ffffff,
1374138b740SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
1384138b740SKuninori Morimoto 	}
1394138b740SKuninori Morimoto };
1404138b740SKuninori Morimoto 
1414138b740SKuninori Morimoto static struct platform_device nor_flash_device = {
1424138b740SKuninori Morimoto 	.name		= "physmap-flash",
1434138b740SKuninori Morimoto 	.resource	= nor_flash_resources,
1444138b740SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(nor_flash_resources),
1454138b740SKuninori Morimoto 	.dev		= {
1464138b740SKuninori Morimoto 		.platform_data = &nor_flash_data,
1474138b740SKuninori Morimoto 	},
1484138b740SKuninori Morimoto };
1494138b740SKuninori Morimoto 
15035a35408SKuninori Morimoto /* SH Eth */
15135a35408SKuninori Morimoto #define SH_ETH_ADDR	(0xA4600000)
15235a35408SKuninori Morimoto static struct resource sh_eth_resources[] = {
15335a35408SKuninori Morimoto 	[0] = {
15435a35408SKuninori Morimoto 		.start = SH_ETH_ADDR,
15535a35408SKuninori Morimoto 		.end   = SH_ETH_ADDR + 0x1FC,
15635a35408SKuninori Morimoto 		.flags = IORESOURCE_MEM,
15735a35408SKuninori Morimoto 	},
15835a35408SKuninori Morimoto 	[1] = {
1599307d115SPaul Mundt 		.start = evt2irq(0xd60),
16035a35408SKuninori Morimoto 		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
16135a35408SKuninori Morimoto 	},
16235a35408SKuninori Morimoto };
16335a35408SKuninori Morimoto 
1643ce09334SKuninori Morimoto static struct sh_eth_plat_data sh_eth_plat = {
16535a35408SKuninori Morimoto 	.phy = 0x1f, /* SMSC LAN8700 */
1669055f895SYoshihiro Shimoda 	.phy_interface = PHY_INTERFACE_MODE_MII,
167acf3cc28SKuninori Morimoto 	.ether_link_active_low = 1
16835a35408SKuninori Morimoto };
16935a35408SKuninori Morimoto 
17035a35408SKuninori Morimoto static struct platform_device sh_eth_device = {
1719c3beaabSSergei Shtylyov 	.name = "sh7724-ether",
17235a35408SKuninori Morimoto 	.id = 0,
17335a35408SKuninori Morimoto 	.dev = {
17435a35408SKuninori Morimoto 		.platform_data = &sh_eth_plat,
17535a35408SKuninori Morimoto 	},
17635a35408SKuninori Morimoto 	.num_resources = ARRAY_SIZE(sh_eth_resources),
17735a35408SKuninori Morimoto 	.resource = sh_eth_resources,
17835a35408SKuninori Morimoto };
17935a35408SKuninori Morimoto 
180907050a3SKuninori Morimoto /* USB0 host */
1813ce09334SKuninori Morimoto static void usb0_port_power(int port, int power)
182907050a3SKuninori Morimoto {
183907050a3SKuninori Morimoto 	gpio_set_value(GPIO_PTB4, power);
184907050a3SKuninori Morimoto }
185907050a3SKuninori Morimoto 
186907050a3SKuninori Morimoto static struct r8a66597_platdata usb0_host_data = {
187907050a3SKuninori Morimoto 	.on_chip = 1,
188907050a3SKuninori Morimoto 	.port_power = usb0_port_power,
189907050a3SKuninori Morimoto };
190907050a3SKuninori Morimoto 
191907050a3SKuninori Morimoto static struct resource usb0_host_resources[] = {
192907050a3SKuninori Morimoto 	[0] = {
193907050a3SKuninori Morimoto 		.start	= 0xa4d80000,
194907050a3SKuninori Morimoto 		.end	= 0xa4d80124 - 1,
195907050a3SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
196907050a3SKuninori Morimoto 	},
197907050a3SKuninori Morimoto 	[1] = {
1989307d115SPaul Mundt 		.start	= evt2irq(0xa20),
1999307d115SPaul Mundt 		.end	= evt2irq(0xa20),
200907050a3SKuninori Morimoto 		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
201907050a3SKuninori Morimoto 	},
202907050a3SKuninori Morimoto };
203907050a3SKuninori Morimoto 
204907050a3SKuninori Morimoto static struct platform_device usb0_host_device = {
205907050a3SKuninori Morimoto 	.name		= "r8a66597_hcd",
206907050a3SKuninori Morimoto 	.id		= 0,
207907050a3SKuninori Morimoto 	.dev = {
208907050a3SKuninori Morimoto 		.dma_mask		= NULL,         /*  not use dma */
209907050a3SKuninori Morimoto 		.coherent_dma_mask	= 0xffffffff,
210907050a3SKuninori Morimoto 		.platform_data		= &usb0_host_data,
211907050a3SKuninori Morimoto 	},
212907050a3SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(usb0_host_resources),
213907050a3SKuninori Morimoto 	.resource	= usb0_host_resources,
214907050a3SKuninori Morimoto };
215907050a3SKuninori Morimoto 
2163714a9a0SKuninori Morimoto /* USB1 host/function */
2173ce09334SKuninori Morimoto static void usb1_port_power(int port, int power)
218907050a3SKuninori Morimoto {
219907050a3SKuninori Morimoto 	gpio_set_value(GPIO_PTB5, power);
220907050a3SKuninori Morimoto }
221907050a3SKuninori Morimoto 
2223714a9a0SKuninori Morimoto static struct r8a66597_platdata usb1_common_data = {
223907050a3SKuninori Morimoto 	.on_chip = 1,
224907050a3SKuninori Morimoto 	.port_power = usb1_port_power,
225907050a3SKuninori Morimoto };
226907050a3SKuninori Morimoto 
2273714a9a0SKuninori Morimoto static struct resource usb1_common_resources[] = {
228907050a3SKuninori Morimoto 	[0] = {
229907050a3SKuninori Morimoto 		.start	= 0xa4d90000,
230907050a3SKuninori Morimoto 		.end	= 0xa4d90124 - 1,
231907050a3SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
232907050a3SKuninori Morimoto 	},
233907050a3SKuninori Morimoto 	[1] = {
2349307d115SPaul Mundt 		.start	= evt2irq(0xa40),
2359307d115SPaul Mundt 		.end	= evt2irq(0xa40),
236907050a3SKuninori Morimoto 		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
237907050a3SKuninori Morimoto 	},
238907050a3SKuninori Morimoto };
239907050a3SKuninori Morimoto 
2403714a9a0SKuninori Morimoto static struct platform_device usb1_common_device = {
2413714a9a0SKuninori Morimoto 	/* .name will be added in arch_setup */
242907050a3SKuninori Morimoto 	.id		= 1,
243907050a3SKuninori Morimoto 	.dev = {
244907050a3SKuninori Morimoto 		.dma_mask		= NULL,         /*  not use dma */
245907050a3SKuninori Morimoto 		.coherent_dma_mask	= 0xffffffff,
2463714a9a0SKuninori Morimoto 		.platform_data		= &usb1_common_data,
247907050a3SKuninori Morimoto 	},
2483714a9a0SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(usb1_common_resources),
2493714a9a0SKuninori Morimoto 	.resource	= usb1_common_resources,
250907050a3SKuninori Morimoto };
251907050a3SKuninori Morimoto 
252fb2e7394SKuninori Morimoto /*
253fb2e7394SKuninori Morimoto  * USBHS
254fb2e7394SKuninori Morimoto  */
255fb2e7394SKuninori Morimoto static int usbhs_get_id(struct platform_device *pdev)
256fb2e7394SKuninori Morimoto {
257fb2e7394SKuninori Morimoto 	return gpio_get_value(GPIO_PTB3);
258fb2e7394SKuninori Morimoto }
259fb2e7394SKuninori Morimoto 
260225da3e3SKuninori Morimoto static int usbhs_phy_reset(struct platform_device *pdev)
2611ca8fe38SKuninori Morimoto {
2621ca8fe38SKuninori Morimoto 	/* enable vbus if HOST */
2631ca8fe38SKuninori Morimoto 	if (!gpio_get_value(GPIO_PTB3))
2641ca8fe38SKuninori Morimoto 		gpio_set_value(GPIO_PTB5, 1);
265225da3e3SKuninori Morimoto 
266225da3e3SKuninori Morimoto 	return 0;
2671ca8fe38SKuninori Morimoto }
2681ca8fe38SKuninori Morimoto 
269fb2e7394SKuninori Morimoto static struct renesas_usbhs_platform_info usbhs_info = {
270fb2e7394SKuninori Morimoto 	.platform_callback = {
271fb2e7394SKuninori Morimoto 		.get_id		= usbhs_get_id,
2721ca8fe38SKuninori Morimoto 		.phy_reset	= usbhs_phy_reset,
273fb2e7394SKuninori Morimoto 	},
274fb2e7394SKuninori Morimoto 	.driver_param = {
275fb2e7394SKuninori Morimoto 		.buswait_bwait		= 4,
276fb2e7394SKuninori Morimoto 		.detection_delay	= 5,
2779f0fa799SKuninori Morimoto 		.d0_tx_id = SHDMA_SLAVE_USB1D0_TX,
2789f0fa799SKuninori Morimoto 		.d0_rx_id = SHDMA_SLAVE_USB1D0_RX,
2799f0fa799SKuninori Morimoto 		.d1_tx_id = SHDMA_SLAVE_USB1D1_TX,
2809f0fa799SKuninori Morimoto 		.d1_rx_id = SHDMA_SLAVE_USB1D1_RX,
281fb2e7394SKuninori Morimoto 	},
282fb2e7394SKuninori Morimoto };
283fb2e7394SKuninori Morimoto 
284fb2e7394SKuninori Morimoto static struct resource usbhs_resources[] = {
285fb2e7394SKuninori Morimoto 	[0] = {
286fb2e7394SKuninori Morimoto 		.start	= 0xa4d90000,
287fb2e7394SKuninori Morimoto 		.end	= 0xa4d90124 - 1,
288fb2e7394SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
289fb2e7394SKuninori Morimoto 	},
290fb2e7394SKuninori Morimoto 	[1] = {
2919307d115SPaul Mundt 		.start	= evt2irq(0xa40),
2929307d115SPaul Mundt 		.end	= evt2irq(0xa40),
293fb2e7394SKuninori Morimoto 		.flags	= IORESOURCE_IRQ,
294fb2e7394SKuninori Morimoto 	},
295fb2e7394SKuninori Morimoto };
296fb2e7394SKuninori Morimoto 
297fb2e7394SKuninori Morimoto static struct platform_device usbhs_device = {
298fb2e7394SKuninori Morimoto 	.name	= "renesas_usbhs",
299fb2e7394SKuninori Morimoto 	.id	= 1,
300fb2e7394SKuninori Morimoto 	.dev = {
301fb2e7394SKuninori Morimoto 		.dma_mask		= NULL,         /*  not use dma */
302fb2e7394SKuninori Morimoto 		.coherent_dma_mask	= 0xffffffff,
303fb2e7394SKuninori Morimoto 		.platform_data		= &usbhs_info,
304fb2e7394SKuninori Morimoto 	},
305fb2e7394SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(usbhs_resources),
306fb2e7394SKuninori Morimoto 	.resource	= usbhs_resources,
307fb2e7394SKuninori Morimoto };
308fb2e7394SKuninori Morimoto 
309fe79f919SLaurent Pinchart /* LCDC and backlight */
310e04008ebSJesper Juhl static const struct fb_videomode ecovec_lcd_modes[] = {
31144432407SGuennadi Liakhovetski 	{
31244432407SGuennadi Liakhovetski 		.name		= "Panel",
31344432407SGuennadi Liakhovetski 		.xres		= 800,
31444432407SGuennadi Liakhovetski 		.yres		= 480,
31544432407SGuennadi Liakhovetski 		.left_margin	= 220,
31644432407SGuennadi Liakhovetski 		.right_margin	= 110,
31744432407SGuennadi Liakhovetski 		.hsync_len	= 70,
31844432407SGuennadi Liakhovetski 		.upper_margin	= 20,
31944432407SGuennadi Liakhovetski 		.lower_margin	= 5,
32044432407SGuennadi Liakhovetski 		.vsync_len	= 5,
32144432407SGuennadi Liakhovetski 		.sync		= 0, /* hsync and vsync are active low */
32244432407SGuennadi Liakhovetski 	},
32344432407SGuennadi Liakhovetski };
32444432407SGuennadi Liakhovetski 
325e04008ebSJesper Juhl static const struct fb_videomode ecovec_dvi_modes[] = {
32644432407SGuennadi Liakhovetski 	{
32744432407SGuennadi Liakhovetski 		.name		= "DVI",
32844432407SGuennadi Liakhovetski 		.xres		= 1280,
32944432407SGuennadi Liakhovetski 		.yres		= 720,
33044432407SGuennadi Liakhovetski 		.left_margin	= 220,
33144432407SGuennadi Liakhovetski 		.right_margin	= 110,
33244432407SGuennadi Liakhovetski 		.hsync_len	= 40,
33344432407SGuennadi Liakhovetski 		.upper_margin	= 20,
33444432407SGuennadi Liakhovetski 		.lower_margin	= 5,
33544432407SGuennadi Liakhovetski 		.vsync_len	= 5,
33644432407SGuennadi Liakhovetski 		.sync = 0, /* hsync and vsync are active low */
33744432407SGuennadi Liakhovetski 	},
33844432407SGuennadi Liakhovetski };
33944432407SGuennadi Liakhovetski 
340fa3ba51bSKuninori Morimoto static struct sh_mobile_lcdc_info lcdc_info = {
341fa3ba51bSKuninori Morimoto 	.ch[0] = {
342fa3ba51bSKuninori Morimoto 		.interface_type = RGB18,
343fa3ba51bSKuninori Morimoto 		.chan = LCDC_CHAN_MAINLCD,
344edd153a3SLaurent Pinchart 		.fourcc = V4L2_PIX_FMT_RGB565,
345afaad83bSLaurent Pinchart 		.panel_cfg = { /* 7.0 inch */
346fa3ba51bSKuninori Morimoto 			.width = 152,
347fa3ba51bSKuninori Morimoto 			.height = 91,
348fa3ba51bSKuninori Morimoto 		},
349fa3ba51bSKuninori Morimoto 	}
350fa3ba51bSKuninori Morimoto };
351fa3ba51bSKuninori Morimoto 
352fa3ba51bSKuninori Morimoto static struct resource lcdc_resources[] = {
353fa3ba51bSKuninori Morimoto 	[0] = {
354fa3ba51bSKuninori Morimoto 		.name	= "LCDC",
355fa3ba51bSKuninori Morimoto 		.start	= 0xfe940000,
356a6f15adeSPhil Edworthy 		.end	= 0xfe942fff,
357fa3ba51bSKuninori Morimoto 		.flags	= IORESOURCE_MEM,
358fa3ba51bSKuninori Morimoto 	},
359fa3ba51bSKuninori Morimoto 	[1] = {
3609307d115SPaul Mundt 		.start	= evt2irq(0xf40),
361fa3ba51bSKuninori Morimoto 		.flags	= IORESOURCE_IRQ,
362fa3ba51bSKuninori Morimoto 	},
363fa3ba51bSKuninori Morimoto };
364fa3ba51bSKuninori Morimoto 
365fa3ba51bSKuninori Morimoto static struct platform_device lcdc_device = {
366fa3ba51bSKuninori Morimoto 	.name		= "sh_mobile_lcdc_fb",
367fa3ba51bSKuninori Morimoto 	.num_resources	= ARRAY_SIZE(lcdc_resources),
368fa3ba51bSKuninori Morimoto 	.resource	= lcdc_resources,
369fa3ba51bSKuninori Morimoto 	.dev		= {
370fa3ba51bSKuninori Morimoto 		.platform_data	= &lcdc_info,
371fa3ba51bSKuninori Morimoto 	},
372fa3ba51bSKuninori Morimoto };
373fa3ba51bSKuninori Morimoto 
374fe79f919SLaurent Pinchart static struct gpio_backlight_platform_data gpio_backlight_data = {
375fe79f919SLaurent Pinchart 	.fbdev = &lcdc_device.dev,
376fe79f919SLaurent Pinchart 	.gpio = GPIO_PTR1,
377fe79f919SLaurent Pinchart 	.def_value = 1,
378fe79f919SLaurent Pinchart 	.name = "backlight",
379fe79f919SLaurent Pinchart };
380fe79f919SLaurent Pinchart 
381fe79f919SLaurent Pinchart static struct platform_device gpio_backlight_device = {
382fe79f919SLaurent Pinchart 	.name = "gpio-backlight",
383fe79f919SLaurent Pinchart 	.dev = {
384fe79f919SLaurent Pinchart 		.platform_data = &gpio_backlight_data,
385fe79f919SLaurent Pinchart 	},
386fe79f919SLaurent Pinchart };
387fe79f919SLaurent Pinchart 
3882153ad32SKuninori Morimoto /* CEU0 */
389c2f9b05fSJacopo Mondi static struct ceu_platform_data ceu0_pdata = {
390c2f9b05fSJacopo Mondi 	.num_subdevs			= 2,
391c2f9b05fSJacopo Mondi 	.subdevs = {
392c2f9b05fSJacopo Mondi 		{ /* [0] = mt9t112  */
393c2f9b05fSJacopo Mondi 			.flags		= 0,
394c2f9b05fSJacopo Mondi 			.bus_width	= 8,
395c2f9b05fSJacopo Mondi 			.bus_shift	= 0,
396c2f9b05fSJacopo Mondi 			.i2c_adapter_id	= 0,
397c2f9b05fSJacopo Mondi 			.i2c_address	= 0x3c,
398c2f9b05fSJacopo Mondi 		},
399c2f9b05fSJacopo Mondi 		{ /* [1] = tw9910  */
400c2f9b05fSJacopo Mondi 			.flags		= 0,
401c2f9b05fSJacopo Mondi 			.bus_width	= 8,
402c2f9b05fSJacopo Mondi 			.bus_shift	= 0,
403c2f9b05fSJacopo Mondi 			.i2c_adapter_id	= 0,
404c2f9b05fSJacopo Mondi 			.i2c_address	= 0x45,
405c2f9b05fSJacopo Mondi 		},
406c2f9b05fSJacopo Mondi 	},
4072153ad32SKuninori Morimoto };
4082153ad32SKuninori Morimoto 
4092153ad32SKuninori Morimoto static struct resource ceu0_resources[] = {
4102153ad32SKuninori Morimoto 	[0] = {
4112153ad32SKuninori Morimoto 		.name	= "CEU0",
4122153ad32SKuninori Morimoto 		.start	= 0xfe910000,
4132153ad32SKuninori Morimoto 		.end	= 0xfe91009f,
4142153ad32SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
4152153ad32SKuninori Morimoto 	},
4162153ad32SKuninori Morimoto 	[1] = {
4179307d115SPaul Mundt 		.start  = evt2irq(0x880),
4182153ad32SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
4192153ad32SKuninori Morimoto 	},
4202153ad32SKuninori Morimoto };
4212153ad32SKuninori Morimoto 
4222153ad32SKuninori Morimoto static struct platform_device ceu0_device = {
423c2f9b05fSJacopo Mondi 	.name		= "renesas-ceu",
424c2f9b05fSJacopo Mondi 	.id             = 0, /* ceu.0 */
4252153ad32SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(ceu0_resources),
4262153ad32SKuninori Morimoto 	.resource	= ceu0_resources,
4272153ad32SKuninori Morimoto 	.dev	= {
428c2f9b05fSJacopo Mondi 		.platform_data	= &ceu0_pdata,
4292153ad32SKuninori Morimoto 	},
4302153ad32SKuninori Morimoto };
4312153ad32SKuninori Morimoto 
4322153ad32SKuninori Morimoto /* CEU1 */
433c2f9b05fSJacopo Mondi static struct ceu_platform_data ceu1_pdata = {
434c2f9b05fSJacopo Mondi 	.num_subdevs			= 1,
435c2f9b05fSJacopo Mondi 	.subdevs = {
436c2f9b05fSJacopo Mondi 		{ /* [0] = mt9t112  */
437c2f9b05fSJacopo Mondi 			.flags		= 0,
438c2f9b05fSJacopo Mondi 			.bus_width	= 8,
439c2f9b05fSJacopo Mondi 			.bus_shift	= 0,
440c2f9b05fSJacopo Mondi 			.i2c_adapter_id	= 1,
441c2f9b05fSJacopo Mondi 			.i2c_address	= 0x3c,
442c2f9b05fSJacopo Mondi 		},
443c2f9b05fSJacopo Mondi 	},
4442153ad32SKuninori Morimoto };
4452153ad32SKuninori Morimoto 
4462153ad32SKuninori Morimoto static struct resource ceu1_resources[] = {
4472153ad32SKuninori Morimoto 	[0] = {
4482153ad32SKuninori Morimoto 		.name	= "CEU1",
4492153ad32SKuninori Morimoto 		.start	= 0xfe914000,
4502153ad32SKuninori Morimoto 		.end	= 0xfe91409f,
4512153ad32SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
4522153ad32SKuninori Morimoto 	},
4532153ad32SKuninori Morimoto 	[1] = {
4549307d115SPaul Mundt 		.start  = evt2irq(0x9e0),
4552153ad32SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
4562153ad32SKuninori Morimoto 	},
4572153ad32SKuninori Morimoto };
4582153ad32SKuninori Morimoto 
4592153ad32SKuninori Morimoto static struct platform_device ceu1_device = {
460c2f9b05fSJacopo Mondi 	.name		= "renesas-ceu",
461c2f9b05fSJacopo Mondi 	.id             = 1, /* ceu.1 */
4622153ad32SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(ceu1_resources),
4632153ad32SKuninori Morimoto 	.resource	= ceu1_resources,
4642153ad32SKuninori Morimoto 	.dev	= {
465c2f9b05fSJacopo Mondi 		.platform_data	= &ceu1_pdata,
466c2f9b05fSJacopo Mondi 	},
467c2f9b05fSJacopo Mondi };
468c2f9b05fSJacopo Mondi 
469c2f9b05fSJacopo Mondi /* Power up/down GPIOs for camera devices and video decoder */
470c2f9b05fSJacopo Mondi static struct gpiod_lookup_table tw9910_gpios = {
471c2f9b05fSJacopo Mondi 	.dev_id		= "0-0045",
472c2f9b05fSJacopo Mondi 	.table		= {
473c2f9b05fSJacopo Mondi 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTU2, "pdn", GPIO_ACTIVE_HIGH),
474c2f9b05fSJacopo Mondi 	},
475c2f9b05fSJacopo Mondi };
476c2f9b05fSJacopo Mondi 
477c2f9b05fSJacopo Mondi static struct gpiod_lookup_table mt9t112_0_gpios = {
478c2f9b05fSJacopo Mondi 	.dev_id		= "0-003c",
479c2f9b05fSJacopo Mondi 	.table		= {
480c2f9b05fSJacopo Mondi 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTA3, "standby",
481c2f9b05fSJacopo Mondi 			    GPIO_ACTIVE_HIGH),
482c2f9b05fSJacopo Mondi 	},
483c2f9b05fSJacopo Mondi };
484c2f9b05fSJacopo Mondi 
485c2f9b05fSJacopo Mondi static struct gpiod_lookup_table mt9t112_1_gpios = {
486c2f9b05fSJacopo Mondi 	.dev_id		= "1-003c",
487c2f9b05fSJacopo Mondi 	.table		= {
488c2f9b05fSJacopo Mondi 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTA4, "standby",
489c2f9b05fSJacopo Mondi 			    GPIO_ACTIVE_HIGH),
4902153ad32SKuninori Morimoto 	},
4912153ad32SKuninori Morimoto };
4922153ad32SKuninori Morimoto 
493125ecce6SKuninori Morimoto /* I2C device */
494c2f9b05fSJacopo Mondi static struct tw9910_video_info tw9910_info = {
495c2f9b05fSJacopo Mondi 	.buswidth	= 8,
496c2f9b05fSJacopo Mondi 	.mpout		= TW9910_MPO_FIELD,
497c2f9b05fSJacopo Mondi };
498c2f9b05fSJacopo Mondi 
499c2f9b05fSJacopo Mondi static struct mt9t112_platform_data mt9t112_0_pdata = {
500c2f9b05fSJacopo Mondi 	.flags = MT9T112_FLAG_PCLK_RISING_EDGE,
501c2f9b05fSJacopo Mondi 	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
502c2f9b05fSJacopo Mondi };
503c2f9b05fSJacopo Mondi 
504c2f9b05fSJacopo Mondi static struct mt9t112_platform_data mt9t112_1_pdata = {
505c2f9b05fSJacopo Mondi 	.flags = MT9T112_FLAG_PCLK_RISING_EDGE,
506c2f9b05fSJacopo Mondi 	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
507c2f9b05fSJacopo Mondi };
508c2f9b05fSJacopo Mondi 
5091980fdc4SKuninori Morimoto static struct i2c_board_info i2c0_devices[] = {
5101980fdc4SKuninori Morimoto 	{
5111980fdc4SKuninori Morimoto 		I2C_BOARD_INFO("da7210", 0x1a),
5121980fdc4SKuninori Morimoto 	},
513c2f9b05fSJacopo Mondi 	{
514c2f9b05fSJacopo Mondi 		I2C_BOARD_INFO("tw9910", 0x45),
515c2f9b05fSJacopo Mondi 		.platform_data = &tw9910_info,
516c2f9b05fSJacopo Mondi 	},
517c2f9b05fSJacopo Mondi 	{
518c2f9b05fSJacopo Mondi 		/* 1st camera */
519c2f9b05fSJacopo Mondi 		I2C_BOARD_INFO("mt9t112", 0x3c),
520c2f9b05fSJacopo Mondi 		.platform_data = &mt9t112_0_pdata,
521c2f9b05fSJacopo Mondi 	},
5221980fdc4SKuninori Morimoto };
5231980fdc4SKuninori Morimoto 
524125ecce6SKuninori Morimoto static struct i2c_board_info i2c1_devices[] = {
525125ecce6SKuninori Morimoto 	{
526125ecce6SKuninori Morimoto 		I2C_BOARD_INFO("r2025sd", 0x32),
527125ecce6SKuninori Morimoto 	},
528ea440783SNISHIMOTO Hiroki 	{
529ea440783SNISHIMOTO Hiroki 		I2C_BOARD_INFO("lis3lv02d", 0x1c),
5309307d115SPaul Mundt 		.irq = evt2irq(0x620),
531c2f9b05fSJacopo Mondi 	},
532c2f9b05fSJacopo Mondi 	{
533c2f9b05fSJacopo Mondi 		/* 2nd camera */
534c2f9b05fSJacopo Mondi 		I2C_BOARD_INFO("mt9t112", 0x3c),
535c2f9b05fSJacopo Mondi 		.platform_data = &mt9t112_1_pdata,
536c2f9b05fSJacopo Mondi 	},
537125ecce6SKuninori Morimoto };
538125ecce6SKuninori Morimoto 
539e9103e74SKuninori Morimoto /* KEYSC */
540e9103e74SKuninori Morimoto static struct sh_keysc_info keysc_info = {
541e9103e74SKuninori Morimoto 	.mode		= SH_KEYSC_MODE_1,
542e9103e74SKuninori Morimoto 	.scan_timing	= 3,
543e9103e74SKuninori Morimoto 	.delay		= 50,
544e9103e74SKuninori Morimoto 	.kycr2_delay	= 100,
545e9103e74SKuninori Morimoto 	.keycodes	= { KEY_1, 0, 0, 0, 0,
546e9103e74SKuninori Morimoto 			    KEY_2, 0, 0, 0, 0,
547e9103e74SKuninori Morimoto 			    KEY_3, 0, 0, 0, 0,
548e9103e74SKuninori Morimoto 			    KEY_4, 0, 0, 0, 0,
549e9103e74SKuninori Morimoto 			    KEY_5, 0, 0, 0, 0,
550e9103e74SKuninori Morimoto 			    KEY_6, 0, 0, 0, 0, },
551e9103e74SKuninori Morimoto };
552e9103e74SKuninori Morimoto 
553e9103e74SKuninori Morimoto static struct resource keysc_resources[] = {
554e9103e74SKuninori Morimoto 	[0] = {
555e9103e74SKuninori Morimoto 		.name	= "KEYSC",
556e9103e74SKuninori Morimoto 		.start  = 0x044b0000,
557e9103e74SKuninori Morimoto 		.end    = 0x044b000f,
558e9103e74SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
559e9103e74SKuninori Morimoto 	},
560e9103e74SKuninori Morimoto 	[1] = {
5619307d115SPaul Mundt 		.start  = evt2irq(0xbe0),
562e9103e74SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
563e9103e74SKuninori Morimoto 	},
564e9103e74SKuninori Morimoto };
565e9103e74SKuninori Morimoto 
566e9103e74SKuninori Morimoto static struct platform_device keysc_device = {
567e9103e74SKuninori Morimoto 	.name           = "sh_keysc",
568e9103e74SKuninori Morimoto 	.id             = 0, /* keysc0 clock */
569e9103e74SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(keysc_resources),
570e9103e74SKuninori Morimoto 	.resource       = keysc_resources,
571e9103e74SKuninori Morimoto 	.dev	= {
572e9103e74SKuninori Morimoto 		.platform_data	= &keysc_info,
573e9103e74SKuninori Morimoto 	},
574e9103e74SKuninori Morimoto };
575e9103e74SKuninori Morimoto 
5768810e055SKuninori Morimoto /* TouchScreen */
5779307d115SPaul Mundt #define IRQ0 evt2irq(0x600)
5789307d115SPaul Mundt 
57907f9e5cfSDenis Carikli static int ts_get_pendown_state(struct device *dev)
5805d75b3a2SPaul Mundt {
5815d75b3a2SPaul Mundt 	int val = 0;
5825d75b3a2SPaul Mundt 	gpio_free(GPIO_FN_INTC_IRQ0);
5835d75b3a2SPaul Mundt 	gpio_request(GPIO_PTZ0, NULL);
5845d75b3a2SPaul Mundt 	gpio_direction_input(GPIO_PTZ0);
5855d75b3a2SPaul Mundt 
5865d75b3a2SPaul Mundt 	val = gpio_get_value(GPIO_PTZ0);
5875d75b3a2SPaul Mundt 
5885d75b3a2SPaul Mundt 	gpio_free(GPIO_PTZ0);
5895d75b3a2SPaul Mundt 	gpio_request(GPIO_FN_INTC_IRQ0, NULL);
5905d75b3a2SPaul Mundt 
5915d75b3a2SPaul Mundt 	return val ? 0 : 1;
5925d75b3a2SPaul Mundt }
5935d75b3a2SPaul Mundt 
5945d75b3a2SPaul Mundt static int ts_init(void)
5955d75b3a2SPaul Mundt {
5965d75b3a2SPaul Mundt 	gpio_request(GPIO_FN_INTC_IRQ0, NULL);
5975d75b3a2SPaul Mundt 	return 0;
5985d75b3a2SPaul Mundt }
5995d75b3a2SPaul Mundt 
6003ce09334SKuninori Morimoto static struct tsc2007_platform_data tsc2007_info = {
6018810e055SKuninori Morimoto 	.model			= 2007,
6025d75b3a2SPaul Mundt 	.x_plate_ohms		= 180,
6035d75b3a2SPaul Mundt 	.get_pendown_state	= ts_get_pendown_state,
6045d75b3a2SPaul Mundt 	.init_platform_hw	= ts_init,
6058810e055SKuninori Morimoto };
6068810e055SKuninori Morimoto 
6078810e055SKuninori Morimoto static struct i2c_board_info ts_i2c_clients = {
6088810e055SKuninori Morimoto 	I2C_BOARD_INFO("tsc2007", 0x48),
6098810e055SKuninori Morimoto 	.type		= "tsc2007",
6108810e055SKuninori Morimoto 	.platform_data	= &tsc2007_info,
6118810e055SKuninori Morimoto 	.irq		= IRQ0,
6128810e055SKuninori Morimoto };
6138810e055SKuninori Morimoto 
614d4c191dfSGuennadi Liakhovetski static struct regulator_consumer_supply cn12_power_consumers[] =
615d4c191dfSGuennadi Liakhovetski {
616d4c191dfSGuennadi Liakhovetski 	REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
617d4c191dfSGuennadi Liakhovetski 	REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
618d4c191dfSGuennadi Liakhovetski 	REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
619d4c191dfSGuennadi Liakhovetski 	REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
620d4c191dfSGuennadi Liakhovetski };
621d4c191dfSGuennadi Liakhovetski 
622d4c191dfSGuennadi Liakhovetski static struct regulator_init_data cn12_power_init_data = {
623d4c191dfSGuennadi Liakhovetski 	.constraints = {
624d4c191dfSGuennadi Liakhovetski 		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
625d4c191dfSGuennadi Liakhovetski 	},
626d4c191dfSGuennadi Liakhovetski 	.num_consumer_supplies  = ARRAY_SIZE(cn12_power_consumers),
627d4c191dfSGuennadi Liakhovetski 	.consumer_supplies      = cn12_power_consumers,
628d4c191dfSGuennadi Liakhovetski };
629d4c191dfSGuennadi Liakhovetski 
630d4c191dfSGuennadi Liakhovetski static struct fixed_voltage_config cn12_power_info = {
631d4c191dfSGuennadi Liakhovetski 	.supply_name = "CN12 SD/MMC Vdd",
632d4c191dfSGuennadi Liakhovetski 	.microvolts = 3300000,
633d4c191dfSGuennadi Liakhovetski 	.init_data = &cn12_power_init_data,
634d4c191dfSGuennadi Liakhovetski };
635d4c191dfSGuennadi Liakhovetski 
636d4c191dfSGuennadi Liakhovetski static struct platform_device cn12_power = {
637d4c191dfSGuennadi Liakhovetski 	.name = "reg-fixed-voltage",
638d4c191dfSGuennadi Liakhovetski 	.id   = 0,
639d4c191dfSGuennadi Liakhovetski 	.dev  = {
640d4c191dfSGuennadi Liakhovetski 		.platform_data = &cn12_power_info,
641d4c191dfSGuennadi Liakhovetski 	},
642d4c191dfSGuennadi Liakhovetski };
643d4c191dfSGuennadi Liakhovetski 
644efdfeb07SLinus Walleij static struct gpiod_lookup_table cn12_power_gpiod_table = {
645efdfeb07SLinus Walleij 	.dev_id = "reg-fixed-voltage.0",
646efdfeb07SLinus Walleij 	.table = {
647efdfeb07SLinus Walleij 		/* Offset 7 on port B */
648efdfeb07SLinus Walleij 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7,
649efdfeb07SLinus Walleij 			    NULL, GPIO_ACTIVE_HIGH),
650efdfeb07SLinus Walleij 		{ },
651efdfeb07SLinus Walleij 	},
652efdfeb07SLinus Walleij };
653efdfeb07SLinus Walleij 
6545744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
6551238c684SYusuke Goda /* SDHI0 */
656d4c191dfSGuennadi Liakhovetski static struct regulator_consumer_supply sdhi0_power_consumers[] =
657d4c191dfSGuennadi Liakhovetski {
658d4c191dfSGuennadi Liakhovetski 	REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
659d4c191dfSGuennadi Liakhovetski 	REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
660d4c191dfSGuennadi Liakhovetski };
661d4c191dfSGuennadi Liakhovetski 
662d4c191dfSGuennadi Liakhovetski static struct regulator_init_data sdhi0_power_init_data = {
663d4c191dfSGuennadi Liakhovetski 	.constraints = {
664d4c191dfSGuennadi Liakhovetski 		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
665d4c191dfSGuennadi Liakhovetski 	},
666d4c191dfSGuennadi Liakhovetski 	.num_consumer_supplies  = ARRAY_SIZE(sdhi0_power_consumers),
667d4c191dfSGuennadi Liakhovetski 	.consumer_supplies      = sdhi0_power_consumers,
668d4c191dfSGuennadi Liakhovetski };
669d4c191dfSGuennadi Liakhovetski 
670d4c191dfSGuennadi Liakhovetski static struct fixed_voltage_config sdhi0_power_info = {
671d4c191dfSGuennadi Liakhovetski 	.supply_name = "CN11 SD/MMC Vdd",
672d4c191dfSGuennadi Liakhovetski 	.microvolts = 3300000,
673d4c191dfSGuennadi Liakhovetski 	.init_data = &sdhi0_power_init_data,
674d4c191dfSGuennadi Liakhovetski };
675d4c191dfSGuennadi Liakhovetski 
676d4c191dfSGuennadi Liakhovetski static struct platform_device sdhi0_power = {
677d4c191dfSGuennadi Liakhovetski 	.name = "reg-fixed-voltage",
678d4c191dfSGuennadi Liakhovetski 	.id   = 1,
679d4c191dfSGuennadi Liakhovetski 	.dev  = {
680d4c191dfSGuennadi Liakhovetski 		.platform_data = &sdhi0_power_info,
681d4c191dfSGuennadi Liakhovetski 	},
682d4c191dfSGuennadi Liakhovetski };
683d4c191dfSGuennadi Liakhovetski 
684efdfeb07SLinus Walleij static struct gpiod_lookup_table sdhi0_power_gpiod_table = {
685efdfeb07SLinus Walleij 	.dev_id = "reg-fixed-voltage.1",
686efdfeb07SLinus Walleij 	.table = {
687efdfeb07SLinus Walleij 		/* Offset 6 on port B */
688efdfeb07SLinus Walleij 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6,
689efdfeb07SLinus Walleij 			    NULL, GPIO_ACTIVE_HIGH),
690efdfeb07SLinus Walleij 		{ },
691efdfeb07SLinus Walleij 	},
692efdfeb07SLinus Walleij };
693efdfeb07SLinus Walleij 
694faed9303SLinus Walleij static struct gpiod_lookup_table sdhi0_gpio_table = {
695faed9303SLinus Walleij 	.dev_id = "sh_mobile_sdhi.0",
696faed9303SLinus Walleij 	.table = {
697faed9303SLinus Walleij 		/* Card detect */
698faed9303SLinus Walleij 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW),
699faed9303SLinus Walleij 		{ },
700faed9303SLinus Walleij 	},
701faed9303SLinus Walleij };
702faed9303SLinus Walleij 
70384f11d5bSKuninori Morimoto static struct tmio_mmc_data sdhi0_info = {
70484f11d5bSKuninori Morimoto 	.chan_priv_tx	= (void *)SHDMA_SLAVE_SDHI0_TX,
70584f11d5bSKuninori Morimoto 	.chan_priv_rx	= (void *)SHDMA_SLAVE_SDHI0_RX,
70684f11d5bSKuninori Morimoto 	.capabilities	= MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
7074eb80146SGuennadi Liakhovetski 			  MMC_CAP_NEEDS_POLL,
70898779ad8SMagnus Damm };
70998779ad8SMagnus Damm 
71096987d96SKuninori Morimoto static struct resource sdhi0_resources[] = {
71196987d96SKuninori Morimoto 	[0] = {
71296987d96SKuninori Morimoto 		.name	= "SDHI0",
71396987d96SKuninori Morimoto 		.start  = 0x04ce0000,
714d80e9221SGuennadi Liakhovetski 		.end    = 0x04ce00ff,
71596987d96SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
71696987d96SKuninori Morimoto 	},
71796987d96SKuninori Morimoto 	[1] = {
7189307d115SPaul Mundt 		.start  = evt2irq(0xe80),
71996987d96SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
72096987d96SKuninori Morimoto 	},
72196987d96SKuninori Morimoto };
72296987d96SKuninori Morimoto 
72396987d96SKuninori Morimoto static struct platform_device sdhi0_device = {
72496987d96SKuninori Morimoto 	.name           = "sh_mobile_sdhi",
72596987d96SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(sdhi0_resources),
72696987d96SKuninori Morimoto 	.resource       = sdhi0_resources,
72796987d96SKuninori Morimoto 	.id             = 0,
72898779ad8SMagnus Damm 	.dev	= {
72998779ad8SMagnus Damm 		.platform_data	= &sdhi0_info,
73098779ad8SMagnus Damm 	},
73196987d96SKuninori Morimoto };
73296987d96SKuninori Morimoto 
733d4c191dfSGuennadi Liakhovetski #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
734d4c191dfSGuennadi Liakhovetski /* SDHI1 */
73584f11d5bSKuninori Morimoto static struct tmio_mmc_data sdhi1_info = {
73684f11d5bSKuninori Morimoto 	.chan_priv_tx	= (void *)SHDMA_SLAVE_SDHI1_TX,
73784f11d5bSKuninori Morimoto 	.chan_priv_rx	= (void *)SHDMA_SLAVE_SDHI1_RX,
73884f11d5bSKuninori Morimoto 	.capabilities	= MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
7394eb80146SGuennadi Liakhovetski 			  MMC_CAP_NEEDS_POLL,
740faed9303SLinus Walleij };
741faed9303SLinus Walleij 
742faed9303SLinus Walleij static struct gpiod_lookup_table sdhi1_gpio_table = {
743faed9303SLinus Walleij 	.dev_id = "sh_mobile_sdhi.1",
744faed9303SLinus Walleij 	.table = {
745faed9303SLinus Walleij 		/* Card detect */
746faed9303SLinus Walleij 		GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW),
747faed9303SLinus Walleij 		{ },
748faed9303SLinus Walleij 	},
74998779ad8SMagnus Damm };
75098779ad8SMagnus Damm 
75196987d96SKuninori Morimoto static struct resource sdhi1_resources[] = {
75296987d96SKuninori Morimoto 	[0] = {
75396987d96SKuninori Morimoto 		.name	= "SDHI1",
75496987d96SKuninori Morimoto 		.start  = 0x04cf0000,
755d80e9221SGuennadi Liakhovetski 		.end    = 0x04cf00ff,
75696987d96SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
75796987d96SKuninori Morimoto 	},
75896987d96SKuninori Morimoto 	[1] = {
7599307d115SPaul Mundt 		.start  = evt2irq(0x4e0),
76096987d96SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
76196987d96SKuninori Morimoto 	},
76296987d96SKuninori Morimoto };
76396987d96SKuninori Morimoto 
76496987d96SKuninori Morimoto static struct platform_device sdhi1_device = {
76596987d96SKuninori Morimoto 	.name           = "sh_mobile_sdhi",
76696987d96SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(sdhi1_resources),
76796987d96SKuninori Morimoto 	.resource       = sdhi1_resources,
76896987d96SKuninori Morimoto 	.id             = 1,
76998779ad8SMagnus Damm 	.dev	= {
77098779ad8SMagnus Damm 		.platform_data	= &sdhi1_info,
77198779ad8SMagnus Damm 	},
77296987d96SKuninori Morimoto };
7731238c684SYusuke Goda #endif /* CONFIG_MMC_SH_MMCIF */
77496987d96SKuninori Morimoto 
7751ce4da7aSMagnus Damm #else
7761ce4da7aSMagnus Damm 
7779503e891SKuninori Morimoto /* MMC SPI */
7781ce4da7aSMagnus Damm static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
7791ce4da7aSMagnus Damm {
7801ce4da7aSMagnus Damm 	gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
7811ce4da7aSMagnus Damm }
7821ce4da7aSMagnus Damm 
7831ce4da7aSMagnus Damm static struct mmc_spi_platform_data mmc_spi_info = {
7841ce4da7aSMagnus Damm 	.caps = MMC_CAP_NEEDS_POLL,
785afa2c940SLaurent Pinchart 	.caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
7861ce4da7aSMagnus Damm 	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
7871ce4da7aSMagnus Damm 	.setpower = mmc_spi_setpower,
7885716fb9bSLinus Walleij };
7895716fb9bSLinus Walleij 
7905716fb9bSLinus Walleij static struct gpiod_lookup_table mmc_spi_gpio_table = {
7915716fb9bSLinus Walleij 	.dev_id = "mmc_spi.0", /* device "mmc_spi" @ CS0 */
7925716fb9bSLinus Walleij 	.table = {
7935716fb9bSLinus Walleij 		/* Card detect */
7945716fb9bSLinus Walleij 		GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY7, NULL, 0,
7955716fb9bSLinus Walleij 				GPIO_ACTIVE_LOW),
7965716fb9bSLinus Walleij 		/* Write protect */
7975716fb9bSLinus Walleij 		GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY6, NULL, 1,
7985716fb9bSLinus Walleij 				GPIO_ACTIVE_HIGH),
7995716fb9bSLinus Walleij 		{ },
8005716fb9bSLinus Walleij 	},
8011ce4da7aSMagnus Damm };
8021ce4da7aSMagnus Damm 
8031ce4da7aSMagnus Damm static struct spi_board_info spi_bus[] = {
8041ce4da7aSMagnus Damm 	{
8051ce4da7aSMagnus Damm 		.modalias	= "mmc_spi",
8061ce4da7aSMagnus Damm 		.platform_data	= &mmc_spi_info,
8071ce4da7aSMagnus Damm 		.max_speed_hz	= 5000000,
8081ce4da7aSMagnus Damm 		.mode		= SPI_MODE_0,
8091ce4da7aSMagnus Damm 		.controller_data = (void *) GPIO_PTM4,
8101ce4da7aSMagnus Damm 	},
8111ce4da7aSMagnus Damm };
8121ce4da7aSMagnus Damm 
8139503e891SKuninori Morimoto /* MSIOF0 */
8141ce4da7aSMagnus Damm static struct sh_msiof_spi_info msiof0_data = {
8151ce4da7aSMagnus Damm 	.num_chipselect = 1,
8161ce4da7aSMagnus Damm };
8171ce4da7aSMagnus Damm 
8181ce4da7aSMagnus Damm static struct resource msiof0_resources[] = {
8191ce4da7aSMagnus Damm 	[0] = {
8201ce4da7aSMagnus Damm 		.name	= "MSIOF0",
8211ce4da7aSMagnus Damm 		.start	= 0xa4c40000,
8221ce4da7aSMagnus Damm 		.end	= 0xa4c40063,
8231ce4da7aSMagnus Damm 		.flags	= IORESOURCE_MEM,
8241ce4da7aSMagnus Damm 	},
8251ce4da7aSMagnus Damm 	[1] = {
8269307d115SPaul Mundt 		.start	= evt2irq(0xc80),
8271ce4da7aSMagnus Damm 		.flags	= IORESOURCE_IRQ,
8281ce4da7aSMagnus Damm 	},
8291ce4da7aSMagnus Damm };
8301ce4da7aSMagnus Damm 
8311ce4da7aSMagnus Damm static struct platform_device msiof0_device = {
8321ce4da7aSMagnus Damm 	.name		= "spi_sh_msiof",
8331ce4da7aSMagnus Damm 	.id		= 0, /* MSIOF0 */
8341ce4da7aSMagnus Damm 	.dev = {
8351ce4da7aSMagnus Damm 		.platform_data = &msiof0_data,
8361ce4da7aSMagnus Damm 	},
8371ce4da7aSMagnus Damm 	.num_resources	= ARRAY_SIZE(msiof0_resources),
8381ce4da7aSMagnus Damm 	.resource	= msiof0_resources,
8391ce4da7aSMagnus Damm };
8401ce4da7aSMagnus Damm 
8411ce4da7aSMagnus Damm #endif
8421ce4da7aSMagnus Damm 
8431980fdc4SKuninori Morimoto /* FSI */
8441980fdc4SKuninori Morimoto static struct resource fsi_resources[] = {
8451980fdc4SKuninori Morimoto 	[0] = {
8461980fdc4SKuninori Morimoto 		.name	= "FSI",
8471980fdc4SKuninori Morimoto 		.start	= 0xFE3C0000,
8481980fdc4SKuninori Morimoto 		.end	= 0xFE3C021d,
8491980fdc4SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
8501980fdc4SKuninori Morimoto 	},
8511980fdc4SKuninori Morimoto 	[1] = {
8529307d115SPaul Mundt 		.start  = evt2irq(0xf80),
8531980fdc4SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
8541980fdc4SKuninori Morimoto 	},
8551980fdc4SKuninori Morimoto };
8561980fdc4SKuninori Morimoto 
8571980fdc4SKuninori Morimoto static struct platform_device fsi_device = {
8581980fdc4SKuninori Morimoto 	.name		= "sh_fsi",
8591980fdc4SKuninori Morimoto 	.id		= 0,
8601980fdc4SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(fsi_resources),
8611980fdc4SKuninori Morimoto 	.resource	= fsi_resources,
8621980fdc4SKuninori Morimoto };
8631980fdc4SKuninori Morimoto 
864064bfadaSKuninori Morimoto static struct asoc_simple_card_info fsi_da7210_info = {
865064bfadaSKuninori Morimoto 	.name		= "DA7210",
866064bfadaSKuninori Morimoto 	.card		= "FSIB-DA7210",
867064bfadaSKuninori Morimoto 	.codec		= "da7210.0-001a",
868064bfadaSKuninori Morimoto 	.platform	= "sh_fsi.0",
869c7a507eeSKuninori Morimoto 	.daifmt		= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM,
870a4a2992cSKuninori Morimoto 	.cpu_dai = {
871a4a2992cSKuninori Morimoto 		.name	= "fsib-dai",
872a4a2992cSKuninori Morimoto 	},
873a4a2992cSKuninori Morimoto 	.codec_dai = {
874a4a2992cSKuninori Morimoto 		.name	= "da7210-hifi",
875a4a2992cSKuninori Morimoto 	},
876064bfadaSKuninori Morimoto };
877064bfadaSKuninori Morimoto 
878064bfadaSKuninori Morimoto static struct platform_device fsi_da7210_device = {
879064bfadaSKuninori Morimoto 	.name	= "asoc-simple-card",
880064bfadaSKuninori Morimoto 	.dev	= {
881064bfadaSKuninori Morimoto 		.platform_data	= &fsi_da7210_info,
882ffb83e8cSKuninori Morimoto 		.coherent_dma_mask = DMA_BIT_MASK(32),
883ffb83e8cSKuninori Morimoto 		.dma_mask = &fsi_da7210_device.dev.coherent_dma_mask,
884064bfadaSKuninori Morimoto 	},
885064bfadaSKuninori Morimoto };
886064bfadaSKuninori Morimoto 
887064bfadaSKuninori Morimoto 
88826365716SKuninori Morimoto /* IrDA */
88926365716SKuninori Morimoto static struct resource irda_resources[] = {
89026365716SKuninori Morimoto 	[0] = {
89126365716SKuninori Morimoto 		.name	= "IrDA",
89226365716SKuninori Morimoto 		.start  = 0xA45D0000,
89326365716SKuninori Morimoto 		.end    = 0xA45D0049,
89426365716SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
89526365716SKuninori Morimoto 	},
89626365716SKuninori Morimoto 	[1] = {
8979307d115SPaul Mundt 		.start  = evt2irq(0x480),
89826365716SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
89926365716SKuninori Morimoto 	},
90026365716SKuninori Morimoto };
90126365716SKuninori Morimoto 
90226365716SKuninori Morimoto static struct platform_device irda_device = {
90326365716SKuninori Morimoto 	.name           = "sh_sir",
90426365716SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(irda_resources),
90526365716SKuninori Morimoto 	.resource       = irda_resources,
90626365716SKuninori Morimoto };
90726365716SKuninori Morimoto 
908b5dcee22SMauro Carvalho Chehab #include <media/i2c/ak881x.h>
909d647f0b7SMauro Carvalho Chehab #include <media/drv-intf/sh_vou.h>
910aee5ab0bSGuennadi Liakhovetski 
9113ce09334SKuninori Morimoto static struct ak881x_pdata ak881x_pdata = {
912aee5ab0bSGuennadi Liakhovetski 	.flags = AK881X_IF_MODE_SLAVE,
913aee5ab0bSGuennadi Liakhovetski };
914aee5ab0bSGuennadi Liakhovetski 
915aee5ab0bSGuennadi Liakhovetski static struct i2c_board_info ak8813 = {
916aee5ab0bSGuennadi Liakhovetski 	I2C_BOARD_INFO("ak8813", 0x20),
917aee5ab0bSGuennadi Liakhovetski 	.platform_data = &ak881x_pdata,
918aee5ab0bSGuennadi Liakhovetski };
919aee5ab0bSGuennadi Liakhovetski 
9203ce09334SKuninori Morimoto static struct sh_vou_pdata sh_vou_pdata = {
921aee5ab0bSGuennadi Liakhovetski 	.bus_fmt	= SH_VOU_BUS_8BIT,
922aee5ab0bSGuennadi Liakhovetski 	.flags		= SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
923aee5ab0bSGuennadi Liakhovetski 	.board_info	= &ak8813,
924aee5ab0bSGuennadi Liakhovetski 	.i2c_adap	= 0,
925aee5ab0bSGuennadi Liakhovetski };
926aee5ab0bSGuennadi Liakhovetski 
927aee5ab0bSGuennadi Liakhovetski static struct resource sh_vou_resources[] = {
928aee5ab0bSGuennadi Liakhovetski 	[0] = {
929aee5ab0bSGuennadi Liakhovetski 		.start  = 0xfe960000,
930aee5ab0bSGuennadi Liakhovetski 		.end    = 0xfe962043,
931aee5ab0bSGuennadi Liakhovetski 		.flags  = IORESOURCE_MEM,
932aee5ab0bSGuennadi Liakhovetski 	},
933aee5ab0bSGuennadi Liakhovetski 	[1] = {
9349307d115SPaul Mundt 		.start  = evt2irq(0x8e0),
935aee5ab0bSGuennadi Liakhovetski 		.flags  = IORESOURCE_IRQ,
936aee5ab0bSGuennadi Liakhovetski 	},
937aee5ab0bSGuennadi Liakhovetski };
938aee5ab0bSGuennadi Liakhovetski 
939aee5ab0bSGuennadi Liakhovetski static struct platform_device vou_device = {
940aee5ab0bSGuennadi Liakhovetski 	.name           = "sh-vou",
941aee5ab0bSGuennadi Liakhovetski 	.id		= -1,
942aee5ab0bSGuennadi Liakhovetski 	.num_resources  = ARRAY_SIZE(sh_vou_resources),
943aee5ab0bSGuennadi Liakhovetski 	.resource       = sh_vou_resources,
944aee5ab0bSGuennadi Liakhovetski 	.dev		= {
945aee5ab0bSGuennadi Liakhovetski 		.platform_data	= &sh_vou_pdata,
946aee5ab0bSGuennadi Liakhovetski 	},
947aee5ab0bSGuennadi Liakhovetski };
948aee5ab0bSGuennadi Liakhovetski 
9495744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
9501238c684SYusuke Goda /* SH_MMCIF */
9511238c684SYusuke Goda static struct resource sh_mmcif_resources[] = {
9521238c684SYusuke Goda 	[0] = {
9531238c684SYusuke Goda 		.name	= "SH_MMCIF",
9541238c684SYusuke Goda 		.start	= 0xA4CA0000,
9551238c684SYusuke Goda 		.end	= 0xA4CA00FF,
9561238c684SYusuke Goda 		.flags	= IORESOURCE_MEM,
9571238c684SYusuke Goda 	},
9581238c684SYusuke Goda 	[1] = {
9591238c684SYusuke Goda 		/* MMC2I */
9609307d115SPaul Mundt 		.start	= evt2irq(0x5a0),
9611238c684SYusuke Goda 		.flags	= IORESOURCE_IRQ,
9621238c684SYusuke Goda 	},
9631238c684SYusuke Goda 	[2] = {
9641238c684SYusuke Goda 		/* MMC3I */
9659307d115SPaul Mundt 		.start	= evt2irq(0x5c0),
9661238c684SYusuke Goda 		.flags	= IORESOURCE_IRQ,
9671238c684SYusuke Goda 	},
9681238c684SYusuke Goda };
9691238c684SYusuke Goda 
9703ce09334SKuninori Morimoto static struct sh_mmcif_plat_data sh_mmcif_plat = {
9711238c684SYusuke Goda 	.sup_pclk	= 0, /* SH7724: Max Pclk/2 */
9721238c684SYusuke Goda 	.caps		= MMC_CAP_4_BIT_DATA |
9731238c684SYusuke Goda 			  MMC_CAP_8_BIT_DATA |
9741238c684SYusuke Goda 			  MMC_CAP_NEEDS_POLL,
9751238c684SYusuke Goda 	.ocr		= MMC_VDD_32_33 | MMC_VDD_33_34,
9761238c684SYusuke Goda };
9771238c684SYusuke Goda 
9781238c684SYusuke Goda static struct platform_device sh_mmcif_device = {
9791238c684SYusuke Goda 	.name		= "sh_mmcif",
9801238c684SYusuke Goda 	.id		= 0,
9811238c684SYusuke Goda 	.dev		= {
9821238c684SYusuke Goda 		.platform_data		= &sh_mmcif_plat,
9831238c684SYusuke Goda 	},
9841238c684SYusuke Goda 	.num_resources	= ARRAY_SIZE(sh_mmcif_resources),
9851238c684SYusuke Goda 	.resource	= sh_mmcif_resources,
9861238c684SYusuke Goda };
9871238c684SYusuke Goda #endif
9881238c684SYusuke Goda 
989c2f9b05fSJacopo Mondi static struct platform_device *ecovec_ceu_devices[] __initdata = {
990c2f9b05fSJacopo Mondi 	&ceu0_device,
991c2f9b05fSJacopo Mondi 	&ceu1_device,
992c2f9b05fSJacopo Mondi };
993c2f9b05fSJacopo Mondi 
9944138b740SKuninori Morimoto static struct platform_device *ecovec_devices[] __initdata = {
9954138b740SKuninori Morimoto 	&heartbeat_device,
9964138b740SKuninori Morimoto 	&nor_flash_device,
99735a35408SKuninori Morimoto 	&sh_eth_device,
998907050a3SKuninori Morimoto 	&usb0_host_device,
9993714a9a0SKuninori Morimoto 	&usb1_common_device,
1000fb2e7394SKuninori Morimoto 	&usbhs_device,
1001fa3ba51bSKuninori Morimoto 	&lcdc_device,
1002fe79f919SLaurent Pinchart 	&gpio_backlight_device,
1003e9103e74SKuninori Morimoto 	&keysc_device,
1004d4c191dfSGuennadi Liakhovetski 	&cn12_power,
10055744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1006d4c191dfSGuennadi Liakhovetski 	&sdhi0_power,
100796987d96SKuninori Morimoto 	&sdhi0_device,
10085744c881SGuennadi Liakhovetski #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
100996987d96SKuninori Morimoto 	&sdhi1_device,
10101238c684SYusuke Goda #endif
10111ce4da7aSMagnus Damm #else
10121ce4da7aSMagnus Damm 	&msiof0_device,
10131ce4da7aSMagnus Damm #endif
10141980fdc4SKuninori Morimoto 	&fsi_device,
1015064bfadaSKuninori Morimoto 	&fsi_da7210_device,
101626365716SKuninori Morimoto 	&irda_device,
1017aee5ab0bSGuennadi Liakhovetski 	&vou_device,
10185744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
10191238c684SYusuke Goda 	&sh_mmcif_device,
10201238c684SYusuke Goda #endif
10214138b740SKuninori Morimoto };
10224138b740SKuninori Morimoto 
10236b3b5575SMagnus Damm #ifdef CONFIG_I2C
10244907d57fSKuninori Morimoto #define EEPROM_ADDR 0x50
10254907d57fSKuninori Morimoto static u8 mac_read(struct i2c_adapter *a, u8 command)
10264907d57fSKuninori Morimoto {
10274907d57fSKuninori Morimoto 	struct i2c_msg msg[2];
10284907d57fSKuninori Morimoto 	u8 buf;
10294907d57fSKuninori Morimoto 	int ret;
10304907d57fSKuninori Morimoto 
10314907d57fSKuninori Morimoto 	msg[0].addr  = EEPROM_ADDR;
10324907d57fSKuninori Morimoto 	msg[0].flags = 0;
10334907d57fSKuninori Morimoto 	msg[0].len   = 1;
10344907d57fSKuninori Morimoto 	msg[0].buf   = &command;
10354907d57fSKuninori Morimoto 
10364907d57fSKuninori Morimoto 	msg[1].addr  = EEPROM_ADDR;
10374907d57fSKuninori Morimoto 	msg[1].flags = I2C_M_RD;
10384907d57fSKuninori Morimoto 	msg[1].len   = 1;
10394907d57fSKuninori Morimoto 	msg[1].buf   = &buf;
10404907d57fSKuninori Morimoto 
10414907d57fSKuninori Morimoto 	ret = i2c_transfer(a, msg, 2);
10424907d57fSKuninori Morimoto 	if (ret < 0) {
10434907d57fSKuninori Morimoto 		printk(KERN_ERR "error %d\n", ret);
10444907d57fSKuninori Morimoto 		buf = 0xff;
10454907d57fSKuninori Morimoto 	}
10464907d57fSKuninori Morimoto 
10474907d57fSKuninori Morimoto 	return buf;
10484907d57fSKuninori Morimoto }
10494907d57fSKuninori Morimoto 
1050376abbb4SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
10514907d57fSKuninori Morimoto {
10524907d57fSKuninori Morimoto 	struct i2c_adapter *a = i2c_get_adapter(1);
10534907d57fSKuninori Morimoto 	int i;
10544907d57fSKuninori Morimoto 
10554907d57fSKuninori Morimoto 	if (!a) {
10564907d57fSKuninori Morimoto 		pr_err("can not get I2C 1\n");
10574907d57fSKuninori Morimoto 		return;
10584907d57fSKuninori Morimoto 	}
10594907d57fSKuninori Morimoto 
106025985edcSLucas De Marchi 	/* read MAC address from EEPROM */
1061376abbb4SMagnus Damm 	for (i = 0; i < sizeof(pd->mac_addr); i++) {
1062376abbb4SMagnus Damm 		pd->mac_addr[i] = mac_read(a, 0x10 + i);
10634907d57fSKuninori Morimoto 		msleep(10);
10644907d57fSKuninori Morimoto 	}
1065b230eb32SKuninori Morimoto 
1066b230eb32SKuninori Morimoto 	i2c_put_adapter(a);
10674907d57fSKuninori Morimoto }
10686b3b5575SMagnus Damm #else
10696b3b5575SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
10706b3b5575SMagnus Damm {
10716b3b5575SMagnus Damm 	pr_err("unable to read sh_eth MAC address\n");
10726b3b5575SMagnus Damm }
10736b3b5575SMagnus Damm #endif
10744907d57fSKuninori Morimoto 
1075fa3ba51bSKuninori Morimoto #define PORT_HIZA 0xA4050158
1076ea15edb2SKuninori Morimoto #define IODRIVEA  0xA405018A
1077eb0cd9e8SMagnus Damm 
1078eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_start;
1079eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_end;
1080eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_start;
1081eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_end;
1082eb0cd9e8SMagnus Damm 
10834907d57fSKuninori Morimoto static int __init arch_setup(void)
10844138b740SKuninori Morimoto {
10851980fdc4SKuninori Morimoto 	struct clk *clk;
10864eb80146SGuennadi Liakhovetski 	bool cn12_enabled = false;
10871980fdc4SKuninori Morimoto 
1088eb0cd9e8SMagnus Damm 	/* register board specific self-refresh code */
10892839bd61SMagnus Damm 	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
10902839bd61SMagnus Damm 					SUSP_SH_RSTANDBY,
1091eb0cd9e8SMagnus Damm 					&ecovec24_sdram_enter_start,
1092eb0cd9e8SMagnus Damm 					&ecovec24_sdram_enter_end,
1093eb0cd9e8SMagnus Damm 					&ecovec24_sdram_leave_start,
1094eb0cd9e8SMagnus Damm 					&ecovec24_sdram_leave_end);
1095eb0cd9e8SMagnus Damm 
1096f78bab30SMagnus Damm 	/* enable STATUS0, STATUS2 and PDSTATUS */
1097f78bab30SMagnus Damm 	gpio_request(GPIO_FN_STATUS0, NULL);
1098f78bab30SMagnus Damm 	gpio_request(GPIO_FN_STATUS2, NULL);
1099f78bab30SMagnus Damm 	gpio_request(GPIO_FN_PDSTATUS, NULL);
1100f78bab30SMagnus Damm 
11014138b740SKuninori Morimoto 	/* enable SCIFA0 */
11024138b740SKuninori Morimoto 	gpio_request(GPIO_FN_SCIF0_TXD, NULL);
11034138b740SKuninori Morimoto 	gpio_request(GPIO_FN_SCIF0_RXD, NULL);
11044138b740SKuninori Morimoto 
11054138b740SKuninori Morimoto 	/* enable debug LED */
11064138b740SKuninori Morimoto 	gpio_request(GPIO_PTG0, NULL);
11074138b740SKuninori Morimoto 	gpio_request(GPIO_PTG1, NULL);
11084138b740SKuninori Morimoto 	gpio_request(GPIO_PTG2, NULL);
11094138b740SKuninori Morimoto 	gpio_request(GPIO_PTG3, NULL);
1110b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG0, 0);
1111b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG1, 0);
1112b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG2, 0);
1113b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG3, 0);
11149d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
11154138b740SKuninori Morimoto 
111635a35408SKuninori Morimoto 	/* enable SH-Eth */
111735a35408SKuninori Morimoto 	gpio_request(GPIO_PTA1, NULL);
111835a35408SKuninori Morimoto 	gpio_direction_output(GPIO_PTA1, 1);
111935a35408SKuninori Morimoto 	mdelay(20);
112035a35408SKuninori Morimoto 
112135a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RXD0,    NULL);
112235a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RXD1,    NULL);
112335a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TXD0,    NULL);
112435a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TXD1,    NULL);
112535a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
112635a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
112735a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
112835a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
112935a35408SKuninori Morimoto 	gpio_request(GPIO_FN_MDIO,         NULL);
113035a35408SKuninori Morimoto 	gpio_request(GPIO_FN_MDC,          NULL);
113135a35408SKuninori Morimoto 	gpio_request(GPIO_FN_LNKSTA,       NULL);
113235a35408SKuninori Morimoto 
1133907050a3SKuninori Morimoto 	/* enable USB */
11349d56dd3bSPaul Mundt 	__raw_writew(0x0000, 0xA4D80000);
11359d56dd3bSPaul Mundt 	__raw_writew(0x0000, 0xA4D90000);
1136907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB3,  NULL);
1137907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB4,  NULL);
1138907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB5,  NULL);
1139907050a3SKuninori Morimoto 	gpio_direction_input(GPIO_PTB3);
1140907050a3SKuninori Morimoto 	gpio_direction_output(GPIO_PTB4, 0);
1141907050a3SKuninori Morimoto 	gpio_direction_output(GPIO_PTB5, 0);
11429d56dd3bSPaul Mundt 	__raw_writew(0x0600, 0xa40501d4);
11439d56dd3bSPaul Mundt 	__raw_writew(0x0600, 0xa4050192);
1144907050a3SKuninori Morimoto 
11453714a9a0SKuninori Morimoto 	if (gpio_get_value(GPIO_PTB3)) {
11463714a9a0SKuninori Morimoto 		printk(KERN_INFO "USB1 function is selected\n");
11473714a9a0SKuninori Morimoto 		usb1_common_device.name = "r8a66597_udc";
11483714a9a0SKuninori Morimoto 	} else {
11493714a9a0SKuninori Morimoto 		printk(KERN_INFO "USB1 host is selected\n");
11503714a9a0SKuninori Morimoto 		usb1_common_device.name = "r8a66597_hcd";
11513714a9a0SKuninori Morimoto 	}
11523714a9a0SKuninori Morimoto 
1153fa3ba51bSKuninori Morimoto 	/* enable LCDC */
1154fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD23,   NULL);
1155fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD22,   NULL);
1156fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD21,   NULL);
1157fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD20,   NULL);
1158fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD19,   NULL);
1159fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD18,   NULL);
1160fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD17,   NULL);
1161fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD16,   NULL);
1162fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD15,   NULL);
1163fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD14,   NULL);
1164fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD13,   NULL);
1165fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD12,   NULL);
1166fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD11,   NULL);
1167fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD10,   NULL);
1168fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD9,    NULL);
1169fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD8,    NULL);
1170fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD7,    NULL);
1171fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD6,    NULL);
1172fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD5,    NULL);
1173fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD4,    NULL);
1174fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD3,    NULL);
1175fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD2,    NULL);
1176fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD1,    NULL);
1177fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD0,    NULL);
1178fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDISP,  NULL);
1179fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDHSYN,  NULL);
1180fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDCK,   NULL);
1181fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDVSYN,  NULL);
1182fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDON,   NULL);
1183fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDLCLK,  NULL);
11849d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
1185fa3ba51bSKuninori Morimoto 
1186fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTE6, NULL);
1187fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTU1, NULL);
1188fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTA2, NULL);
1189fa3ba51bSKuninori Morimoto 	gpio_direction_input(GPIO_PTE6);
1190fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTU1, 0);
1191fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTA2, 0);
1192fa3ba51bSKuninori Morimoto 
119382b33221SKuninori Morimoto 	/* I/O buffer drive ability is high */
11949d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
1195ea15edb2SKuninori Morimoto 
1196fa3ba51bSKuninori Morimoto 	if (gpio_get_value(GPIO_PTE6)) {
1197fa3ba51bSKuninori Morimoto 		/* DVI */
1198fa3ba51bSKuninori Morimoto 		lcdc_info.clock_source			= LCDC_CLK_EXTERNAL;
119944432407SGuennadi Liakhovetski 		lcdc_info.ch[0].clock_divider		= 1;
120093ff2598SLaurent Pinchart 		lcdc_info.ch[0].lcd_modes		= ecovec_dvi_modes;
120193ff2598SLaurent Pinchart 		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_dvi_modes);
1202fa3ba51bSKuninori Morimoto 
1203fe79f919SLaurent Pinchart 		/* No backlight */
1204fe79f919SLaurent Pinchart 		gpio_backlight_data.fbdev = NULL;
1205fe79f919SLaurent Pinchart 
1206fa3ba51bSKuninori Morimoto 		gpio_set_value(GPIO_PTA2, 1);
1207fa3ba51bSKuninori Morimoto 		gpio_set_value(GPIO_PTU1, 1);
1208fa3ba51bSKuninori Morimoto 	} else {
1209fa3ba51bSKuninori Morimoto 		/* Panel */
1210ea15edb2SKuninori Morimoto 		lcdc_info.clock_source			= LCDC_CLK_PERIPHERAL;
121144432407SGuennadi Liakhovetski 		lcdc_info.ch[0].clock_divider		= 2;
121293ff2598SLaurent Pinchart 		lcdc_info.ch[0].lcd_modes		= ecovec_lcd_modes;
121393ff2598SLaurent Pinchart 		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_lcd_modes);
1214ea15edb2SKuninori Morimoto 
1215ea15edb2SKuninori Morimoto 		/* FIXME
1216ea15edb2SKuninori Morimoto 		 *
1217ea15edb2SKuninori Morimoto 		 * LCDDON control is needed for Panel,
1218ea15edb2SKuninori Morimoto 		 * but current sh_mobile_lcdc driver doesn't control it.
1219ea15edb2SKuninori Morimoto 		 * It is temporary correspondence
1220ea15edb2SKuninori Morimoto 		 */
1221ea15edb2SKuninori Morimoto 		gpio_request(GPIO_PTF4, NULL);
1222ea15edb2SKuninori Morimoto 		gpio_direction_output(GPIO_PTF4, 1);
12238810e055SKuninori Morimoto 
12248810e055SKuninori Morimoto 		/* enable TouchScreen */
12258810e055SKuninori Morimoto 		i2c_register_board_info(0, &ts_i2c_clients, 1);
1226fcb8918fSThomas Gleixner 		irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
1227fa3ba51bSKuninori Morimoto 	}
1228fa3ba51bSKuninori Morimoto 
12292153ad32SKuninori Morimoto 	/* enable CEU0 */
12302153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D15, NULL);
12312153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D14, NULL);
12322153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D13, NULL);
12332153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D12, NULL);
12342153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D11, NULL);
12352153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D10, NULL);
12362153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D9,  NULL);
12372153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D8,  NULL);
12382153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D7,  NULL);
12392153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D6,  NULL);
12402153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D5,  NULL);
12412153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D4,  NULL);
12422153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D3,  NULL);
12432153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D2,  NULL);
12442153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D1,  NULL);
12452153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D0,  NULL);
12462153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_VD,  NULL);
12472153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_CLK, NULL);
12482153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_FLD, NULL);
12492153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_HD,  NULL);
12502153ad32SKuninori Morimoto 
12512153ad32SKuninori Morimoto 	/* enable CEU1 */
12522153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D7,  NULL);
12532153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D6,  NULL);
12542153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D5,  NULL);
12552153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D4,  NULL);
12562153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D3,  NULL);
12572153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D2,  NULL);
12582153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D1,  NULL);
12592153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D0,  NULL);
12602153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_FLD, NULL);
12612153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_HD,  NULL);
12622153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_VD,  NULL);
12632153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_CLK, NULL);
12642153ad32SKuninori Morimoto 
1265e9103e74SKuninori Morimoto 	/* enable KEYSC */
1266e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
1267e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
1268e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT3,     NULL);
1269e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT2,     NULL);
1270e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT1,     NULL);
1271e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT0,     NULL);
1272e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYIN0,      NULL);
1273e9103e74SKuninori Morimoto 
1274064a16dcSKuninori Morimoto 	/* enable user debug switch */
1275064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR0, NULL);
1276064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR4, NULL);
1277064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR5, NULL);
1278064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR6, NULL);
1279064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR0);
1280064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR4);
1281064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR5);
1282064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR6);
1283064a16dcSKuninori Morimoto 
12844eb80146SGuennadi Liakhovetski 	/* SD-card slot CN11 */
12855744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
12861ce4da7aSMagnus Damm 	/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
128796987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0WP,  NULL);
128896987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CMD, NULL);
128996987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CLK, NULL);
129096987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D3,  NULL);
129196987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D2,  NULL);
129296987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D1,  NULL);
129396987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D0,  NULL);
12941ce4da7aSMagnus Damm #else
12951ce4da7aSMagnus Damm 	/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
12961ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
12971ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
12981ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
12991ce4da7aSMagnus Damm 	gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
13001ce4da7aSMagnus Damm 	gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
13011ce4da7aSMagnus Damm 	gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
13021ce4da7aSMagnus Damm 	gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
13031ce4da7aSMagnus Damm 
13045716fb9bSLinus Walleij 	gpiod_add_lookup_table(&mmc_spi_gpio_table);
13051ce4da7aSMagnus Damm 	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
13061ce4da7aSMagnus Damm #endif
130796987d96SKuninori Morimoto 
13084eb80146SGuennadi Liakhovetski 	/* MMC/SD-card slot CN12 */
13094eb80146SGuennadi Liakhovetski #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
13104eb80146SGuennadi Liakhovetski 	/* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
13114eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D7, NULL);
13124eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D6, NULL);
13134eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D5, NULL);
13144eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D4, NULL);
13154eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D3, NULL);
13164eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D2, NULL);
13174eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D1, NULL);
13184eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_D0, NULL);
13194eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_CLK, NULL);
13204eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_MMC_CMD, NULL);
13214eb80146SGuennadi Liakhovetski 
13224eb80146SGuennadi Liakhovetski 	cn12_enabled = true;
13234eb80146SGuennadi Liakhovetski #elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
13244eb80146SGuennadi Liakhovetski 	/* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
13254eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1WP,  NULL);
13264eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1CMD, NULL);
13274eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1CLK, NULL);
13284eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1D3,  NULL);
13294eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1D2,  NULL);
13304eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1D1,  NULL);
13314eb80146SGuennadi Liakhovetski 	gpio_request(GPIO_FN_SDHI1D0,  NULL);
13324eb80146SGuennadi Liakhovetski 
13334eb80146SGuennadi Liakhovetski 	cn12_enabled = true;
13344eb80146SGuennadi Liakhovetski #endif
13354eb80146SGuennadi Liakhovetski 
13364eb80146SGuennadi Liakhovetski 	if (cn12_enabled)
13374eb80146SGuennadi Liakhovetski 		/* I/O buffer drive ability is high for CN12 */
13384eb80146SGuennadi Liakhovetski 		__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000,
13394eb80146SGuennadi Liakhovetski 			     IODRIVEA);
13404eb80146SGuennadi Liakhovetski 
13411980fdc4SKuninori Morimoto 	/* enable FSI */
13421980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIMCKB,    NULL);
13431980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBSD,    NULL);
13441980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBSD,    NULL);
13451980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBBCK,   NULL);
13461980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBLRCK,  NULL);
13471980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBBCK,   NULL);
13481980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
13491980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
13501980fdc4SKuninori Morimoto 
135116afc9fbSKuninori Morimoto 	/* set SPU2 clock to 83.4 MHz */
135216afc9fbSKuninori Morimoto 	clk = clk_get(NULL, "spu_clk");
135356ea5109SGuennadi Liakhovetski 	if (!IS_ERR(clk)) {
135416afc9fbSKuninori Morimoto 		clk_set_rate(clk, clk_round_rate(clk, 83333333));
135516afc9fbSKuninori Morimoto 		clk_put(clk);
135610305853SKuninori Morimoto 	}
135716afc9fbSKuninori Morimoto 
13581980fdc4SKuninori Morimoto 	/* change parent of FSI B */
13591980fdc4SKuninori Morimoto 	clk = clk_get(NULL, "fsib_clk");
136056ea5109SGuennadi Liakhovetski 	if (!IS_ERR(clk)) {
13614bd5d259SKuninori Morimoto 		/* 48kHz dummy clock was used to make sure 1/1 divide */
13624bd5d259SKuninori Morimoto 		clk_set_rate(&sh7724_fsimckb_clk, 48000);
13634bd5d259SKuninori Morimoto 		clk_set_parent(clk, &sh7724_fsimckb_clk);
13644bd5d259SKuninori Morimoto 		clk_set_rate(clk, 48000);
13651980fdc4SKuninori Morimoto 		clk_put(clk);
136610305853SKuninori Morimoto 	}
13671980fdc4SKuninori Morimoto 
13681980fdc4SKuninori Morimoto 	gpio_request(GPIO_PTU0, NULL);
13691980fdc4SKuninori Morimoto 	gpio_direction_output(GPIO_PTU0, 0);
13701980fdc4SKuninori Morimoto 	mdelay(20);
13711980fdc4SKuninori Morimoto 
1372ea440783SNISHIMOTO Hiroki 	/* enable motion sensor */
1373ea440783SNISHIMOTO Hiroki 	gpio_request(GPIO_FN_INTC_IRQ1, NULL);
1374ea440783SNISHIMOTO Hiroki 	gpio_direction_input(GPIO_FN_INTC_IRQ1);
1375ea440783SNISHIMOTO Hiroki 
13766f26d19fSMagnus Damm 	/* set VPU clock to 166 MHz */
13776f26d19fSMagnus Damm 	clk = clk_get(NULL, "vpu_clk");
137856ea5109SGuennadi Liakhovetski 	if (!IS_ERR(clk)) {
13796f26d19fSMagnus Damm 		clk_set_rate(clk, clk_round_rate(clk, 166000000));
13806f26d19fSMagnus Damm 		clk_put(clk);
138110305853SKuninori Morimoto 	}
13826f26d19fSMagnus Damm 
138326365716SKuninori Morimoto 	/* enable IrDA */
138426365716SKuninori Morimoto 	gpio_request(GPIO_FN_IRDA_OUT, NULL);
138526365716SKuninori Morimoto 	gpio_request(GPIO_FN_IRDA_IN,  NULL);
138626365716SKuninori Morimoto 	gpio_request(GPIO_PTU5, NULL);
138726365716SKuninori Morimoto 	gpio_direction_output(GPIO_PTU5, 0);
138826365716SKuninori Morimoto 
1389c2f9b05fSJacopo Mondi 	/* Register gpio lookup tables for cameras and video decoder */
1390c2f9b05fSJacopo Mondi 	gpiod_add_lookup_table(&tw9910_gpios);
1391c2f9b05fSJacopo Mondi 	gpiod_add_lookup_table(&mt9t112_0_gpios);
1392c2f9b05fSJacopo Mondi 	gpiod_add_lookup_table(&mt9t112_1_gpios);
1393c2f9b05fSJacopo Mondi 
1394125ecce6SKuninori Morimoto 	/* enable I2C device */
13951980fdc4SKuninori Morimoto 	i2c_register_board_info(0, i2c0_devices,
13961980fdc4SKuninori Morimoto 				ARRAY_SIZE(i2c0_devices));
13971980fdc4SKuninori Morimoto 
1398125ecce6SKuninori Morimoto 	i2c_register_board_info(1, i2c1_devices,
1399125ecce6SKuninori Morimoto 				ARRAY_SIZE(i2c1_devices));
1400125ecce6SKuninori Morimoto 
140192359a70SGuennadi Liakhovetski #if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
1402aee5ab0bSGuennadi Liakhovetski 	/* VOU */
1403aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D15, NULL);
1404aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D14, NULL);
1405aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D13, NULL);
1406aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D12, NULL);
1407aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D11, NULL);
1408aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D10, NULL);
1409aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D9, NULL);
1410aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D8, NULL);
1411aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_CLKI, NULL);
1412aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_CLK, NULL);
1413aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_VSYNC, NULL);
1414aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_HSYNC, NULL);
1415aee5ab0bSGuennadi Liakhovetski 
1416aee5ab0bSGuennadi Liakhovetski 	/* AK8813 power / reset sequence */
1417aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_PTG4, NULL);
1418aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_PTU3, NULL);
1419aee5ab0bSGuennadi Liakhovetski 	/* Reset */
1420aee5ab0bSGuennadi Liakhovetski 	gpio_direction_output(GPIO_PTG4, 0);
1421aee5ab0bSGuennadi Liakhovetski 	/* Power down */
1422aee5ab0bSGuennadi Liakhovetski 	gpio_direction_output(GPIO_PTU3, 1);
1423aee5ab0bSGuennadi Liakhovetski 
1424aee5ab0bSGuennadi Liakhovetski 	udelay(10);
1425aee5ab0bSGuennadi Liakhovetski 
1426aee5ab0bSGuennadi Liakhovetski 	/* Power up, reset */
1427aee5ab0bSGuennadi Liakhovetski 	gpio_set_value(GPIO_PTU3, 0);
1428aee5ab0bSGuennadi Liakhovetski 
1429aee5ab0bSGuennadi Liakhovetski 	udelay(10);
1430aee5ab0bSGuennadi Liakhovetski 
1431aee5ab0bSGuennadi Liakhovetski 	/* Remove reset */
1432aee5ab0bSGuennadi Liakhovetski 	gpio_set_value(GPIO_PTG4, 1);
143392359a70SGuennadi Liakhovetski #endif
1434aee5ab0bSGuennadi Liakhovetski 
1435c2f9b05fSJacopo Mondi 	/* Initialize CEU platform devices separately to map memory first */
1436c2f9b05fSJacopo Mondi 	device_initialize(&ecovec_ceu_devices[0]->dev);
1437c2f9b05fSJacopo Mondi 	arch_setup_pdev_archdata(ecovec_ceu_devices[0]);
1438c2f9b05fSJacopo Mondi 	dma_declare_coherent_memory(&ecovec_ceu_devices[0]->dev,
1439c2f9b05fSJacopo Mondi 				    ceu0_dma_membase, ceu0_dma_membase,
1440c2f9b05fSJacopo Mondi 				    ceu0_dma_membase +
144182c5de0aSChristoph Hellwig 				    CEU_BUFFER_MEMORY_SIZE - 1);
1442c2f9b05fSJacopo Mondi 	platform_device_add(ecovec_ceu_devices[0]);
1443c2f9b05fSJacopo Mondi 
1444c2f9b05fSJacopo Mondi 	device_initialize(&ecovec_ceu_devices[1]->dev);
1445c2f9b05fSJacopo Mondi 	arch_setup_pdev_archdata(ecovec_ceu_devices[1]);
1446c2f9b05fSJacopo Mondi 	dma_declare_coherent_memory(&ecovec_ceu_devices[1]->dev,
1447c2f9b05fSJacopo Mondi 				    ceu1_dma_membase, ceu1_dma_membase,
1448c2f9b05fSJacopo Mondi 				    ceu1_dma_membase +
144982c5de0aSChristoph Hellwig 				    CEU_BUFFER_MEMORY_SIZE - 1);
1450c2f9b05fSJacopo Mondi 	platform_device_add(ecovec_ceu_devices[1]);
1451c2f9b05fSJacopo Mondi 
1452efdfeb07SLinus Walleij 	gpiod_add_lookup_table(&cn12_power_gpiod_table);
1453efdfeb07SLinus Walleij #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1454efdfeb07SLinus Walleij 	gpiod_add_lookup_table(&sdhi0_power_gpiod_table);
1455faed9303SLinus Walleij 	gpiod_add_lookup_table(&sdhi0_gpio_table);
1456faed9303SLinus Walleij #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1457faed9303SLinus Walleij 	gpiod_add_lookup_table(&sdhi1_gpio_table);
1458efdfeb07SLinus Walleij #endif
1459c4916c24SLinus Walleij #endif
1460efdfeb07SLinus Walleij 
14614138b740SKuninori Morimoto 	return platform_add_devices(ecovec_devices,
14624138b740SKuninori Morimoto 				    ARRAY_SIZE(ecovec_devices));
14634138b740SKuninori Morimoto }
14644907d57fSKuninori Morimoto arch_initcall(arch_setup);
14654907d57fSKuninori Morimoto 
14664907d57fSKuninori Morimoto static int __init devices_setup(void)
14674907d57fSKuninori Morimoto {
1468376abbb4SMagnus Damm 	sh_eth_init(&sh_eth_plat);
14694907d57fSKuninori Morimoto 	return 0;
14704907d57fSKuninori Morimoto }
14714907d57fSKuninori Morimoto device_initcall(devices_setup);
14724907d57fSKuninori Morimoto 
1473c2f9b05fSJacopo Mondi /* Reserve a portion of memory for CEU 0 and CEU 1 buffers */
1474c2f9b05fSJacopo Mondi static void __init ecovec_mv_mem_reserve(void)
1475c2f9b05fSJacopo Mondi {
1476c2f9b05fSJacopo Mondi 	phys_addr_t phys;
1477c2f9b05fSJacopo Mondi 	phys_addr_t size = CEU_BUFFER_MEMORY_SIZE;
1478c2f9b05fSJacopo Mondi 
1479*f240ec09SMike Rapoport 	phys = memblock_phys_alloc(size, PAGE_SIZE);
1480c2f9b05fSJacopo Mondi 	memblock_free(phys, size);
1481c2f9b05fSJacopo Mondi 	memblock_remove(phys, size);
1482c2f9b05fSJacopo Mondi 	ceu0_dma_membase = phys;
1483c2f9b05fSJacopo Mondi 
1484*f240ec09SMike Rapoport 	phys = memblock_phys_alloc(size, PAGE_SIZE);
1485c2f9b05fSJacopo Mondi 	memblock_free(phys, size);
1486c2f9b05fSJacopo Mondi 	memblock_remove(phys, size);
1487c2f9b05fSJacopo Mondi 	ceu1_dma_membase = phys;
1488c2f9b05fSJacopo Mondi }
1489c2f9b05fSJacopo Mondi 
14904138b740SKuninori Morimoto static struct sh_machine_vector mv_ecovec __initmv = {
14914138b740SKuninori Morimoto 	.mv_name	= "R0P7724 (EcoVec)",
1492c2f9b05fSJacopo Mondi 	.mv_mem_reserve	= ecovec_mv_mem_reserve,
14934138b740SKuninori Morimoto };
1494