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