summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Wu <pengw@nvidia.com>2013-09-27 14:00:02 -0700
committerMatthew Pedro <mapedro@nvidia.com>2013-10-16 15:23:23 -0700
commit936120ccdc70b17fe1e58fa26081b0862cce16f2 (patch)
tree57b859e538197ef8e82f066a24fcc2340678d588
parent83b4fb0e77eb8950e225e62d0193a26af03e307e (diff)
ARM: tegra: cardhu: enable OV5650/OV5640 sensor
Enable OV5650 and OV5640 sensor in Cardhu board file with the help of Tegra V4L2 SoC camera interface. To use V4L2 driver, we need to disable old camera HAL driver. Bug 1240806 Bug 1369083 Change-Id: I0dc529d44fba4d80b45690e384e8bf81b29f69e5 Signed-off-by: Bryan Wu <pengw@nvidia.com> Reviewed-on: http://git-master/r/246266 (cherry picked from commit 6b2f7cc4117208dc992478f27d5873ea38071fdc) Reviewed-on: http://git-master/r/279988 Reviewed-by: Matthew Pedro <mapedro@nvidia.com> Tested-by: Matthew Pedro <mapedro@nvidia.com>
-rw-r--r--arch/arm/mach-tegra/board-cardhu-sensors.c126
1 files changed, 85 insertions, 41 deletions
diff --git a/arch/arm/mach-tegra/board-cardhu-sensors.c b/arch/arm/mach-tegra/board-cardhu-sensors.c
index d9c569bf3104..af66e1f571c6 100644
--- a/arch/arm/mach-tegra/board-cardhu-sensors.c
+++ b/arch/arm/mach-tegra/board-cardhu-sensors.c
@@ -37,6 +37,8 @@
#include <linux/i2c/pca954x.h>
#include <linux/i2c/pca953x.h>
#include <linux/nct1008.h>
+#include <linux/module.h>
+
#include <mach/fb.h>
#include <mach/gpio.h>
#include <media/ov5650.h>
@@ -62,11 +64,15 @@
#include "board-cardhu.h"
#include "cpu-tegra.h"
-static struct regulator *cardhu_supply_csi;
+#if defined(CONFIG_VIDEO_OV5650) || \
+ defined(CONFIG_VIDEO_OV5650_MODULE) || \
+ defined(CONFIG_SOC_CAMERA_OV5650) || \
+ defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
static struct regulator *cardhu_1v8_cam1;
+static struct regulator *cardhu_vdd_2v8_cam1;
+#endif
static struct regulator *cardhu_1v8_cam2;
static struct regulator *cardhu_1v8_cam3;
-static struct regulator *cardhu_vdd_2v8_cam1;
static struct regulator *cardhu_vdd_2v8_cam2;
static struct regulator *cardhu_vdd_cam3;
@@ -84,30 +90,86 @@ static struct pca954x_platform_data cardhu_pca954x_data = {
.num_modes = ARRAY_SIZE(cardhu_pca954x_modes),
};
+#if defined(CONFIG_SOC_CAMERA_OV5640) \
+ || defined(CONFIG_SOC_CAMERA_OV5640_MODULE)
+static int cardhu_ov5640_power_on(void);
+static int cardhu_ov5640_power_off(void);
+
+static int cardhu_ov5640_power(struct device *dev, int enable)
+{
+ if (enable)
+ return cardhu_ov5640_power_on();
+ else
+ cardhu_ov5640_power_off();
+
+ return 0;
+}
+
+static struct i2c_board_info cardhu_ov5640_camera_i2c_device = {
+ I2C_BOARD_INFO("ov5640", 0x3C),
+};
+
+static struct tegra_camera_platform_data cardhu_ov5640_camera_platform_data = {
+ .flip_v = 0,
+ .flip_h = 0,
+ .port = TEGRA_CAMERA_PORT_CSI_B,
+ .lanes = 2,
+ .continuous_clk = 0,
+};
+
+static struct soc_camera_link ov5640_iclink = {
+ .bus_id = -1, /* This must match the .id of tegra_vi01_device */
+ .board_info = &cardhu_ov5640_camera_i2c_device,
+ .module_name = "ov5640",
+ .i2c_adapter_id = PCA954x_I2C_BUS2,
+ .power = cardhu_ov5640_power,
+ .priv = &cardhu_ov5640_camera_platform_data,
+};
+
+static struct platform_device cardhu_ov5640_soc_camera_device = {
+ .name = "soc-camera-pdrv",
+ .id = 1,
+ .dev = {
+ .platform_data = &ov5640_iclink,
+ },
+};
+#endif
+
/* OV5650 V4L2 device */
-#ifdef CONFIG_SOC_CAMERA_OV5650
+#if defined(CONFIG_SOC_CAMERA_OV5650) \
+ || defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
static int cardhu_left_ov5650_power_on(void);
static int cardhu_left_ov5650_power_off(void);
-static int cardhu_ov5650_camera_power_enable(struct nvhost_device *ndev)
+static int cardhu_ov5650_power(struct device *dev, int enable)
{
- return cardhu_left_ov5650_power_on();
-}
+ if (enable)
+ return cardhu_left_ov5650_power_on();
+ else
+ cardhu_left_ov5650_power_off();
-static void cardhu_ov5650_camera_power_disable(struct nvhost_device *ndev)
-{
- cardhu_left_ov5650_power_off();
+ return 0;
}
static struct i2c_board_info cardhu_ov5650_camera_i2c_device = {
I2C_BOARD_INFO("ov5650", 0x36),
};
+static struct tegra_camera_platform_data cardhu_ov5650_camera_platform_data = {
+ .flip_v = 0,
+ .flip_h = 0,
+ .port = TEGRA_CAMERA_PORT_CSI_A,
+ .lanes = 2,
+ .continuous_clk = 1,
+};
+
static struct soc_camera_link ov5650_iclink = {
.bus_id = -1, /* This must match the .id of tegra_vi01_device */
.board_info = &cardhu_ov5650_camera_i2c_device,
.module_name = "ov5650",
.i2c_adapter_id = PCA954x_I2C_BUS0,
+ .power = cardhu_ov5650_power,
+ .priv = &cardhu_ov5650_camera_platform_data,
};
static struct platform_device cardhu_ov5650_soc_camera_device = {
@@ -117,16 +179,6 @@ static struct platform_device cardhu_ov5650_soc_camera_device = {
.platform_data = &ov5650_iclink,
},
};
-
-static struct tegra_camera_platform_data cardhu_ov5650_camera_platform_data = {
- .enable_camera = cardhu_ov5650_camera_power_enable,
- .disable_camera = cardhu_ov5650_camera_power_disable,
- .flip_v = 0,
- .flip_h = 0,
- .port = TEGRA_CAMERA_PORT_CSI_A,
- .lanes = 2,
- .continuous_clk = 1,
-};
#endif
static int cardhu_camera_init(void)
@@ -181,19 +233,12 @@ static int cardhu_camera_init(void)
return 0;
}
+#if defined(CONFIG_VIDEO_OV5650) || \
+ defined(CONFIG_VIDEO_OV5650_MODULE) || \
+ defined(CONFIG_SOC_CAMERA_OV5650) || \
+ defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
static int cardhu_left_ov5650_power_on(void)
{
-
- if (cardhu_supply_csi == NULL) {
- cardhu_supply_csi = regulator_get(NULL, "avdd_dsi_csi");
- if (WARN_ON(IS_ERR(cardhu_supply_csi))) {
- pr_err("%s: couldn't get regulator avdd_dsi_csi: %ld\n",
- __func__, PTR_ERR(cardhu_supply_csi));
- goto reg_alloc_fail;
- }
- }
- regulator_enable(cardhu_supply_csi);
-
/* Boards E1198 and E1291 are of Cardhu personality
* and donot have TCA6416 exp for camera */
if ((board_info.board_id == BOARD_E1198) ||
@@ -251,10 +296,6 @@ reg_alloc_fail:
regulator_put(cardhu_vdd_2v8_cam1);
cardhu_vdd_2v8_cam1 = NULL;
}
- if (cardhu_supply_csi) {
- regulator_put(cardhu_supply_csi);
- cardhu_supply_csi = NULL;
- }
return -ENODEV;
@@ -275,11 +316,10 @@ static int cardhu_left_ov5650_power_off(void)
regulator_disable(cardhu_1v8_cam1);
if (cardhu_vdd_2v8_cam1)
regulator_disable(cardhu_vdd_2v8_cam1);
- if (cardhu_supply_csi)
- regulator_disable(cardhu_supply_csi);
return 0;
}
+#endif
#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
struct ov5650_platform_data cardhu_left_ov5650_data = {
@@ -551,7 +591,6 @@ static int cardhu_ov5640_power_on(void)
(board_info.board_id == BOARD_E1291) ||
(board_info.board_id == BOARD_PM315)) {
- gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
mdelay(10);
@@ -604,7 +643,6 @@ static int cardhu_ov5640_power_off(void)
if ((board_info.board_id == BOARD_E1198) ||
(board_info.board_id == BOARD_E1291) ||
(board_info.board_id == BOARD_PM315)) {
- gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
}
@@ -817,10 +855,12 @@ static struct i2c_board_info cardhu_i2c8_board_info[] = {
I2C_BOARD_INFO("ov2710", 0x36),
.platform_data = &cardhu_ov2710_data,
},
+#if defined(CONFIG_VIDEO_OV5640) || defined(CONFIG_VIDEO_OV5640_MODULE)
{
I2C_BOARD_INFO("ov5640", 0x3C),
.platform_data = &cardhu_ov5640_data,
},
+#endif
};
static int nct_get_temp(void *_data, long *temp)
@@ -1213,11 +1253,15 @@ int __init cardhu_sensors_init(void)
if (board_info.board_id != BOARD_PM315)
mpuirq_init();
-#ifdef CONFIG_SOC_CAMERA_OV5650
- t30_get_tegra_vi01_device()->dev.platform_data =
- &cardhu_ov5650_camera_platform_data;
+#if defined(CONFIG_SOC_CAMERA_OV5650) \
+ || defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
platform_device_register(&cardhu_ov5650_soc_camera_device);
#endif
+#if defined(CONFIG_SOC_CAMERA_OV5640) \
+ || defined(CONFIG_SOC_CAMERA_OV5640_MODULE)
+ platform_device_register(&cardhu_ov5640_soc_camera_device);
+#endif
+
return 0;
}