From f72117d9b36b11d38db625af4ceacdfe3b0bf649 Mon Sep 17 00:00:00 2001 From: Charlie Huang Date: Fri, 27 Apr 2012 17:07:12 -0700 Subject: arm: tegra: cardhu: add ov5640 support bug 921322 Change-Id: If7f05c632816abac54852293ebd3834b5b3984d8 Signed-off-by: Charlie Huang Reviewed-on: http://git-master/r/99508 Reviewed-by: Rohan Somvanshi Tested-by: Rohan Somvanshi --- arch/arm/mach-tegra/board-cardhu-sensors.c | 87 +++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-tegra/board-cardhu-sensors.c b/arch/arm/mach-tegra/board-cardhu-sensors.c index fe3188ec1cfd..0ee537eaf3bb 100644 --- a/arch/arm/mach-tegra/board-cardhu-sensors.c +++ b/arch/arm/mach-tegra/board-cardhu-sensors.c @@ -1,7 +1,7 @@ /* * arch/arm/mach-tegra/board-cardhu-sensors.c * - * Copyright (c) 2010-2011, NVIDIA CORPORATION, All rights reserved. + * Copyright (c) 2010-2012, NVIDIA CORPORATION, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -464,6 +465,86 @@ struct ov2710_platform_data cardhu_ov2710_data = { .power_off = cardhu_ov2710_power_off, }; +static int cardhu_ov5640_power_on(void) +{ + /* CSI-B and front sensor are muxed on cardhu */ + gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1); + + /* Boards E1198 and E1291 are of Cardhu personality + * and donot have TCA6416 exp for camera */ + if ((board_info.board_id == BOARD_E1198) || + (board_info.board_id == BOARD_E1291)) { + + 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); + + if (cardhu_vdd_cam3 == NULL) { + cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3"); + if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) { + pr_err("%s: couldn't get regulator vdd_cam3: %ld\n", + __func__, PTR_ERR(cardhu_vdd_cam3)); + goto reg_alloc_fail; + } + } + regulator_enable(cardhu_vdd_cam3); + } + + /* Enable VDD_1V8_Cam3 */ + if (cardhu_1v8_cam3 == NULL) { + cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3"); + if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) { + pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n", + __func__, PTR_ERR(cardhu_1v8_cam3)); + goto reg_alloc_fail; + } + } + regulator_enable(cardhu_1v8_cam3); + mdelay(5); + + return 0; + +reg_alloc_fail: + if (cardhu_1v8_cam3) { + regulator_put(cardhu_1v8_cam3); + cardhu_1v8_cam3 = NULL; + } + if (cardhu_vdd_cam3) { + regulator_put(cardhu_vdd_cam3); + cardhu_vdd_cam3 = NULL; + } + + return -ENODEV; +} + +static int cardhu_ov5640_power_off(void) +{ + /* CSI-B and front sensor are muxed on cardhu */ + gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1); + + /* Boards E1198 and E1291 are of Cardhu personality + * and donot have TCA6416 exp for camera */ + if ((board_info.board_id == BOARD_E1198) || + (board_info.board_id == BOARD_E1291)) { + gpio_direction_output(CAM1_POWER_DWN_GPIO, 1); + gpio_direction_output(CAM2_POWER_DWN_GPIO, 1); + gpio_direction_output(CAM3_POWER_DWN_GPIO, 1); + } + + if (cardhu_1v8_cam3) + regulator_disable(cardhu_1v8_cam3); + if (cardhu_vdd_cam3) + regulator_disable(cardhu_vdd_cam3); + + return 0; +} + +struct ov5640_platform_data cardhu_ov5640_data = { + .power_on = cardhu_ov5640_power_on, + .power_off = cardhu_ov5640_power_off, +}; + static const struct i2c_board_info cardhu_i2c3_board_info[] = { { I2C_BOARD_INFO("pca9546", 0x70), @@ -587,6 +668,10 @@ static struct i2c_board_info cardhu_i2c8_board_info[] = { I2C_BOARD_INFO("ov2710", 0x36), .platform_data = &cardhu_ov2710_data, }, + { + I2C_BOARD_INFO("ov5640", 0x3C), + .platform_data = &cardhu_ov5640_data, + }, }; static int nct_get_temp(void *_data, long *temp) -- cgit v1.2.3