kernel: driver: modify ar0330 power sequence
Ming Wong [Sat, 8 Nov 2014 01:35:31 +0000 (17:35 -0800)]
Bug 1552628
Bug 1576621

Change-Id: Icc881724f0e4e5c0346aa44ffeb80dc8d498919c
Signed-off-by: Ming Wong <miwong@nvidia.com>
Reviewed-on: http://git-master/r/598929
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>

arch/arm/boot/dts/tegra124-platforms/tegra124-pm359-camera-a00.dtsi
arch/arm/mach-tegra/board-ardbeg-sensors.c
drivers/media/platform/tegra/ar0330.c
include/media/ar0330.h

index 5fed467..d911161 100644 (file)
                                        CAMERA_END
                                        >;
                        };
-                       ar0330_1: ar0330@2_0010 {
+                       ar0330_1: ar0330@2_0018 {
                                index = <4>;
                                chipname = "pcl_AR0330";
                                type = "sensor";
                                position = <0>;
                                bustype = "i2c";
                                busnum = <2>;
-                               addr = <0x10>;
+                               addr = <0x18>;
                                datalen = <2>;
                                pinmuxgrp = <0xFFFF>;
                                gpios = <3>;
                                devid = <0x0330>;
                                poweron = <
                                        CAMERA_IND_CLK_SET(10000)
-                                       CAMERA_GPIO_CLR(219)
+                                       CAMERA_GPIO_CLR(221)
+                                       CAMERA_GPIO_CLR(222)
                                        CAMERA_REGULATOR_ON(0)
+                                       CAMERA_WAITMS(10)
                                        CAMERA_REGULATOR_ON(1)
                                        CAMERA_REGULATOR_ON(2)
                                        CAMERA_WAITMS(40)
-                                       CAMERA_GPIO_SET(219)
+                                       CAMERA_GPIO_SET(221)
+                                       CAMERA_GPIO_SET(222)
                                        CAMERA_WAITMS(20)
                                        CAMERA_END
                                        >;
                                poweroff = <
                                        CAMERA_IND_CLK_CLR
-                                       CAMERA_GPIO_CLR(219)
+                                       CAMERA_GPIO_CLR(221)
+                                       CAMERA_GPIO_CLR(222)
                                        CAMERA_WAITUS(10)
                                        CAMERA_REGULATOR_OFF(2)
                                        CAMERA_REGULATOR_OFF(1)
                                        CAMERA_END
                                        >;
                        };
-                       ar0330_2: ar0330@2_0018 {
+                       ar0330_2: ar0330@2_0010 {
                                index = <5>;
                                chipname = "pcl_AR0330";
                                type = "sensor";
                                position = <1>;
                                bustype = "i2c";
                                busnum = <2>;
-                               addr = <0x18>;
+                               addr = <0x10>;
                                datalen = <2>;
                                pinmuxgrp = <0xFFFF>;
                                gpios = <3>;
                                regulators = "vana", "vdig", "vif";
-                               clocks = "mclk";
+                               clocks = "mclk2";
                                drivername = "ar0330";
                                detect = <0x0002 0x3000 0xFFFF 0x2604>;
                                devid = <0x0330>;
                                poweron = <
                                        CAMERA_IND_CLK_SET(10000)
-                                       CAMERA_GPIO_CLR(219)
+                                       CAMERA_GPIO_CLR(221)
+                                       CAMERA_GPIO_CLR(222)
                                        CAMERA_REGULATOR_ON(0)
+                                       CAMERA_WAITMS(10)
                                        CAMERA_REGULATOR_ON(1)
                                        CAMERA_REGULATOR_ON(2)
                                        CAMERA_WAITMS(40)
-                                       CAMERA_GPIO_SET(219)
+                                       CAMERA_GPIO_SET(221)
+                                       CAMERA_GPIO_SET(222)
                                        CAMERA_WAITMS(20)
                                        CAMERA_END
                                        >;
                                poweroff = <
                                        CAMERA_IND_CLK_CLR
-                                       CAMERA_GPIO_CLR(219)
+                                       CAMERA_GPIO_CLR(221)
+                                       CAMERA_GPIO_CLR(222)
                                        CAMERA_WAITUS(10)
                                        CAMERA_REGULATOR_OFF(2)
                                        CAMERA_REGULATOR_OFF(1)
index 55dd519..b8ea94d 100644 (file)
@@ -300,56 +300,31 @@ static int ardbeg_ar0330_front_power_on(struct ar0330_power_rail *pw)
 {
        int err;
 
-       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd)))
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
                return -EFAULT;
 
-       pr_info("!!! mach-tegra front power on\n");
        /* disable CSIE IOs DPD mode to turn on front camera for ardbeg */
        tegra_io_dpd_disable(&csie_io);
 
-       if (ardbeg_get_extra_regulators())
-               goto ardbeg_ar0330_front_poweron_fail;
-
-       gpio_set_value(CAM_RSTN, 0);
-       gpio_set_value(CAM_AF_PWDN, 1);
-
-
-       err = regulator_enable(ardbeg_vcmvdd);
-       if (unlikely(err))
-               goto ar0330_front_vcm_fail;
+       gpio_set_value(CAM2_PWDN, 0);
 
-       err = regulator_enable(pw->dvdd);
+       err = regulator_enable(pw->iovdd);
        if (unlikely(err))
-               goto ar0330_front_dvdd_fail;
+               goto ar0330_front_iovdd_fail;
 
+       usleep_range(1000, 1100);
        err = regulator_enable(pw->avdd);
        if (unlikely(err))
                goto ar0330_front_avdd_fail;
 
-       err = regulator_enable(pw->iovdd);
-       if (unlikely(err))
-               goto ar0330_front_iovdd_fail;
-
        usleep_range(1, 2);
        gpio_set_value(CAM2_PWDN, 1);
 
-       gpio_set_value(CAM_RSTN, 1);
-
        return 0;
-ar0330_front_iovdd_fail:
-       regulator_disable(pw->dvdd);
-
-ar0330_front_dvdd_fail:
-       regulator_disable(pw->avdd);
-
 ar0330_front_avdd_fail:
-       regulator_disable(ardbeg_vcmvdd);
-
-ar0330_front_vcm_fail:
-       pr_err("%s vcmvdd failed.\n", __func__);
-       return -ENODEV;
+       regulator_disable(pw->iovdd);
 
-ardbeg_ar0330_front_poweron_fail:
+ar0330_front_iovdd_fail:
        /* put CSIE IOs into DPD mode to save additional power for ardbeg */
        tegra_io_dpd_enable(&csie_io);
        pr_err("%s failed.\n", __func__);
@@ -358,8 +333,7 @@ ardbeg_ar0330_front_poweron_fail:
 
 static int ardbeg_ar0330_front_power_off(struct ar0330_power_rail *pw)
 {
-       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd ||
-                                       !ardbeg_vcmvdd))) {
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd))) {
                /* put CSIE IOs into DPD mode to
                 * save additional power for ardbeg
                 */
@@ -367,14 +341,12 @@ static int ardbeg_ar0330_front_power_off(struct ar0330_power_rail *pw)
                return -EFAULT;
        }
 
