arm: tegra: sensors: pair sh532u focuser to right camera
garyz [Thu, 2 Jun 2011 01:41:35 +0000 (18:41 -0700)]
The sh532u focuser is added to pair with the stereo right camera with the
required power control configurations.

Bug #827897

Original-Change-Id: I5ca836a51b03cb9550eb468270af5bbf350aa957
Reviewed-on: http://git-master/r/34820
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: Rad6137ec52951c560c67135595d560910eb97aa0

arch/arm/mach-tegra/board-cardhu-sensors.c

index d15cef2..e8fdae7 100644 (file)
@@ -269,6 +269,7 @@ static int cardhu_right_ov5650_power_off(void)
                (board_info.board_id == BOARD_E1291)) {
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
+               gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
        }
 
        if (cardhu_1v8_cam2)
@@ -391,37 +392,54 @@ static const struct i2c_board_info cardhu_i2c3_board_info[] = {
        },
 };
 
-static int sh532u_power_control(void *cdata, int is_enable) {
+static int sh532u_power_control(void *cdata, int is_enable, int which) {
        static struct regulator *vdd_2v8_cam1_af = NULL;
-       if (vdd_2v8_cam1_af == NULL) {
-               vdd_2v8_cam1_af = regulator_get(NULL, "vdd_2v8_cam1_af");
-               if (WARN_ON(IS_ERR_OR_NULL(vdd_2v8_cam1_af))) {
-                       pr_err("%s: couldn't get regulator vdd_2v8_cam1_af:"
-                               " %ld\n", __func__, PTR_ERR(vdd_2v8_cam1_af));
+       static struct regulator *vdd_2v8_cam2_af = NULL;
+
+       struct regulator *vdd_2v8_camx_af = (1 == which) ? vdd_2v8_cam1_af : vdd_2v8_cam2_af;
+       char *vdd_2v8_camx_tag = (1 == which) ? "vdd_2v8_cam1_af" : "vdd_2v8_cam2_af";
 
-                       vdd_2v8_cam1_af = NULL;
+       if (vdd_2v8_camx_af == NULL) {
+               vdd_2v8_camx_af = regulator_get(NULL, vdd_2v8_camx_tag);
+               if (WARN_ON(IS_ERR_OR_NULL(vdd_2v8_camx_af))) {
+                       pr_err("%s: couldn't get regulator %s:"
+                               " %ld\n", __func__, vdd_2v8_camx_tag, PTR_ERR(vdd_2v8_camx_af));
+                       vdd_2v8_camx_af = NULL;
                        return -ENODEV;
                }
        }
        if (is_enable) {
-               regulator_enable(vdd_2v8_cam1_af);
+               regulator_enable(vdd_2v8_camx_af);
                mdelay(20);
        } else
-               regulator_disable(vdd_2v8_cam1_af);
+               regulator_disable(vdd_2v8_camx_af);
+
        return 0;
 }
-static int sh532u_init(void *cdata) {
-       return sh532u_power_control(cdata, true);
+
+static int sh532u_left_init(void *cdata) {
+       return sh532u_power_control(cdata, true, 1);
 }
-static int sh532u_deinit(void *cdata) {
-       return sh532u_power_control(cdata, false);
+static int sh532u_left_deinit(void *cdata) {
+       return sh532u_power_control(cdata, false, 1);
 }
 
-struct sh532u_platform_data sh532u_pdata = {
-       .board_init = sh532u_init,
-       .board_deinit = sh532u_deinit,
+static int sh532u_right_init(void *cdata) {
+       return sh532u_power_control(cdata, true, 2);
+}
+static int sh532u_right_deinit(void *cdata) {
+       return sh532u_power_control(cdata, false, 2);
+}
+
+struct sh532u_platform_data sh532u_left_pdata = {
+       .board_init = sh532u_left_init,
+       .board_deinit = sh532u_left_deinit,
 };
 
+struct sh532u_platform_data sh532u_right_pdata = {
+       .board_init = sh532u_right_init,
+       .board_deinit = sh532u_right_deinit,
+};
 
 static bool cardhu_tps61050_pm_flag = 0;
 
@@ -486,15 +504,14 @@ static const struct i2c_board_info cardhu_i2c_board_info_tps61050[] = {
        },
 };
 
-
 static struct i2c_board_info cardhu_i2c6_board_info[] = {
        {
                I2C_BOARD_INFO("ov5650L", 0x36),
                .platform_data = &cardhu_left_ov5650_data,
        },
        {
-               I2C_BOARD_INFO("sh532u", 0x72),
-               .platform_data = &sh532u_pdata,
+               I2C_BOARD_INFO("sh532uL", 0x72),
+               .platform_data = &sh532u_left_pdata,
        },
 };
 
@@ -503,6 +520,10 @@ static struct i2c_board_info cardhu_i2c7_board_info[] = {
                I2C_BOARD_INFO("ov5650R", 0x36),
                .platform_data = &cardhu_right_ov5650_data,
        },
+       {
+               I2C_BOARD_INFO("sh532uR", 0x72),
+               .platform_data = &sh532u_right_pdata,
+       },
 };
 
 static struct i2c_board_info cardhu_i2c8_board_info[] = {