aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/mach-kfr2r09/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/mach-kfr2r09/setup.c')
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c238
1 files changed, 237 insertions, 1 deletions
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
218static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
219 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
220};
221
222static 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
239static 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
252static struct i2c_board_info kfr2r09_i2c_camera = {
253 I2C_BOARD_INFO("rj54n1cb0c", 0x50),
254};
255
256static struct clk *camera_clk;
257
258#define DRVCRB 0xA405018C
259static 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);
308eclkon:
309 gpio_set_value(GPIO_PTB7, 0);
310egpioout:
311 gpio_set_value(GPIO_PTB4, 0);
312 gpio_free(GPIO_PTB7);
313eptb7:
314 gpio_free(GPIO_PTB4);
315eptb4:
316eclkrate:
317 clk_put(camera_clk);
318 return ret;
319}
320
321static 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
328static struct platform_device kfr2r09_camera = {
329 .name = "soc-camera-pdrv",
330 .id = 0,
331 .dev = {
332 .platform_data = &rj54n1_link,
333 },
334};
335
336static 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
349static 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
215static struct platform_device *kfr2r09_devices[] __initdata = { 358static 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
418static 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
272static int kfr2r09_usb0_gadget_i2c_setup(void) 461static int kfr2r09_usb0_gadget_i2c_setup(void)
273{ 462{
274 return -ENODEV; 463 return -ENODEV;
275} 464}
465
466static int kfr2r09_serial_i2c_setup(void)
467{
468 return -ENODEV;
469}
276#endif 470#endif
277 471
278static int kfr2r09_usb0_gadget_setup(void) 472static 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
496extern char kfr2r09_sdram_enter_start;
497extern char kfr2r09_sdram_enter_end;
498extern char kfr2r09_sdram_leave_start;
499extern char kfr2r09_sdram_leave_end;
500
302static int __init kfr2r09_devices_setup(void) 501static 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}