-       gpio_set_value(CAM_RSTN, 0);
+       gpio_set_value(CAM2_PWDN, 0);
 
        usleep_range(1, 2);
 
        regulator_disable(pw->iovdd);
-       regulator_disable(pw->dvdd);
        regulator_disable(pw->avdd);
-       regulator_disable(ardbeg_vcmvdd);
        /* put CSIE IOs into DPD mode to save additional power for ardbeg */
        tegra_io_dpd_enable(&csie_io);
        return 0;
@@ -384,64 +356,39 @@ struct ar0330_platform_data ardbeg_ar0330_front_data = {
        .power_on = ardbeg_ar0330_front_power_on,
        .power_off = ardbeg_ar0330_front_power_off,
        .dev_name       = "ar0330.1",
-       .mclk_name = "mclk",
+       .mclk_name = "mclk2",
 };
 
 static int ardbeg_ar0330_power_on(struct ar0330_power_rail *pw)
 {
        int err;
 
-       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd)))
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
                return -EFAULT;
 
-       pr_info("!!! mach-tegra rear power on\n");
        /* disable CSIE IOs DPD mode to turn on front camera for ardbeg */
        tegra_io_dpd_disable(&csia_io);
        tegra_io_dpd_disable(&csib_io);
 
-       if (ardbeg_get_extra_regulators())
-               goto ardbeg_ar0330_poweron_fail;
-
-       gpio_set_value(CAM_RSTN, 0);
-       gpio_set_value(CAM_AF_PWDN, 1);
-
-
-       err = regulator_enable(ardbeg_vcmvdd);
-       if (unlikely(err))
-               goto ar0330_vcm_fail;
+       gpio_set_value(CAM1_PWDN, 0);
 
