xref: /linux/arch/sh/boards/mach-kfr2r09/setup.c (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 /*
2  * KFR2R09 board support code
3  *
4  * Copyright (C) 2009 Magnus Damm
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/interrupt.h>
13 #include <linux/mmc/host.h>
14 #include <linux/mmc/sh_mobile_sdhi.h>
15 #include <linux/mfd/tmio.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/mtd/onenand.h>
18 #include <linux/delay.h>
19 #include <linux/clk.h>
20 #include <linux/gpio.h>
21 #include <linux/input.h>
22 #include <linux/input/sh_keysc.h>
23 #include <linux/i2c.h>
24 #include <linux/platform_data/lv5207lp.h>
25 #include <linux/regulator/fixed.h>
26 #include <linux/regulator/machine.h>
27 #include <linux/usb/r8a66597.h>
28 #include <linux/videodev2.h>
29 #include <linux/sh_intc.h>
30 #include <media/rj54n1cb0c.h>
31 #include <media/soc_camera.h>
32 #include <media/sh_mobile_ceu.h>
33 #include <video/sh_mobile_lcdc.h>
34 #include <asm/suspend.h>
35 #include <asm/clock.h>
36 #include <asm/machvec.h>
37 #include <asm/io.h>
38 #include <cpu/sh7724.h>
39 #include <mach/kfr2r09.h>
40 
41 static struct mtd_partition kfr2r09_nor_flash_partitions[] =
42 {
43 	{
44 		.name = "boot",
45 		.offset = 0,
46 		.size = (4 * 1024 * 1024),
47 		.mask_flags = MTD_WRITEABLE,	/* Read-only */
48 	},
49 	{
50 		.name = "other",
51 		.offset = MTDPART_OFS_APPEND,
52 		.size = MTDPART_SIZ_FULL,
53 	},
54 };
55 
56 static struct physmap_flash_data kfr2r09_nor_flash_data = {
57 	.width		= 2,
58 	.parts		= kfr2r09_nor_flash_partitions,
59 	.nr_parts	= ARRAY_SIZE(kfr2r09_nor_flash_partitions),
60 };
61 
62 static struct resource kfr2r09_nor_flash_resources[] = {
63 	[0] = {
64 		.name		= "NOR Flash",
65 		.start		= 0x00000000,
66 		.end		= 0x03ffffff,
67 		.flags		= IORESOURCE_MEM,
68 	}
69 };
70 
71 static struct platform_device kfr2r09_nor_flash_device = {
72 	.name		= "physmap-flash",
73 	.resource	= kfr2r09_nor_flash_resources,
74 	.num_resources	= ARRAY_SIZE(kfr2r09_nor_flash_resources),
75 	.dev		= {
76 		.platform_data = &kfr2r09_nor_flash_data,
77 	},
78 };
79 
80 static struct resource kfr2r09_nand_flash_resources[] = {
81 	[0] = {
82 		.name		= "NAND Flash",
83 		.start		= 0x10000000,
84 		.end		= 0x1001ffff,
85 		.flags		= IORESOURCE_MEM,
86 	}
87 };
88 
89 static struct platform_device kfr2r09_nand_flash_device = {
90 	.name		= "onenand-flash",
91 	.resource	= kfr2r09_nand_flash_resources,
92 	.num_resources	= ARRAY_SIZE(kfr2r09_nand_flash_resources),
93 };
94 
95 static struct sh_keysc_info kfr2r09_sh_keysc_info = {
96 	.mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */
97 	.scan_timing = 3,
98 	.delay = 10,
99 	.keycodes = {
100 		KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER,
101 		KEY_1, KEY_2, KEY_3, 0, KEY_UP,
102 		KEY_4, KEY_5, KEY_6, 0, KEY_LEFT,
103 		KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT,
104 		KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN,
105 		0, 0, 0, 0, 0
106 	},
107 };
108 
109 static struct resource kfr2r09_sh_keysc_resources[] = {
110 	[0] = {
111 		.name	= "KEYSC",
112 		.start  = 0x044b0000,
113 		.end    = 0x044b000f,
114 		.flags  = IORESOURCE_MEM,
115 	},
116 	[1] = {
117 		.start  = evt2irq(0xbe0),
118 		.flags  = IORESOURCE_IRQ,
119 	},
120 };
121 
122 static struct platform_device kfr2r09_sh_keysc_device = {
123 	.name           = "sh_keysc",
124 	.id             = 0, /* "keysc0" clock */
125 	.num_resources  = ARRAY_SIZE(kfr2r09_sh_keysc_resources),
126 	.resource       = kfr2r09_sh_keysc_resources,
127 	.dev	= {
128 		.platform_data	= &kfr2r09_sh_keysc_info,
129 	},
130 };
131 
132 static const struct fb_videomode kfr2r09_lcdc_modes[] = {
133 	{
134 		.name = "TX07D34VM0AAA",
135 		.xres = 240,
136 		.yres = 400,
137 		.left_margin = 0,
138 		.right_margin = 16,
139 		.hsync_len = 8,
140 		.upper_margin = 0,
141 		.lower_margin = 1,
142 		.vsync_len = 1,
143 		.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
144 	},
145 };
146 
147 static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
148 	.clock_source = LCDC_CLK_BUS,
149 	.ch[0] = {
150 		.chan = LCDC_CHAN_MAINLCD,
151 		.fourcc = V4L2_PIX_FMT_RGB565,
152 		.interface_type = SYS18,
153 		.clock_divider = 6,
154 		.flags = LCDC_FLAGS_DWPOL,
155 		.lcd_modes = kfr2r09_lcdc_modes,
156 		.num_modes = ARRAY_SIZE(kfr2r09_lcdc_modes),
157 		.panel_cfg = {
158 			.width = 35,
159 			.height = 58,
160 			.setup_sys = kfr2r09_lcd_setup,
161 			.start_transfer = kfr2r09_lcd_start,
162 		},
163 		.sys_bus_cfg = {
164 			.ldmt2r = 0x07010904,
165 			.ldmt3r = 0x14012914,
166 			/* set 1s delay to encourage fsync() */
167 			.deferred_io_msec = 1000,
168 		},
169 	}
170 };
171 
172 static struct resource kfr2r09_sh_lcdc_resources[] = {
173 	[0] = {
174 		.name	= "LCDC",
175 		.start	= 0xfe940000, /* P4-only space */
176 		.end	= 0xfe942fff,
177 		.flags	= IORESOURCE_MEM,
178 	},
179 	[1] = {
180 		.start	= evt2irq(0xf40),
181 		.flags	= IORESOURCE_IRQ,
182 	},
183 };
184 
185 static struct platform_device kfr2r09_sh_lcdc_device = {
186 	.name		= "sh_mobile_lcdc_fb",
187 	.num_resources	= ARRAY_SIZE(kfr2r09_sh_lcdc_resources),
188 	.resource	= kfr2r09_sh_lcdc_resources,
189 	.dev	= {
190 		.platform_data	= &kfr2r09_sh_lcdc_info,
191 	},
192 };
193 
194 static struct lv5207lp_platform_data kfr2r09_backlight_data = {
195 	.fbdev = &kfr2r09_sh_lcdc_device.dev,
196 	.def_value = 13,
197 	.max_value = 13,
198 };
199 
200 static struct i2c_board_info kfr2r09_backlight_board_info = {
201 	I2C_BOARD_INFO("lv5207lp", 0x75),
202 	.platform_data = &kfr2r09_backlight_data,
203 };
204 
205 static struct r8a66597_platdata kfr2r09_usb0_gadget_data = {
206 	.on_chip = 1,
207 };
208 
209 static struct resource kfr2r09_usb0_gadget_resources[] = {
210 	[0] = {
211 		.start	= 0x04d80000,
212 		.end	= 0x04d80123,
213 		.flags	= IORESOURCE_MEM,
214 	},
215 	[1] = {
216 		.start	= evt2irq(0xa20),
217 		.end	= evt2irq(0xa20),
218 		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
219 	},
220 };
221 
222 static struct platform_device kfr2r09_usb0_gadget_device = {
223 	.name		= "r8a66597_udc",
224 	.id		= 0,
225 	.dev = {
226 		.dma_mask		= NULL,         /*  not use dma */
227 		.coherent_dma_mask	= 0xffffffff,
228 		.platform_data	= &kfr2r09_usb0_gadget_data,
229 	},
230 	.num_resources	= ARRAY_SIZE(kfr2r09_usb0_gadget_resources),
231 	.resource	= kfr2r09_usb0_gadget_resources,
232 };
233 
234 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
235 	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
236 };
237 
238 static struct resource kfr2r09_ceu_resources[] = {
239 	[0] = {
240 		.name	= "CEU",
241 		.start	= 0xfe910000,
242 		.end	= 0xfe91009f,
243 		.flags	= IORESOURCE_MEM,
244 	},
245 	[1] = {
246 		.start  = evt2irq(0x880),
247 		.end	= evt2irq(0x880),
248 		.flags  = IORESOURCE_IRQ,
249 	},
250 	[2] = {
251 		/* place holder for contiguous memory */
252 	},
253 };
254 
255 static struct platform_device kfr2r09_ceu_device = {
256 	.name		= "sh_mobile_ceu",
257 	.id             = 0, /* "ceu0" clock */
258 	.num_resources	= ARRAY_SIZE(kfr2r09_ceu_resources),
259 	.resource	= kfr2r09_ceu_resources,
260 	.dev	= {
261 		.platform_data	= &sh_mobile_ceu_info,
262 	},
263 };
264 
265 static struct i2c_board_info kfr2r09_i2c_camera = {
266 	I2C_BOARD_INFO("rj54n1cb0c", 0x50),
267 };
268 
269 static struct clk *camera_clk;
270 
271 /* set VIO_CKO clock to 25MHz */
272 #define CEU_MCLK_FREQ 25000000
273 
274 #define DRVCRB 0xA405018C
275 static int camera_power(struct device *dev, int mode)
276 {
277 	int ret;
278 
279 	if (mode) {
280 		long rate;
281 
282 		camera_clk = clk_get(NULL, "video_clk");
283 		if (IS_ERR(camera_clk))
284 			return PTR_ERR(camera_clk);
285 
286 		rate = clk_round_rate(camera_clk, CEU_MCLK_FREQ);
287 		ret = clk_set_rate(camera_clk, rate);
288 		if (ret < 0)
289 			goto eclkrate;
290 
291 		/* set DRVCRB
292 		 *
293 		 * use 1.8 V for VccQ_VIO
294 		 * use 2.85V for VccQ_SR
295 		 */
296 		__raw_writew((__raw_readw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB);
297 
298 		/* reset clear */
299 		ret = gpio_request(GPIO_PTB4, NULL);
300 		if (ret < 0)
301 			goto eptb4;
302 		ret = gpio_request(GPIO_PTB7, NULL);
303 		if (ret < 0)
304 			goto eptb7;
305 
306 		ret = gpio_direction_output(GPIO_PTB4, 1);
307 		if (!ret)
308 			ret = gpio_direction_output(GPIO_PTB7, 1);
309 		if (ret < 0)
310 			goto egpioout;
311 		msleep(1);
312 
313 		ret = clk_enable(camera_clk);	/* start VIO_CKO */
314 		if (ret < 0)
315 			goto eclkon;
316 
317 		return 0;
318 	}
319 
320 	ret = 0;
321 
322 	clk_disable(camera_clk);
323 eclkon:
324 	gpio_set_value(GPIO_PTB7, 0);
325 egpioout:
326 	gpio_set_value(GPIO_PTB4, 0);
327 	gpio_free(GPIO_PTB7);
328 eptb7:
329 	gpio_free(GPIO_PTB4);
330 eptb4:
331 eclkrate:
332 	clk_put(camera_clk);
333 	return ret;
334 }
335 
336 static struct rj54n1_pdata rj54n1_priv = {
337 	.mclk_freq	= CEU_MCLK_FREQ,
338 	.ioctl_high	= false,
339 };
340 
341 static struct soc_camera_link rj54n1_link = {
342 	.power		= camera_power,
343 	.board_info	= &kfr2r09_i2c_camera,
344 	.i2c_adapter_id	= 1,
345 	.priv		= &rj54n1_priv,
346 };
347 
348 static struct platform_device kfr2r09_camera = {
349 	.name	= "soc-camera-pdrv",
350 	.id	= 0,
351 	.dev	= {
352 		.platform_data = &rj54n1_link,
353 	},
354 };
355 
356 /* Fixed 3.3V regulator to be used by SDHI0 */
357 static struct regulator_consumer_supply fixed3v3_power_consumers[] =
358 {
359 	REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
360 	REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
361 };
362 
363 static struct resource kfr2r09_sh_sdhi0_resources[] = {
364 	[0] = {
365 		.name	= "SDHI0",
366 		.start  = 0x04ce0000,
367 		.end    = 0x04ce00ff,
368 		.flags  = IORESOURCE_MEM,
369 	},
370 	[1] = {
371 		.start  = evt2irq(0xe80),
372 		.flags  = IORESOURCE_IRQ,
373 	},
374 };
375 
376 static struct tmio_mmc_data sh7724_sdhi0_data = {
377 	.chan_priv_tx	= (void *)SHDMA_SLAVE_SDHI0_TX,
378 	.chan_priv_rx	= (void *)SHDMA_SLAVE_SDHI0_RX,
379 	.flags		= TMIO_MMC_WRPROTECT_DISABLE,
380 	.capabilities	= MMC_CAP_SDIO_IRQ,
381 };
382 
383 static struct platform_device kfr2r09_sh_sdhi0_device = {
384 	.name           = "sh_mobile_sdhi",
385 	.num_resources  = ARRAY_SIZE(kfr2r09_sh_sdhi0_resources),
386 	.resource       = kfr2r09_sh_sdhi0_resources,
387 	.dev = {
388 		.platform_data	= &sh7724_sdhi0_data,
389 	},
390 };
391 
392 static struct platform_device *kfr2r09_devices[] __initdata = {
393 	&kfr2r09_nor_flash_device,
394 	&kfr2r09_nand_flash_device,
395 	&kfr2r09_sh_keysc_device,
396 	&kfr2r09_sh_lcdc_device,
397 	&kfr2r09_ceu_device,
398 	&kfr2r09_camera,
399 	&kfr2r09_sh_sdhi0_device,
400 };
401 
402 #define BSC_CS0BCR 0xfec10004
403 #define BSC_CS0WCR 0xfec10024
404 #define BSC_CS4BCR 0xfec10010
405 #define BSC_CS4WCR 0xfec10030
406 #define PORT_MSELCRB 0xa4050182
407 
408 #ifdef CONFIG_I2C
409 static int kfr2r09_usb0_gadget_i2c_setup(void)
410 {
411 	struct i2c_adapter *a;
412 	struct i2c_msg msg;
413 	unsigned char buf[2];
414 	int ret;
415 
416 	a = i2c_get_adapter(0);
417 	if (!a)
418 		return -ENODEV;
419 
420 	/* set bit 1 (the second bit) of chip at 0x09, register 0x13 */
421 	buf[0] = 0x13;
422 	msg.addr = 0x09;
423 	msg.buf = buf;
424 	msg.len = 1;
425 	msg.flags = 0;
426 	ret = i2c_transfer(a, &msg, 1);
427 	if (ret != 1)
428 		return -ENODEV;
429 
430 	buf[0] = 0;
431 	msg.addr = 0x09;
432 	msg.buf = buf;
433 	msg.len = 1;
434 	msg.flags = I2C_M_RD;
435 	ret = i2c_transfer(a, &msg, 1);
436 	if (ret != 1)
437 		return -ENODEV;
438 
439 	buf[1] = buf[0] | (1 << 1);
440 	buf[0] = 0x13;
441 	msg.addr = 0x09;
442 	msg.buf = buf;
443 	msg.len = 2;
444 	msg.flags = 0;
445 	ret = i2c_transfer(a, &msg, 1);
446 	if (ret != 1)
447 		return -ENODEV;
448 
449 	return 0;
450 }
451 
452 static int kfr2r09_serial_i2c_setup(void)
453 {
454 	struct i2c_adapter *a;
455 	struct i2c_msg msg;
456 	unsigned char buf[2];
457 	int ret;
458 
459 	a = i2c_get_adapter(0);
460 	if (!a)
461 		return -ENODEV;
462 
463 	/* set bit 6 (the 7th bit) of chip at 0x09, register 0x13 */
464 	buf[0] = 0x13;
465 	msg.addr = 0x09;
466 	msg.buf = buf;
467 	msg.len = 1;
468 	msg.flags = 0;
469 	ret = i2c_transfer(a, &msg, 1);
470 	if (ret != 1)
471 		return -ENODEV;
472 
473 	buf[0] = 0;
474 	msg.addr = 0x09;
475 	msg.buf = buf;
476 	msg.len = 1;
477 	msg.flags = I2C_M_RD;
478 	ret = i2c_transfer(a, &msg, 1);
479 	if (ret != 1)
480 		return -ENODEV;
481 
482 	buf[1] = buf[0] | (1 << 6);
483 	buf[0] = 0x13;
484 	msg.addr = 0x09;
485 	msg.buf = buf;
486 	msg.len = 2;
487 	msg.flags = 0;
488 	ret = i2c_transfer(a, &msg, 1);
489 	if (ret != 1)
490 		return -ENODEV;
491 
492 	return 0;
493 }
494 #else
495 static int kfr2r09_usb0_gadget_i2c_setup(void)
496 {
497 	return -ENODEV;
498 }
499 
500 static int kfr2r09_serial_i2c_setup(void)
501 {
502 	return -ENODEV;
503 }
504 #endif
505 
506 static int kfr2r09_usb0_gadget_setup(void)
507 {
508 	int plugged_in;
509 
510 	gpio_request(GPIO_PTN4, NULL); /* USB_DET */
511 	gpio_direction_input(GPIO_PTN4);
512 	plugged_in = gpio_get_value(GPIO_PTN4);
513 	if (!plugged_in)
514 		return -ENODEV; /* no cable plugged in */
515 
516 	if (kfr2r09_usb0_gadget_i2c_setup() != 0)
517 		return -ENODEV; /* unable to configure using i2c */
518 
519 	__raw_writew((__raw_readw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
520 	gpio_request(GPIO_FN_PDSTATUS, NULL); /* R-standby disables USB clock */
521 	gpio_request(GPIO_PTV6, NULL); /* USBCLK_ON */
522 	gpio_direction_output(GPIO_PTV6, 1); /* USBCLK_ON = H */
523 	msleep(20); /* wait 20ms to let the clock settle */
524 	clk_enable(clk_get(NULL, "usb0"));
525 	__raw_writew(0x0600, 0xa40501d4);
526 
527 	return 0;
528 }
529 
530 extern char kfr2r09_sdram_enter_start;
531 extern char kfr2r09_sdram_enter_end;
532 extern char kfr2r09_sdram_leave_start;
533 extern char kfr2r09_sdram_leave_end;
534 
535 static int __init kfr2r09_devices_setup(void)
536 {
537 	/* register board specific self-refresh code */
538 	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
539 					SUSP_SH_RSTANDBY,
540 					&kfr2r09_sdram_enter_start,
541 					&kfr2r09_sdram_enter_end,
542 					&kfr2r09_sdram_leave_start,
543 					&kfr2r09_sdram_leave_end);
544 
545 	regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
546 				     ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
547 
548 	/* enable SCIF1 serial port for YC401 console support */
549 	gpio_request(GPIO_FN_SCIF1_RXD, NULL);
550 	gpio_request(GPIO_FN_SCIF1_TXD, NULL);
551 	kfr2r09_serial_i2c_setup(); /* ECONTMSK(bit6=L10ONEN) set 1 */
552 	gpio_request(GPIO_PTG3, NULL); /* HPON_ON */
553 	gpio_direction_output(GPIO_PTG3, 1); /* HPON_ON = H */
554 
555 	/* setup NOR flash at CS0 */
556 	__raw_writel(0x36db0400, BSC_CS0BCR);
557 	__raw_writel(0x00000500, BSC_CS0WCR);
558 
559 	/* setup NAND flash at CS4 */
560 	__raw_writel(0x36db0400, BSC_CS4BCR);
561 	__raw_writel(0x00000500, BSC_CS4WCR);
562 
563 	/* setup KEYSC pins */
564 	gpio_request(GPIO_FN_KEYOUT0, NULL);
565 	gpio_request(GPIO_FN_KEYOUT1, NULL);
566 	gpio_request(GPIO_FN_KEYOUT2, NULL);
567 	gpio_request(GPIO_FN_KEYOUT3, NULL);
568 	gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
569 	gpio_request(GPIO_FN_KEYIN0, NULL);
570 	gpio_request(GPIO_FN_KEYIN1, NULL);
571 	gpio_request(GPIO_FN_KEYIN2, NULL);
572 	gpio_request(GPIO_FN_KEYIN3, NULL);
573 	gpio_request(GPIO_FN_KEYIN4, NULL);
574 	gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
575 
576 	/* setup LCDC pins for SYS panel */
577 	gpio_request(GPIO_FN_LCDD17, NULL);
578 	gpio_request(GPIO_FN_LCDD16, NULL);
579 	gpio_request(GPIO_FN_LCDD15, NULL);
580 	gpio_request(GPIO_FN_LCDD14, NULL);
581 	gpio_request(GPIO_FN_LCDD13, NULL);
582 	gpio_request(GPIO_FN_LCDD12, NULL);
583 	gpio_request(GPIO_FN_LCDD11, NULL);
584 	gpio_request(GPIO_FN_LCDD10, NULL);
585 	gpio_request(GPIO_FN_LCDD9, NULL);
586 	gpio_request(GPIO_FN_LCDD8, NULL);
587 	gpio_request(GPIO_FN_LCDD7, NULL);
588 	gpio_request(GPIO_FN_LCDD6, NULL);
589 	gpio_request(GPIO_FN_LCDD5, NULL);
590 	gpio_request(GPIO_FN_LCDD4, NULL);
591 	gpio_request(GPIO_FN_LCDD3, NULL);
592 	gpio_request(GPIO_FN_LCDD2, NULL);
593 	gpio_request(GPIO_FN_LCDD1, NULL);
594 	gpio_request(GPIO_FN_LCDD0, NULL);
595 	gpio_request(GPIO_FN_LCDRS, NULL); /* LCD_RS */
596 	gpio_request(GPIO_FN_LCDCS, NULL); /* LCD_CS/ */
597 	gpio_request(GPIO_FN_LCDRD, NULL); /* LCD_RD/ */
598 	gpio_request(GPIO_FN_LCDWR, NULL); /* LCD_WR/ */
599 	gpio_request(GPIO_FN_LCDVSYN, NULL); /* LCD_VSYNC */
600 	gpio_request(GPIO_PTE4, NULL); /* LCD_RST/ */
601 	gpio_direction_output(GPIO_PTE4, 1);
602 	gpio_request(GPIO_PTF4, NULL); /* PROTECT/ */
603 	gpio_direction_output(GPIO_PTF4, 1);
604 	gpio_request(GPIO_PTU0, NULL); /* LEDSTDBY/ */
605 	gpio_direction_output(GPIO_PTU0, 1);
606 
607 	/* setup USB function */
608 	if (kfr2r09_usb0_gadget_setup() == 0)
609 		platform_device_register(&kfr2r09_usb0_gadget_device);
610 
611 	/* CEU */
612 	gpio_request(GPIO_FN_VIO_CKO, NULL);
613 	gpio_request(GPIO_FN_VIO0_CLK, NULL);
614 	gpio_request(GPIO_FN_VIO0_VD, NULL);
615 	gpio_request(GPIO_FN_VIO0_HD, NULL);
616 	gpio_request(GPIO_FN_VIO0_FLD, NULL);
617 	gpio_request(GPIO_FN_VIO0_D7, NULL);
618 	gpio_request(GPIO_FN_VIO0_D6, NULL);
619 	gpio_request(GPIO_FN_VIO0_D5, NULL);
620 	gpio_request(GPIO_FN_VIO0_D4, NULL);
621 	gpio_request(GPIO_FN_VIO0_D3, NULL);
622 	gpio_request(GPIO_FN_VIO0_D2, NULL);
623 	gpio_request(GPIO_FN_VIO0_D1, NULL);
624 	gpio_request(GPIO_FN_VIO0_D0, NULL);
625 
626 	platform_resource_setup_memory(&kfr2r09_ceu_device, "ceu", 4 << 20);
627 
628 	/* SDHI0 connected to yc304 */
629 	gpio_request(GPIO_FN_SDHI0CD, NULL);
630 	gpio_request(GPIO_FN_SDHI0D3, NULL);
631 	gpio_request(GPIO_FN_SDHI0D2, NULL);
632 	gpio_request(GPIO_FN_SDHI0D1, NULL);
633 	gpio_request(GPIO_FN_SDHI0D0, NULL);
634 	gpio_request(GPIO_FN_SDHI0CMD, NULL);
635 	gpio_request(GPIO_FN_SDHI0CLK, NULL);
636 
637 	i2c_register_board_info(0, &kfr2r09_backlight_board_info, 1);
638 
639 	return platform_add_devices(kfr2r09_devices,
640 				    ARRAY_SIZE(kfr2r09_devices));
641 }
642 device_initcall(kfr2r09_devices_setup);
643 
644 /* Return the board specific boot mode pin configuration */
645 static int kfr2r09_mode_pins(void)
646 {
647 	/* MD0=1, MD1=1, MD2=0: Clock Mode 3
648 	 * MD3=0: 16-bit Area0 Bus Width
649 	 * MD5=1: Little Endian
650 	 * MD8=1: Test Mode Disabled
651 	 */
652 	return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
653 }
654 
655 /*
656  * The Machine Vector
657  */
658 static struct sh_machine_vector mv_kfr2r09 __initmv = {
659 	.mv_name		= "kfr2r09",
660 	.mv_mode_pins		= kfr2r09_mode_pins,
661 };
662