ARM: tegra: TN8: Add mt9m114 sensor support
David Wang [Tue, 1 Oct 2013 19:29:51 +0000 (12:29 -0700)]
Add SOC1040 (mt9m114) YUV sensor board file
support.

bug 1364405

Change-Id: Ib778467f96fa77f376cad2c127cd9e9763955e3f
Signed-off-by: David Wang <davidw@nvidia.com>
Reviewed-on: http://git-master/r/282824
Reviewed-by: Chao Xu <cxu@nvidia.com>

arch/arm/boot/dts/tegra124-tn8-power.dtsi
arch/arm/mach-tegra/board-ardbeg-sensors.c
arch/arm/mach-tegra/board-ardbeg.h

index 596fc9d..d5805eb 100644 (file)
@@ -628,6 +628,10 @@ palmas: tps65913 {
                                                regulator-consumer-supply = "vi2c";
                                                regulator-consumer-device = "2-0030";
                                        };
+                                       c9 {
+                                               regulator-consumer-supply = "vif";
+                                               regulator-consumer-device = "2-0048";
+                                       };
                                };
                        };
 
@@ -651,6 +655,10 @@ palmas: tps65913 {
                                                regulator-consumer-supply = "vdd";
                                                regulator-consumer-device = "2-000c";
                                        };
+                                       c5 {
+                                               regulator-consumer-supply = "vana";
+                                               regulator-consumer-device = "2-0048";
+                                       };
                                };
                        };
 
index a4dfd5a..fd90aa2 100644 (file)
@@ -29,6 +29,7 @@
 #include <media/as364x.h>
 #include <media/ov5693.h>
 #include <media/ov7695.h>
+#include <media/mt9m114.h>
 #include <media/ad5823.h>
 #include <linux/pid_thermal_gov.h>
 #include <linux/power/sbs-battery.h>
@@ -515,6 +516,62 @@ struct ov7695_platform_data ardbeg_ov7695_pdata = {
        .mclk_name = "mclk2",
 };
 
+static int ardbeg_mt9m114_power_on(struct mt9m114_power_rail *pw)
+{
+       int err;
+       if (unlikely(!pw || !pw->avdd || !pw->iovdd))
+               return -EFAULT;
+
+       gpio_set_value(CAM_RSTN, 0);
+       gpio_set_value(CAM2_PWDN, 1);
+       usleep_range(1000, 1020);
+
+       err = regulator_enable(pw->iovdd);
+       if (unlikely(err))
+               goto mt9m114_iovdd_fail;
+
+       err = regulator_enable(pw->avdd);
+       if (unlikely(err))
+               goto mt9m114_avdd_fail;
+
+       usleep_range(1000, 1020);
+       gpio_set_value(CAM_RSTN, 1);
+       gpio_set_value(CAM2_PWDN, 0);
+       usleep_range(1000, 1020);
+
+       /* return 1 to skip the in-driver power_on swquence */
+       return 1;
+
+mt9m114_avdd_fail:
+       regulator_disable(pw->iovdd);
+
+mt9m114_iovdd_fail:
+       gpio_set_value(CAM_RSTN, 0);
+       return -ENODEV;
+}
+
+static int ardbeg_mt9m114_power_off(struct mt9m114_power_rail *pw)
+{
+       if (unlikely(!pw || !pw->avdd || !pw->iovdd))
+               return -EFAULT;
+
+       usleep_range(100, 120);
+       gpio_set_value(CAM_RSTN, 0);
+       usleep_range(100, 120);
+       regulator_disable(pw->avdd);
+       usleep_range(100, 120);
+       regulator_disable(pw->iovdd);
+
+       return 1;
+}
+
+struct mt9m114_platform_data ardbeg_mt9m114_pdata = {
+       .power_on = ardbeg_mt9m114_power_on,
+       .power_off = ardbeg_mt9m114_power_off,
+       .mclk_name = "mclk2",
+};
+
+
 static int ardbeg_ov5693_power_on(struct ov5693_power_rail *pw)
 {
        int err;
@@ -650,6 +707,25 @@ static struct i2c_board_info ardbeg_i2c_board_info_e1793[] = {
        },
 };
 
+static struct i2c_board_info ardbeg_i2c_board_info_e1806[] = {
+       {
+               I2C_BOARD_INFO("ov5693", 0x10),
+               .platform_data = &ardbeg_ov5693_pdata,
+       },
+       {
+               I2C_BOARD_INFO("mt9m114", 0x48),
+               .platform_data = &ardbeg_mt9m114_pdata,
+       },
+       {
+               I2C_BOARD_INFO("ad5823", 0x0c),
+               .platform_data = &ardbeg_ad5823_pdata,
+       },
+       {
+               I2C_BOARD_INFO("as3648", 0x30),
+               .platform_data = &ardbeg_as3648_data,
+       },
+};
+
 
 static int ardbeg_camera_init(void)
 {
@@ -666,8 +742,14 @@ static int ardbeg_camera_init(void)
                tegra_io_dpd_enable(&csib_io);
                tegra_io_dpd_enable(&csie_io);
        } else {
+
+#ifdef CAM_BOARD_E1793
                i2c_register_board_info(2, ardbeg_i2c_board_info_e1793,
                                ARRAY_SIZE(ardbeg_i2c_board_info_e1793));
+#elif defined CAM_BOARD_E1806
+               i2c_register_board_info(2, ardbeg_i2c_board_info_e1806,
+                               ARRAY_SIZE(ardbeg_i2c_board_info_e1806));
+#endif
        }
        return 0;
 }
index 82ca11c..3776f40 100644 (file)
@@ -77,6 +77,7 @@ int ardbeg_soctherm_init(void);
 #define CAM2_PWDN TEGRA_GPIO_PBB6
 #define CAM1_PWDN TEGRA_GPIO_PBB5
 #define CAM_AF_PWDN TEGRA_GPIO_PBB7
+#define CAM_BOARD_E1806
 
 /* Modem related GPIOs */
 #define MODEM_EN               TEGRA_GPIO_PS4