diff options
author | Erik Lilliebjerg <elilliebjerg@nvidia.com> | 2011-03-04 07:46:05 -0700 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-03-08 17:41:29 -0800 |
commit | 362884d11e53e845d2e0ef4f7eee7243afe4d5be (patch) | |
tree | 8d7fbb0d0a80324bcb3fbda722ebf32b44d38e34 | |
parent | b817b18821e2c4bb5fe2a4e25c7d45739dfdd4b3 (diff) |
ARM: tegra: ventana: Add power management to cameras.
Before this change, the Ventana code was lacking power management support for camera.
bug 782390
Change-Id: I13c78da7a2dd9d48d787e10c4b4b3e7f52f1a0cb
Reviewed-on: http://git-master/r/21666
Reviewed-by: Erik M Lilliebjerg <elilliebjerg@nvidia.com>
Tested-by: Erik M Lilliebjerg <elilliebjerg@nvidia.com>
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | arch/arm/mach-tegra/board-ventana-sensors.c | 88 |
1 files changed, 74 insertions, 14 deletions
diff --git a/arch/arm/mach-tegra/board-ventana-sensors.c b/arch/arm/mach-tegra/board-ventana-sensors.c index 85ebb36479f2..030c348e3b52 100644 --- a/arch/arm/mach-tegra/board-ventana-sensors.c +++ b/arch/arm/mach-tegra/board-ventana-sensors.c @@ -18,6 +18,7 @@ * */ +#include <linux/delay.h> #include <linux/i2c.h> #include <linux/akm8975.h> #include <linux/mpu.h> @@ -62,11 +63,21 @@ static int ventana_camera_init(void) static int ventana_ov5650_power_on(void) { gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0); + gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 1); + gpio_direction_output(CAM2_PWR_DN_GPIO, 0); + msleep(5); + gpio_direction_output(CAM2_RST_L_GPIO, 0); + msleep(1); + gpio_direction_output(CAM2_RST_L_GPIO, 1); + msleep(20); return 0; } static int ventana_ov5650_power_off(void) { + gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 0); + gpio_direction_output(CAM2_RST_L_GPIO, 0); + gpio_direction_output(CAM2_PWR_DN_GPIO, 1); return 0; } @@ -75,14 +86,53 @@ struct ov5650_platform_data ventana_ov5650_data = { .power_off = ventana_ov5650_power_off, }; +static int ventana_ov5650s_power_on(void) +{ + ventana_ov5650_power_on(); + gpio_direction_output(CAM1_LDO_SHUTDN_L_GPIO, 1); + msleep(5); + gpio_direction_output(CAM1_PWR_DN_GPIO, 0); + msleep(5); + gpio_direction_output(CAM1_RST_L_GPIO, 0); + msleep(1); + gpio_direction_output(CAM1_RST_L_GPIO, 1); + msleep(20); + return 0; +} + +static int ventana_ov5650s_power_off(void) +{ + gpio_direction_output(CAM1_RST_L_GPIO, 0); + gpio_direction_output(CAM1_PWR_DN_GPIO, 1); + gpio_direction_output(CAM1_LDO_SHUTDN_L_GPIO, 0); + ventana_ov5650_power_off(); + return 0; +} + +struct ov5650_platform_data ventana_ov5650s_data = { + .power_on = ventana_ov5650s_power_on, + .power_off = ventana_ov5650s_power_off, +}; + static int ventana_ov2710_power_on(void) { gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1); + gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 1); + gpio_direction_output(CAM3_PWR_DN_GPIO, 0); + msleep(5); + gpio_direction_output(CAM3_RST_L_GPIO, 0); + msleep(1); + gpio_direction_output(CAM3_RST_L_GPIO, 1); + msleep(20); return 0; } static int ventana_ov2710_power_off(void) { + gpio_direction_output(CAM3_RST_L_GPIO, 0); + gpio_direction_output(CAM3_PWR_DN_GPIO, 1); + gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 0); + gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0); return 0; } @@ -191,6 +241,13 @@ static struct i2c_board_info ventana_i2c4_board_info[] = { #endif }; +static struct i2c_board_info ventana_i2c6_board_info[] = { + { + I2C_BOARD_INFO("ov5650s", 0x36), + .platform_data = &ventana_ov5650s_data, + }, +}; + static struct i2c_board_info ventana_i2c7_board_info[] = { { I2C_BOARD_INFO("ov5650", 0x36), @@ -286,6 +343,9 @@ int __init ventana_sensors_init(void) i2c_register_board_info(4, ventana_i2c4_board_info, ARRAY_SIZE(ventana_i2c4_board_info)); + i2c_register_board_info(6, ventana_i2c6_board_info, + ARRAY_SIZE(ventana_i2c6_board_info)); + i2c_register_board_info(7, ventana_i2c7_board_info, ARRAY_SIZE(ventana_i2c7_board_info)); @@ -320,21 +380,20 @@ static struct ov5650_gpios ov5650_gpio_keys[] = { [0] = OV5650_GPIO("en_avdd_csi", AVDD_DSI_CSI_ENB_GPIO, 1), [1] = OV5650_GPIO("cam_i2c_mux_rst_lo", CAM_I2C_MUX_RST_GPIO, 1), - [2] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0), - [3] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1), - [4] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 1), - [5] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1), + [2] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1), + [3] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 0), + [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0), + [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1), - [6] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0), - [7] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1), - [8] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0), - [9] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1), - - [10] = OV5650_GPIO("cam3_pwdn", CAM3_PWR_DN_GPIO, 0), - [11] = OV5650_GPIO("cam3_rst_lo", CAM3_RST_L_GPIO, 1), - [12] = OV5650_GPIO("cam3_af_pwdn_lo", CAM3_AF_PWR_DN_L_GPIO, 0), - [13] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM3_LDO_SHUTDN_L_GPIO, 1), + [6] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM3_LDO_SHUTDN_L_GPIO, 1), + [7] = OV5650_GPIO("cam3_af_pwdn_lo", CAM3_AF_PWR_DN_L_GPIO, 0), + [8] = OV5650_GPIO("cam3_pwdn", CAM3_PWR_DN_GPIO, 0), + [9] = OV5650_GPIO("cam3_rst_lo", CAM3_RST_L_GPIO, 1), + [10] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1), + [11] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0), + [12] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0), + [13] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1), }; int __init ventana_ov5650_late_init(void) @@ -361,7 +420,8 @@ int __init ventana_ov5650_late_init(void) } i2c_new_device(i2c_get_adapter(3), ventana_i2c3_board_info_pca9546); - + ventana_ov2710_power_off(); + ventana_ov5650s_power_off(); return 0; fail: |