arm: tegra: cardhu: enable power for OV2710
Prayas Mohanty [Tue, 15 Mar 2011 14:14:54 +0000 (19:14 +0530)]
Use the regulator to enable power for OV2710.
bug: 794025

Original-Change-Id: Ib1245d7cb9c9a91011be29872bbf06576fba225e
Reviewed-on: http://git-master/r/23020
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Original-Change-Id: Ida7a765be52de2f2df69f0c5bb4d0953309b2489

Rebase-Id: R6d01300427993d528418e31e0c1fa1c02e6d1b00

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

index f248bd6..3daec0d 100644 (file)
 #include "board-cardhu.h"
 
 static struct regulator *cardhu_1v8_cam1 = NULL;
+static struct regulator *cardhu_1v8_cam3 = NULL;
 static struct regulator *cardhu_avdd_dsi_csi = NULL;
 static struct regulator *cardhu_vdd_2v8_cam1 = NULL;
+static struct regulator *cardhu_vdd_cam3 = NULL;
 
 #ifdef CONFIG_I2C_MUX_PCA954x
 static struct pca954x_platform_mode cardhu_pca954x_modes[] = {
@@ -71,11 +73,20 @@ static int cardhu_camera_init(void)
                if (ret < 0)
                        pr_err("%s: gpio_request failed for gpio %s\n",
                                __func__, "CAM1_POWER_DWN_GPIO");
+
+               tegra_gpio_enable(CAM3_POWER_DWN_GPIO);
+               ret = gpio_request(CAM3_POWER_DWN_GPIO, "cam3_power_en");
+               if (ret < 0)
+                       pr_err("%s: gpio_request failed for gpio %s\n",
+                               __func__, "CAM3_POWER_DWN_GPIO");
+
                tegra_gpio_enable(OV5650_RESETN_GPIO);
                ret = gpio_request(OV5650_RESETN_GPIO, "camera_reset");
                if (ret < 0)
                        pr_err("%s: gpio_request failed for gpio %s\n",
                                __func__, "OV5650_RESETN_GPIO");
+
+               gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
                mdelay(10);
 
@@ -109,6 +120,7 @@ static int cardhu_ov5650_power_on(void)
        if ((board_info.board_id == BOARD_E1198) ||
                (board_info.board_id == BOARD_E1291)) {
 
+               gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                mdelay(10);
 
@@ -120,10 +132,32 @@ static int cardhu_ov5650_power_on(void)
                                goto reg_alloc_fail;
                        }
                }
-
                regulator_enable(cardhu_vdd_2v8_cam1);
+
+               if (cardhu_vdd_cam3 == NULL) {
+                       cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
+                       if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
+                               pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
+                                       __func__, PTR_ERR(cardhu_vdd_cam3));
+                               goto reg_alloc_fail;
+                       }
+               }
+               regulator_enable(cardhu_vdd_cam3);
+
+               /* Enable VDD_1V8_Cam3 */
+               if (cardhu_1v8_cam3 == NULL) {
+                       cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
+                       if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
+                               pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
+                                       __func__, PTR_ERR(cardhu_1v8_cam3));
+                               goto reg_alloc_fail;
+                       }
+               }
+               regulator_enable(cardhu_1v8_cam3);
+
                mdelay(5);
        }
+
        /* Enable VDD_1V8_Cam1 */
        if (cardhu_1v8_cam1 == NULL) {
                cardhu_1v8_cam1 = regulator_get(NULL, "vdd_1v8_cam1");
@@ -153,6 +187,10 @@ reg_alloc_fail:
                regulator_put(cardhu_1v8_cam1);
                cardhu_1v8_cam1 = NULL;
        }
+       if (cardhu_1v8_cam3) {
+               regulator_put(cardhu_1v8_cam3);
+               cardhu_1v8_cam3 = NULL;
+       }
        if (cardhu_avdd_dsi_csi) {
                regulator_put(cardhu_avdd_dsi_csi);
                cardhu_avdd_dsi_csi = NULL;
@@ -161,6 +199,10 @@ reg_alloc_fail:
                regulator_put(cardhu_vdd_2v8_cam1);
                cardhu_vdd_2v8_cam1 = NULL;
        }
+       if (cardhu_vdd_cam3) {
+               regulator_put(cardhu_vdd_cam3);
+               cardhu_vdd_cam3 = NULL;
+       }
        return -ENODEV;
 
 }
index 72d44c7..aa6565a 100644 (file)
 #define CAM_I2C_MUX_RST_EXP                    CAM_TCA6416_GPIO_BASE + 15
 #define CAM_TCA6416_GPIO_END           CAM_TCA6416_GPIO_BASE + 16
 
-/* CAMERA RELATED GPIOs */
+/* CAMERA RELATED GPIOs on CARDHU */
 #define OV5650_RESETN_GPIO                     TEGRA_GPIO_PBB0
 #define CAM1_POWER_DWN_GPIO                    TEGRA_GPIO_PBB5
+#define CAM3_POWER_DWN_GPIO                    TEGRA_GPIO_PBB7
 #define CAMERA_CSI_CAM_SEL_GPIO                TEGRA_GPIO_PBB4
 #define CAMERA_CSI_MUX_SEL_GPIO                TEGRA_GPIO_PCC1
 #define CAM1_LDO_EN_GPIO                       TEGRA_GPIO_PR6
+#define CAM3_LDO_EN_GPIO                       TEGRA_GPIO_PS0
 
 /* PCA954x I2C bus expander bus addresses */
 #define PCA954x_I2C_BUS_BASE   6