xref: /openbmc/linux/arch/sh/boards/mach-ecovec24/setup.c (revision aee5ab0bbd224b618408cacfcc656699feec4230)
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 	.ops		= &fsimck_clk_ops,
7141980fdc4SKuninori Morimoto 	.enable_reg	= (void __iomem *)FCLKBCR,
7151980fdc4SKuninori Morimoto 	.rate		= 0, /* unknown */
7161980fdc4SKuninori Morimoto };
7171980fdc4SKuninori Morimoto 
7181980fdc4SKuninori Morimoto struct sh_fsi_platform_info fsi_info = {
7191980fdc4SKuninori Morimoto 	.portb_flags = SH_FSI_BRS_INV |
7201980fdc4SKuninori Morimoto 		       SH_FSI_OUT_SLAVE_MODE |
7211980fdc4SKuninori Morimoto 		       SH_FSI_IN_SLAVE_MODE |
7221980fdc4SKuninori Morimoto 		       SH_FSI_OFMT(I2S) |
7231980fdc4SKuninori Morimoto 		       SH_FSI_IFMT(I2S),
7241980fdc4SKuninori Morimoto };
7251980fdc4SKuninori Morimoto 
7261980fdc4SKuninori Morimoto static struct resource fsi_resources[] = {
7271980fdc4SKuninori Morimoto 	[0] = {
7281980fdc4SKuninori Morimoto 		.name	= "FSI",
7291980fdc4SKuninori Morimoto 		.start	= 0xFE3C0000,
7301980fdc4SKuninori Morimoto 		.end	= 0xFE3C021d,
7311980fdc4SKuninori Morimoto 		.flags	= IORESOURCE_MEM,
7321980fdc4SKuninori Morimoto 	},
7331980fdc4SKuninori Morimoto 	[1] = {
7341980fdc4SKuninori Morimoto 		.start  = 108,
7351980fdc4SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
7361980fdc4SKuninori Morimoto 	},
7371980fdc4SKuninori Morimoto };
7381980fdc4SKuninori Morimoto 
7391980fdc4SKuninori Morimoto static struct platform_device fsi_device = {
7401980fdc4SKuninori Morimoto 	.name		= "sh_fsi",
7411980fdc4SKuninori Morimoto 	.id		= 0,
7421980fdc4SKuninori Morimoto 	.num_resources	= ARRAY_SIZE(fsi_resources),
7431980fdc4SKuninori Morimoto 	.resource	= fsi_resources,
7441980fdc4SKuninori Morimoto 	.dev	= {
7451980fdc4SKuninori Morimoto 		.platform_data	= &fsi_info,
7461980fdc4SKuninori Morimoto 	},
7471980fdc4SKuninori Morimoto 	.archdata = {
7481980fdc4SKuninori Morimoto 		.hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
7491980fdc4SKuninori Morimoto 	},
7501980fdc4SKuninori Morimoto };
7511980fdc4SKuninori Morimoto 
75226365716SKuninori Morimoto /* IrDA */
75326365716SKuninori Morimoto static struct resource irda_resources[] = {
75426365716SKuninori Morimoto 	[0] = {
75526365716SKuninori Morimoto 		.name	= "IrDA",
75626365716SKuninori Morimoto 		.start  = 0xA45D0000,
75726365716SKuninori Morimoto 		.end    = 0xA45D0049,
75826365716SKuninori Morimoto 		.flags  = IORESOURCE_MEM,
75926365716SKuninori Morimoto 	},
76026365716SKuninori Morimoto 	[1] = {
76126365716SKuninori Morimoto 		.start  = 20,
76226365716SKuninori Morimoto 		.flags  = IORESOURCE_IRQ,
76326365716SKuninori Morimoto 	},
76426365716SKuninori Morimoto };
76526365716SKuninori Morimoto 
76626365716SKuninori Morimoto static struct platform_device irda_device = {
76726365716SKuninori Morimoto 	.name           = "sh_sir",
76826365716SKuninori Morimoto 	.num_resources  = ARRAY_SIZE(irda_resources),
76926365716SKuninori Morimoto 	.resource       = irda_resources,
77026365716SKuninori Morimoto };
77126365716SKuninori Morimoto 
772*aee5ab0bSGuennadi Liakhovetski #include <media/ak881x.h>
773*aee5ab0bSGuennadi Liakhovetski #include <media/sh_vou.h>
774*aee5ab0bSGuennadi Liakhovetski 
775*aee5ab0bSGuennadi Liakhovetski struct ak881x_pdata ak881x_pdata = {
776*aee5ab0bSGuennadi Liakhovetski 	.flags = AK881X_IF_MODE_SLAVE,
777*aee5ab0bSGuennadi Liakhovetski };
778*aee5ab0bSGuennadi Liakhovetski 
779*aee5ab0bSGuennadi Liakhovetski static struct i2c_board_info ak8813 = {
780*aee5ab0bSGuennadi Liakhovetski 	I2C_BOARD_INFO("ak8813", 0x20),
781*aee5ab0bSGuennadi Liakhovetski 	.platform_data = &ak881x_pdata,
782*aee5ab0bSGuennadi Liakhovetski };
783*aee5ab0bSGuennadi Liakhovetski 
784*aee5ab0bSGuennadi Liakhovetski struct sh_vou_pdata sh_vou_pdata = {
785*aee5ab0bSGuennadi Liakhovetski 	.bus_fmt	= SH_VOU_BUS_8BIT,
786*aee5ab0bSGuennadi Liakhovetski 	.flags		= SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
787*aee5ab0bSGuennadi Liakhovetski 	.board_info	= &ak8813,
788*aee5ab0bSGuennadi Liakhovetski 	.i2c_adap	= 0,
789*aee5ab0bSGuennadi Liakhovetski 	.module_name	= "ak881x",
790*aee5ab0bSGuennadi Liakhovetski };
791*aee5ab0bSGuennadi Liakhovetski 
792*aee5ab0bSGuennadi Liakhovetski static struct resource sh_vou_resources[] = {
793*aee5ab0bSGuennadi Liakhovetski 	[0] = {
794*aee5ab0bSGuennadi Liakhovetski 		.start  = 0xfe960000,
795*aee5ab0bSGuennadi Liakhovetski 		.end    = 0xfe962043,
796*aee5ab0bSGuennadi Liakhovetski 		.flags  = IORESOURCE_MEM,
797*aee5ab0bSGuennadi Liakhovetski 	},
798*aee5ab0bSGuennadi Liakhovetski 	[1] = {
799*aee5ab0bSGuennadi Liakhovetski 		.start  = 55,
800*aee5ab0bSGuennadi Liakhovetski 		.flags  = IORESOURCE_IRQ,
801*aee5ab0bSGuennadi Liakhovetski 	},
802*aee5ab0bSGuennadi Liakhovetski };
803*aee5ab0bSGuennadi Liakhovetski 
804*aee5ab0bSGuennadi Liakhovetski static struct platform_device vou_device = {
805*aee5ab0bSGuennadi Liakhovetski 	.name           = "sh-vou",
806*aee5ab0bSGuennadi Liakhovetski 	.id		= -1,
807*aee5ab0bSGuennadi Liakhovetski 	.num_resources  = ARRAY_SIZE(sh_vou_resources),
808*aee5ab0bSGuennadi Liakhovetski 	.resource       = sh_vou_resources,
809*aee5ab0bSGuennadi Liakhovetski 	.dev		= {
810*aee5ab0bSGuennadi Liakhovetski 		.platform_data	= &sh_vou_pdata,
811*aee5ab0bSGuennadi Liakhovetski 	},
812*aee5ab0bSGuennadi Liakhovetski 	.archdata	= {
813*aee5ab0bSGuennadi Liakhovetski 		.hwblk_id	= HWBLK_VOU,
814*aee5ab0bSGuennadi Liakhovetski 	},
815*aee5ab0bSGuennadi Liakhovetski };
816*aee5ab0bSGuennadi Liakhovetski 
8174138b740SKuninori Morimoto static struct platform_device *ecovec_devices[] __initdata = {
8184138b740SKuninori Morimoto 	&heartbeat_device,
8194138b740SKuninori Morimoto 	&nor_flash_device,
82035a35408SKuninori Morimoto 	&sh_eth_device,
821907050a3SKuninori Morimoto 	&usb0_host_device,
8223714a9a0SKuninori Morimoto 	&usb1_common_device,
823fa3ba51bSKuninori Morimoto 	&lcdc_device,
8242153ad32SKuninori Morimoto 	&ceu0_device,
8252153ad32SKuninori Morimoto 	&ceu1_device,
826e9103e74SKuninori Morimoto 	&keysc_device,
8271ce4da7aSMagnus Damm #ifdef CONFIG_MFD_SH_MOBILE_SDHI
82896987d96SKuninori Morimoto 	&sdhi0_device,
82996987d96SKuninori Morimoto 	&sdhi1_device,
8301ce4da7aSMagnus Damm #else
8311ce4da7aSMagnus Damm 	&msiof0_device,
8321ce4da7aSMagnus Damm #endif
833207efd07SKuninori Morimoto 	&camera_devices[0],
8349aa25d64SKuninori Morimoto 	&camera_devices[1],
8359aa25d64SKuninori Morimoto 	&camera_devices[2],
8361980fdc4SKuninori Morimoto 	&fsi_device,
83726365716SKuninori Morimoto 	&irda_device,
838*aee5ab0bSGuennadi Liakhovetski 	&vou_device,
8394138b740SKuninori Morimoto };
8404138b740SKuninori Morimoto 
8416b3b5575SMagnus Damm #ifdef CONFIG_I2C
8424907d57fSKuninori Morimoto #define EEPROM_ADDR 0x50
8434907d57fSKuninori Morimoto static u8 mac_read(struct i2c_adapter *a, u8 command)
8444907d57fSKuninori Morimoto {
8454907d57fSKuninori Morimoto 	struct i2c_msg msg[2];
8464907d57fSKuninori Morimoto 	u8 buf;
8474907d57fSKuninori Morimoto 	int ret;
8484907d57fSKuninori Morimoto 
8494907d57fSKuninori Morimoto 	msg[0].addr  = EEPROM_ADDR;
8504907d57fSKuninori Morimoto 	msg[0].flags = 0;
8514907d57fSKuninori Morimoto 	msg[0].len   = 1;
8524907d57fSKuninori Morimoto 	msg[0].buf   = &command;
8534907d57fSKuninori Morimoto 
8544907d57fSKuninori Morimoto 	msg[1].addr  = EEPROM_ADDR;
8554907d57fSKuninori Morimoto 	msg[1].flags = I2C_M_RD;
8564907d57fSKuninori Morimoto 	msg[1].len   = 1;
8574907d57fSKuninori Morimoto 	msg[1].buf   = &buf;
8584907d57fSKuninori Morimoto 
8594907d57fSKuninori Morimoto 	ret = i2c_transfer(a, msg, 2);
8604907d57fSKuninori Morimoto 	if (ret < 0) {
8614907d57fSKuninori Morimoto 		printk(KERN_ERR "error %d\n", ret);
8624907d57fSKuninori Morimoto 		buf = 0xff;
8634907d57fSKuninori Morimoto 	}
8644907d57fSKuninori Morimoto 
8654907d57fSKuninori Morimoto 	return buf;
8664907d57fSKuninori Morimoto }
8674907d57fSKuninori Morimoto 
868376abbb4SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
8694907d57fSKuninori Morimoto {
8704907d57fSKuninori Morimoto 	struct i2c_adapter *a = i2c_get_adapter(1);
8714907d57fSKuninori Morimoto 	int i;
8724907d57fSKuninori Morimoto 
8734907d57fSKuninori Morimoto 	if (!a) {
8744907d57fSKuninori Morimoto 		pr_err("can not get I2C 1\n");
8754907d57fSKuninori Morimoto 		return;
8764907d57fSKuninori Morimoto 	}
8774907d57fSKuninori Morimoto 
8784907d57fSKuninori Morimoto 	/* read MAC address frome EEPROM */
879376abbb4SMagnus Damm 	for (i = 0; i < sizeof(pd->mac_addr); i++) {
880376abbb4SMagnus Damm 		pd->mac_addr[i] = mac_read(a, 0x10 + i);
8814907d57fSKuninori Morimoto 		msleep(10);
8824907d57fSKuninori Morimoto 	}
883b230eb32SKuninori Morimoto 
884b230eb32SKuninori Morimoto 	i2c_put_adapter(a);
8854907d57fSKuninori Morimoto }
8866b3b5575SMagnus Damm #else
8876b3b5575SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
8886b3b5575SMagnus Damm {
8896b3b5575SMagnus Damm 	pr_err("unable to read sh_eth MAC address\n");
8906b3b5575SMagnus Damm }
8916b3b5575SMagnus Damm #endif
8924907d57fSKuninori Morimoto 
893fa3ba51bSKuninori Morimoto #define PORT_HIZA 0xA4050158
894ea15edb2SKuninori Morimoto #define IODRIVEA  0xA405018A
895eb0cd9e8SMagnus Damm 
896eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_start;
897eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_end;
898eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_start;
899eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_end;
900eb0cd9e8SMagnus Damm 
9014907d57fSKuninori Morimoto static int __init arch_setup(void)
9024138b740SKuninori Morimoto {
9031980fdc4SKuninori Morimoto 	struct clk *clk;
9041980fdc4SKuninori Morimoto 
905eb0cd9e8SMagnus Damm 	/* register board specific self-refresh code */
9062839bd61SMagnus Damm 	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
9072839bd61SMagnus Damm 					SUSP_SH_RSTANDBY,
908eb0cd9e8SMagnus Damm 					&ecovec24_sdram_enter_start,
909eb0cd9e8SMagnus Damm 					&ecovec24_sdram_enter_end,
910eb0cd9e8SMagnus Damm 					&ecovec24_sdram_leave_start,
911eb0cd9e8SMagnus Damm 					&ecovec24_sdram_leave_end);
912eb0cd9e8SMagnus Damm 
913f78bab30SMagnus Damm 	/* enable STATUS0, STATUS2 and PDSTATUS */
914f78bab30SMagnus Damm 	gpio_request(GPIO_FN_STATUS0, NULL);
915f78bab30SMagnus Damm 	gpio_request(GPIO_FN_STATUS2, NULL);
916f78bab30SMagnus Damm 	gpio_request(GPIO_FN_PDSTATUS, NULL);
917f78bab30SMagnus Damm 
9184138b740SKuninori Morimoto 	/* enable SCIFA0 */
9194138b740SKuninori Morimoto 	gpio_request(GPIO_FN_SCIF0_TXD, NULL);
9204138b740SKuninori Morimoto 	gpio_request(GPIO_FN_SCIF0_RXD, NULL);
9214138b740SKuninori Morimoto 
9224138b740SKuninori Morimoto 	/* enable debug LED */
9234138b740SKuninori Morimoto 	gpio_request(GPIO_PTG0, NULL);
9244138b740SKuninori Morimoto 	gpio_request(GPIO_PTG1, NULL);
9254138b740SKuninori Morimoto 	gpio_request(GPIO_PTG2, NULL);
9264138b740SKuninori Morimoto 	gpio_request(GPIO_PTG3, NULL);
927b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG0, 0);
928b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG1, 0);
929b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG2, 0);
930b7056bc1SKuninori Morimoto 	gpio_direction_output(GPIO_PTG3, 0);
9319d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
9324138b740SKuninori Morimoto 
93335a35408SKuninori Morimoto 	/* enable SH-Eth */
93435a35408SKuninori Morimoto 	gpio_request(GPIO_PTA1, NULL);
93535a35408SKuninori Morimoto 	gpio_direction_output(GPIO_PTA1, 1);
93635a35408SKuninori Morimoto 	mdelay(20);
93735a35408SKuninori Morimoto 
93835a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RXD0,    NULL);
93935a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RXD1,    NULL);
94035a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TXD0,    NULL);
94135a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TXD1,    NULL);
94235a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
94335a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
94435a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
94535a35408SKuninori Morimoto 	gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
94635a35408SKuninori Morimoto 	gpio_request(GPIO_FN_MDIO,         NULL);
94735a35408SKuninori Morimoto 	gpio_request(GPIO_FN_MDC,          NULL);
94835a35408SKuninori Morimoto 	gpio_request(GPIO_FN_LNKSTA,       NULL);
94935a35408SKuninori Morimoto 
950907050a3SKuninori Morimoto 	/* enable USB */
9519d56dd3bSPaul Mundt 	__raw_writew(0x0000, 0xA4D80000);
9529d56dd3bSPaul Mundt 	__raw_writew(0x0000, 0xA4D90000);
953907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB3,  NULL);
954907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB4,  NULL);
955907050a3SKuninori Morimoto 	gpio_request(GPIO_PTB5,  NULL);
956907050a3SKuninori Morimoto 	gpio_direction_input(GPIO_PTB3);
957907050a3SKuninori Morimoto 	gpio_direction_output(GPIO_PTB4, 0);
958907050a3SKuninori Morimoto 	gpio_direction_output(GPIO_PTB5, 0);
9599d56dd3bSPaul Mundt 	__raw_writew(0x0600, 0xa40501d4);
9609d56dd3bSPaul Mundt 	__raw_writew(0x0600, 0xa4050192);
961907050a3SKuninori Morimoto 
9623714a9a0SKuninori Morimoto 	if (gpio_get_value(GPIO_PTB3)) {
9633714a9a0SKuninori Morimoto 		printk(KERN_INFO "USB1 function is selected\n");
9643714a9a0SKuninori Morimoto 		usb1_common_device.name = "r8a66597_udc";
9653714a9a0SKuninori Morimoto 	} else {
9663714a9a0SKuninori Morimoto 		printk(KERN_INFO "USB1 host is selected\n");
9673714a9a0SKuninori Morimoto 		usb1_common_device.name = "r8a66597_hcd";
9683714a9a0SKuninori Morimoto 	}
9693714a9a0SKuninori Morimoto 
970fa3ba51bSKuninori Morimoto 	/* enable LCDC */
971fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD23,   NULL);
972fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD22,   NULL);
973fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD21,   NULL);
974fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD20,   NULL);
975fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD19,   NULL);
976fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD18,   NULL);
977fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD17,   NULL);
978fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD16,   NULL);
979fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD15,   NULL);
980fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD14,   NULL);
981fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD13,   NULL);
982fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD12,   NULL);
983fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD11,   NULL);
984fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD10,   NULL);
985fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD9,    NULL);
986fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD8,    NULL);
987fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD7,    NULL);
988fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD6,    NULL);
989fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD5,    NULL);
990fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD4,    NULL);
991fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD3,    NULL);
992fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD2,    NULL);
993fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD1,    NULL);
994fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDD0,    NULL);
995fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDISP,  NULL);
996fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDHSYN,  NULL);
997fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDCK,   NULL);
998fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDVSYN,  NULL);
999fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDDON,   NULL);
1000fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_FN_LCDLCLK,  NULL);
10019d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
1002fa3ba51bSKuninori Morimoto 
1003fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTE6, NULL);
1004fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTU1, NULL);
1005fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTR1, NULL);
1006fa3ba51bSKuninori Morimoto 	gpio_request(GPIO_PTA2, NULL);
1007fa3ba51bSKuninori Morimoto 	gpio_direction_input(GPIO_PTE6);
1008fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTU1, 0);
1009fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTR1, 0);
1010fa3ba51bSKuninori Morimoto 	gpio_direction_output(GPIO_PTA2, 0);
1011fa3ba51bSKuninori Morimoto 
101282b33221SKuninori Morimoto 	/* I/O buffer drive ability is high */
10139d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
1014ea15edb2SKuninori Morimoto 
1015fa3ba51bSKuninori Morimoto 	if (gpio_get_value(GPIO_PTE6)) {
1016fa3ba51bSKuninori Morimoto 		/* DVI */
1017fa3ba51bSKuninori Morimoto 		lcdc_info.clock_source			= LCDC_CLK_EXTERNAL;
1018ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].clock_divider		= 1,
1019fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.name		= "DVI";
1020fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.xres		= 1280;
1021fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.yres		= 720;
1022fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.left_margin	= 220;
1023fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.right_margin	= 110;
1024fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.hsync_len	= 40;
1025fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.upper_margin	= 20;
1026fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.lower_margin	= 5;
1027fa3ba51bSKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.vsync_len	= 5;
1028fa3ba51bSKuninori Morimoto 
1029fa3ba51bSKuninori Morimoto 		gpio_set_value(GPIO_PTA2, 1);
1030fa3ba51bSKuninori Morimoto 		gpio_set_value(GPIO_PTU1, 1);
1031fa3ba51bSKuninori Morimoto 	} else {
1032fa3ba51bSKuninori Morimoto 		/* Panel */
1033ea15edb2SKuninori Morimoto 
1034ea15edb2SKuninori Morimoto 		lcdc_info.clock_source			= LCDC_CLK_PERIPHERAL;
1035ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].clock_divider		= 2,
1036ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.name		= "Panel";
1037ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.xres		= 800;
1038ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.yres		= 480;
1039ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.left_margin	= 220;
1040ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.right_margin	= 110;
1041ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.hsync_len	= 70;
1042ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.upper_margin	= 20;
1043ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.lower_margin	= 5;
1044ea15edb2SKuninori Morimoto 		lcdc_info.ch[0].lcd_cfg.vsync_len	= 5;
1045ea15edb2SKuninori Morimoto 
1046ea15edb2SKuninori Morimoto 		gpio_set_value(GPIO_PTR1, 1);
1047ea15edb2SKuninori Morimoto 
1048ea15edb2SKuninori Morimoto 		/* FIXME
1049ea15edb2SKuninori Morimoto 		 *
1050ea15edb2SKuninori Morimoto 		 * LCDDON control is needed for Panel,
1051ea15edb2SKuninori Morimoto 		 * but current sh_mobile_lcdc driver doesn't control it.
1052ea15edb2SKuninori Morimoto 		 * It is temporary correspondence
1053ea15edb2SKuninori Morimoto 		 */
1054ea15edb2SKuninori Morimoto 		gpio_request(GPIO_PTF4, NULL);
1055ea15edb2SKuninori Morimoto 		gpio_direction_output(GPIO_PTF4, 1);
10568810e055SKuninori Morimoto 
10578810e055SKuninori Morimoto 		/* enable TouchScreen */
10588810e055SKuninori Morimoto 		i2c_register_board_info(0, &ts_i2c_clients, 1);
10598810e055SKuninori Morimoto 		set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
1060fa3ba51bSKuninori Morimoto 	}
1061fa3ba51bSKuninori Morimoto 
10622153ad32SKuninori Morimoto 	/* enable CEU0 */
10632153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D15, NULL);
10642153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D14, NULL);
10652153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D13, NULL);
10662153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D12, NULL);
10672153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D11, NULL);
10682153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D10, NULL);
10692153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D9,  NULL);
10702153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D8,  NULL);
10712153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D7,  NULL);
10722153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D6,  NULL);
10732153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D5,  NULL);
10742153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D4,  NULL);
10752153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D3,  NULL);
10762153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D2,  NULL);
10772153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D1,  NULL);
10782153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_D0,  NULL);
10792153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_VD,  NULL);
10802153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_CLK, NULL);
10812153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_FLD, NULL);
10822153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO0_HD,  NULL);
10832153ad32SKuninori Morimoto 	platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
10842153ad32SKuninori Morimoto 
10852153ad32SKuninori Morimoto 	/* enable CEU1 */
10862153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D7,  NULL);
10872153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D6,  NULL);
10882153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D5,  NULL);
10892153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D4,  NULL);
10902153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D3,  NULL);
10912153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D2,  NULL);
10922153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D1,  NULL);
10932153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_D0,  NULL);
10942153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_FLD, NULL);
10952153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_HD,  NULL);
10962153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_VD,  NULL);
10972153ad32SKuninori Morimoto 	gpio_request(GPIO_FN_VIO1_CLK, NULL);
10982153ad32SKuninori Morimoto 	platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
10992153ad32SKuninori Morimoto 
1100e9103e74SKuninori Morimoto 	/* enable KEYSC */
1101e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
1102e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
1103e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT3,     NULL);
1104e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT2,     NULL);
1105e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT1,     NULL);
1106e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYOUT0,     NULL);
1107e9103e74SKuninori Morimoto 	gpio_request(GPIO_FN_KEYIN0,      NULL);
1108e9103e74SKuninori Morimoto 
1109064a16dcSKuninori Morimoto 	/* enable user debug switch */
1110064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR0, NULL);
1111064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR4, NULL);
1112064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR5, NULL);
1113064a16dcSKuninori Morimoto 	gpio_request(GPIO_PTR6, NULL);
1114064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR0);
1115064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR4);
1116064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR5);
1117064a16dcSKuninori Morimoto 	gpio_direction_input(GPIO_PTR6);
1118064a16dcSKuninori Morimoto 
11191ce4da7aSMagnus Damm #ifdef CONFIG_MFD_SH_MOBILE_SDHI
11201ce4da7aSMagnus Damm 	/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
112196987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CD,  NULL);
112296987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0WP,  NULL);
112396987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CMD, NULL);
112496987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0CLK, NULL);
112596987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D3,  NULL);
112696987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D2,  NULL);
112796987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D1,  NULL);
112896987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI0D0,  NULL);
112998779ad8SMagnus Damm 	gpio_request(GPIO_PTB6, NULL);
113098779ad8SMagnus Damm 	gpio_direction_output(GPIO_PTB6, 0);
113196987d96SKuninori Morimoto 
11321ce4da7aSMagnus Damm 	/* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
113396987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1CD,  NULL);
113496987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1WP,  NULL);
113596987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1CMD, NULL);
113696987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1CLK, NULL);
113796987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D3,  NULL);
113896987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D2,  NULL);
113996987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D1,  NULL);
114096987d96SKuninori Morimoto 	gpio_request(GPIO_FN_SDHI1D0,  NULL);
114196987d96SKuninori Morimoto 	gpio_request(GPIO_PTB7, NULL);
114298779ad8SMagnus Damm 	gpio_direction_output(GPIO_PTB7, 0);
114396987d96SKuninori Morimoto 
114496987d96SKuninori Morimoto 	/* I/O buffer drive ability is high for SDHI1 */
11459d56dd3bSPaul Mundt 	__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
11461ce4da7aSMagnus Damm #else
11471ce4da7aSMagnus Damm 	/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
11481ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
11491ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
11501ce4da7aSMagnus Damm 	gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
11511ce4da7aSMagnus Damm 	gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
11521ce4da7aSMagnus Damm 	gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
11531ce4da7aSMagnus Damm 	gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
11541ce4da7aSMagnus Damm 	gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
11551ce4da7aSMagnus Damm 	gpio_request(GPIO_PTY6, NULL); /* write protect */
11561ce4da7aSMagnus Damm 	gpio_direction_input(GPIO_PTY6);
11571ce4da7aSMagnus Damm 	gpio_request(GPIO_PTY7, NULL); /* card detect */
11581ce4da7aSMagnus Damm 	gpio_direction_input(GPIO_PTY7);
11591ce4da7aSMagnus Damm 
11601ce4da7aSMagnus Damm 	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
11611ce4da7aSMagnus Damm #endif
116296987d96SKuninori Morimoto 
1163207efd07SKuninori Morimoto 	/* enable Video */
1164207efd07SKuninori Morimoto 	gpio_request(GPIO_PTU2, NULL);
1165207efd07SKuninori Morimoto 	gpio_direction_output(GPIO_PTU2, 1);
1166207efd07SKuninori Morimoto 
11679aa25d64SKuninori Morimoto 	/* enable Camera */
11689aa25d64SKuninori Morimoto 	gpio_request(GPIO_PTA3, NULL);
11699aa25d64SKuninori Morimoto 	gpio_request(GPIO_PTA4, NULL);
11709aa25d64SKuninori Morimoto 	gpio_direction_output(GPIO_PTA3, 0);
11719aa25d64SKuninori Morimoto 	gpio_direction_output(GPIO_PTA4, 0);
11729aa25d64SKuninori Morimoto 
11731980fdc4SKuninori Morimoto 	/* enable FSI */
11741980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIMCKB,    NULL);
11751980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBSD,    NULL);
11761980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBSD,    NULL);
11771980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBBCK,   NULL);
11781980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIIBLRCK,  NULL);
11791980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBBCK,   NULL);
11801980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
11811980fdc4SKuninori Morimoto 	gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
11821980fdc4SKuninori Morimoto 
118316afc9fbSKuninori Morimoto 	/* set SPU2 clock to 83.4 MHz */
118416afc9fbSKuninori Morimoto 	clk = clk_get(NULL, "spu_clk");
118510305853SKuninori Morimoto 	if (clk) {
118616afc9fbSKuninori Morimoto 		clk_set_rate(clk, clk_round_rate(clk, 83333333));
118716afc9fbSKuninori Morimoto 		clk_put(clk);
118810305853SKuninori Morimoto 	}
118916afc9fbSKuninori Morimoto 
11901980fdc4SKuninori Morimoto 	/* change parent of FSI B */
11911980fdc4SKuninori Morimoto 	clk = clk_get(NULL, "fsib_clk");
119210305853SKuninori Morimoto 	if (clk) {
11931980fdc4SKuninori Morimoto 		clk_register(&fsimckb_clk);
11941980fdc4SKuninori Morimoto 		clk_set_parent(clk, &fsimckb_clk);
11951980fdc4SKuninori Morimoto 		clk_set_rate(clk, 11000);
11961980fdc4SKuninori Morimoto 		clk_set_rate(&fsimckb_clk, 11000);
11971980fdc4SKuninori Morimoto 		clk_put(clk);
119810305853SKuninori Morimoto 	}
11991980fdc4SKuninori Morimoto 
12001980fdc4SKuninori Morimoto 	gpio_request(GPIO_PTU0, NULL);
12011980fdc4SKuninori Morimoto 	gpio_direction_output(GPIO_PTU0, 0);
12021980fdc4SKuninori Morimoto 	mdelay(20);
12031980fdc4SKuninori Morimoto 
1204ea440783SNISHIMOTO Hiroki 	/* enable motion sensor */
1205ea440783SNISHIMOTO Hiroki 	gpio_request(GPIO_FN_INTC_IRQ1, NULL);
1206ea440783SNISHIMOTO Hiroki 	gpio_direction_input(GPIO_FN_INTC_IRQ1);
1207ea440783SNISHIMOTO Hiroki 
12086f26d19fSMagnus Damm 	/* set VPU clock to 166 MHz */
12096f26d19fSMagnus Damm 	clk = clk_get(NULL, "vpu_clk");
121010305853SKuninori Morimoto 	if (clk) {
12116f26d19fSMagnus Damm 		clk_set_rate(clk, clk_round_rate(clk, 166000000));
12126f26d19fSMagnus Damm 		clk_put(clk);
121310305853SKuninori Morimoto 	}
12146f26d19fSMagnus Damm 
121526365716SKuninori Morimoto 	/* enable IrDA */
121626365716SKuninori Morimoto 	gpio_request(GPIO_FN_IRDA_OUT, NULL);
121726365716SKuninori Morimoto 	gpio_request(GPIO_FN_IRDA_IN,  NULL);
121826365716SKuninori Morimoto 	gpio_request(GPIO_PTU5, NULL);
121926365716SKuninori Morimoto 	gpio_direction_output(GPIO_PTU5, 0);
122026365716SKuninori Morimoto 
1221125ecce6SKuninori Morimoto 	/* enable I2C device */
12221980fdc4SKuninori Morimoto 	i2c_register_board_info(0, i2c0_devices,
12231980fdc4SKuninori Morimoto 				ARRAY_SIZE(i2c0_devices));
12241980fdc4SKuninori Morimoto 
1225125ecce6SKuninori Morimoto 	i2c_register_board_info(1, i2c1_devices,
1226125ecce6SKuninori Morimoto 				ARRAY_SIZE(i2c1_devices));
1227125ecce6SKuninori Morimoto 
1228*aee5ab0bSGuennadi Liakhovetski 	/* VOU */
1229*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D15, NULL);
1230*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D14, NULL);
1231*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D13, NULL);
1232*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D12, NULL);
1233*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D11, NULL);
1234*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D10, NULL);
1235*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D9, NULL);
1236*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_D8, NULL);
1237*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_CLKI, NULL);
1238*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_CLK, NULL);
1239*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_VSYNC, NULL);
1240*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_FN_DV_HSYNC, NULL);
1241*aee5ab0bSGuennadi Liakhovetski 
1242*aee5ab0bSGuennadi Liakhovetski 	/* AK8813 power / reset sequence */
1243*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_PTG4, NULL);
1244*aee5ab0bSGuennadi Liakhovetski 	gpio_request(GPIO_PTU3, NULL);
1245*aee5ab0bSGuennadi Liakhovetski 	/* Reset */
1246*aee5ab0bSGuennadi Liakhovetski 	gpio_direction_output(GPIO_PTG4, 0);
1247*aee5ab0bSGuennadi Liakhovetski 	/* Power down */
1248*aee5ab0bSGuennadi Liakhovetski 	gpio_direction_output(GPIO_PTU3, 1);
1249*aee5ab0bSGuennadi Liakhovetski 
1250*aee5ab0bSGuennadi Liakhovetski 	udelay(10);
1251*aee5ab0bSGuennadi Liakhovetski 
1252*aee5ab0bSGuennadi Liakhovetski 	/* Power up, reset */
1253*aee5ab0bSGuennadi Liakhovetski 	gpio_set_value(GPIO_PTU3, 0);
1254*aee5ab0bSGuennadi Liakhovetski 
1255*aee5ab0bSGuennadi Liakhovetski 	udelay(10);
1256*aee5ab0bSGuennadi Liakhovetski 
1257*aee5ab0bSGuennadi Liakhovetski 	/* Remove reset */
1258*aee5ab0bSGuennadi Liakhovetski 	gpio_set_value(GPIO_PTG4, 1);
1259*aee5ab0bSGuennadi Liakhovetski 
12604138b740SKuninori Morimoto 	return platform_add_devices(ecovec_devices,
12614138b740SKuninori Morimoto 				    ARRAY_SIZE(ecovec_devices));
12624138b740SKuninori Morimoto }
12634907d57fSKuninori Morimoto arch_initcall(arch_setup);
12644907d57fSKuninori Morimoto 
12654907d57fSKuninori Morimoto static int __init devices_setup(void)
12664907d57fSKuninori Morimoto {
1267376abbb4SMagnus Damm 	sh_eth_init(&sh_eth_plat);
12684907d57fSKuninori Morimoto 	return 0;
12694907d57fSKuninori Morimoto }
12704907d57fSKuninori Morimoto device_initcall(devices_setup);
12714907d57fSKuninori Morimoto 
12724138b740SKuninori Morimoto static struct sh_machine_vector mv_ecovec __initmv = {
12734138b740SKuninori Morimoto 	.mv_name	= "R0P7724 (EcoVec)",
12744138b740SKuninori Morimoto };
1275