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