diff options
Diffstat (limited to 'arch/sh/boards/mach-kfr2r09')
-rw-r--r-- | arch/sh/boards/mach-kfr2r09/Makefile | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-kfr2r09/sdram.S | 80 | ||||
-rw-r--r-- | arch/sh/boards/mach-kfr2r09/setup.c | 238 |
3 files changed, 318 insertions, 2 deletions
diff --git a/arch/sh/boards/mach-kfr2r09/Makefile b/arch/sh/boards/mach-kfr2r09/Makefile index 5d5867826e3b..4e577a3bf658 100644 --- a/arch/sh/boards/mach-kfr2r09/Makefile +++ b/arch/sh/boards/mach-kfr2r09/Makefile | |||
@@ -1,2 +1,2 @@ | |||
1 | obj-y := setup.o | 1 | obj-y := setup.o sdram.o |
2 | obj-$(CONFIG_FB_SH_MOBILE_LCDC) += lcd_wqvga.o | 2 | obj-$(CONFIG_FB_SH_MOBILE_LCDC) += lcd_wqvga.o |
diff --git a/arch/sh/boards/mach-kfr2r09/sdram.S b/arch/sh/boards/mach-kfr2r09/sdram.S new file mode 100644 index 000000000000..0c9f55bec2fe --- /dev/null +++ b/arch/sh/boards/mach-kfr2r09/sdram.S | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * KFR2R09 sdram self/auto-refresh setup 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 | |||
11 | #include <linux/sys.h> | ||
12 | #include <linux/errno.h> | ||
13 | #include <linux/linkage.h> | ||
14 | #include <asm/asm-offsets.h> | ||
15 | #include <asm/suspend.h> | ||
16 | #include <asm/romimage-macros.h> | ||
17 | |||
18 | /* code to enter and leave self-refresh. must be self-contained. | ||
19 | * this code will be copied to on-chip memory and executed from there. | ||
20 | */ | ||
21 | .balign 4 | ||
22 | ENTRY(kfr2r09_sdram_enter_start) | ||
23 | |||
24 | /* DBSC: put memory in self-refresh mode */ | ||
25 | |||
26 | ED 0xFD000010, 0x00000000 /* DBEN */ | ||
27 | ED 0xFD000040, 0x00000000 /* DBRFPDN0 */ | ||
28 | ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ | ||
29 | ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ | ||
30 | ED 0xFD000040, 0x00000001 /* DBRFPDN0 */ | ||
31 | |||
32 | rts | ||
33 | nop | ||
34 | |||
35 | ENTRY(kfr2r09_sdram_enter_end) | ||
36 | |||
37 | .balign 4 | ||
38 | ENTRY(kfr2r09_sdram_leave_start) | ||
39 | |||
40 | /* DBSC: put memory in auto-refresh mode */ | ||
41 | |||
42 | mov.l @(SH_SLEEP_MODE, r5), r0 | ||
43 | tst #SUSP_SH_RSTANDBY, r0 | ||
44 | bf resume_rstandby | ||
45 | |||
46 | ED 0xFD000040, 0x00000000 /* DBRFPDN0 */ | ||
47 | WAIT 1 | ||
48 | ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ | ||
49 | ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ | ||
50 | ED 0xFD000010, 0x00000001 /* DBEN */ | ||
51 | ED 0xFD000040, 0x00010000 /* DBRFPDN0 */ | ||
52 | |||
53 | rts | ||
54 | nop | ||
55 | |||
56 | resume_rstandby: | ||
57 | |||
58 | /* DBSC: re-initialize and put in auto-refresh */ | ||
59 | |||
60 | ED 0xFD000108, 0x40000301 /* DBPDCNT0 */ | ||
61 | ED 0xFD000020, 0x011B0002 /* DBCONF */ | ||
62 | ED 0xFD000030, 0x03060E02 /* DBTR0 */ | ||
63 | ED 0xFD000034, 0x01020102 /* DBTR1 */ | ||
64 | ED 0xFD000038, 0x01090406 /* DBTR2 */ | ||
65 | ED 0xFD000008, 0x00000004 /* DBKIND */ | ||
66 | ED 0xFD000040, 0x00000001 /* DBRFPDN0 */ | ||
67 | ED 0xFD000040, 0x00000000 /* DBRFPDN0 */ | ||
68 | ED 0xFD000018, 0x00000001 /* DBCKECNT */ | ||
69 | WAIT 1 | ||
70 | ED 0xFD000010, 0x00000001 /* DBEN */ | ||
71 | ED 0xFD000044, 0x000004AF /* DBRFPDN1 */ | ||
72 | ED 0xFD000048, 0x20CF0037 /* DBRFPDN2 */ | ||
73 | ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ | ||
74 | ED 0xFD000108, 0x40000300 /* DBPDCNT0 */ | ||
75 | ED 0xFD000040, 0x00010000 /* DBRFPDN0 */ | ||
76 | |||
77 | rts | ||
78 | nop | ||
79 | |||
80 | ENTRY(kfr2r09_sdram_leave_end) | ||
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c index c08d33fe2104..87438d6603d6 100644 --- a/arch/sh/boards/mach-kfr2r09/setup.c +++ b/arch/sh/boards/mach-kfr2r09/setup.c | |||
@@ -16,13 +16,16 @@ | |||
16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
17 | #include <linux/gpio.h> | 17 | #include <linux/gpio.h> |
18 | #include <linux/input.h> | 18 | #include <linux/input.h> |
19 | #include <linux/input/sh_keysc.h> | ||
19 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
20 | #include <linux/usb/r8a66597.h> | 21 | #include <linux/usb/r8a66597.h> |
22 | #include <media/soc_camera.h> | ||
23 | #include <media/sh_mobile_ceu.h> | ||
21 | #include <video/sh_mobile_lcdc.h> | 24 | #include <video/sh_mobile_lcdc.h> |
25 | #include <asm/suspend.h> | ||
22 | #include <asm/clock.h> | 26 | #include <asm/clock.h> |
23 | #include <asm/machvec.h> | 27 | #include <asm/machvec.h> |
24 | #include <asm/io.h> | 28 | #include <asm/io.h> |
25 | #include <asm/sh_keysc.h> | ||
26 | #include <cpu/sh7724.h> | 29 | #include <cpu/sh7724.h> |
27 | #include <mach/kfr2r09.h> | 30 | #include <mach/kfr2r09.h> |
28 | 31 | ||
@@ -212,11 +215,154 @@ static struct platform_device kfr2r09_usb0_gadget_device = { | |||
212 | .resource = kfr2r09_usb0_gadget_resources, | 215 | .resource = kfr2r09_usb0_gadget_resources, |
213 | }; | 216 | }; |
214 | 217 | ||
218 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { | ||
219 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, | ||
220 | }; | ||
221 | |||
222 | static struct resource kfr2r09_ceu_resources[] = { | ||
223 | [0] = { | ||
224 | .name = "CEU", | ||
225 | .start = 0xfe910000, | ||
226 | .end = 0xfe91009f, | ||
227 | .flags = IORESOURCE_MEM, | ||
228 | }, | ||
229 | [1] = { | ||
230 | .start = 52, | ||
231 | .end = 52, | ||
232 | .flags = IORESOURCE_IRQ, | ||
233 | }, | ||
234 | [2] = { | ||
235 | /* place holder for contiguous memory */ | ||
236 | }, | ||
237 | }; | ||
238 | |||
239 | static struct platform_device kfr2r09_ceu_device = { | ||
240 | .name = "sh_mobile_ceu", | ||
241 | .id = 0, /* "ceu0" clock */ | ||
242 | .num_resources = ARRAY_SIZE(kfr2r09_ceu_resources), | ||
243 | .resource = kfr2r09_ceu_resources, | ||
244 | .dev = { | ||
245 | .platform_data = &sh_mobile_ceu_info, | ||
246 | }, | ||
247 | .archdata = { | ||
248 | .hwblk_id = HWBLK_CEU0, | ||
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 | #define DRVCRB 0xA405018C | ||
259 | static int camera_power(struct device *dev, int mode) | ||
260 | { | ||
261 | int ret; | ||
262 | |||
263 | if (mode) { | ||
264 | long rate; | ||
265 | |||
266 | camera_clk = clk_get(NULL, "video_clk"); | ||
267 | if (IS_ERR(camera_clk)) | ||
268 | return PTR_ERR(camera_clk); | ||
269 | |||
270 | /* set VIO_CKO clock to 25MHz */ | ||
271 | rate = clk_round_rate(camera_clk, 25000000); | ||
272 | ret = clk_set_rate(camera_clk, rate); | ||
273 | if (ret < 0) | ||
274 | goto eclkrate; | ||
275 | |||
276 | /* set DRVCRB | ||
277 | * | ||
278 | * use 1.8 V for VccQ_VIO | ||
279 | * use 2.85V for VccQ_SR | ||
280 | */ | ||
281 | ctrl_outw((ctrl_inw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB); | ||
282 | |||
283 | /* reset clear */ | ||
284 | ret = gpio_request(GPIO_PTB4, NULL); | ||
285 | if (ret < 0) | ||
286 | goto eptb4; | ||
287 | ret = gpio_request(GPIO_PTB7, NULL); | ||
288 | if (ret < 0) | ||
289 | goto eptb7; | ||
290 | |||
291 | ret = gpio_direction_output(GPIO_PTB4, 1); | ||
292 | if (!ret) | ||
293 | ret = gpio_direction_output(GPIO_PTB7, 1); | ||
294 | if (ret < 0) | ||
295 | goto egpioout; | ||
296 | msleep(1); | ||
297 | |||
298 | ret = clk_enable(camera_clk); /* start VIO_CKO */ | ||
299 | if (ret < 0) | ||
300 | goto eclkon; | ||
301 | |||
302 | return 0; | ||
303 | } | ||
304 | |||
305 | ret = 0; | ||
306 | |||
307 | clk_disable(camera_clk); | ||
308 | eclkon: | ||
309 | gpio_set_value(GPIO_PTB7, 0); | ||
310 | egpioout: | ||
311 | gpio_set_value(GPIO_PTB4, 0); | ||
312 | gpio_free(GPIO_PTB7); | ||
313 | eptb7: | ||
314 | gpio_free(GPIO_PTB4); | ||
315 | eptb4: | ||
316 | eclkrate: | ||
317 | clk_put(camera_clk); | ||
318 | return ret; | ||
319 | } | ||
320 | |||
321 | static struct soc_camera_link rj54n1_link = { | ||
322 | .power = camera_power, | ||
323 | .board_info = &kfr2r09_i2c_camera, | ||
324 | .i2c_adapter_id = 1, | ||
325 | .module_name = "rj54n1cb0c", | ||
326 | }; | ||
327 | |||
328 | static struct platform_device kfr2r09_camera = { | ||
329 | .name = "soc-camera-pdrv", | ||
330 | .id = 0, | ||
331 | .dev = { | ||
332 | .platform_data = &rj54n1_link, | ||
333 | }, | ||
334 | }; | ||
335 | |||
336 | static struct resource kfr2r09_sh_sdhi0_resources[] = { | ||
337 | [0] = { | ||
338 | .name = "SDHI0", | ||
339 | .start = 0x04ce0000, | ||
340 | .end = 0x04ce01ff, | ||
341 | .flags = IORESOURCE_MEM, | ||
342 | }, | ||
343 | [1] = { | ||
344 | .start = 101, | ||
345 | .flags = IORESOURCE_IRQ, | ||
346 | }, | ||
347 | }; | ||
348 | |||
349 | static struct platform_device kfr2r09_sh_sdhi0_device = { | ||
350 | .name = "sh_mobile_sdhi", | ||
351 | .num_resources = ARRAY_SIZE(kfr2r09_sh_sdhi0_resources), | ||
352 | .resource = kfr2r09_sh_sdhi0_resources, | ||
353 | .archdata = { | ||
354 | .hwblk_id = HWBLK_SDHI0, | ||
355 | }, | ||
356 | }; | ||
357 | |||
215 | static struct platform_device *kfr2r09_devices[] __initdata = { | 358 | static struct platform_device *kfr2r09_devices[] __initdata = { |
216 | &kfr2r09_nor_flash_device, | 359 | &kfr2r09_nor_flash_device, |
217 | &kfr2r09_nand_flash_device, | 360 | &kfr2r09_nand_flash_device, |
218 | &kfr2r09_sh_keysc_device, | 361 | &kfr2r09_sh_keysc_device, |
219 | &kfr2r09_sh_lcdc_device, | 362 | &kfr2r09_sh_lcdc_device, |
363 | &kfr2r09_ceu_device, | ||
364 | &kfr2r09_camera, | ||
365 | &kfr2r09_sh_sdhi0_device, | ||
220 | }; | 366 | }; |
221 | 367 | ||
222 | #define BSC_CS0BCR 0xfec10004 | 368 | #define BSC_CS0BCR 0xfec10004 |
@@ -268,11 +414,59 @@ static int kfr2r09_usb0_gadget_i2c_setup(void) | |||
268 | 414 | ||
269 | return 0; | 415 | return 0; |
270 | } | 416 | } |
417 | |||
418 | static int kfr2r09_serial_i2c_setup(void) | ||
419 | { | ||
420 | struct i2c_adapter *a; | ||
421 | struct i2c_msg msg; | ||
422 | unsigned char buf[2]; | ||
423 | int ret; | ||
424 | |||
425 | a = i2c_get_adapter(0); | ||
426 | if (!a) | ||
427 | return -ENODEV; | ||
428 | |||
429 | /* set bit 6 (the 7th bit) of chip at 0x09, register 0x13 */ | ||
430 | buf[0] = 0x13; | ||
431 | msg.addr = 0x09; | ||
432 | msg.buf = buf; | ||
433 | msg.len = 1; | ||
434 | msg.flags = 0; | ||
435 | ret = i2c_transfer(a, &msg, 1); | ||
436 | if (ret != 1) | ||
437 | return -ENODEV; | ||
438 | |||
439 | buf[0] = 0; | ||
440 | msg.addr = 0x09; | ||
441 | msg.buf = buf; | ||
442 | msg.len = 1; | ||
443 | msg.flags = I2C_M_RD; | ||
444 | ret = i2c_transfer(a, &msg, 1); | ||
445 | if (ret != 1) | ||
446 | return -ENODEV; | ||
447 | |||
448 | buf[1] = buf[0] | (1 << 6); | ||
449 | buf[0] = 0x13; | ||
450 | msg.addr = 0x09; | ||
451 | msg.buf = buf; | ||
452 | msg.len = 2; | ||
453 | msg.flags = 0; | ||
454 | ret = i2c_transfer(a, &msg, 1); | ||
455 | if (ret != 1) | ||
456 | return -ENODEV; | ||
457 | |||
458 | return 0; | ||
459 | } | ||
271 | #else | 460 | #else |
272 | static int kfr2r09_usb0_gadget_i2c_setup(void) | 461 | static int kfr2r09_usb0_gadget_i2c_setup(void) |
273 | { | 462 | { |
274 | return -ENODEV; | 463 | return -ENODEV; |
275 | } | 464 | } |
465 | |||
466 | static int kfr2r09_serial_i2c_setup(void) | ||
467 | { | ||
468 | return -ENODEV; | ||
469 | } | ||
276 | #endif | 470 | #endif |
277 | 471 | ||
278 | static int kfr2r09_usb0_gadget_setup(void) | 472 | static int kfr2r09_usb0_gadget_setup(void) |
@@ -299,11 +493,27 @@ static int kfr2r09_usb0_gadget_setup(void) | |||
299 | return 0; | 493 | return 0; |
300 | } | 494 | } |
301 | 495 | ||
496 | extern char kfr2r09_sdram_enter_start; | ||
497 | extern char kfr2r09_sdram_enter_end; | ||
498 | extern char kfr2r09_sdram_leave_start; | ||
499 | extern char kfr2r09_sdram_leave_end; | ||
500 | |||
302 | static int __init kfr2r09_devices_setup(void) | 501 | static int __init kfr2r09_devices_setup(void) |
303 | { | 502 | { |
503 | /* register board specific self-refresh code */ | ||
504 | sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF | | ||
505 | SUSP_SH_RSTANDBY, | ||
506 | &kfr2r09_sdram_enter_start, | ||
507 | &kfr2r09_sdram_enter_end, | ||
508 | &kfr2r09_sdram_leave_start, | ||
509 | &kfr2r09_sdram_leave_end); | ||
510 | |||
304 | /* enable SCIF1 serial port for YC401 console support */ | 511 | /* enable SCIF1 serial port for YC401 console support */ |
305 | gpio_request(GPIO_FN_SCIF1_RXD, NULL); | 512 | gpio_request(GPIO_FN_SCIF1_RXD, NULL); |
306 | gpio_request(GPIO_FN_SCIF1_TXD, NULL); | 513 | gpio_request(GPIO_FN_SCIF1_TXD, NULL); |
514 | kfr2r09_serial_i2c_setup(); /* ECONTMSK(bit6=L10ONEN) set 1 */ | ||
515 | gpio_request(GPIO_PTG3, NULL); /* HPON_ON */ | ||
516 | gpio_direction_output(GPIO_PTG3, 1); /* HPON_ON = H */ | ||
307 | 517 | ||
308 | /* setup NOR flash at CS0 */ | 518 | /* setup NOR flash at CS0 */ |
309 | ctrl_outl(0x36db0400, BSC_CS0BCR); | 519 | ctrl_outl(0x36db0400, BSC_CS0BCR); |
@@ -361,6 +571,32 @@ static int __init kfr2r09_devices_setup(void) | |||
361 | if (kfr2r09_usb0_gadget_setup() == 0) | 571 | if (kfr2r09_usb0_gadget_setup() == 0) |
362 | platform_device_register(&kfr2r09_usb0_gadget_device); | 572 | platform_device_register(&kfr2r09_usb0_gadget_device); |
363 | 573 | ||
574 | /* CEU */ | ||
575 | gpio_request(GPIO_FN_VIO_CKO, NULL); | ||
576 | gpio_request(GPIO_FN_VIO0_CLK, NULL); | ||
577 | gpio_request(GPIO_FN_VIO0_VD, NULL); | ||
578 | gpio_request(GPIO_FN_VIO0_HD, NULL); | ||
579 | gpio_request(GPIO_FN_VIO0_FLD, NULL); | ||
580 | gpio_request(GPIO_FN_VIO0_D7, NULL); | ||
581 | gpio_request(GPIO_FN_VIO0_D6, NULL); | ||
582 | gpio_request(GPIO_FN_VIO0_D5, NULL); | ||
583 | gpio_request(GPIO_FN_VIO0_D4, NULL); | ||
584 | gpio_request(GPIO_FN_VIO0_D3, NULL); | ||
585 | gpio_request(GPIO_FN_VIO0_D2, NULL); | ||
586 | gpio_request(GPIO_FN_VIO0_D1, NULL); | ||
587 | gpio_request(GPIO_FN_VIO0_D0, NULL); | ||
588 | |||
589 | platform_resource_setup_memory(&kfr2r09_ceu_device, "ceu", 4 << 20); | ||
590 | |||
591 | /* SDHI0 connected to yc304 */ | ||
592 | gpio_request(GPIO_FN_SDHI0CD, NULL); | ||
593 | gpio_request(GPIO_FN_SDHI0D3, NULL); | ||
594 | gpio_request(GPIO_FN_SDHI0D2, NULL); | ||
595 | gpio_request(GPIO_FN_SDHI0D1, NULL); | ||
596 | gpio_request(GPIO_FN_SDHI0D0, NULL); | ||
597 | gpio_request(GPIO_FN_SDHI0CMD, NULL); | ||
598 | gpio_request(GPIO_FN_SDHI0CLK, NULL); | ||
599 | |||
364 | return platform_add_devices(kfr2r09_devices, | 600 | return platform_add_devices(kfr2r09_devices, |
365 | ARRAY_SIZE(kfr2r09_devices)); | 601 | ARRAY_SIZE(kfr2r09_devices)); |
366 | } | 602 | } |