ARM:tegra:ardbeg: various senor bringup on TN8
David Wang [Thu, 5 Sep 2013 01:09:07 +0000 (18:09 -0700)]
Modified ardbeg board file to support ov5693,
ov7695 sensors and ad5823 focuser to work on TN8.
Also added matching reguatlor names for
ov5693 and ov7695 in tn8 board power file.

Bug 1349826
Bug 1349914

Change-Id: I8a4268a23d0fe46a290719261fdfbd4f235443e3
Signed-off-by: David Wang <davidw@nvidia.com>
Reviewed-on: http://git-master/r/270941
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
Tested-by: Thomas Cherry <tcherry@nvidia.com>

arch/arm/mach-tegra/board-ardbeg-sensors.c
arch/arm/mach-tegra/board-tn8-power.c

index 5b30f51..37c201b 100644 (file)
 #include <media/imx135.h>
 #include <media/dw9718.h>
 #include <media/as364x.h>
+#include <media/ov5693.h>
+#include <media/ov7695.h>
+#include <media/ad5823.h>
 #include <linux/pid_thermal_gov.h>
 #include <linux/power/sbs-battery.h>
 #include <mach/edp.h>
 #include <mach/tegra_fuse.h>
+#include <mach/pinmux-t12.h>
+#include <mach/pinmux.h>
 
 #include "cpu-tegra.h"
 #include "devices.h"
@@ -419,6 +424,158 @@ static struct as364x_platform_data ardbeg_as3648_data = {
        .gpio_strobe    = CAM_FLASH_STROBE,
 };
 
