diff options
author | Johnny Qiu <joqiu@nvidia.com> | 2012-02-14 01:45:26 -0800 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-02-15 12:44:26 -0800 |
commit | a138e0615700e7d31a6595aa01f5b3fe1a620d7c (patch) | |
tree | 8cc315371815495211dada577aa58cee5b5d35b3 | |
parent | 6d87641e1842128eba6fbc05ba16d2cb12674a3f (diff) |
arm: tegra: kai: add ov2710 front camera
Bug 913259
Change-Id: Idc26f500390b476942819289949f042bc25ae4a6
Signed-off-by: Peter Zu <pzu@nvidia.com>
Signed-off-by: Johnny Qiu <joqiu@nvidia.com>
Signed-off-by: Hao Tang <htang@nvidia.com>
Reviewed-on: http://git-master/r/82762
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
-rw-r--r-- | arch/arm/mach-tegra/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-kai-sensors.c | 137 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-kai.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-kai.h | 4 |
4 files changed, 143 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index f2566ec054af..b89d656a75f6 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile @@ -183,6 +183,7 @@ obj-${CONFIG_MACH_KAI} += board-kai-panel.o obj-${CONFIG_MACH_KAI} += board-kai-pinmux.o obj-${CONFIG_MACH_KAI} += board-kai-power.o obj-${CONFIG_MACH_KAI} += board-kai-sdhci.o +obj-${CONFIG_MACH_KAI} += board-kai-sensors.o obj-${CONFIG_TEGRA_BB_XMM_POWER} += baseband-xmm-power.o obj-${CONFIG_TEGRA_BB_XMM_POWER2} += baseband-xmm-power2.o diff --git a/arch/arm/mach-tegra/board-kai-sensors.c b/arch/arm/mach-tegra/board-kai-sensors.c new file mode 100644 index 000000000000..70289650d086 --- /dev/null +++ b/arch/arm/mach-tegra/board-kai-sensors.c @@ -0,0 +1,137 @@ + +/* + * arch/arm/mach-tegra/board-kai-sensors.c + * + * Copyright (c) 2012, NVIDIA Corporation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/regulator/consumer.h> +#include <asm/mach-types.h> +#include <mach/gpio.h> +#include <media/ov2710.h> +#include "board.h" +#include "board-kai.h" +#include "cpu-tegra.h" + +static struct regulator *kai_1v8_cam3; +static struct regulator *kai_vdd_cam3; + +static int kai_camera_init(void) +{ + int ret; + + tegra_gpio_enable(CAM2_POWER_DWN_GPIO); + ret = gpio_request(CAM2_POWER_DWN_GPIO, "cam2_power_en"); + if (ret < 0) { + pr_err("%s: gpio_request failed for gpio %s\n", + __func__, "CAM2_POWER_DWN_GPIO"); + } + + gpio_direction_output(CAM2_POWER_DWN_GPIO, 1); + mdelay(10); + + tegra_gpio_enable(CAM2_RST_GPIO); + ret = gpio_request(CAM2_RST_GPIO, "cam2_reset"); + if (ret < 0) { + pr_err("%s: gpio_request failed for gpio %s\n", + __func__, "CAM2_RST_GPIO"); + } + + gpio_direction_output(CAM2_RST_GPIO, 0); + mdelay(5); + + return 0; +} + +static int kai_ov2710_power_on(void) +{ + gpio_direction_output(CAM2_POWER_DWN_GPIO, 0); + mdelay(10); + + if (kai_vdd_cam3 == NULL) { + kai_vdd_cam3 = regulator_get(NULL, "vdd_cam3"); + if (WARN_ON(IS_ERR(kai_vdd_cam3))) { + pr_err("%s: couldn't get regulator vdd_cam3: %d\n", + __func__, PTR_ERR(kai_vdd_cam3)); + goto reg_get_vdd_cam3_fail; + } + } + regulator_enable(kai_vdd_cam3); + + if (kai_1v8_cam3 == NULL) { + kai_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3"); + if (WARN_ON(IS_ERR(kai_1v8_cam3))) { + pr_err("%s: couldn't get regulator vdd_1v8_cam3: %d\n", + __func__, PTR_ERR(kai_1v8_cam3)); + goto reg_get_vdd_1v8_cam3_fail; + } + } + regulator_enable(kai_1v8_cam3); + mdelay(5); + + gpio_direction_output(CAM2_RST_GPIO, 1); + mdelay(10); + + return 0; + +reg_get_vdd_1v8_cam3_fail: + kai_1v8_cam3 = NULL; + regulator_put(kai_vdd_cam3); + +reg_get_vdd_cam3_fail: + kai_vdd_cam3 = NULL; + + return -ENODEV; +} + +static int kai_ov2710_power_off(void) +{ + gpio_direction_output(CAM2_POWER_DWN_GPIO, 1); + + gpio_direction_output(CAM2_RST_GPIO, 0); + + if (kai_1v8_cam3) + regulator_disable(kai_1v8_cam3); + if (kai_vdd_cam3) + regulator_disable(kai_vdd_cam3); + + return 0; +} + +struct ov2710_platform_data kai_ov2710_data = { + .power_on = kai_ov2710_power_on, + .power_off = kai_ov2710_power_off, +}; + +static struct i2c_board_info kai_i2c2_board_info[] = { + { + I2C_BOARD_INFO("ov2710", 0x36), + .platform_data = &kai_ov2710_data, + }, +}; + +int __init kai_sensors_init(void) +{ + kai_camera_init(); + + i2c_register_board_info(2, kai_i2c2_board_info, + ARRAY_SIZE(kai_i2c2_board_info)); + + return 0; +} diff --git a/arch/arm/mach-tegra/board-kai.c b/arch/arm/mach-tegra/board-kai.c index 79467774329a..a1b7c8c9abfe 100644 --- a/arch/arm/mach-tegra/board-kai.c +++ b/arch/arm/mach-tegra/board-kai.c @@ -686,6 +686,7 @@ static void __init tegra_kai_init(void) kai_keys_init(); kai_panel_init(); kai_bt_st(); + kai_sensors_init(); kai_pins_state_init(); tegra_release_bootloader_fb(); #ifdef CONFIG_TEGRA_WDT_RECOVERY diff --git a/arch/arm/mach-tegra/board-kai.h b/arch/arm/mach-tegra/board-kai.h index b09761e60caa..183fa3821dbf 100644 --- a/arch/arm/mach-tegra/board-kai.h +++ b/arch/arm/mach-tegra/board-kai.h @@ -41,6 +41,9 @@ #define MAX77663_GPIO_BASE TEGRA_NR_GPIOS #define MAX77663_GPIO_END (MAX77663_GPIO_BASE + MAX77663_GPIO_NR) +/* CAMERA RELATED GPIOs on KAI */ +#define CAM2_RST_GPIO TEGRA_GPIO_PBB4 +#define CAM2_POWER_DWN_GPIO TEGRA_GPIO_PBB6 /* Audio-related GPIOs */ #define TEGRA_GPIO_CDC_IRQ TEGRA_GPIO_PW3 #define TEGRA_GPIO_SPKR_EN -1 @@ -63,6 +66,7 @@ int kai_suspend_init(void); int kai_sdhci_init(void); int kai_pinmux_init(void); int kai_panel_init(void); +int kai_sensors_init(void); int kai_keys_init(void); int kai_pins_state_init(void); int kai_power_off_init(void); |