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