arm: tegra: cardhu: Enabling all required rails properly for camera
Laxman Dewangan [Mon, 14 Feb 2011 13:21:14 +0000 (18:21 +0530)]
Enabling all required power rails for camera. Also fixing the issue
with mutliple power on of rails.

bug 791239

Original-Change-Id: Iea6bb398ee490733b4b4749570d65300565fcc31
Reviewed-on: http://git-master/r/19435
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Prayas Mohanty <pmohanty@nvidia.com>
Tested-by: Prayas Mohanty <pmohanty@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Original-Change-Id: I91050df2b331da73bcf86674e73b2cd179270830

Rebase-Id: Rbf62b96827299d0b03447ec85ad1f47228537f80

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

index 42e5728..d26a6b6 100644 (file)
@@ -33,6 +33,7 @@
 #include "board-cardhu.h"
 
 static struct regulator *cardhu_1v8_cam1 = NULL;
+static struct regulator *cardhu_avdd_dsi_csi = NULL;
 
 #ifdef CONFIG_I2C_MUX_PCA954x
 static struct pca954x_platform_mode cardhu_pca954x_modes[] = {
@@ -120,12 +121,38 @@ static int cardhu_ov5650_power_on(void)
        else {
                if (cardhu_1v8_cam1 == NULL) {
                        cardhu_1v8_cam1 = regulator_get(NULL, "vdd_1v8_cam1");
-                       if (WARN_ON(IS_ERR(cardhu_1v8_cam1)))
+                       if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
                                pr_err("%s: couldn't get regulator vdd_1v8_cam1: %ld\n",
                                        __func__, PTR_ERR(cardhu_1v8_cam1));
-                       else
-                               regulator_enable(cardhu_1v8_cam1);
+                               goto reg_alloc_fail;
+                       }
                }
+
+               /* Enable AVDD_CSI_DSI */
+               if (cardhu_avdd_dsi_csi == NULL) {
+                       cardhu_avdd_dsi_csi = regulator_get(NULL, "avdd_dsi_csi");
+                       if (WARN_ON(IS_ERR(cardhu_avdd_dsi_csi))) {
+                               pr_err("%s: couldn't get regulator avdd_dsi_csi: %ld\n",
+                                       __func__, PTR_ERR(cardhu_avdd_dsi_csi));
+                               goto reg_alloc_fail;
+                       }
+               }
+
+               regulator_enable(cardhu_1v8_cam1);
+               regulator_enable(cardhu_avdd_dsi_csi);
+               mdelay(5);
+               return 0;
+
+reg_alloc_fail:
+               if (cardhu_1v8_cam1) {
+                       regulator_put(cardhu_1v8_cam1);
+                       cardhu_1v8_cam1 = NULL;
+               }
+               if (cardhu_avdd_dsi_csi) {
+                       regulator_put(cardhu_avdd_dsi_csi);
+                       cardhu_avdd_dsi_csi = NULL;
+               }
+               return -ENODEV;
        }
 
        return 0;
@@ -146,6 +173,9 @@ static int cardhu_ov5650_power_off(void)
        else {
                if (cardhu_1v8_cam1)
                        regulator_disable(cardhu_1v8_cam1);
+
+               if (cardhu_avdd_dsi_csi)
+                       regulator_disable(cardhu_avdd_dsi_csi);
        }
 
        return 0;