]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
ARM: tegra12: ardbeg: Add CSIA/B/E DPD mode
authorFrank Chen <frankc@nvidia.com>
Tue, 7 Jan 2014 01:47:36 +0000 (17:47 -0800)
committerBharat Nihalani <bnihalani@nvidia.com>
Wed, 8 Jan 2014 05:51:11 +0000 (21:51 -0800)
For T124, set CSIA/B/E to DPD mode when camera
is not in use. This can save extra power.

Bug 1352773
Bug 1403888

Change-Id: I61b0e9683217bf2511b279acc44e64262a036fb0
Signed-off-by: Frank Chen <frankc@nvidia.com>
Reviewed-on: http://git-master/r/352494
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
arch/arm/mach-tegra/board-ardbeg-sensors.c
arch/arm/mach-tegra/board-loki-sensors.c

index 3921b0e49699c0da5f47fbfaa7a58e6a8744afab..d258454b548ac45efd408c3cd2aa6f6901f8fb6b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-ardbeg-sensors.c
  *
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -587,6 +587,9 @@ static int ardbeg_ov7695_power_on(struct ov7695_power_rail *pw)
        if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
                return -EFAULT;
 
+       /* disable CSIE IOs DPD mode to turn on front camera for ardbeg */
+       tegra_io_dpd_disable(&csie_io);
+
        gpio_set_value(CAM2_PWDN, 0);
        usleep_range(1000, 1020);
 
@@ -609,15 +612,21 @@ ov7695_iovdd_fail:
        regulator_disable(pw->avdd);
 
 ov7695_avdd_fail:
-
        gpio_set_value(CAM_RSTN, 0);
+       /* put CSIE IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csie_io);
        return -ENODEV;
 }
 
 static int ardbeg_ov7695_power_off(struct ov7695_power_rail *pw)
 {
-       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd))) {
+               /* put CSIE IOs into DPD mode to
+                * save additional power for ardbeg
+                */
+               tegra_io_dpd_enable(&csie_io);
                return -EFAULT;
+       }
        usleep_range(100, 120);
 
        gpio_set_value(CAM2_PWDN, 0);
@@ -627,6 +636,9 @@ static int ardbeg_ov7695_power_off(struct ov7695_power_rail *pw)
        usleep_range(100, 120);
 
        regulator_disable(pw->avdd);
+
+       /* put CSIE IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csie_io);
        return 0;
 }
 
@@ -642,6 +654,9 @@ static int ardbeg_mt9m114_power_on(struct mt9m114_power_rail *pw)
        if (unlikely(!pw || !pw->avdd || !pw->iovdd))
                return -EFAULT;
 
+       /* disable CSIE IOs DPD mode to turn on front camera for ardbeg */
+       tegra_io_dpd_disable(&csie_io);
+
        gpio_set_value(CAM_RSTN, 0);
        gpio_set_value(CAM2_PWDN, 1);
        usleep_range(1000, 1020);
@@ -667,13 +682,20 @@ mt9m114_avdd_fail:
 
 mt9m114_iovdd_fail:
        gpio_set_value(CAM_RSTN, 0);
+       /* put CSIE IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csie_io);
        return -ENODEV;
 }
 
 static int ardbeg_mt9m114_power_off(struct mt9m114_power_rail *pw)
 {
-       if (unlikely(!pw || !pw->avdd || !pw->iovdd))
+       if (unlikely(!pw || !pw->avdd || !pw->iovdd)) {
+               /* put CSIE IOs into DPD mode to
+                * save additional power for ardbeg
+                */
+               tegra_io_dpd_enable(&csie_io);
                return -EFAULT;
+       }
 
        usleep_range(100, 120);
        gpio_set_value(CAM_RSTN, 0);
@@ -682,6 +704,8 @@ static int ardbeg_mt9m114_power_off(struct mt9m114_power_rail *pw)
        usleep_range(100, 120);
        regulator_disable(pw->iovdd);
 
+       /* put CSIE IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csie_io);
        return 1;
 }
 
@@ -699,6 +723,10 @@ static int ardbeg_ov5693_power_on(struct ov5693_power_rail *pw)
        if (unlikely(WARN_ON(!pw || !pw->dovdd || !pw->avdd)))
                return -EFAULT;
 
+       /* disable CSIA/B IOs DPD mode to turn on camera for ardbeg */
+       tegra_io_dpd_disable(&csia_io);
+       tegra_io_dpd_disable(&csib_io);
+
        if (ardbeg_get_extra_regulators())
                goto ov5693_poweron_fail;
 
@@ -734,14 +762,23 @@ ov5693_avdd_fail:
        gpio_set_value(CAM1_PWDN, 0);
 
 ov5693_poweron_fail:
+       /* put CSIA/B IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csia_io);
+       tegra_io_dpd_enable(&csib_io);
        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)))
+       if (unlikely(WARN_ON(!pw || !pw->dovdd || !pw->avdd))) {
+               /* put CSIA/B IOs into DPD mode to
+                * save additional power for ardbeg
+                */
+               tegra_io_dpd_enable(&csia_io);
+               tegra_io_dpd_enable(&csib_io);
                return -EFAULT;
+       }
 
        usleep_range(21, 25);
        gpio_set_value(CAM1_PWDN, 0);
@@ -751,6 +788,9 @@ static int ardbeg_ov5693_power_off(struct ov5693_power_rail *pw)
        regulator_disable(pw->dovdd);
        regulator_disable(pw->avdd);
 
