diff options
Diffstat (limited to 'arch/sh/boards/mach-migor/setup.c')
-rw-r--r-- | arch/sh/boards/mach-migor/setup.c | 171 |
1 files changed, 76 insertions, 95 deletions
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c index cc1408119c24..28e56c5809a2 100644 --- a/arch/sh/boards/mach-migor/setup.c +++ b/arch/sh/boards/mach-migor/setup.c | |||
@@ -18,9 +18,12 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
20 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
21 | #include <media/soc_camera_platform.h> | 21 | #include <linux/spi/spi.h> |
22 | #include <media/sh_mobile_ceu.h> | 22 | #include <linux/spi/spi_gpio.h> |
23 | #include <video/sh_mobile_lcdc.h> | 23 | #include <video/sh_mobile_lcdc.h> |
24 | #include <media/sh_mobile_ceu.h> | ||
25 | #include <media/ov772x.h> | ||
26 | #include <media/tw9910.h> | ||
24 | #include <asm/clock.h> | 27 | #include <asm/clock.h> |
25 | #include <asm/machvec.h> | 28 | #include <asm/machvec.h> |
26 | #include <asm/io.h> | 29 | #include <asm/io.h> |
@@ -292,9 +295,12 @@ static struct platform_device migor_lcdc_device = { | |||
292 | }; | 295 | }; |
293 | 296 | ||
294 | static struct clk *camera_clk; | 297 | static struct clk *camera_clk; |
298 | static DEFINE_MUTEX(camera_lock); | ||
295 | 299 | ||
296 | static void camera_power_on(void) | 300 | static void camera_power_on(int is_tw) |
297 | { | 301 | { |
302 | mutex_lock(&camera_lock); | ||
303 | |||
298 | /* Use 10 MHz VIO_CKO instead of 24 MHz to work | 304 | /* Use 10 MHz VIO_CKO instead of 24 MHz to work |
299 | * around signal quality issues on Panel Board V2.1. | 305 | * around signal quality issues on Panel Board V2.1. |
300 | */ | 306 | */ |
@@ -304,6 +310,12 @@ static void camera_power_on(void) | |||
304 | 310 | ||
305 | /* use VIO_RST to take camera out of reset */ | 311 | /* use VIO_RST to take camera out of reset */ |
306 | mdelay(10); | 312 | mdelay(10); |
313 | if (is_tw) { | ||
314 | gpio_set_value(GPIO_PTT2, 0); | ||
315 | gpio_set_value(GPIO_PTT0, 0); | ||
316 | } else { | ||
317 | gpio_set_value(GPIO_PTT0, 1); | ||
318 | } | ||
307 | gpio_set_value(GPIO_PTT3, 0); | 319 | gpio_set_value(GPIO_PTT3, 0); |
308 | mdelay(10); | 320 | mdelay(10); |
309 | gpio_set_value(GPIO_PTT3, 1); | 321 | gpio_set_value(GPIO_PTT3, 1); |
@@ -316,107 +328,29 @@ static void camera_power_off(void) | |||
316 | clk_put(camera_clk); | 328 | clk_put(camera_clk); |
317 | 329 | ||
318 | gpio_set_value(GPIO_PTT3, 0); | 330 | gpio_set_value(GPIO_PTT3, 0); |
331 | mutex_unlock(&camera_lock); | ||
319 | } | 332 | } |
320 | 333 | ||
321 | static void camera_power(int mode) | 334 | static int ov7725_power(struct device *dev, int mode) |
322 | { | 335 | { |
323 | if (mode) | 336 | if (mode) |
324 | camera_power_on(); | 337 | camera_power_on(0); |
325 | else | 338 | else |
326 | camera_power_off(); | 339 | camera_power_off(); |
327 | } | ||
328 | 340 | ||
329 | #ifdef CONFIG_I2C | 341 | return 0; |
330 | static unsigned char camera_ov772x_magic[] = | 342 | } |
331 | { | ||
332 | 0x09, 0x01, 0x0c, 0x20, 0x0d, 0x41, 0x0e, 0x01, | ||
333 | 0x12, 0x00, 0x13, 0x8F, 0x14, 0x4A, 0x15, 0x00, | ||
334 | 0x16, 0x00, 0x17, 0x23, 0x18, 0xa0, 0x19, 0x07, | ||
335 | 0x1a, 0xf0, 0x1b, 0x40, 0x1f, 0x00, 0x20, 0x10, | ||
336 | 0x22, 0xff, 0x23, 0x01, 0x28, 0x00, 0x29, 0xa0, | ||
337 | 0x2a, 0x00, 0x2b, 0x00, 0x2c, 0xf0, 0x2d, 0x00, | ||
338 | 0x2e, 0x00, 0x30, 0x80, 0x31, 0x60, 0x32, 0x00, | ||
339 | 0x33, 0x00, 0x34, 0x00, 0x3d, 0x80, 0x3e, 0xe2, | ||
340 | 0x3f, 0x1f, 0x42, 0x80, 0x43, 0x80, 0x44, 0x80, | ||
341 | 0x45, 0x80, 0x46, 0x00, 0x47, 0x00, 0x48, 0x00, | ||
342 | 0x49, 0x50, 0x4a, 0x30, 0x4b, 0x50, 0x4c, 0x50, | ||
343 | 0x4d, 0x00, 0x4e, 0xef, 0x4f, 0x10, 0x50, 0x60, | ||
344 | 0x51, 0x00, 0x52, 0x00, 0x53, 0x24, 0x54, 0x7a, | ||
345 | 0x55, 0xfc, 0x62, 0xff, 0x63, 0xf0, 0x64, 0x1f, | ||
346 | 0x65, 0x00, 0x66, 0x10, 0x67, 0x00, 0x68, 0x00, | ||
347 | 0x69, 0x5c, 0x6a, 0x11, 0x6b, 0xa2, 0x6c, 0x01, | ||
348 | 0x6d, 0x50, 0x6e, 0x80, 0x6f, 0x80, 0x70, 0x0f, | ||
349 | 0x71, 0x00, 0x72, 0x00, 0x73, 0x0f, 0x74, 0x0f, | ||
350 | 0x75, 0xff, 0x78, 0x10, 0x79, 0x70, 0x7a, 0x70, | ||
351 | 0x7b, 0xf0, 0x7c, 0xf0, 0x7d, 0xf0, 0x7e, 0x0e, | ||
352 | 0x7f, 0x1a, 0x80, 0x31, 0x81, 0x5a, 0x82, 0x69, | ||
353 | 0x83, 0x75, 0x84, 0x7e, 0x85, 0x88, 0x86, 0x8f, | ||
354 | 0x87, 0x96, 0x88, 0xa3, 0x89, 0xaf, 0x8a, 0xc4, | ||
355 | 0x8b, 0xd7, 0x8c, 0xe8, 0x8d, 0x20, 0x8e, 0x00, | ||
356 | 0x8f, 0x00, 0x90, 0x08, 0x91, 0x10, 0x92, 0x1f, | ||
357 | 0x93, 0x01, 0x94, 0x2c, 0x95, 0x24, 0x96, 0x08, | ||
358 | 0x97, 0x14, 0x98, 0x24, 0x99, 0x38, 0x9a, 0x9e, | ||
359 | 0x9b, 0x00, 0x9c, 0x40, 0x9e, 0x11, 0x9f, 0x02, | ||
360 | 0xa0, 0x00, 0xa1, 0x40, 0xa2, 0x40, 0xa3, 0x06, | ||
361 | 0xa4, 0x00, 0xa6, 0x00, 0xa7, 0x40, 0xa8, 0x40, | ||
362 | 0xa9, 0x80, 0xaa, 0x80, 0xab, 0x06, 0xac, 0xff, | ||
363 | 0x12, 0x06, 0x64, 0x3f, 0x12, 0x46, 0x17, 0x3f, | ||
364 | 0x18, 0x50, 0x19, 0x03, 0x1a, 0x78, 0x29, 0x50, | ||
365 | 0x2c, 0x78, | ||
366 | }; | ||
367 | 343 | ||
368 | static int ov772x_set_capture(struct soc_camera_platform_info *info, | 344 | static int tw9910_power(struct device *dev, int mode) |
369 | int enable) | ||
370 | { | 345 | { |
371 | struct i2c_adapter *a = i2c_get_adapter(0); | 346 | if (mode) |
372 | struct i2c_msg msg; | 347 | camera_power_on(1); |
373 | int ret = 0; | 348 | else |
374 | int i; | 349 | camera_power_off(); |
375 | |||
376 | if (!enable) | ||
377 | return 0; /* camera_power_off() is enough */ | ||
378 | |||
379 | for (i = 0; i < ARRAY_SIZE(camera_ov772x_magic); i += 2) { | ||
380 | u_int8_t buf[8]; | ||
381 | |||
382 | msg.addr = 0x21; | ||
383 | msg.buf = buf; | ||
384 | msg.len = 2; | ||
385 | msg.flags = 0; | ||
386 | |||
387 | buf[0] = camera_ov772x_magic[i]; | ||
388 | buf[1] = camera_ov772x_magic[i + 1]; | ||
389 | |||
390 | ret = (ret < 0) ? ret : i2c_transfer(a, &msg, 1); | ||
391 | } | ||
392 | 350 | ||
393 | return ret; | 351 | return 0; |
394 | } | 352 | } |
395 | 353 | ||
396 | static struct soc_camera_platform_info ov772x_info = { | ||
397 | .iface = 0, | ||
398 | .format_name = "RGB565", | ||
399 | .format_depth = 16, | ||
400 | .format = { | ||
401 | .pixelformat = V4L2_PIX_FMT_RGB565, | ||
402 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
403 | .width = 320, | ||
404 | .height = 240, | ||
405 | }, | ||
406 | .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH | | ||
407 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8, | ||
408 | .power = camera_power, | ||
409 | .set_capture = ov772x_set_capture, | ||
410 | }; | ||
411 | |||
412 | static struct platform_device migor_camera_device = { | ||
413 | .name = "soc_camera_platform", | ||
414 | .dev = { | ||
415 | .platform_data = &ov772x_info, | ||
416 | }, | ||
417 | }; | ||
418 | #endif /* CONFIG_I2C */ | ||
419 | |||
420 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { | 354 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { |
421 | .flags = SOCAM_MASTER | SOCAM_DATAWIDTH_8 | SOCAM_PCLK_SAMPLE_RISING \ | 355 | .flags = SOCAM_MASTER | SOCAM_DATAWIDTH_8 | SOCAM_PCLK_SAMPLE_RISING \ |
422 | | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH, | 356 | | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH, |
@@ -448,16 +382,43 @@ static struct platform_device migor_ceu_device = { | |||
448 | }, | 382 | }, |
449 | }; | 383 | }; |
450 | 384 | ||
385 | static struct ov772x_camera_info ov7725_info = { | ||
386 | .buswidth = SOCAM_DATAWIDTH_8, | ||
387 | .link = { | ||
388 | .power = ov7725_power, | ||
389 | }, | ||
390 | }; | ||
391 | |||
392 | static struct tw9910_video_info tw9910_info = { | ||
393 | .buswidth = SOCAM_DATAWIDTH_8, | ||
394 | .mpout = TW9910_MPO_FIELD, | ||
395 | .link = { | ||
396 | .power = tw9910_power, | ||
397 | } | ||
398 | }; | ||
399 | |||
400 | struct spi_gpio_platform_data sdcard_cn9_platform_data = { | ||
401 | .sck = GPIO_PTD0, | ||
402 | .mosi = GPIO_PTD1, | ||
403 | .miso = GPIO_PTD2, | ||
404 | .num_chipselect = 1, | ||
405 | }; | ||
406 | |||
407 | static struct platform_device sdcard_cn9_device = { | ||
408 | .name = "spi_gpio", | ||
409 | .dev = { | ||
410 | .platform_data = &sdcard_cn9_platform_data, | ||
411 | }, | ||
412 | }; | ||
413 | |||
451 | static struct platform_device *migor_devices[] __initdata = { | 414 | static struct platform_device *migor_devices[] __initdata = { |
452 | &smc91x_eth_device, | 415 | &smc91x_eth_device, |
453 | &sh_keysc_device, | 416 | &sh_keysc_device, |
454 | &migor_lcdc_device, | 417 | &migor_lcdc_device, |
455 | &migor_ceu_device, | 418 | &migor_ceu_device, |
456 | #ifdef CONFIG_I2C | ||
457 | &migor_camera_device, | ||
458 | #endif | ||
459 | &migor_nor_flash_device, | 419 | &migor_nor_flash_device, |
460 | &migor_nand_flash_device, | 420 | &migor_nand_flash_device, |
421 | &sdcard_cn9_device, | ||
461 | }; | 422 | }; |
462 | 423 | ||
463 | static struct i2c_board_info migor_i2c_devices[] = { | 424 | static struct i2c_board_info migor_i2c_devices[] = { |
@@ -468,6 +429,23 @@ static struct i2c_board_info migor_i2c_devices[] = { | |||
468 | I2C_BOARD_INFO("migor_ts", 0x51), | 429 | I2C_BOARD_INFO("migor_ts", 0x51), |
469 | .irq = 38, /* IRQ6 */ | 430 | .irq = 38, /* IRQ6 */ |
470 | }, | 431 | }, |
432 | { | ||
433 | I2C_BOARD_INFO("ov772x", 0x21), | ||
434 | .platform_data = &ov7725_info, | ||
435 | }, | ||
436 | { | ||
437 | I2C_BOARD_INFO("tw9910", 0x45), | ||
438 | .platform_data = &tw9910_info, | ||
439 | }, | ||
440 | }; | ||
441 | |||
442 | static struct spi_board_info migor_spi_devices[] = { | ||
443 | { | ||
444 | .modalias = "mmc_spi", | ||
445 | .max_speed_hz = 5000000, | ||
446 | .chip_select = 0, | ||
447 | .controller_data = (void *) GPIO_PTD5, | ||
448 | }, | ||
471 | }; | 449 | }; |
472 | 450 | ||
473 | static int __init migor_devices_setup(void) | 451 | static int __init migor_devices_setup(void) |
@@ -592,6 +570,9 @@ static int __init migor_devices_setup(void) | |||
592 | i2c_register_board_info(0, migor_i2c_devices, | 570 | i2c_register_board_info(0, migor_i2c_devices, |
593 | ARRAY_SIZE(migor_i2c_devices)); | 571 | ARRAY_SIZE(migor_i2c_devices)); |
594 | 572 | ||
573 | spi_register_board_info(migor_spi_devices, | ||
574 | ARRAY_SIZE(migor_spi_devices)); | ||
575 | |||
595 | return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices)); | 576 | return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices)); |
596 | } | 577 | } |
597 | __initcall(migor_devices_setup); | 578 | __initcall(migor_devices_setup); |