msm: camera: Reorganize power up functions for sensors
Moving regulators and gpio to board file
GPIO and regulators are usually different for OEM projects.
This will give them the flexibility to support multiple
devices without changing the driver.
Change-Id: I37549d2eaf3a6c31c1b7cf81270c2b22dde30011
Signed-off-by: Kevin Chan <ktchan@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8960-camera.c b/arch/arm/mach-msm/board-8960-camera.c
index 2ad92b3..2995679 100644
--- a/arch/arm/mach-msm/board-8960-camera.c
+++ b/arch/arm/mach-msm/board-8960-camera.c
@@ -12,9 +12,9 @@
*/
#include <asm/mach-types.h>
+#include <linux/gpio.h>
#include <mach/board.h>
#include <mach/msm_bus_board.h>
-#include <mach/gpio.h>
#include <mach/gpiomux.h>
#include "devices.h"
#include "board-8960.h"
@@ -181,20 +181,6 @@
};
#ifdef CONFIG_MSM_CAMERA
-
-static uint16_t msm_cam_gpio_2d_tbl[] = {
- 5, /*CAMIF_MCLK*/
- 20, /*CAMIF_I2C_DATA*/
- 21, /*CAMIF_I2C_CLK*/
-};
-
-static struct msm_camera_gpio_conf gpio_conf = {
- .cam_gpiomux_conf_tbl = msm8960_cam_2d_configs,
- .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(msm8960_cam_2d_configs),
- .cam_gpio_tbl = msm_cam_gpio_2d_tbl,
- .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_2d_tbl),
-};
-
#define VFE_CAMIF_TIMER1_GPIO 2
#define VFE_CAMIF_TIMER2_GPIO 3
#define VFE_CAMIF_TIMER3_GPIO_INT 4
@@ -350,8 +336,6 @@
static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
{
- .ioclk.mclk_clk_rate = 24000000,
- .ioclk.vfe_clk_rate = 228570000,
.csid_core = 0,
.is_csiphy = 1,
.is_csid = 1,
@@ -360,8 +344,6 @@
.cam_bus_scale_table = &cam_bus_client_pdata,
},
{
- .ioclk.mclk_clk_rate = 24000000,
- .ioclk.vfe_clk_rate = 228570000,
.csid_core = 1,
.is_csiphy = 1,
.is_csid = 1,
@@ -371,6 +353,67 @@
},
};
+static struct camera_vreg_t msm_8960_back_cam_vreg[] = {
+ {"mipi_csi_vdd", REG_LDO, 1200000, 1200000, 20000},
+ {"cam_vana", REG_LDO, 2800000, 2850000, 85600},
+ {"cam_vio", REG_VS, 0, 0, 0},
+ {"cam_vdig", REG_LDO, 1200000, 1200000, 105000},
+ {"cam_vaf", REG_LDO, 2800000, 2800000, 300000},
+};
+
+static struct camera_vreg_t msm_8960_front_cam_vreg[] = {
+ {"mipi_csi_vdd", REG_LDO, 1200000, 1200000, 20000},
+ {"cam_vana", REG_LDO, 2800000, 2850000, 85600},
+ {"cam_vio", REG_VS, 0, 0, 0},
+ {"cam_vdig", REG_LDO, 1200000, 1200000, 105000},
+};
+
+static struct gpio msm8960_common_cam_gpio[] = {
+ {5, GPIOF_DIR_IN, "CAMIF_MCLK"},
+ {20, GPIOF_DIR_IN, "CAMIF_I2C_DATA"},
+ {21, GPIOF_DIR_IN, "CAMIF_I2C_CLK"},
+};
+
+static struct gpio msm8960_front_cam_gpio[] = {
+ {76, GPIOF_DIR_OUT, "CAM_RESET"},
+};
+
+static struct gpio msm8960_back_cam_gpio[] = {
+ {107, GPIOF_DIR_OUT, "CAM_RESET"},
+};
+
+static struct msm_gpio_set_tbl msm8960_front_cam_gpio_set_tbl[] = {
+ {76, GPIOF_OUT_INIT_LOW, 1000},
+ {76, GPIOF_OUT_INIT_HIGH, 4000},
+};
+
+static struct msm_gpio_set_tbl msm8960_back_cam_gpio_set_tbl[] = {
+ {107, GPIOF_OUT_INIT_LOW, 1000},
+ {107, GPIOF_OUT_INIT_HIGH, 4000},
+};
+
+static struct msm_camera_gpio_conf msm_8960_front_cam_gpio_conf = {
+ .cam_gpiomux_conf_tbl = msm8960_cam_2d_configs,
+ .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(msm8960_cam_2d_configs),
+ .cam_gpio_common_tbl = msm8960_common_cam_gpio,
+ .cam_gpio_common_tbl_size = ARRAY_SIZE(msm8960_common_cam_gpio),
+ .cam_gpio_req_tbl = msm8960_front_cam_gpio,
+ .cam_gpio_req_tbl_size = ARRAY_SIZE(msm8960_front_cam_gpio),
+ .cam_gpio_set_tbl = msm8960_front_cam_gpio_set_tbl,
+ .cam_gpio_set_tbl_size = ARRAY_SIZE(msm8960_front_cam_gpio_set_tbl),
+};
+
+static struct msm_camera_gpio_conf msm_8960_back_cam_gpio_conf = {
+ .cam_gpiomux_conf_tbl = msm8960_cam_2d_configs,
+ .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(msm8960_cam_2d_configs),
+ .cam_gpio_common_tbl = msm8960_common_cam_gpio,
+ .cam_gpio_common_tbl_size = ARRAY_SIZE(msm8960_common_cam_gpio),
+ .cam_gpio_req_tbl = msm8960_back_cam_gpio,
+ .cam_gpio_req_tbl_size = ARRAY_SIZE(msm8960_back_cam_gpio),
+ .cam_gpio_set_tbl = msm8960_back_cam_gpio_set_tbl,
+ .cam_gpio_set_tbl_size = ARRAY_SIZE(msm8960_back_cam_gpio_set_tbl),
+};
+
#ifdef CONFIG_IMX074_ACT
static struct i2c_board_info imx074_actuator_i2c_info = {
I2C_BOARD_INFO("imx074_act", 0x11),
@@ -394,10 +437,9 @@
static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
.mount_angle = 90,
- .sensor_reset = 107,
- .sensor_pwd = 85,
- .vcm_pwd = 0,
- .vcm_enable = 1,
+ .cam_vreg = msm_8960_back_cam_vreg,
+ .num_vreg = ARRAY_SIZE(msm_8960_back_cam_vreg),
+ .gpio_conf = &msm_8960_back_cam_gpio_conf,
};
static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
@@ -406,7 +448,6 @@
.flash_data = &flash_imx074,
.strobe_flash_data = &strobe_flash_xenon,
.sensor_platform_info = &sensor_board_info_imx074,
- .gpio_conf = &gpio_conf,
.csi_if = 1,
.camera_type = BACK_CAMERA_2D,
#ifdef CONFIG_IMX074_ACT
@@ -422,7 +463,9 @@
static struct msm_camera_sensor_platform_info sensor_board_info_mt9m114 = {
.mount_angle = 90,
- .sensor_reset = 107,
+ .cam_vreg = msm_8960_back_cam_vreg,
+ .num_vreg = ARRAY_SIZE(msm_8960_back_cam_vreg),
+ .gpio_conf = &msm_8960_back_cam_gpio_conf,
};
static struct msm_camera_sensor_info msm_camera_sensor_mt9m114_data = {
@@ -430,7 +473,6 @@
.pdata = &msm_camera_csi_device_data[0],
.flash_data = &flash_mt9m114,
.sensor_platform_info = &sensor_board_info_mt9m114,
- .gpio_conf = &gpio_conf,
.csi_if = 1,
.camera_type = BACK_CAMERA_2D,
};
@@ -443,10 +485,9 @@
static struct msm_camera_sensor_platform_info sensor_board_info_ov2720 = {
.mount_angle = 0,
- .sensor_reset = 76,
- .sensor_pwd = 85,
- .vcm_pwd = 0,
- .vcm_enable = 1,
+ .cam_vreg = msm_8960_front_cam_vreg,
+ .num_vreg = ARRAY_SIZE(msm_8960_front_cam_vreg),
+ .gpio_conf = &msm_8960_front_cam_gpio_conf,
};
static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = {
@@ -454,16 +495,36 @@
.pdata = &msm_camera_csi_device_data[1],
.flash_data = &flash_ov2720,
.sensor_platform_info = &sensor_board_info_ov2720,
- .gpio_conf = &gpio_conf,
.csi_if = 1,
.camera_type = FRONT_CAMERA_2D,
};
#endif
-static struct msm8960_privacy_light_cfg privacy_light_info = {
- .mpp = PM8921_MPP_PM_TO_SYS(12),
+static struct pm8xxx_mpp_config_data privacy_light_on_config = {
+ .type = PM8XXX_MPP_TYPE_SINK,
+ .level = PM8XXX_MPP_CS_OUT_5MA,
+ .control = PM8XXX_MPP_CS_CTRL_MPP_LOW_EN,
};
+static struct pm8xxx_mpp_config_data privacy_light_off_config = {
+ .type = PM8XXX_MPP_TYPE_SINK,
+ .level = PM8XXX_MPP_CS_OUT_5MA,
+ .control = PM8XXX_MPP_CS_CTRL_DISABLE,
+};
+
+static int32_t msm_camera_8960_ext_power_ctrl(int enable)
+{
+ int rc = 0;
+ if (enable) {
+ rc = pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(12),
+ &privacy_light_on_config);
+ } else {
+ rc = pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(12),
+ &privacy_light_off_config);
+ }
+ return rc;
+}
+
void __init msm8960_init_cam(void)
{
msm_gpiomux_install(msm8960_cam_common_configs,
@@ -488,9 +549,8 @@
s_info = &msm_camera_sensor_imx074_data;
s_info->sensor_platform_info->mount_angle = 180;
s_info = &msm_camera_sensor_ov2720_data;
- s_info->sensor_platform_info->privacy_light = 1;
- s_info->sensor_platform_info->privacy_light_info =
- &privacy_light_info;
+ s_info->sensor_platform_info->ext_power_ctrl =
+ msm_camera_8960_ext_power_ctrl;
}
platform_device_register(&msm8960_device_csiphy0);