+       /* put CSIA/B IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csia_io);
+       tegra_io_dpd_enable(&csib_io);
        return 0;
 }
 
@@ -881,14 +921,12 @@ static int ardbeg_camera_init(void)
 {
        pr_debug("%s: ++\n", __func__);
 
-       if (!of_machine_is_compatible("nvidia,tn8")) {
-               /* put CSIA/B/E IOs into DPD mode to
-                * save additional power for ardbeg
-                */
-               tegra_io_dpd_enable(&csia_io);
-               tegra_io_dpd_enable(&csib_io);
-               tegra_io_dpd_enable(&csie_io);
-       }
+       /* put CSIA/B/E IOs into DPD mode to
+        * save additional power for ardbeg
+        */
+       tegra_io_dpd_enable(&csia_io);
+       tegra_io_dpd_enable(&csib_io);
+       tegra_io_dpd_enable(&csie_io);
 
        platform_device_add_data(&ardbeg_camera_generic,
                &ardbeg_pcl_pdata, sizeof(ardbeg_pcl_pdata));
index a78f836780dcc43b9a33920490ceab8c5ba8894a..858d59f0d6617cd2d2131c55533606669891bb4e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-loki-sensors.c
  *
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -28,6 +28,7 @@
 #include <media/ov7695.h>
 #include <mach/gpio-tegra.h>
 #include <mach/edp.h>
+#include <mach/io_dpd.h>
 #include <linux/gpio.h>
 #include <linux/therm_est.h>
 #include <linux/iio/light/jsa1127.h>
@@ -194,12 +195,33 @@ static void loki_jsa1127_init(void)
                ARRAY_SIZE(loki_i2c_jsa1127_board_info));
 }
 
+static struct tegra_io_dpd csia_io = {
+       .name                   = "CSIA",
+       .io_dpd_reg_index       = 0,
+       .io_dpd_bit             = 0,
+};
+
+static struct tegra_io_dpd csib_io = {
+       .name                   = "CSIB",
+       .io_dpd_reg_index       = 0,
+       .io_dpd_bit             = 1,
+};
+
+static struct tegra_io_dpd csie_io = {
+       .name                   = "CSIE",
+       .io_dpd_reg_index       = 1,
+       .io_dpd_bit             = 12,
+};
+
 static int loki_mt9m114_power_on(struct mt9m114_power_rail *pw)
 {
        int err;
        if (unlikely(!pw || !pw->avdd || !pw->iovdd))
                return -EFAULT;
 
+       /* disable CSIA IOs DPD mode to turn on front camera for ardbeg */
+       tegra_io_dpd_disable(&csia_io);
+
        gpio_set_value(CAM_RSTN, 0);
        gpio_set_value(CAM2_PWDN, 1);
        usleep_range(1000, 1020);
@@ -225,13 +247,20 @@ mt9m114_avdd_fail:
 
 mt9m114_iovdd_fail:
        gpio_set_value(CAM_RSTN, 0);
+       /* put CSIA IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csia_io);
        return -ENODEV;
 }
 
 static int loki_mt9m114_power_off(struct mt9m114_power_rail *pw)
 {
-       if (unlikely(!pw || !pw->avdd || !pw->iovdd))
+       if (unlikely(!pw || !pw->avdd || !pw->iovdd)) {
+               /* put CSIA IOs into DPD mode to
+                * save additional power for ardbeg
+                */
+               tegra_io_dpd_enable(&csia_io);
                return -EFAULT;
+       }
 
        usleep_range(100, 120);
        gpio_set_value(CAM_RSTN, 0);
@@ -240,6 +269,8 @@ static int loki_mt9m114_power_off(struct mt9m114_power_rail *pw)
        usleep_range(100, 120);
        regulator_disable(pw->iovdd);
 
+       /* put CSIA IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csia_io);
        return 1;
 }
 
@@ -255,6 +286,9 @@ static int loki_ov7695_power_on(struct ov7695_power_rail *pw)
        if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
                return -EFAULT;
 
+       /* disable CSIA IOs DPD mode to turn on front camera for ardbeg */
+       tegra_io_dpd_disable(&csia_io);
+
        gpio_set_value(CAM2_PWDN, 0);
        usleep_range(1000, 1020);
 
@@ -277,15 +311,22 @@ ov7695_iovdd_fail:
        regulator_disable(pw->avdd);
 
 ov7695_avdd_fail:
-
        gpio_set_value(CAM_RSTN, 0);
+       /* put CSIA IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csia_io);
        return -ENODEV;
 }
 
 static int loki_ov7695_power_off(struct ov7695_power_rail *pw)
 {
-       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd)))
+       if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd))) {
+               /* put CSIA IOs into DPD mode to
+                * save additional power for ardbeg
+                */
+               tegra_io_dpd_enable(&csia_io);
                return -EFAULT;
+       }
+
        usleep_range(100, 120);
 
        regulator_disable(pw->iovdd);
@@ -295,6 +336,9 @@ static int loki_ov7695_power_off(struct ov7695_power_rail *pw)
        usleep_range(100, 120);
 
        gpio_set_value(CAM2_PWDN, 0);
+
+       /* put CSIA IOs into DPD mode to save additional power for ardbeg */
+       tegra_io_dpd_enable(&csia_io);
        return 0;
 }
 
@@ -331,6 +375,13 @@ static int loki_camera_init(void)
 {
        pr_debug("%s: ++\n", __func__);
 
+       /* put CSIA/B/E IOs into DPD mode to
+        * save additional power
+        */
+       tegra_io_dpd_enable(&csia_io);
+       tegra_io_dpd_enable(&csib_io);
+       tegra_io_dpd_enable(&csie_io);
+
        platform_device_add_data(&loki_camera_generic,
                &loki_pcl_pdata, sizeof(loki_pcl_pdata));
        platform_device_register(&loki_camera_generic);