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