-       err = regulator_enable(pw->dvdd);
+       err = regulator_enable(pw->iovdd);
        if (unlikely(err))
-               goto ar0330_dvdd_fail;
+               goto ar0330_iovdd_fail;
 
+       usleep_range(1000, 1100);
        err = regulator_enable(pw->avdd);
        if (unlikely(err))
                goto ar0330_avdd_fail;
 
-       err = regulator_enable(pw->iovdd);
-       if (unlikely(err))
-               goto ar0330_iovdd_fail;
-
        usleep_range(1, 2);
-       gpio_set_value(CAM2_PWDN, 1);
-
-       gpio_set_value(CAM_RSTN, 1);
+       gpio_set_value(CAM1_PWDN, 1);
 
        return 0;
-ar0330_iovdd_fail:
-       regulator_disable(pw->dvdd);
-
-ar0330_dvdd_fail:
-       regulator_disable(pw->avdd);
-
 ar0330_avdd_fail:
-       regulator_disable(ardbeg_vcmvdd);
-
-ar0330_vcm_fail:
-       pr_err("%s vcmvdd failed.\n", __func__);
-       return -ENODEV;
+       regulator_disable(pw->iovdd);
 
-ardbeg_ar0330_poweron_fail:
+ar0330_iovdd_fail:
        /* put CSIE IOs into DPD mode to save additional power for ardbeg */
        tegra_io_dpd_enable(&csia_io);
        tegra_io_dpd_enable(&csib_io);
@@ -451,8 +398,7 @@ ardbeg_ar0330_poweron_fail:
 
 static int ardbeg_ar0330_power_off(struct ar0330_power_rail *pw)
 {
-       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd ||
-                                       !ardbeg_vcmvdd))) {
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd))) {
                /* put CSIE IOs into DPD mode to
                 * save additional power for ardbeg
                 */
@@ -461,14 +407,12 @@ static int ardbeg_ar0330_power_off(struct ar0330_power_rail *pw)
                return -EFAULT;
        }
 
-       gpio_set_value(CAM_RSTN, 0);
+       gpio_set_value(CAM1_PWDN, 0);
 
        usleep_range(1, 2);
 
        regulator_disable(pw->iovdd);
-       regulator_disable(pw->dvdd);
        regulator_disable(pw->avdd);
-       regulator_disable(ardbeg_vcmvdd);
        /* put CSIE IOs into DPD mode to save additional power for ardbeg */
        tegra_io_dpd_enable(&csia_io);
        tegra_io_dpd_enable(&csib_io);
index cb16a2f..dd612d0 100644 (file)
@@ -1262,7 +1262,6 @@ static int ar0330_power_get(struct ar0330_info *info)
        err |= ar0330_regulator_get(info, &pw->avdd, "vana"); /* ananlog 2.7v */
        err |= ar0330_regulator_get(info, &pw->dvdd, "vdig"); /* digital 1.2v */
        err |= ar0330_regulator_get(info, &pw->iovdd, "vif"); /* IO 1.8v */
-       err |= ar0330_regulator_get(info, &pw->vdd_af, "avdd_af1_cam"); /* IO 1.8v */
 
        return err;
 }
index 1af6ea4..3451e81 100644 (file)
@@ -69,7 +69,6 @@ struct ar0330_power_rail {
        struct regulator *dvdd;
        struct regulator *avdd;
        struct regulator *iovdd;
-       struct regulator *vdd_af;
 };
 
 struct ar0330_platform_data {