sh: mach-ecovec24: Add mt9t112 camera support
authorKuninori Morimoto <morimoto.kuninori@renesas.com>
Tue, 15 Dec 2009 05:37:26 +0000 (05:37 +0000)
committerPaul Mundt <lethal@linux-sh.org>
Tue, 15 Dec 2009 13:03:07 +0000 (22:03 +0900)
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/boards/mach-ecovec24/setup.c

index d4ac32b63572fa245649032e01e0d45bc1d23cc0..89c5a715d0b6ad538c7224da5a0779130edc6eb9 100644 (file)
@@ -29,6 +29,7 @@
 #include <video/sh_mobile_lcdc.h>
 #include <media/sh_mobile_ceu.h>
 #include <media/tw9910.h>
+#include <media/mt9t112.h>
 #include <asm/heartbeat.h>
 #include <asm/sh_eth.h>
 #include <asm/clock.h>
@@ -566,11 +567,19 @@ static struct platform_device msiof0_device = {
 
 #endif
 
-/* I2C Video */
+/* I2C Video/Camera */
 static struct i2c_board_info i2c_camera[] = {
        {
                I2C_BOARD_INFO("tw9910", 0x45),
        },
+       {
+               /* 1st camera */
+               I2C_BOARD_INFO("mt9t112", 0x3c),
+       },
+       {
+               /* 2nd camera */
+               I2C_BOARD_INFO("mt9t112", 0x3c),
+       },
 };
 
 /* tw9910 */
@@ -599,6 +608,52 @@ static struct soc_camera_link tw9910_link = {
        .priv           = &tw9910_info,
 };
 
+/* mt9t112 */
+static int mt9t112_power1(struct device *dev, int mode)
+{
+       gpio_set_value(GPIO_PTA3, mode);
+       if (mode)
+               mdelay(100);
+
+       return 0;
+}
+
+static struct mt9t112_camera_info mt9t112_info1 = {
+       .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
+       .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
+};
+
+static struct soc_camera_link mt9t112_link1 = {
+       .i2c_adapter_id = 0,
+       .power          = mt9t112_power1,
+       .bus_id         = 0,
+       .board_info     = &i2c_camera[1],
+       .module_name    = "mt9t112",
+       .priv           = &mt9t112_info1,
+};
+
+static int mt9t112_power2(struct device *dev, int mode)
+{
+       gpio_set_value(GPIO_PTA4, mode);
+       if (mode)
+               mdelay(100);
+
+       return 0;
+}
+
+static struct mt9t112_camera_info mt9t112_info2 = {
+       .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
+       .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
+};
+
+static struct soc_camera_link mt9t112_link2 = {
+       .i2c_adapter_id = 1,
+       .power          = mt9t112_power2,
+       .bus_id         = 1,
+       .board_info     = &i2c_camera[2],
+       .module_name    = "mt9t112",
+       .priv           = &mt9t112_info2,
+};
 
 static struct platform_device camera_devices[] = {
        {
@@ -608,6 +663,20 @@ static struct platform_device camera_devices[] = {
                        .platform_data = &tw9910_link,
                },
        },
+       {
+               .name   = "soc-camera-pdrv",
+               .id     = 1,
+               .dev    = {
+                       .platform_data = &mt9t112_link1,
+               },
+       },
+       {
+               .name   = "soc-camera-pdrv",
+               .id     = 2,
+               .dev    = {
+                       .platform_data = &mt9t112_link2,
+               },
+       },
 };
 
 static struct platform_device *ecovec_devices[] __initdata = {
@@ -627,6 +696,8 @@ static struct platform_device *ecovec_devices[] __initdata = {
        &msiof0_device,
 #endif
        &camera_devices[0],
+       &camera_devices[1],
+       &camera_devices[2],
 };
 
 #define EEPROM_ADDR 0x50
@@ -943,6 +1014,12 @@ static int __init arch_setup(void)
        gpio_request(GPIO_PTU2, NULL);
        gpio_direction_output(GPIO_PTU2, 1);
 
+       /* enable Camera */
+       gpio_request(GPIO_PTA3, NULL);
+       gpio_request(GPIO_PTA4, NULL);
+       gpio_direction_output(GPIO_PTA3, 0);
+       gpio_direction_output(GPIO_PTA4, 0);
+
        /* enable I2C device */
        i2c_register_board_info(1, i2c1_devices,
                                ARRAY_SIZE(i2c1_devices));