xref: /openbmc/linux/arch/sh/boards/mach-ecovec24/setup.c (revision 6f26d19fce5907cdd0fd953ac1a1d0b1e6e5982c)
14138b740SKuninori Morimoto /*
24138b740SKuninori Morimoto  * Copyright (C) 2009 Renesas Solutions Corp.
34138b740SKuninori Morimoto  *
44138b740SKuninori Morimoto  * Kuninori Morimoto <morimoto.kuninori@renesas.com>
54138b740SKuninori Morimoto  *
64138b740SKuninori Morimoto  * This file is subject to the terms and conditions of the GNU General Public
74138b740SKuninori Morimoto  * License.  See the file "COPYING" in the main directory of this archive
84138b740SKuninori Morimoto  * for more details.
94138b740SKuninori Morimoto  */
104138b740SKuninori Morimoto 
114138b740SKuninori Morimoto #include <linux/init.h>
124138b740SKuninori Morimoto #include <linux/device.h>
134138b740SKuninori Morimoto #include <linux/platform_device.h>
144138b740SKuninori Morimoto #include <linux/mtd/physmap.h>
154138b740SKuninori Morimoto #include <linux/gpio.h>
164138b740SKuninori Morimoto #include <linux/interrupt.h>
1735a35408SKuninori Morimoto #include <linux/io.h>
1835a35408SKuninori Morimoto #include <linux/delay.h>
19907050a3SKuninori Morimoto #include <linux/usb/r8a66597.h>
204907d57fSKuninori Morimoto #include <linux/i2c.h>
218810e055SKuninori Morimoto #include <linux/i2c/tsc2007.h>
221ce4da7aSMagnus Damm #include <linux/spi/spi.h>
231ce4da7aSMagnus Damm #include <linux/spi/sh_msiof.h>
241ce4da7aSMagnus Damm #include <linux/spi/mmc_spi.h>
251ce4da7aSMagnus Damm #include <linux/mmc/host.h>
26e9103e74SKuninori Morimoto #include <linux/input.h>
27fc1d003dSMagnus Damm #include <linux/input/sh_keysc.h>
2898779ad8SMagnus Damm #include <linux/mfd/sh_mobile_sdhi.h>
29fa3ba51bSKuninori Morimoto #include <video/sh_mobile_lcdc.h>
301980fdc4SKuninori Morimoto #include <sound/sh_fsi.h>
312153ad32SKuninori Morimoto #include <media/sh_mobile_ceu.h>
32207efd07SKuninori Morimoto #include <media/tw9910.h>
339aa25d64SKuninori Morimoto #include <media/mt9t112.h>
344138b740SKuninori Morimoto #include <asm/heartbeat.h>
3535a35408SKuninori Morimoto #include <asm/sh_eth.h>
36a991801aSKuninori Morimoto #include <asm/clock.h>
37eb0cd9e8SMagnus Damm #include <asm/suspend.h>
384138b740SKuninori Morimoto #include <cpu/sh7724.h>
394138b740SKuninori Morimoto 
404138b740SKuninori Morimoto /*
41b7056bc1SKuninori Morimoto  *  Address      Interface        BusWidth
42b7056bc1SKuninori Morimoto  *-----------------------------------------
43b7056bc1SKuninori Morimoto  *  0x0000_0000  uboot            16bit
44b7056bc1SKuninori Morimoto  *  0x0004_0000  Linux romImage   16bit
45b7056bc1SKuninori Morimoto  *  0x0014_0000  MTD for Linux    16bit
46b7056bc1SKuninori Morimoto  *  0x0400_0000  Internal I/O     16/32bit
47b7056bc1SKuninori Morimoto  *  0x0800_0000  DRAM             32bit
48b7056bc1SKuninori Morimoto  *  0x1800_0000  MFI              16bit
494138b740SKuninori Morimoto  */
504138b740SKuninori Morimoto 
519c472c4dSKuninori Morimoto /* SWITCH
529c472c4dSKuninori Morimoto  *------------------------------
539c472c4dSKuninori Morimoto  * DS2[1] = FlashROM write protect  ON     : write protect
549c472c4dSKuninori Morimoto  *                                  OFF    : No write protect
559c472c4dSKuninori Morimoto  * DS2[2] = RMII / TS, SCIF         ON     : RMII
569c472c4dSKuninori Morimoto  *                                  OFF    : TS, SCIF3
579c472c4dSKuninori Morimoto  * DS2[3] = Camera / Video          ON     : Camera
589c472c4dSKuninori Morimoto  *                                  OFF    : NTSC/PAL (IN)
599c472c4dSKuninori Morimoto  * DS2[5] = NTSC_OUT Clock          ON     : On board OSC
609c472c4dSKuninori Morimoto  *                                  OFF    : SH7724 DV_CLK
619c472c4dSKuninori Morimoto  * DS2[6-7] = MMC / SD              ON-OFF : SD
629c472c4dSKuninori Morimoto  *                                  OFF-ON : MMC
639c472c4dSKuninori Morimoto  */
649c472c4dSKuninori Morimoto 
654138b740SKuninori Morimoto /* Heartbeat */
664138b740SKuninori Morimoto static unsigned char led_pos[] = { 0, 1, 2, 3 };
67a09d2831SPaul Mundt 
684138b740SKuninori Morimoto static struct heartbeat_data heartbeat_data = {
694138b740SKuninori Morimoto 	.nr_bits = 4,
704138b740SKuninori Morimoto 	.bit_pos = led_pos,
714138b740SKuninori Morimoto };
724138b740SKuninori Morimoto 
73a09d2831SPaul Mundt static struct resource heartbeat_resource = {
744138b740SKuninori Morimoto 	.start  = 0xA405012C, /* PTG */
754138b740SKuninori Morimoto 	.end    = 0xA405012E - 1,
76a09d2831SPaul Mundt 	.flags  = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
774138b740SKuninori Morimoto };
784138b740SKuninori Morimoto 
794138b740SKuninori Morimoto static struct platform_device heartbeat_device = {
804138b740SKuninori Morimoto 	.name           = "heartbeat",
814138b740SKuninori Morimoto 	.id             = -1,
824138b740SKuninori Morimoto 	.dev = {
834138b740SKuninori Morimoto 		.platform_data = &heartbeat_data,
844138b740SKuninori Morimoto 	},
85a09d2831SPaul Mundt 	.num_resources  = 1,
86a09d2831SPaul Mundt 	.resource       = &heartbeat_resource,
874138b740SKuninori Morimoto };
884138b740SKuninori Morimoto 
894138b740SKuninori Morimoto /* MTD */
904138b740SKuninori Morimoto static struct mtd_partition nor_flash_partitions[] = {
914138b740SKuninori Morimoto 	{
92b7056bc1SKuninori Morimoto 		.name = "boot loader",
934138b740SKuninori Morimoto 		.offset = 0,
94b7056bc1SKuninori Morimoto 		.size = (5 * 1024 * 1024),
95d5ce010cSKuninori Morimoto 		.mask_flags = MTD_WRITEABLE,  /* force read-only */
964138b740SKuninori Morimoto 	}, {
974138b740SKuninori Morimoto 		.name = "free-area",
984138b740SKuninori Morimoto 		.offset = MTDPART_OFS_APPEND,
994138b740SKuninori Morimoto 		.size = MTDPART_SIZ_FULL,
1004138b740SKuninori Morimoto 	},
1014138b740SKuninori Morimoto };
1024138b740SKuninori Morimoto 
1034138b740SKuninori Morimoto static struct physmap_flash_data nor_flash_data = {
1044138b740SKuninori Morimoto 	.width		= 2,
1054138b740SKuninori Morimoto 	.parts		= nor_flash_partitions,
1064138b740SKuninori Morimoto 	.nr_parts	= ARRAY_SIZE(nor_flash_partitions),
1074138b740SKuninori Morimoto };
1084138b740SKuninori Morimoto 
1094138b740SKuninori Morimoto static struct resource nor_flash_resources[] = {
1104138b740SKuninori Morimoto 	[0] = {
1114138b740SKuninori Morimoto 		.name	= "NOR Flash",
1124138b740SKuninori Morimoto 		.start	= 0x00000000,
1134138b740SKuninori Morimoto 		.end	= 0x03ffffff,
1144138b740SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
1154138b740SKuninori Morimoto 	}
1164138b740SKuninori Morimoto };
1174138b740SKuninori Morimoto 
1184138b740SKuninori Morimoto static struct platform_device nor_flash_device = {
1194138b740SKuninori Morimoto 	.name		= "physmap-flash",
1204138b740SKuninori Morimoto 	.resource	= nor_flash_resources,
1214138b740SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(nor_flash_resources),
1224138b740SKuninori Morimoto 	.dev		= {
1234138b740SKuninori Morimoto 		.platform_data = &nor_flash_data,
1244138b740SKuninori Morimoto 	},
1254138b740SKuninori Morimoto };
1264138b740SKuninori Morimoto 
12735a35408SKuninori Morimoto /* SH Eth */
12835a35408SKuninori Morimoto #define SH_ETH_ADDR	(0xA4600000)
12935a35408SKuninori Morimoto static struct resource sh_eth_resources[] = {
13035a35408SKuninori Morimoto 	[0] = {
13135a35408SKuninori Morimoto 		.start = SH_ETH_ADDR,
13235a35408SKuninori Morimoto 		.end   = SH_ETH_ADDR + 0x1FC,
13335a35408SKuninori Morimoto 		.flags = IORESOURCE_MEM,
13435a35408SKuninori Morimoto 	},
13535a35408SKuninori Morimoto 	[1] = {
13635a35408SKuninori Morimoto 		.start = 91,
13735a35408SKuninori Morimoto 		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
13835a35408SKuninori Morimoto 	},
13935a35408SKuninori Morimoto };
14035a35408SKuninori Morimoto 
14135a35408SKuninori Morimoto struct sh_eth_plat_data sh_eth_plat = {
14235a35408SKuninori Morimoto 	.phy = 0x1f, /* SMSC LAN8700 */
14335a35408SKuninori Morimoto 	.edmac_endian = EDMAC_LITTLE_ENDIAN,
144acf3cc28SKuninori Morimoto 	.ether_link_active_low = 1
14535a35408SKuninori Morimoto };
14635a35408SKuninori Morimoto 
14735a35408SKuninori Morimoto static struct platform_device sh_eth_device = {
14835a35408SKuninori Morimoto 	.name = "sh-eth",
14935a35408SKuninori Morimoto 	.id	= 0,
15035a35408SKuninori Morimoto 	.dev = {
15135a35408SKuninori Morimoto 		.platform_data = &sh_eth_plat,
15235a35408SKuninori Morimoto 	},
15335a35408SKuninori Morimoto 	.num_resources = ARRAY_SIZE(sh_eth_resources),
15435a35408SKuninori Morimoto 	.resource = sh_eth_resources,
15540e42318SMagnus Damm 	.archdata = {
15640e42318SMagnus Damm 		.hwblk_id = HWBLK_ETHER,
15740e42318SMagnus Damm 	},
15835a35408SKuninori Morimoto };
15935a35408SKuninori Morimoto 
160907050a3SKuninori Morimoto /* USB0 host */
161907050a3SKuninori Morimoto void usb0_port_power(int port, int power)
162907050a3SKuninori Morimoto {
163907050a3SKuninori Morimoto 	gpio_set_value(GPIO_PTB4, power);
164907050a3SKuninori Morimoto }
165907050a3SKuninori Morimoto 
166907050a3SKuninori Morimoto static struct r8a66597_platdata usb0_host_data = {
167907050a3SKuninori Morimoto 	.on_chip = 1,
168907050a3SKuninori Morimoto 	.port_power = usb0_port_power,
169907050a3SKuninori Morimoto };
170907050a3SKuninori Morimoto 
171907050a3SKuninori Morimoto static struct resource usb0_host_resources[] = {
172907050a3SKuninori Morimoto 	[0] = {
173907050a3SKuninori Morimoto 		.start	= 0xa4d80000,
174907050a3SKuninori Morimoto 		.end	= 0xa4d80124 - 1,
175907050a3SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
176907050a3SKuninori Morimoto 	},
177907050a3SKuninori Morimoto 	[1] = {
178907050a3SKuninori Morimoto 		.start	= 65,
179907050a3SKuninori Morimoto 		.end	= 65,
180907050a3SKuninori Morimoto 		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
181907050a3SKuninori Morimoto 	},
182907050a3SKuninori Morimoto };
183907050a3SKuninori Morimoto 
184907050a3SKuninori Morimoto static struct platform_device usb0_host_device = {
185907050a3SKuninori Morimoto 	.name		= "r8a66597_hcd",
186907050a3SKuninori Morimoto 	.id		= 0,
187907050a3SKuninori Morimoto 	.dev = {
188907050a3SKuninori Morimoto 		.dma_mask		= NULL,         /*  not use dma */
189907050a3SKuninori Morimoto 		.coherent_dma_mask	= 0xffffffff,
190907050a3SKuninori Morimoto 		.platform_data		= &usb0_host_data,
191907050a3SKuninori Morimoto 	},
192907050a3SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(usb0_host_resources),
193907050a3SKuninori Morimoto 	.resource	= usb0_host_resources,
194907050a3SKuninori Morimoto };
195907050a3SKuninori Morimoto 
1963714a9a0SKuninori Morimoto /* USB1 host/function */
197907050a3SKuninori Morimoto void usb1_port_power(int port, int power)
198907050a3SKuninori Morimoto {
199907050a3SKuninori Morimoto 	gpio_set_value(GPIO_PTB5, power);
200907050a3SKuninori Morimoto }
201907050a3SKuninori Morimoto 
2023714a9a0SKuninori Morimoto static struct r8a66597_platdata usb1_common_data = {
203907050a3SKuninori Morimoto 	.on_chip = 1,
204907050a3SKuninori Morimoto 	.port_power = usb1_port_power,
205907050a3SKuninori Morimoto };
206907050a3SKuninori Morimoto 
2073714a9a0SKuninori Morimoto static struct resource usb1_common_resources[] = {
208907050a3SKuninori Morimoto 	[0] = {
209907050a3SKuninori Morimoto 		.start	= 0xa4d90000,
210907050a3SKuninori Morimoto 		.end	= 0xa4d90124 - 1,
211907050a3SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
212907050a3SKuninori Morimoto 	},
213907050a3SKuninori Morimoto 	[1] = {
214907050a3SKuninori Morimoto 		.start	= 66,
215907050a3SKuninori Morimoto 		.end	= 66,
216907050a3SKuninori Morimoto 		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
217907050a3SKuninori Morimoto 	},
218907050a3SKuninori Morimoto };
219907050a3SKuninori Morimoto 
2203714a9a0SKuninori Morimoto static struct platform_device usb1_common_device = {
2213714a9a0SKuninori Morimoto 	/* .name will be added in arch_setup */
222907050a3SKuninori Morimoto 	.id		= 1,
223907050a3SKuninori Morimoto 	.dev = {
224907050a3SKuninori Morimoto 		.dma_mask		= NULL,         /*  not use dma */
225907050a3SKuninori Morimoto 		.coherent_dma_mask	= 0xffffffff,
2263714a9a0SKuninori Morimoto 		.platform_data		= &usb1_common_data,
227907050a3SKuninori Morimoto 	},
2283714a9a0SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(usb1_common_resources),
2293714a9a0SKuninori Morimoto 	.resource	= usb1_common_resources,
230907050a3SKuninori Morimoto };
231907050a3SKuninori Morimoto 
232fa3ba51bSKuninori Morimoto /* LCDC */
233fa3ba51bSKuninori Morimoto static struct sh_mobile_lcdc_info lcdc_info = {
234fa3ba51bSKuninori Morimoto 	.ch[0] = {
235fa3ba51bSKuninori Morimoto 		.interface_type = RGB18,
236fa3ba51bSKuninori Morimoto 		.chan = LCDC_CHAN_MAINLCD,
237fa3ba51bSKuninori Morimoto 		.bpp = 16,
238fa3ba51bSKuninori Morimoto 		.lcd_cfg = {
239fa3ba51bSKuninori Morimoto 			.sync = 0, /* hsync and vsync are active low */
240fa3ba51bSKuninori Morimoto 		},
241fa3ba51bSKuninori Morimoto 		.lcd_size_cfg = { /* 7.0 inch */
242fa3ba51bSKuninori Morimoto 			.width = 152,
243fa3ba51bSKuninori Morimoto 			.height = 91,
244fa3ba51bSKuninori Morimoto 		},
245fa3ba51bSKuninori Morimoto 		.board_cfg = {
246fa3ba51bSKuninori Morimoto 		},
247fa3ba51bSKuninori Morimoto 	}
248fa3ba51bSKuninori Morimoto };
249fa3ba51bSKuninori Morimoto 
250fa3ba51bSKuninori Morimoto static struct resource lcdc_resources[] = {
251fa3ba51bSKuninori Morimoto 	[0] = {
252fa3ba51bSKuninori Morimoto 		.name	= "LCDC",
253fa3ba51bSKuninori Morimoto 		.start	= 0xfe940000,
254a6f15adeSPhil Edworthy 		.end	= 0xfe942fff,
255fa3ba51bSKuninori Morimoto 		.flags	= IORESOURCE_MEM,
256fa3ba51bSKuninori Morimoto 	},
257fa3ba51bSKuninori Morimoto 	[1] = {
258fa3ba51bSKuninori Morimoto 		.start	= 106,
259fa3ba51bSKuninori Morimoto 		.flags	= IORESOURCE_IRQ,
260fa3ba51bSKuninori Morimoto 	},
261fa3ba51bSKuninori Morimoto };
262fa3ba51bSKuninori Morimoto 
263fa3ba51bSKuninori Morimoto static struct platform_device lcdc_device = {
264fa3ba51bSKuninori Morimoto 	.name		= "sh_mobile_lcdc_fb",
265fa3ba51bSKuninori Morimoto 	.num_resources	= ARRAY_SIZE(lcdc_resources),
266fa3ba51bSKuninori Morimoto 	.resource	= lcdc_resources,
267fa3ba51bSKuninori Morimoto 	.dev		= {
268fa3ba51bSKuninori Morimoto 		.platform_data	= &lcdc_info,
269fa3ba51bSKuninori Morimoto 	},
270fa3ba51bSKuninori Morimoto 	.archdata = {
271fa3ba51bSKuninori Morimoto 		.hwblk_id = HWBLK_LCDC,
272fa3ba51bSKuninori Morimoto 	},
273fa3ba51bSKuninori Morimoto };
274fa3ba51bSKuninori Morimoto 
2752153ad32SKuninori Morimoto /* CEU0 */
2762153ad32SKuninori Morimoto static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
2772153ad32SKuninori Morimoto 	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
2782153ad32SKuninori Morimoto };
2792153ad32SKuninori Morimoto 
2802153ad32SKuninori Morimoto static struct resource ceu0_resources[] = {
2812153ad32SKuninori Morimoto 	[0] = {
2822153ad32SKuninori Morimoto 		.name	= "CEU0",
2832153ad32SKuninori Morimoto 		.start	= 0xfe910000,
2842153ad32SKuninori Morimoto 		.end	= 0xfe91009f,
2852153ad32SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
2862153ad32SKuninori Morimoto 	},
2872153ad32SKuninori Morimoto 	[1] = {
2882153ad32SKuninori Morimoto 		.start  = 52,
2892153ad32SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
2902153ad32SKuninori Morimoto 	},
2912153ad32SKuninori Morimoto 	[2] = {
2922153ad32SKuninori Morimoto 		/* place holder for contiguous memory */
2932153ad32SKuninori Morimoto 	},
2942153ad32SKuninori Morimoto };
2952153ad32SKuninori Morimoto 
2962153ad32SKuninori Morimoto static struct platform_device ceu0_device = {
2972153ad32SKuninori Morimoto 	.name		= "sh_mobile_ceu",
2982153ad32SKuninori Morimoto 	.id             = 0, /* "ceu0" clock */
2992153ad32SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(ceu0_resources),
3002153ad32SKuninori Morimoto 	.resource	= ceu0_resources,
3012153ad32SKuninori Morimoto 	.dev	= {
3022153ad32SKuninori Morimoto 		.platform_data	= &sh_mobile_ceu0_info,
3032153ad32SKuninori Morimoto 	},
3042153ad32SKuninori Morimoto 	.archdata = {
3052153ad32SKuninori Morimoto 		.hwblk_id = HWBLK_CEU0,
3062153ad32SKuninori Morimoto 	},
3072153ad32SKuninori Morimoto };
3082153ad32SKuninori Morimoto 
3092153ad32SKuninori Morimoto /* CEU1 */
3102153ad32SKuninori Morimoto static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
3112153ad32SKuninori Morimoto 	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
3122153ad32SKuninori Morimoto };
3132153ad32SKuninori Morimoto 
3142153ad32SKuninori Morimoto static struct resource ceu1_resources[] = {
3152153ad32SKuninori Morimoto 	[0] = {
3162153ad32SKuninori Morimoto 		.name	= "CEU1",
3172153ad32SKuninori Morimoto 		.start	= 0xfe914000,
3182153ad32SKuninori Morimoto 		.end	= 0xfe91409f,
3192153ad32SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
3202153ad32SKuninori Morimoto 	},
3212153ad32SKuninori Morimoto 	[1] = {
3222153ad32SKuninori Morimoto 		.start  = 63,
3232153ad32SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
3242153ad32SKuninori Morimoto 	},
3252153ad32SKuninori Morimoto 	[2] = {
3262153ad32SKuninori Morimoto 		/* place holder for contiguous memory */
3272153ad32SKuninori Morimoto 	},
3282153ad32SKuninori Morimoto };
3292153ad32SKuninori Morimoto 
3302153ad32SKuninori Morimoto static struct platform_device ceu1_device = {
3312153ad32SKuninori Morimoto 	.name		= "sh_mobile_ceu",
3322153ad32SKuninori Morimoto 	.id             = 1, /* "ceu1" clock */
3332153ad32SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(ceu1_resources),
3342153ad32SKuninori Morimoto 	.resource	= ceu1_resources,
3352153ad32SKuninori Morimoto 	.dev	= {
3362153ad32SKuninori Morimoto 		.platform_data	= &sh_mobile_ceu1_info,
3372153ad32SKuninori Morimoto 	},
3382153ad32SKuninori Morimoto 	.archdata = {
3392153ad32SKuninori Morimoto 		.hwblk_id = HWBLK_CEU1,
3402153ad32SKuninori Morimoto 	},
3412153ad32SKuninori Morimoto };
3422153ad32SKuninori Morimoto 
343125ecce6SKuninori Morimoto /* I2C device */
3441980fdc4SKuninori Morimoto static struct i2c_board_info i2c0_devices[] = {
3451980fdc4SKuninori Morimoto 	{
3461980fdc4SKuninori Morimoto 		I2C_BOARD_INFO("da7210", 0x1a),
3471980fdc4SKuninori Morimoto 	},
3481980fdc4SKuninori Morimoto };
3491980fdc4SKuninori Morimoto 
350125ecce6SKuninori Morimoto static struct i2c_board_info i2c1_devices[] = {
351125ecce6SKuninori Morimoto 	{
352125ecce6SKuninori Morimoto 		I2C_BOARD_INFO("r2025sd", 0x32),
353125ecce6SKuninori Morimoto 	},
354ea440783SNISHIMOTO Hiroki 	{
355ea440783SNISHIMOTO Hiroki 		I2C_BOARD_INFO("lis3lv02d", 0x1c),
356ea440783SNISHIMOTO Hiroki 		.irq = 33,
357ea440783SNISHIMOTO Hiroki 	}
358125ecce6SKuninori Morimoto };
359125ecce6SKuninori Morimoto 
360e9103e74SKuninori Morimoto /* KEYSC */
361e9103e74SKuninori Morimoto static struct sh_keysc_info keysc_info = {
362e9103e74SKuninori Morimoto 	.mode		= SH_KEYSC_MODE_1,
363e9103e74SKuninori Morimoto 	.scan_timing	= 3,
364e9103e74SKuninori Morimoto 	.delay		= 50,
365e9103e74SKuninori Morimoto 	.kycr2_delay	= 100,
366e9103e74SKuninori Morimoto 	.keycodes	= { KEY_1, 0, 0, 0, 0,
367e9103e74SKuninori Morimoto 			    KEY_2, 0, 0, 0, 0,
368e9103e74SKuninori Morimoto 			    KEY_3, 0, 0, 0, 0,
369e9103e74SKuninori Morimoto 			    KEY_4, 0, 0, 0, 0,
370e9103e74SKuninori Morimoto 			    KEY_5, 0, 0, 0, 0,
371e9103e74SKuninori Morimoto 			    KEY_6, 0, 0, 0, 0, },
372e9103e74SKuninori Morimoto };
373e9103e74SKuninori Morimoto 
374e9103e74SKuninori Morimoto static struct resource keysc_resources[] = {
375e9103e74SKuninori Morimoto 	[0] = {
376e9103e74SKuninori Morimoto 		.name	= "KEYSC",
377e9103e74SKuninori Morimoto 		.start  = 0x044b0000,
378e9103e74SKuninori Morimoto 		.end    = 0x044b000f,
379e9103e74SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
380e9103e74SKuninori Morimoto 	},
381e9103e74SKuninori Morimoto 	[1] = {
382e9103e74SKuninori Morimoto 		.start  = 79,
383e9103e74SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
384e9103e74SKuninori Morimoto 	},
385e9103e74SKuninori Morimoto };
386e9103e74SKuninori Morimoto 
387e9103e74SKuninori Morimoto static struct platform_device keysc_device = {
388e9103e74SKuninori Morimoto 	.name           = "sh_keysc",
389e9103e74SKuninori Morimoto 	.id             = 0, /* keysc0 clock */
390e9103e74SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(keysc_resources),
391e9103e74SKuninori Morimoto 	.resource       = keysc_resources,
392e9103e74SKuninori Morimoto 	.dev	= {
393e9103e74SKuninori Morimoto 		.platform_data	= &keysc_info,
394e9103e74SKuninori Morimoto 	},
395e9103e74SKuninori Morimoto 	.archdata = {
396e9103e74SKuninori Morimoto 		.hwblk_id = HWBLK_KEYSC,
397e9103e74SKuninori Morimoto 	},
398e9103e74SKuninori Morimoto };
399e9103e74SKuninori Morimoto 
4008810e055SKuninori Morimoto /* TouchScreen */
4018810e055SKuninori Morimoto #define IRQ0 32
4028810e055SKuninori Morimoto static int ts_get_pendown_state(void)
4038810e055SKuninori Morimoto {
4048810e055SKuninori Morimoto 	int val = 0;
4058810e055SKuninori Morimoto 	gpio_free(GPIO_FN_INTC_IRQ0);
4068810e055SKuninori Morimoto 	gpio_request(GPIO_PTZ0, NULL);
4078810e055SKuninori Morimoto 	gpio_direction_input(GPIO_PTZ0);
4088810e055SKuninori Morimoto 
4098810e055SKuninori Morimoto 	val = gpio_get_value(GPIO_PTZ0);
4108810e055SKuninori Morimoto 
4118810e055SKuninori Morimoto 	gpio_free(GPIO_PTZ0);
4128810e055SKuninori Morimoto 	gpio_request(GPIO_FN_INTC_IRQ0, NULL);
4138810e055SKuninori Morimoto 
4148810e055SKuninori Morimoto 	return val ? 0 : 1;
4158810e055SKuninori Morimoto }
4168810e055SKuninori Morimoto 
4178810e055SKuninori Morimoto static int ts_init(void)
4188810e055SKuninori Morimoto {
4198810e055SKuninori Morimoto 	gpio_request(GPIO_FN_INTC_IRQ0, NULL);
4208810e055SKuninori Morimoto 	return 0;
4218810e055SKuninori Morimoto }
4228810e055SKuninori Morimoto 
4238810e055SKuninori Morimoto struct tsc2007_platform_data tsc2007_info = {
4248810e055SKuninori Morimoto 	.model			= 2007,
4258810e055SKuninori Morimoto 	.x_plate_ohms		= 180,
4268810e055SKuninori Morimoto 	.get_pendown_state	= ts_get_pendown_state,
4278810e055SKuninori Morimoto 	.init_platform_hw	= ts_init,
4288810e055SKuninori Morimoto };
4298810e055SKuninori Morimoto 
4308810e055SKuninori Morimoto static struct i2c_board_info ts_i2c_clients = {
4318810e055SKuninori Morimoto 	I2C_BOARD_INFO("tsc2007", 0x48),
4328810e055SKuninori Morimoto 	.type		= "tsc2007",
4338810e055SKuninori Morimoto 	.platform_data	= &tsc2007_info,
4348810e055SKuninori Morimoto 	.irq		= IRQ0,
4358810e055SKuninori Morimoto };
4368810e055SKuninori Morimoto 
4371ce4da7aSMagnus Damm #ifdef CONFIG_MFD_SH_MOBILE_SDHI
43896987d96SKuninori Morimoto /* SHDI0 */
43998779ad8SMagnus Damm static void sdhi0_set_pwr(struct platform_device *pdev, int state)
44098779ad8SMagnus Damm {
44198779ad8SMagnus Damm 	gpio_set_value(GPIO_PTB6, state);
44298779ad8SMagnus Damm }
44398779ad8SMagnus Damm 
44498779ad8SMagnus Damm static struct sh_mobile_sdhi_info sdhi0_info = {
44598779ad8SMagnus Damm 	.set_pwr = sdhi0_set_pwr,
44698779ad8SMagnus Damm };
44798779ad8SMagnus Damm 
44896987d96SKuninori Morimoto static struct resource sdhi0_resources[] = {
44996987d96SKuninori Morimoto 	[0] = {
45096987d96SKuninori Morimoto 		.name	= "SDHI0",
45196987d96SKuninori Morimoto 		.start  = 0x04ce0000,
45296987d96SKuninori Morimoto 		.end    = 0x04ce01ff,
45396987d96SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
45496987d96SKuninori Morimoto 	},
45596987d96SKuninori Morimoto 	[1] = {
4563844eadcSMagnus Damm 		.start  = 100,
45796987d96SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
45896987d96SKuninori Morimoto 	},
45996987d96SKuninori Morimoto };
46096987d96SKuninori Morimoto 
46196987d96SKuninori Morimoto static struct platform_device sdhi0_device = {
46296987d96SKuninori Morimoto 	.name           = "sh_mobile_sdhi",
46396987d96SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(sdhi0_resources),
46496987d96SKuninori Morimoto 	.resource       = sdhi0_resources,
46596987d96SKuninori Morimoto 	.id             = 0,
46698779ad8SMagnus Damm 	.dev	= {
46798779ad8SMagnus Damm 		.platform_data	= &sdhi0_info,
46898779ad8SMagnus Damm 	},
46996987d96SKuninori Morimoto 	.archdata = {
47096987d96SKuninori Morimoto 		.hwblk_id = HWBLK_SDHI0,
47196987d96SKuninori Morimoto 	},
47296987d96SKuninori Morimoto };
47396987d96SKuninori Morimoto 
47496987d96SKuninori Morimoto /* SHDI1 */
47598779ad8SMagnus Damm static void sdhi1_set_pwr(struct platform_device *pdev, int state)
47698779ad8SMagnus Damm {
47798779ad8SMagnus Damm 	gpio_set_value(GPIO_PTB7, state);
47898779ad8SMagnus Damm }
47998779ad8SMagnus Damm 
48098779ad8SMagnus Damm static struct sh_mobile_sdhi_info sdhi1_info = {
48198779ad8SMagnus Damm 	.set_pwr = sdhi1_set_pwr,
48298779ad8SMagnus Damm };
48398779ad8SMagnus Damm 
48496987d96SKuninori Morimoto static struct resource sdhi1_resources[] = {
48596987d96SKuninori Morimoto 	[0] = {
48696987d96SKuninori Morimoto 		.name	= "SDHI1",
48796987d96SKuninori Morimoto 		.start  = 0x04cf0000,
48896987d96SKuninori Morimoto 		.end    = 0x04cf01ff,
48996987d96SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
49096987d96SKuninori Morimoto 	},
49196987d96SKuninori Morimoto 	[1] = {
4923844eadcSMagnus Damm 		.start  = 23,
49396987d96SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
49496987d96SKuninori Morimoto 	},
49596987d96SKuninori Morimoto };
49696987d96SKuninori Morimoto 
49796987d96SKuninori Morimoto static struct platform_device sdhi1_device = {
49896987d96SKuninori Morimoto 	.name           = "sh_mobile_sdhi",
49996987d96SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(sdhi1_resources),
50096987d96SKuninori Morimoto 	.resource       = sdhi1_resources,
50196987d96SKuninori Morimoto 	.id             = 1,
50298779ad8SMagnus Damm 	.dev	= {
50398779ad8SMagnus Damm 		.platform_data	= &sdhi1_info,
50498779ad8SMagnus Damm 	},
50596987d96SKuninori Morimoto 	.archdata = {
50696987d96SKuninori Morimoto 		.hwblk_id = HWBLK_SDHI1,
50796987d96SKuninori Morimoto 	},
50896987d96SKuninori Morimoto };
50996987d96SKuninori Morimoto 
5101ce4da7aSMagnus Damm #else
5111ce4da7aSMagnus Damm 
5129503e891SKuninori Morimoto /* MMC SPI */
5131ce4da7aSMagnus Damm static int mmc_spi_get_ro(struct device *dev)
5141ce4da7aSMagnus Damm {
5151ce4da7aSMagnus Damm 	return gpio_get_value(GPIO_PTY6);
5161ce4da7aSMagnus Damm }
5171ce4da7aSMagnus Damm 
5181ce4da7aSMagnus Damm static int mmc_spi_get_cd(struct device *dev)
5191ce4da7aSMagnus Damm {
5201ce4da7aSMagnus Damm 	return !gpio_get_value(GPIO_PTY7);
5211ce4da7aSMagnus Damm }
5221ce4da7aSMagnus Damm 
5231ce4da7aSMagnus Damm static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
5241ce4da7aSMagnus Damm {
5251ce4da7aSMagnus Damm 	gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
5261ce4da7aSMagnus Damm }
5271ce4da7aSMagnus Damm 
5281ce4da7aSMagnus Damm static struct mmc_spi_platform_data mmc_spi_info = {
5291ce4da7aSMagnus Damm 	.get_ro = mmc_spi_get_ro,
5301ce4da7aSMagnus Damm 	.get_cd = mmc_spi_get_cd,
5311ce4da7aSMagnus Damm 	.caps = MMC_CAP_NEEDS_POLL,
5321ce4da7aSMagnus Damm 	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
5331ce4da7aSMagnus Damm 	.setpower = mmc_spi_setpower,
5341ce4da7aSMagnus Damm };
5351ce4da7aSMagnus Damm 
5361ce4da7aSMagnus Damm static struct spi_board_info spi_bus[] = {
5371ce4da7aSMagnus Damm 	{
5381ce4da7aSMagnus Damm 		.modalias	= "mmc_spi",
5391ce4da7aSMagnus Damm 		.platform_data	= &mmc_spi_info,
5401ce4da7aSMagnus Damm 		.max_speed_hz	= 5000000,
5411ce4da7aSMagnus Damm 		.mode		= SPI_MODE_0,
5421ce4da7aSMagnus Damm 		.controller_data = (void *) GPIO_PTM4,
5431ce4da7aSMagnus Damm 	},
5441ce4da7aSMagnus Damm };
5451ce4da7aSMagnus Damm 
5469503e891SKuninori Morimoto /* MSIOF0 */
5471ce4da7aSMagnus Damm static struct sh_msiof_spi_info msiof0_data = {
5481ce4da7aSMagnus Damm 	.num_chipselect = 1,
5491ce4da7aSMagnus Damm };
5501ce4da7aSMagnus Damm 
5511ce4da7aSMagnus Damm static struct resource msiof0_resources[] = {
5521ce4da7aSMagnus Damm 	[0] = {
5531ce4da7aSMagnus Damm 		.name	= "MSIOF0",
5541ce4da7aSMagnus Damm 		.start	= 0xa4c40000,
5551ce4da7aSMagnus Damm 		.end	= 0xa4c40063,
5561ce4da7aSMagnus Damm 		.flags	= IORESOURCE_MEM,
5571ce4da7aSMagnus Damm 	},
5581ce4da7aSMagnus Damm 	[1] = {
5591ce4da7aSMagnus Damm 		.start	= 84,
5601ce4da7aSMagnus Damm 		.flags	= IORESOURCE_IRQ,
5611ce4da7aSMagnus Damm 	},
5621ce4da7aSMagnus Damm };
5631ce4da7aSMagnus Damm 
5641ce4da7aSMagnus Damm static struct platform_device msiof0_device = {
5651ce4da7aSMagnus Damm 	.name		= "spi_sh_msiof",
5661ce4da7aSMagnus Damm 	.id		= 0, /* MSIOF0 */
5671ce4da7aSMagnus Damm 	.dev = {
5681ce4da7aSMagnus Damm 		.platform_data = &msiof0_data,
5691ce4da7aSMagnus Damm 	},
5701ce4da7aSMagnus Damm 	.num_resources	= ARRAY_SIZE(msiof0_resources),
5711ce4da7aSMagnus Damm 	.resource	= msiof0_resources,
5721ce4da7aSMagnus Damm 	.archdata = {
5731ce4da7aSMagnus Damm 		.hwblk_id = HWBLK_MSIOF0,
5741ce4da7aSMagnus Damm 	},
5751ce4da7aSMagnus Damm };
5761ce4da7aSMagnus Damm 
5771ce4da7aSMagnus Damm #endif
5781ce4da7aSMagnus Damm 
5799aa25d64SKuninori Morimoto /* I2C Video/Camera */
580207efd07SKuninori Morimoto static struct i2c_board_info i2c_camera[] = {
581207efd07SKuninori Morimoto 	{
582207efd07SKuninori Morimoto 		I2C_BOARD_INFO("tw9910", 0x45),
583207efd07SKuninori Morimoto 	},
5849aa25d64SKuninori Morimoto 	{
5859aa25d64SKuninori Morimoto 		/* 1st camera */
5869aa25d64SKuninori Morimoto 		I2C_BOARD_INFO("mt9t112", 0x3c),
5879aa25d64SKuninori Morimoto 	},
5889aa25d64SKuninori Morimoto 	{
5899aa25d64SKuninori Morimoto 		/* 2nd camera */
5909aa25d64SKuninori Morimoto 		I2C_BOARD_INFO("mt9t112", 0x3c),
5919aa25d64SKuninori Morimoto 	},
592207efd07SKuninori Morimoto };
593207efd07SKuninori Morimoto 
594207efd07SKuninori Morimoto /* tw9910 */
595207efd07SKuninori Morimoto static int tw9910_power(struct device *dev, int mode)
596207efd07SKuninori Morimoto {
597207efd07SKuninori Morimoto 	int val = mode ? 0 : 1;
598207efd07SKuninori Morimoto 
599207efd07SKuninori Morimoto 	gpio_set_value(GPIO_PTU2, val);
600207efd07SKuninori Morimoto 	if (mode)
601207efd07SKuninori Morimoto 		mdelay(100);
602207efd07SKuninori Morimoto 
603207efd07SKuninori Morimoto 	return 0;
604207efd07SKuninori Morimoto }
605207efd07SKuninori Morimoto 
606207efd07SKuninori Morimoto static struct tw9910_video_info tw9910_info = {
607207efd07SKuninori Morimoto 	.buswidth	= SOCAM_DATAWIDTH_8,
608207efd07SKuninori Morimoto 	.mpout		= TW9910_MPO_FIELD,
609207efd07SKuninori Morimoto };
610207efd07SKuninori Morimoto 
611207efd07SKuninori Morimoto static struct soc_camera_link tw9910_link = {
612207efd07SKuninori Morimoto 	.i2c_adapter_id	= 0,
613207efd07SKuninori Morimoto 	.bus_id		= 1,
614207efd07SKuninori Morimoto 	.power		= tw9910_power,
615207efd07SKuninori Morimoto 	.board_info	= &i2c_camera[0],
616207efd07SKuninori Morimoto 	.module_name	= "tw9910",
617207efd07SKuninori Morimoto 	.priv		= &tw9910_info,
618207efd07SKuninori Morimoto };
619207efd07SKuninori Morimoto 
6209aa25d64SKuninori Morimoto /* mt9t112 */
6219aa25d64SKuninori Morimoto static int mt9t112_power1(struct device *dev, int mode)
6229aa25d64SKuninori Morimoto {
6239aa25d64SKuninori Morimoto 	gpio_set_value(GPIO_PTA3, mode);
6249aa25d64SKuninori Morimoto 	if (mode)
6259aa25d64SKuninori Morimoto 		mdelay(100);
6269aa25d64SKuninori Morimoto 
6279aa25d64SKuninori Morimoto 	return 0;
6289aa25d64SKuninori Morimoto }
6299aa25d64SKuninori Morimoto 
6309aa25d64SKuninori Morimoto static struct mt9t112_camera_info mt9t112_info1 = {
6319aa25d64SKuninori Morimoto 	.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
6329aa25d64SKuninori Morimoto 	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
6339aa25d64SKuninori Morimoto };
6349aa25d64SKuninori Morimoto 
6359aa25d64SKuninori Morimoto static struct soc_camera_link mt9t112_link1 = {
6369aa25d64SKuninori Morimoto 	.i2c_adapter_id	= 0,
6379aa25d64SKuninori Morimoto 	.power		= mt9t112_power1,
6389aa25d64SKuninori Morimoto 	.bus_id		= 0,
6399aa25d64SKuninori Morimoto 	.board_info	= &i2c_camera[1],
6409aa25d64SKuninori Morimoto 	.module_name	= "mt9t112",
6419aa25d64SKuninori Morimoto 	.priv		= &mt9t112_info1,
6429aa25d64SKuninori Morimoto };
6439aa25d64SKuninori Morimoto 
6449aa25d64SKuninori Morimoto static int mt9t112_power2(struct device *dev, int mode)
6459aa25d64SKuninori Morimoto {
6469aa25d64SKuninori Morimoto 	gpio_set_value(GPIO_PTA4, mode);
6479aa25d64SKuninori Morimoto 	if (mode)
6489aa25d64SKuninori Morimoto 		mdelay(100);
6499aa25d64SKuninori Morimoto 
6509aa25d64SKuninori Morimoto 	return 0;
6519aa25d64SKuninori Morimoto }
6529aa25d64SKuninori Morimoto 
6539aa25d64SKuninori Morimoto static struct mt9t112_camera_info mt9t112_info2 = {
6549aa25d64SKuninori Morimoto 	.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
6559aa25d64SKuninori Morimoto 	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
6569aa25d64SKuninori Morimoto };
6579aa25d64SKuninori Morimoto 
6589aa25d64SKuninori Morimoto static struct soc_camera_link mt9t112_link2 = {
6599aa25d64SKuninori Morimoto 	.i2c_adapter_id	= 1,
6609aa25d64SKuninori Morimoto 	.power		= mt9t112_power2,
6619aa25d64SKuninori Morimoto 	.bus_id		= 1,
6629aa25d64SKuninori Morimoto 	.board_info	= &i2c_camera[2],
6639aa25d64SKuninori Morimoto 	.module_name	= "mt9t112",
6649aa25d64SKuninori Morimoto 	.priv		= &mt9t112_info2,
6659aa25d64SKuninori Morimoto };
666207efd07SKuninori Morimoto 
667207efd07SKuninori Morimoto static struct platform_device camera_devices[] = {
668207efd07SKuninori Morimoto 	{
669207efd07SKuninori Morimoto 		.name	= "soc-camera-pdrv",
670207efd07SKuninori Morimoto 		.id	= 0,
671207efd07SKuninori Morimoto 		.dev	= {
672207efd07SKuninori Morimoto 			.platform_data = &tw9910_link,
673207efd07SKuninori Morimoto 		},
674207efd07SKuninori Morimoto 	},
6759aa25d64SKuninori Morimoto 	{
6769aa25d64SKuninori Morimoto 		.name	= "soc-camera-pdrv",
6779aa25d64SKuninori Morimoto 		.id	= 1,
6789aa25d64SKuninori Morimoto 		.dev	= {
6799aa25d64SKuninori Morimoto 			.platform_data = &mt9t112_link1,
6809aa25d64SKuninori Morimoto 		},
6819aa25d64SKuninori Morimoto 	},
6829aa25d64SKuninori Morimoto 	{
6839aa25d64SKuninori Morimoto 		.name	= "soc-camera-pdrv",
6849aa25d64SKuninori Morimoto 		.id	= 2,
6859aa25d64SKuninori Morimoto 		.dev	= {
6869aa25d64SKuninori Morimoto 			.platform_data = &mt9t112_link2,
6879aa25d64SKuninori Morimoto 		},
6889aa25d64SKuninori Morimoto 	},
689207efd07SKuninori Morimoto };
690207efd07SKuninori Morimoto 
6911980fdc4SKuninori Morimoto /* FSI */
6921980fdc4SKuninori Morimoto /*
6931980fdc4SKuninori Morimoto  * FSI-B use external clock which came from da7210.
6941980fdc4SKuninori Morimoto  * So, we should change parent of fsi
6951980fdc4SKuninori Morimoto  */
6961980fdc4SKuninori Morimoto #define FCLKBCR		0xa415000c
6971980fdc4SKuninori Morimoto static void fsimck_init(struct clk *clk)
6981980fdc4SKuninori Morimoto {
6999d56dd3bSPaul Mundt 	u32 status = __raw_readl(clk->enable_reg);
7001980fdc4SKuninori Morimoto 
7011980fdc4SKuninori Morimoto 	/* use external clock */
7021980fdc4SKuninori Morimoto 	status &= ~0x000000ff;
7031980fdc4SKuninori Morimoto 	status |= 0x00000080;
7041980fdc4SKuninori Morimoto 
7059d56dd3bSPaul Mundt 	__raw_writel(status, clk->enable_reg);
7061980fdc4SKuninori Morimoto }
7071980fdc4SKuninori Morimoto 
7081980fdc4SKuninori Morimoto static struct clk_ops fsimck_clk_ops = {
7091980fdc4SKuninori Morimoto 	.init = fsimck_init,
7101980fdc4SKuninori Morimoto };
7111980fdc4SKuninori Morimoto 
7121980fdc4SKuninori Morimoto static struct clk fsimckb_clk = {
7131980fdc4SKuninori Morimoto 	.name		= "fsimckb_clk",
7141980fdc4SKuninori Morimoto 	.id		= -1,
7151980fdc4SKuninori Morimoto 	.ops		= &fsimck_clk_ops,
7161980fdc4SKuninori Morimoto 	.enable_reg	= (void __iomem *)FCLKBCR,
7171980fdc4SKuninori Morimoto 	.rate		= 0, /* unknown */
7181980fdc4SKuninori Morimoto };
7191980fdc4SKuninori Morimoto 
7201980fdc4SKuninori Morimoto struct sh_fsi_platform_info fsi_info = {
7211980fdc4SKuninori Morimoto 	.portb_flags = SH_FSI_BRS_INV |
7221980fdc4SKuninori Morimoto 		       SH_FSI_OUT_SLAVE_MODE |
7231980fdc4SKuninori Morimoto 		       SH_FSI_IN_SLAVE_MODE |
7241980fdc4SKuninori Morimoto 		       SH_FSI_OFMT(I2S) |
7251980fdc4SKuninori Morimoto 		       SH_FSI_IFMT(I2S),
7261980fdc4SKuninori Morimoto };
7271980fdc4SKuninori Morimoto 
7281980fdc4SKuninori Morimoto static struct resource fsi_resources[] = {
7291980fdc4SKuninori Morimoto 	[0] = {
7301980fdc4SKuninori Morimoto 		.name	= "FSI",
7311980fdc4SKuninori Morimoto 		.start	= 0xFE3C0000,
7321980fdc4SKuninori Morimoto 		.end	= 0xFE3C021d,
7331980fdc4SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
7341980fdc4SKuninori Morimoto 	},
7351980fdc4SKuninori Morimoto 	[1] = {
7361980fdc4SKuninori Morimoto 		.start  = 108,
7371980fdc4SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
7381980fdc4SKuninori Morimoto 	},
7391980fdc4SKuninori Morimoto };
7401980fdc4SKuninori Morimoto 
7411980fdc4SKuninori Morimoto static struct platform_device fsi_device = {
7421980fdc4SKuninori Morimoto 	.name		= "sh_fsi",
7431980fdc4SKuninori Morimoto 	.id		= 0,
7441980fdc4SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(fsi_resources),
7451980fdc4SKuninori Morimoto 	.resource	= fsi_resources,
7461980fdc4SKuninori Morimoto 	.dev	= {
7471980fdc4SKuninori Morimoto 		.platform_data	= &fsi_info,
7481980fdc4SKuninori Morimoto 	},
7491980fdc4SKuninori Morimoto 	.archdata = {
7501980fdc4SKuninori Morimoto 		.hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
7511980fdc4SKuninori Morimoto 	},
7521980fdc4SKuninori Morimoto };
7531980fdc4SKuninori Morimoto 
7544138b740SKuninori Morimoto static struct platform_device *ecovec_devices[] __initdata = {
7554138b740SKuninori Morimoto 	&heartbeat_device,
7564138b740SKuninori Morimoto 	&nor_flash_device,
75735a35408SKuninori Morimoto 	&sh_eth_device,
758907050a3SKuninori Morimoto 	&usb0_host_device,
7593714a9a0SKuninori Morimoto 	&usb1_common_device,
760fa3ba51bSKuninori Morimoto 	&lcdc_device,
7612153ad32SKuninori Morimoto 	&ceu0_device,
7622153ad32SKuninori Morimoto 	&ceu1_device,
763e9103e74SKuninori Morimoto 	&keysc_device,
7641ce4da7aSMagnus Damm #ifdef CONFIG_MFD_SH_MOBILE_SDHI
76596987d96SKuninori Morimoto 	&sdhi0_device,
76696987d96SKuninori Morimoto 	&sdhi1_device,
7671ce4da7aSMagnus Damm #else
7681ce4da7aSMagnus Damm 	&msiof0_device,
7691ce4da7aSMagnus Damm #endif
770207efd07SKuninori Morimoto 	&camera_devices[0],
7719aa25d64SKuninori Morimoto 	&camera_devices[1],
7729aa25d64SKuninori Morimoto 	&camera_devices[2],
7731980fdc4SKuninori Morimoto 	&fsi_device,
7744138b740SKuninori Morimoto };
7754138b740SKuninori Morimoto 
7764907d57fSKuninori Morimoto #define EEPROM_ADDR 0x50
7774907d57fSKuninori Morimoto static u8 mac_read(struct i2c_adapter *a, u8 command)
7784907d57fSKuninori Morimoto {
7794907d57fSKuninori Morimoto 	struct i2c_msg msg[2];
7804907d57fSKuninori Morimoto 	u8 buf;
7814907d57fSKuninori Morimoto 	int ret;
7824907d57fSKuninori Morimoto 
7834907d57fSKuninori Morimoto 	msg[0].addr  = EEPROM_ADDR;
7844907d57fSKuninori Morimoto 	msg[0].flags = 0;
7854907d57fSKuninori Morimoto 	msg[0].len   = 1;
7864907d57fSKuninori Morimoto 	msg[0].buf   = &command;
7874907d57fSKuninori Morimoto 
7884907d57fSKuninori Morimoto 	msg[1].addr  = EEPROM_ADDR;
7894907d57fSKuninori Morimoto 	msg[1].flags = I2C_M_RD;
7904907d57fSKuninori Morimoto 	msg[1].len   = 1;
7914907d57fSKuninori Morimoto 	msg[1].buf   = &buf;
7924907d57fSKuninori Morimoto 
7934907d57fSKuninori Morimoto 	ret = i2c_transfer(a, msg, 2);
7944907d57fSKuninori Morimoto 	if (ret < 0) {
7954907d57fSKuninori Morimoto 		printk(KERN_ERR "error %d\n", ret);
7964907d57fSKuninori Morimoto 		buf = 0xff;
7974907d57fSKuninori Morimoto 	}
7984907d57fSKuninori Morimoto 
7994907d57fSKuninori Morimoto 	return buf;
8004907d57fSKuninori Morimoto }
8014907d57fSKuninori Morimoto 
802376abbb4SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
8034907d57fSKuninori Morimoto {
8044907d57fSKuninori Morimoto 	struct i2c_adapter *a = i2c_get_adapter(1);
8054907d57fSKuninori Morimoto 	int i;
8064907d57fSKuninori Morimoto 
8074907d57fSKuninori Morimoto 	if (!a) {
8084907d57fSKuninori Morimoto 		pr_err("can not get I2C 1\n");
8094907d57fSKuninori Morimoto 		return;
8104907d57fSKuninori Morimoto 	}
8114907d57fSKuninori Morimoto 
8124907d57fSKuninori Morimoto 	/* read MAC address frome EEPROM */
813376abbb4SMagnus Damm 	for (i = 0; i < sizeof(pd->mac_addr); i++) {
814376abbb4SMagnus Damm 		pd->mac_addr[i] = mac_read(a, 0x10 + i);
8154907d57fSKuninori Morimoto 		msleep(10);
8164907d57fSKuninori Morimoto 	}
8174907d57fSKuninori Morimoto }
8184907d57fSKuninori Morimoto 
819fa3ba51bSKuninori Morimoto #define PORT_HIZA 0xA4050158
820ea15edb2SKuninori Morimoto #define IODRIVEA  0xA405018A
821eb0cd9e8SMagnus Damm 
822eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_start;
823eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_end;
824eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_start;
825eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_end;
826eb0cd9e8SMagnus Damm 
8274907d57fSKuninori Morimoto static int __init arch_setup(void)
8284138b740SKuninori Morimoto {
8291980fdc4SKuninori Morimoto 	struct clk *clk;
8301980fdc4SKuninori Morimoto 
831eb0cd9e8SMagnus Damm 	/* register board specific self-refresh code */
832eb0cd9e8SMagnus Damm 	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
833eb0cd9e8SMagnus Damm 					&ecovec24_sdram_enter_start,
834eb0cd9e8SMagnus Damm 					&ecovec24_sdram_enter_end,
835eb0cd9e8SMagnus Damm 					&ecovec24_sdram_leave_start,
836eb0cd9e8SMagnus Damm 					&ecovec24_sdram_leave_end);
837eb0cd9e8SMagnus Damm 
838f78bab30SMagnus Damm 	/* enable STATUS0, STATUS2 and PDSTATUS */
839f78bab30SMagnus Damm 	gpio_request(GPIO_FN_STATUS0, NULL);
840f78bab30SMagnus Damm 	gpio_request(GPIO_FN_STATUS2, NULL);
841f78bab30SMagnus Damm 	gpio_request(GPIO_FN_PDSTATUS, NULL);
842f78bab30SMagnus Damm 
8434138b740SKuninori Morimoto 	/* enable SCIFA0 */
8444138b740SKuninori Morimoto 	gpio_request(GPIO_FN_SCIF0_TXD, NULL);
8454138b740SKuninori Morimoto 	gpio_request(GPIO_FN_SCIF0_RXD, NULL);
8464138b740SKuninori Morimoto 
8474138b740SKuninori Morimoto 	/* enable debug LED */
8484138b740SKuninori Morimoto 	gpio_request(GPIO_PTG0, NULL);
8494138b740SKuninori Morimoto 	gpio_request(GPIO_PTG1, NULL);
8504138b740SKuninori Morimoto 	gpio_request(GPIO_PTG2, NULL);
8514138b740SKuninori Morimoto 	gpio_request(GPIO_PTG3, NULL);
852b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG0, 0);
853b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG1, 0);
854b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG2, 0);
855b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG3, 0);
8569d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
8574138b740SKuninori Morimoto 
85835a35408SKuninori Morimoto 	/* enable SH-Eth */
85935a35408SKuninori Morimoto 	gpio_request(GPIO_PTA1, NULL);
86035a35408SKuninori Morimoto 	gpio_direction_output(GPIO_PTA1, 1);
86135a35408SKuninori Morimoto 	mdelay(20);
86235a35408SKuninori Morimoto 
86335a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RXD0,    NULL);
86435a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RXD1,    NULL);
86535a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TXD0,    NULL);
86635a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TXD1,    NULL);
86735a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
86835a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
86935a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
87035a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
87135a35408SKuninori Morimoto 	gpio_request(GPIO_FN_MDIO,         NULL);
87235a35408SKuninori Morimoto 	gpio_request(GPIO_FN_MDC,          NULL);
87335a35408SKuninori Morimoto 	gpio_request(GPIO_FN_LNKSTA,       NULL);
87435a35408SKuninori Morimoto 
875907050a3SKuninori Morimoto 	/* enable USB */
8769d56dd3bSPaul Mundt 	__raw_writew(0x0000, 0xA4D80000);
8779d56dd3bSPaul Mundt 	__raw_writew(0x0000, 0xA4D90000);
878907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB3,  NULL);
879907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB4,  NULL);
880907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB5,  NULL);
881907050a3SKuninori Morimoto 	gpio_direction_input(GPIO_PTB3);
882907050a3SKuninori Morimoto 	gpio_direction_output(GPIO_PTB4, 0);
883907050a3SKuninori Morimoto 	gpio_direction_output(GPIO_PTB5, 0);
8849d56dd3bSPaul Mundt 	__raw_writew(0x0600, 0xa40501d4);
8859d56dd3bSPaul Mundt 	__raw_writew(0x0600, 0xa4050192);
886907050a3SKuninori Morimoto 
8873714a9a0SKuninori Morimoto 	if (gpio_get_value(GPIO_PTB3)) {
8883714a9a0SKuninori Morimoto 		printk(KERN_INFO "USB1 function is selected\n");
8893714a9a0SKuninori Morimoto 		usb1_common_device.name = "r8a66597_udc";
8903714a9a0SKuninori Morimoto 	} else {
8913714a9a0SKuninori Morimoto 		printk(KERN_INFO "USB1 host is selected\n");
8923714a9a0SKuninori Morimoto 		usb1_common_device.name = "r8a66597_hcd";
8933714a9a0SKuninori Morimoto 	}
8943714a9a0SKuninori Morimoto 
895fa3ba51bSKuninori Morimoto 	/* enable LCDC */
896fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD23,   NULL);
897fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD22,   NULL);
898fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD21,   NULL);
899fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD20,   NULL);
900fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD19,   NULL);
901fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD18,   NULL);
902fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD17,   NULL);
903fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD16,   NULL);
904fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD15,   NULL);
905fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD14,   NULL);
906fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD13,   NULL);
907fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD12,   NULL);
908fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD11,   NULL);
909fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD10,   NULL);
910fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD9,    NULL);
911fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD8,    NULL);
912fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD7,    NULL);
913fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD6,    NULL);
914fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD5,    NULL);
915fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD4,    NULL);
916fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD3,    NULL);
917fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD2,    NULL);
918fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD1,    NULL);
919fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD0,    NULL);
920fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDISP,  NULL);
921fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDHSYN,  NULL);
922fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDCK,   NULL);
923fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDVSYN,  NULL);
924fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDON,   NULL);
925fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDLCLK,  NULL);
9269d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
927fa3ba51bSKuninori Morimoto 
928fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTE6, NULL);
929fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTU1, NULL);
930fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTR1, NULL);
931fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTA2, NULL);
932fa3ba51bSKuninori Morimoto 	gpio_direction_input(GPIO_PTE6);
933fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTU1, 0);
934fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTR1, 0);
935fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTA2, 0);
936fa3ba51bSKuninori Morimoto 
93782b33221SKuninori Morimoto 	/* I/O buffer drive ability is high */
9389d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
939ea15edb2SKuninori Morimoto 
940fa3ba51bSKuninori Morimoto 	if (gpio_get_value(GPIO_PTE6)) {
941fa3ba51bSKuninori Morimoto 		/* DVI */
942fa3ba51bSKuninori Morimoto 		lcdc_info.clock_source			= LCDC_CLK_EXTERNAL;
943ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].clock_divider		= 1,
944fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.name		= "DVI";
945fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.xres		= 1280;
946fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.yres		= 720;
947fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.left_margin	= 220;
948fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.right_margin	= 110;
949fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.hsync_len	= 40;
950fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.upper_margin	= 20;
951fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.lower_margin	= 5;
952fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.vsync_len	= 5;
953fa3ba51bSKuninori Morimoto 
954fa3ba51bSKuninori Morimoto 		gpio_set_value(GPIO_PTA2, 1);
955fa3ba51bSKuninori Morimoto 		gpio_set_value(GPIO_PTU1, 1);
956fa3ba51bSKuninori Morimoto 	} else {
957fa3ba51bSKuninori Morimoto 		/* Panel */
958ea15edb2SKuninori Morimoto 
959ea15edb2SKuninori Morimoto 		lcdc_info.clock_source			= LCDC_CLK_PERIPHERAL;
960ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].clock_divider		= 2,
961ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.name		= "Panel";
962ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.xres		= 800;
963ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.yres		= 480;
964ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.left_margin	= 220;
965ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.right_margin	= 110;
966ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.hsync_len	= 70;
967ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.upper_margin	= 20;
968ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.lower_margin	= 5;
969ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.vsync_len	= 5;
970ea15edb2SKuninori Morimoto 
971ea15edb2SKuninori Morimoto 		gpio_set_value(GPIO_PTR1, 1);
972ea15edb2SKuninori Morimoto 
973ea15edb2SKuninori Morimoto 		/* FIXME
974ea15edb2SKuninori Morimoto 		 *
975ea15edb2SKuninori Morimoto 		 * LCDDON control is needed for Panel,
976ea15edb2SKuninori Morimoto 		 * but current sh_mobile_lcdc driver doesn't control it.
977ea15edb2SKuninori Morimoto 		 * It is temporary correspondence
978ea15edb2SKuninori Morimoto 		 */
979ea15edb2SKuninori Morimoto 		gpio_request(GPIO_PTF4, NULL);
980ea15edb2SKuninori Morimoto 		gpio_direction_output(GPIO_PTF4, 1);
9818810e055SKuninori Morimoto 
9828810e055SKuninori Morimoto 		/* enable TouchScreen */
9838810e055SKuninori Morimoto 		i2c_register_board_info(0, &ts_i2c_clients, 1);
9848810e055SKuninori Morimoto 		set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
985fa3ba51bSKuninori Morimoto 	}
986fa3ba51bSKuninori Morimoto 
9872153ad32SKuninori Morimoto 	/* enable CEU0 */
9882153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D15, NULL);
9892153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D14, NULL);
9902153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D13, NULL);
9912153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D12, NULL);
9922153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D11, NULL);
9932153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D10, NULL);
9942153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D9,  NULL);
9952153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D8,  NULL);
9962153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D7,  NULL);
9972153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D6,  NULL);
9982153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D5,  NULL);
9992153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D4,  NULL);
10002153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D3,  NULL);
10012153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D2,  NULL);
10022153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D1,  NULL);
10032153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D0,  NULL);
10042153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_VD,  NULL);
10052153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_CLK, NULL);
10062153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_FLD, NULL);
10072153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_HD,  NULL);
10082153ad32SKuninori Morimoto 	platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
10092153ad32SKuninori Morimoto 
10102153ad32SKuninori Morimoto 	/* enable CEU1 */
10112153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D7,  NULL);
10122153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D6,  NULL);
10132153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D5,  NULL);
10142153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D4,  NULL);
10152153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D3,  NULL);
10162153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D2,  NULL);
10172153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D1,  NULL);
10182153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D0,  NULL);
10192153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_FLD, NULL);
10202153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_HD,  NULL);
10212153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_VD,  NULL);
10222153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_CLK, NULL);
10232153ad32SKuninori Morimoto 	platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
10242153ad32SKuninori Morimoto 
1025e9103e74SKuninori Morimoto 	/* enable KEYSC */
1026e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
1027e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
1028e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT3,     NULL);
1029e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT2,     NULL);
1030e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT1,     NULL);
1031e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT0,     NULL);
1032e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYIN0,      NULL);
1033e9103e74SKuninori Morimoto 
1034064a16dcSKuninori Morimoto 	/* enable user debug switch */
1035064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR0, NULL);
1036064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR4, NULL);
1037064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR5, NULL);
1038064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR6, NULL);
1039064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR0);
1040064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR4);
1041064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR5);
1042064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR6);
1043064a16dcSKuninori Morimoto 
10441ce4da7aSMagnus Damm #ifdef CONFIG_MFD_SH_MOBILE_SDHI
10451ce4da7aSMagnus Damm 	/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
104696987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CD,  NULL);
104796987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0WP,  NULL);
104896987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CMD, NULL);
104996987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CLK, NULL);
105096987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D3,  NULL);
105196987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D2,  NULL);
105296987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D1,  NULL);
105396987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D0,  NULL);
105498779ad8SMagnus Damm 	gpio_request(GPIO_PTB6, NULL);
105598779ad8SMagnus Damm 	gpio_direction_output(GPIO_PTB6, 0);
105696987d96SKuninori Morimoto 
10571ce4da7aSMagnus Damm 	/* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
105896987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1CD,  NULL);
105996987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1WP,  NULL);
106096987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1CMD, NULL);
106196987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1CLK, NULL);
106296987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D3,  NULL);
106396987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D2,  NULL);
106496987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D1,  NULL);
106596987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D0,  NULL);
106696987d96SKuninori Morimoto 	gpio_request(GPIO_PTB7, NULL);
106798779ad8SMagnus Damm 	gpio_direction_output(GPIO_PTB7, 0);
106896987d96SKuninori Morimoto 
106996987d96SKuninori Morimoto 	/* I/O buffer drive ability is high for SDHI1 */
10709d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
10711ce4da7aSMagnus Damm #else
10721ce4da7aSMagnus Damm 	/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
10731ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
10741ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
10751ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
10761ce4da7aSMagnus Damm 	gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
10771ce4da7aSMagnus Damm 	gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
10781ce4da7aSMagnus Damm 	gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
10791ce4da7aSMagnus Damm 	gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
10801ce4da7aSMagnus Damm 	gpio_request(GPIO_PTY6, NULL); /* write protect */
10811ce4da7aSMagnus Damm 	gpio_direction_input(GPIO_PTY6);
10821ce4da7aSMagnus Damm 	gpio_request(GPIO_PTY7, NULL); /* card detect */
10831ce4da7aSMagnus Damm 	gpio_direction_input(GPIO_PTY7);
10841ce4da7aSMagnus Damm 
10851ce4da7aSMagnus Damm 	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
10861ce4da7aSMagnus Damm #endif
108796987d96SKuninori Morimoto 
1088207efd07SKuninori Morimoto 	/* enable Video */
1089207efd07SKuninori Morimoto 	gpio_request(GPIO_PTU2, NULL);
1090207efd07SKuninori Morimoto 	gpio_direction_output(GPIO_PTU2, 1);
1091207efd07SKuninori Morimoto 
10929aa25d64SKuninori Morimoto 	/* enable Camera */
10939aa25d64SKuninori Morimoto 	gpio_request(GPIO_PTA3, NULL);
10949aa25d64SKuninori Morimoto 	gpio_request(GPIO_PTA4, NULL);
10959aa25d64SKuninori Morimoto 	gpio_direction_output(GPIO_PTA3, 0);
10969aa25d64SKuninori Morimoto 	gpio_direction_output(GPIO_PTA4, 0);
10979aa25d64SKuninori Morimoto 
10981980fdc4SKuninori Morimoto 	/* enable FSI */
10991980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIMCKB,    NULL);
11001980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBSD,    NULL);
11011980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBSD,    NULL);
11021980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBBCK,   NULL);
11031980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBLRCK,  NULL);
11041980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBBCK,   NULL);
11051980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
11061980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
11071980fdc4SKuninori Morimoto 
11081980fdc4SKuninori Morimoto 	/* change parent of FSI B */
11091980fdc4SKuninori Morimoto 	clk = clk_get(NULL, "fsib_clk");
11101980fdc4SKuninori Morimoto 	clk_register(&fsimckb_clk);
11111980fdc4SKuninori Morimoto 	clk_set_parent(clk, &fsimckb_clk);
11121980fdc4SKuninori Morimoto 	clk_set_rate(clk, 11000);
11131980fdc4SKuninori Morimoto 	clk_set_rate(&fsimckb_clk, 11000);
11141980fdc4SKuninori Morimoto 	clk_put(clk);
11151980fdc4SKuninori Morimoto 
11161980fdc4SKuninori Morimoto 	gpio_request(GPIO_PTU0, NULL);
11171980fdc4SKuninori Morimoto 	gpio_direction_output(GPIO_PTU0, 0);
11181980fdc4SKuninori Morimoto 	mdelay(20);
11191980fdc4SKuninori Morimoto 
1120ea440783SNISHIMOTO Hiroki 	/* enable motion sensor */
1121ea440783SNISHIMOTO Hiroki 	gpio_request(GPIO_FN_INTC_IRQ1, NULL);
1122ea440783SNISHIMOTO Hiroki 	gpio_direction_input(GPIO_FN_INTC_IRQ1);
1123ea440783SNISHIMOTO Hiroki 
1124*6f26d19fSMagnus Damm 	/* set VPU clock to 166 MHz */
1125*6f26d19fSMagnus Damm 	clk = clk_get(NULL, "vpu_clk");
1126*6f26d19fSMagnus Damm 	clk_set_rate(clk, clk_round_rate(clk, 166000000));
1127*6f26d19fSMagnus Damm 	clk_put(clk);
1128*6f26d19fSMagnus Damm 
1129125ecce6SKuninori Morimoto 	/* enable I2C device */
11301980fdc4SKuninori Morimoto 	i2c_register_board_info(0, i2c0_devices,
11311980fdc4SKuninori Morimoto 				ARRAY_SIZE(i2c0_devices));
11321980fdc4SKuninori Morimoto 
1133125ecce6SKuninori Morimoto 	i2c_register_board_info(1, i2c1_devices,
1134125ecce6SKuninori Morimoto 				ARRAY_SIZE(i2c1_devices));
1135125ecce6SKuninori Morimoto 
11364138b740SKuninori Morimoto 	return platform_add_devices(ecovec_devices,
11374138b740SKuninori Morimoto 				    ARRAY_SIZE(ecovec_devices));
11384138b740SKuninori Morimoto }
11394907d57fSKuninori Morimoto arch_initcall(arch_setup);
11404907d57fSKuninori Morimoto 
11414907d57fSKuninori Morimoto static int __init devices_setup(void)
11424907d57fSKuninori Morimoto {
1143376abbb4SMagnus Damm 	sh_eth_init(&sh_eth_plat);
11444907d57fSKuninori Morimoto 	return 0;
11454907d57fSKuninori Morimoto }
11464907d57fSKuninori Morimoto device_initcall(devices_setup);
11474907d57fSKuninori Morimoto 
11484138b740SKuninori Morimoto static struct sh_machine_vector mv_ecovec __initmv = {
11494138b740SKuninori Morimoto 	.mv_name	= "R0P7724 (EcoVec)",
11504138b740SKuninori Morimoto };
1151