+static int ardbeg_ov7695_power_on(struct ov7695_power_rail *pw)
+{
+       int err;
+
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
+               return -EFAULT;
+
+       gpio_set_value(CAM2_PWDN, 0);
+       usleep_range(1000, 1020);
+
+       err = regulator_enable(pw->avdd);
+       if (unlikely(err))
+               goto ov7695_avdd_fail;
+       usleep_range(300, 320);
+
+       err = regulator_enable(pw->iovdd);
+       if (unlikely(err))
+               goto ov7695_iovdd_fail;
+       usleep_range(1000, 1020);
+
+       gpio_set_value(CAM2_PWDN, 1);
+       usleep_range(1000, 1020);
+
+       return 0;
+
+ov7695_iovdd_fail:
+       regulator_disable(pw->avdd);
+
+ov7695_avdd_fail:
+
+       gpio_set_value(CAM_RSTN, 0);
+       return -ENODEV;
+}
+
+static int ardbeg_ov7695_power_off(struct ov7695_power_rail *pw)
+{
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
+               return -EFAULT;
+       usleep_range(100, 120);
+
+       gpio_set_value(CAM2_PWDN, 0);
+       usleep_range(100, 120);
+
+       regulator_disable(pw->iovdd);
+       usleep_range(100, 120);
+
+       regulator_disable(pw->avdd);
+       return 0;
+}
+
+struct ov7695_platform_data ardbeg_ov7695_pdata = {
+       .power_on = ardbeg_ov7695_power_on,
+       .power_off = ardbeg_ov7695_power_off,
+       .mclk_name = "mclk2",
+};
+
+static int ardbeg_ov5693_power_on(struct ov5693_power_rail *pw)
+{
+       int err;
+
+       if (unlikely(WARN_ON(!pw || !pw->dovdd || !pw->avdd)))
+               return -EFAULT;
+
+       if (ardbeg_get_extra_regulators())
+               goto ov5693_poweron_fail;
+
+       gpio_set_value(CAM1_PWDN, 0);
+       usleep_range(10, 20);
+
+       err = regulator_enable(pw->avdd);
+       if (err)
+               goto ov5693_avdd_fail;
+
+       err = regulator_enable(pw->dovdd);
+       if (err)
+               goto ov5693_iovdd_fail;
+
+       udelay(2);
+       gpio_set_value(CAM1_PWDN, 1);
+
+       err = regulator_enable(ardbeg_vcmvdd);
+       if (unlikely(err))
+               goto ov5693_vcmvdd_fail;
+
+       usleep_range(300, 310);
+
+       return 0;
+
+ov5693_vcmvdd_fail:
+       regulator_disable(pw->dovdd);
+
+ov5693_iovdd_fail:
+       regulator_disable(pw->avdd);
+
+ov5693_avdd_fail:
+       gpio_set_value(CAM1_PWDN, 0);
+
+ov5693_poweron_fail:
+       pr_err("%s FAILED\n", __func__);
+       return -ENODEV;
+}
+
+static int ardbeg_ov5693_power_off(struct ov5693_power_rail *pw)
+{
+       if (unlikely(WARN_ON(!pw || !pw->dovdd || !pw->avdd)))
+               return -EFAULT;
+
+       usleep_range(21, 25);
+       gpio_set_value(CAM1_PWDN, 0);
+       udelay(2);
+
+       regulator_disable(ardbeg_vcmvdd);
+       regulator_disable(pw->dovdd);
+       regulator_disable(pw->avdd);
+
+       return 0;
+}
+
+static struct nvc_gpio_pdata ov5693_gpio_pdata[] = {
+       { OV5693_GPIO_TYPE_PWRDN, CAM_RSTN, true, 0, },
+};
+
+static struct ov5693_platform_data ardbeg_ov5693_pdata = {
+       .gpio_count     = ARRAY_SIZE(ov5693_gpio_pdata),
+       .gpio           = ov5693_gpio_pdata,
+       .power_on       = ardbeg_ov5693_power_on,
+       .power_off      = ardbeg_ov5693_power_off,
+};
+
+static int ardbeg_ad5823_power_on(struct ad5823_platform_data *pdata)
+{
+       int err = 0;
+
+       pr_info("%s\n", __func__);
+       gpio_set_value_cansleep(pdata->gpio, 1);
+
+       return err;
+}
+
+static int ardbeg_ad5823_power_off(struct ad5823_platform_data *pdata)
+{
+       pr_info("%s\n", __func__);
+       gpio_set_value_cansleep(pdata->gpio, 0);
+
+       return 0;
+}
+
+static struct ad5823_platform_data ardbeg_ad5823_pdata = {
+       .gpio = CAM_AF_PWDN,
+       .power_on       = ardbeg_ad5823_power_on,
+       .power_off      = ardbeg_ad5823_power_off,
+};
 
 static struct i2c_board_info ardbeg_i2c_board_info_e1823[] = {
        {
@@ -439,14 +596,37 @@ static struct i2c_board_info ardbeg_i2c_board_info_e1823[] = {
        },
 };
 
+static struct i2c_board_info ardbeg_i2c_board_info_e1793[] = {
+       {
+               I2C_BOARD_INFO("ov5693", 0x10),
+               .platform_data = &ardbeg_ov5693_pdata,
+       },
+       {
+               I2C_BOARD_INFO("ov7695", 0x21),
+               .platform_data = &ardbeg_ov7695_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)
 {
        pr_debug("%s: ++\n", __func__);
 
-
-       i2c_register_board_info(2, ardbeg_i2c_board_info_e1823,
-                       ARRAY_SIZE(ardbeg_i2c_board_info_e1823));
+       if (!of_machine_is_compatible("nvidia,tn8")) {
+               i2c_register_board_info(2, ardbeg_i2c_board_info_e1823,
+                               ARRAY_SIZE(ardbeg_i2c_board_info_e1823));
+       } else {
+               i2c_register_board_info(2, ardbeg_i2c_board_info_e1793,
+                               ARRAY_SIZE(ardbeg_i2c_board_info_e1793));
+       }
        return 0;
 }
 
index 494c592..c77eded 100644 (file)
@@ -182,6 +182,7 @@ static struct regulator_consumer_supply palmas_ldo2_supply[] = {
        REGULATOR_SUPPLY("imx135_reg2", NULL),
        REGULATOR_SUPPLY("vdd_1v2_cam", NULL),
        REGULATOR_SUPPLY("vdig", "2-0010"),
+       REGULATOR_SUPPLY("dvdd", "2-0010"),
        REGULATOR_SUPPLY("vdig", "2-0036"),
 };
 
@@ -196,6 +197,7 @@ static struct regulator_consumer_supply palmas_ldo4_supply[] = {
        REGULATOR_SUPPLY("avdd_cam2_cam", NULL),
        REGULATOR_SUPPLY("avdd_cam3_cam", NULL),
        REGULATOR_SUPPLY("vana", "2-0010"),
+       REGULATOR_SUPPLY("avdd", "2-0010"),
        REGULATOR_SUPPLY("vana", "2-0036"),
 };
 
@@ -216,6 +218,8 @@ static struct regulator_consumer_supply palmas_ldo6_supply[] = {
        REGULATOR_SUPPLY("vdd_cam1_1v8_cam", NULL),
        REGULATOR_SUPPLY("vdd_cam2_1v8_cam", NULL),
        REGULATOR_SUPPLY("vif", "2-0010"),
+       REGULATOR_SUPPLY("dovdd", "2-0010"),
+       REGULATOR_SUPPLY("vif2", "2-0021"),
        REGULATOR_SUPPLY("vif", "2-0036"),
        REGULATOR_SUPPLY("vdd_i2c", "2-000c"),
        REGULATOR_SUPPLY("vi2c", "2-0030"),
@@ -224,6 +228,7 @@ static struct regulator_consumer_supply palmas_ldo6_supply[] = {
 static struct regulator_consumer_supply palmas_ldo7_supply[] = {
        REGULATOR_SUPPLY("avdd_af1_cam", NULL),
        REGULATOR_SUPPLY("imx135_reg1", NULL),
+       REGULATOR_SUPPLY("vana", "2-0021"),
        REGULATOR_SUPPLY("vdd", "2-000c"),
 };