Loading Documentation/devicetree/bindings/media/video/msm-cci.txt +24 −2 Original line number Diff line number Diff line Loading @@ -173,6 +173,22 @@ Required properties: - 0 -> MASTER 0 - 1 -> MASTER 1 Optional properties: - qcom,cam-vreg-name : should contain names of all regulators needed by this actuator - "cam_vaf" - qcom,cam-vreg-type : should contain regulator type for regulators mentioned in qcom,cam-vreg-name property (in the same order) - 0 for LDO and 1 for LVS - qcom,cam-vreg-min-voltage : should contain minimum voltage level in mcrovolts for regulators mentioned in qcom,cam-vreg-name property (in the same order) - qcom,cam-vreg-max-voltage : should contain maximum voltage level in mcrovolts for regulators mentioned in qcom,cam-vreg-name property (in the same order) - qcom,cam-vreg-op-mode : should contain the maximum current in microamps required from the regulators mentioned in the qcom,cam-vreg-name property (in the same order). - cam_vaf-supply : should contain regulator from which AF voltage is supplied Example: qcom,cci@0xfda0c000 { Loading Loading @@ -208,6 +224,12 @@ Example: reg = <0x18>; compatible = "qcom,actuator"; qcom,cci-master = <0>; cam_vaf-supply = <&pm8941_l23>; qcom,cam-vreg-name = "cam_vaf"; qcom,cam-vreg-type = <0>; qcom,cam-vreg-min-voltage = <3000000>; qcom,cam-vreg-max-voltage = <3000000>; qcom,cam-vreg-op-mode = <100000>; }; qcom,s5k3l1yx@6e { Loading drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c +63 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,10 @@ DEFINE_MSM_MUTEX(msm_actuator_mutex); #define CDBG(fmt, args...) pr_debug(fmt, ##args) #endif static int32_t msm_actuator_power_up(struct msm_actuator_ctrl_t *a_ctrl); static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl); static struct msm_actuator msm_vcm_actuator_table; static struct msm_actuator msm_piezo_actuator_table; Loading Loading @@ -442,6 +446,31 @@ static int32_t msm_actuator_set_default_focus( return rc; } static int32_t msm_actuator_vreg_control(struct msm_actuator_ctrl_t *a_ctrl, int config) { int rc = 0, i, cnt; struct msm_actuator_vreg *vreg_cfg; vreg_cfg = &a_ctrl->vreg_cfg; cnt = vreg_cfg->num_vreg; if (!cnt) return 0; if (cnt >= MSM_ACTUATOT_MAX_VREGS) { pr_err("%s failed %d cnt %d\n", __func__, __LINE__, cnt); return -EINVAL; } for (i = 0; i < cnt; i++) { rc = msm_camera_config_single_vreg(&(a_ctrl->pdev->dev), &vreg_cfg->cam_vreg[i], (struct regulator **)&vreg_cfg->data[i], config); } return rc; } static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl) { int32_t rc = 0; Loading @@ -453,6 +482,12 @@ static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl) gpio_free(a_ctrl->vcm_pwd); } rc = msm_actuator_vreg_control(a_ctrl, 0); if (rc < 0) { pr_err("%s failed %d\n", __func__, __LINE__); return rc; } kfree(a_ctrl->step_position_table); a_ctrl->step_position_table = NULL; kfree(a_ctrl->i2c_reg_tbl); Loading Loading @@ -677,6 +712,13 @@ static int32_t msm_actuator_config(struct msm_actuator_ctrl_t *a_ctrl, if (rc < 0) pr_err("actuator_set_position failed %d\n", rc); break; case CFG_ACTUATOR_POWERUP: rc = msm_actuator_power_up(a_ctrl); if (rc < 0) pr_err("Failed actuator power up%d\n", rc); break; default: break; } Loading Loading @@ -800,6 +842,13 @@ static int32_t msm_actuator_power_up(struct msm_actuator_ctrl_t *a_ctrl) CDBG("vcm info: %d %d\n", a_ctrl->vcm_pwd, a_ctrl->vcm_enable); rc = msm_actuator_vreg_control(a_ctrl, 1); if (rc < 0) { pr_err("%s failed %d\n", __func__, __LINE__); return rc; } if (a_ctrl->vcm_enable) { rc = gpio_request(a_ctrl->vcm_pwd, "msm_actuator"); if (!rc) { Loading Loading @@ -915,6 +964,7 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev) int32_t rc = 0; struct msm_camera_cci_client *cci_client = NULL; struct msm_actuator_ctrl_t *msm_actuator_t = NULL; struct msm_actuator_vreg *vreg_cfg; CDBG("Enter\n"); if (!pdev->dev.of_node) { Loading Loading @@ -946,6 +996,18 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev) return rc; } if (of_find_property((&pdev->dev)->of_node, "qcom,cam-vreg-name", NULL)) { vreg_cfg = &msm_actuator_t->vreg_cfg; rc = msm_camera_get_dt_vreg_data((&pdev->dev)->of_node, &vreg_cfg->cam_vreg, &vreg_cfg->num_vreg); if (rc < 0) { kfree(msm_actuator_t); pr_err("failed rc %d\n", rc); return rc; } } msm_actuator_t->act_v4l2_subdev_ops = &msm_actuator_subdev_ops; msm_actuator_t->actuator_mutex = &msm_actuator_mutex; msm_actuator_t->cam_name = pdev->id; Loading @@ -958,6 +1020,7 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev) msm_actuator_t->i2c_client.cci_client = kzalloc(sizeof( struct msm_camera_cci_client), GFP_KERNEL); if (!msm_actuator_t->i2c_client.cci_client) { kfree(msm_actuator_t->vreg_cfg.cam_vreg); kfree(msm_actuator_t); pr_err("failed no memory\n"); return -ENOMEM; Loading drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.h +12 −0 Original line number Diff line number Diff line Loading @@ -18,10 +18,15 @@ #include <media/v4l2-subdev.h> #include <media/msmb_camera.h> #include "msm_camera_i2c.h" #include "msm_camera_dt_util.h" #include "msm_camera_io_util.h" #define DEFINE_MSM_MUTEX(mutexname) \ static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) #define MSM_ACTUATOT_MAX_VREGS (10) struct msm_actuator_ctrl_t; enum msm_actuator_state_t { Loading Loading @@ -57,6 +62,12 @@ struct msm_actuator { struct msm_actuator_func_tbl func_tbl; }; struct msm_actuator_vreg { struct camera_vreg_t *cam_vreg; void *data[MSM_ACTUATOT_MAX_VREGS]; int num_vreg; }; struct msm_actuator_ctrl_t { struct i2c_driver *i2c_driver; struct platform_driver *pdriver; Loading Loading @@ -89,6 +100,7 @@ struct msm_actuator_ctrl_t { enum cci_i2c_master_t cci_master; uint32_t subdev_id; enum msm_actuator_state_t actuator_state; struct msm_actuator_vreg vreg_cfg; }; #endif include/media/msm_cam_sensor.h +1 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,7 @@ enum msm_actuator_cfg_type_t { CFG_SET_POSITION, CFG_MOVE_FOCUS, CFG_ACTUATOR_POWERDOWN, CFG_ACTUATOR_POWERUP, }; enum actuator_type { Loading Loading
Documentation/devicetree/bindings/media/video/msm-cci.txt +24 −2 Original line number Diff line number Diff line Loading @@ -173,6 +173,22 @@ Required properties: - 0 -> MASTER 0 - 1 -> MASTER 1 Optional properties: - qcom,cam-vreg-name : should contain names of all regulators needed by this actuator - "cam_vaf" - qcom,cam-vreg-type : should contain regulator type for regulators mentioned in qcom,cam-vreg-name property (in the same order) - 0 for LDO and 1 for LVS - qcom,cam-vreg-min-voltage : should contain minimum voltage level in mcrovolts for regulators mentioned in qcom,cam-vreg-name property (in the same order) - qcom,cam-vreg-max-voltage : should contain maximum voltage level in mcrovolts for regulators mentioned in qcom,cam-vreg-name property (in the same order) - qcom,cam-vreg-op-mode : should contain the maximum current in microamps required from the regulators mentioned in the qcom,cam-vreg-name property (in the same order). - cam_vaf-supply : should contain regulator from which AF voltage is supplied Example: qcom,cci@0xfda0c000 { Loading Loading @@ -208,6 +224,12 @@ Example: reg = <0x18>; compatible = "qcom,actuator"; qcom,cci-master = <0>; cam_vaf-supply = <&pm8941_l23>; qcom,cam-vreg-name = "cam_vaf"; qcom,cam-vreg-type = <0>; qcom,cam-vreg-min-voltage = <3000000>; qcom,cam-vreg-max-voltage = <3000000>; qcom,cam-vreg-op-mode = <100000>; }; qcom,s5k3l1yx@6e { Loading
drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c +63 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,10 @@ DEFINE_MSM_MUTEX(msm_actuator_mutex); #define CDBG(fmt, args...) pr_debug(fmt, ##args) #endif static int32_t msm_actuator_power_up(struct msm_actuator_ctrl_t *a_ctrl); static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl); static struct msm_actuator msm_vcm_actuator_table; static struct msm_actuator msm_piezo_actuator_table; Loading Loading @@ -442,6 +446,31 @@ static int32_t msm_actuator_set_default_focus( return rc; } static int32_t msm_actuator_vreg_control(struct msm_actuator_ctrl_t *a_ctrl, int config) { int rc = 0, i, cnt; struct msm_actuator_vreg *vreg_cfg; vreg_cfg = &a_ctrl->vreg_cfg; cnt = vreg_cfg->num_vreg; if (!cnt) return 0; if (cnt >= MSM_ACTUATOT_MAX_VREGS) { pr_err("%s failed %d cnt %d\n", __func__, __LINE__, cnt); return -EINVAL; } for (i = 0; i < cnt; i++) { rc = msm_camera_config_single_vreg(&(a_ctrl->pdev->dev), &vreg_cfg->cam_vreg[i], (struct regulator **)&vreg_cfg->data[i], config); } return rc; } static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl) { int32_t rc = 0; Loading @@ -453,6 +482,12 @@ static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl) gpio_free(a_ctrl->vcm_pwd); } rc = msm_actuator_vreg_control(a_ctrl, 0); if (rc < 0) { pr_err("%s failed %d\n", __func__, __LINE__); return rc; } kfree(a_ctrl->step_position_table); a_ctrl->step_position_table = NULL; kfree(a_ctrl->i2c_reg_tbl); Loading Loading @@ -677,6 +712,13 @@ static int32_t msm_actuator_config(struct msm_actuator_ctrl_t *a_ctrl, if (rc < 0) pr_err("actuator_set_position failed %d\n", rc); break; case CFG_ACTUATOR_POWERUP: rc = msm_actuator_power_up(a_ctrl); if (rc < 0) pr_err("Failed actuator power up%d\n", rc); break; default: break; } Loading Loading @@ -800,6 +842,13 @@ static int32_t msm_actuator_power_up(struct msm_actuator_ctrl_t *a_ctrl) CDBG("vcm info: %d %d\n", a_ctrl->vcm_pwd, a_ctrl->vcm_enable); rc = msm_actuator_vreg_control(a_ctrl, 1); if (rc < 0) { pr_err("%s failed %d\n", __func__, __LINE__); return rc; } if (a_ctrl->vcm_enable) { rc = gpio_request(a_ctrl->vcm_pwd, "msm_actuator"); if (!rc) { Loading Loading @@ -915,6 +964,7 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev) int32_t rc = 0; struct msm_camera_cci_client *cci_client = NULL; struct msm_actuator_ctrl_t *msm_actuator_t = NULL; struct msm_actuator_vreg *vreg_cfg; CDBG("Enter\n"); if (!pdev->dev.of_node) { Loading Loading @@ -946,6 +996,18 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev) return rc; } if (of_find_property((&pdev->dev)->of_node, "qcom,cam-vreg-name", NULL)) { vreg_cfg = &msm_actuator_t->vreg_cfg; rc = msm_camera_get_dt_vreg_data((&pdev->dev)->of_node, &vreg_cfg->cam_vreg, &vreg_cfg->num_vreg); if (rc < 0) { kfree(msm_actuator_t); pr_err("failed rc %d\n", rc); return rc; } } msm_actuator_t->act_v4l2_subdev_ops = &msm_actuator_subdev_ops; msm_actuator_t->actuator_mutex = &msm_actuator_mutex; msm_actuator_t->cam_name = pdev->id; Loading @@ -958,6 +1020,7 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev) msm_actuator_t->i2c_client.cci_client = kzalloc(sizeof( struct msm_camera_cci_client), GFP_KERNEL); if (!msm_actuator_t->i2c_client.cci_client) { kfree(msm_actuator_t->vreg_cfg.cam_vreg); kfree(msm_actuator_t); pr_err("failed no memory\n"); return -ENOMEM; Loading
drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.h +12 −0 Original line number Diff line number Diff line Loading @@ -18,10 +18,15 @@ #include <media/v4l2-subdev.h> #include <media/msmb_camera.h> #include "msm_camera_i2c.h" #include "msm_camera_dt_util.h" #include "msm_camera_io_util.h" #define DEFINE_MSM_MUTEX(mutexname) \ static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) #define MSM_ACTUATOT_MAX_VREGS (10) struct msm_actuator_ctrl_t; enum msm_actuator_state_t { Loading Loading @@ -57,6 +62,12 @@ struct msm_actuator { struct msm_actuator_func_tbl func_tbl; }; struct msm_actuator_vreg { struct camera_vreg_t *cam_vreg; void *data[MSM_ACTUATOT_MAX_VREGS]; int num_vreg; }; struct msm_actuator_ctrl_t { struct i2c_driver *i2c_driver; struct platform_driver *pdriver; Loading Loading @@ -89,6 +100,7 @@ struct msm_actuator_ctrl_t { enum cci_i2c_master_t cci_master; uint32_t subdev_id; enum msm_actuator_state_t actuator_state; struct msm_actuator_vreg vreg_cfg; }; #endif
include/media/msm_cam_sensor.h +1 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,7 @@ enum msm_actuator_cfg_type_t { CFG_SET_POSITION, CFG_MOVE_FOCUS, CFG_ACTUATOR_POWERDOWN, CFG_ACTUATOR_POWERUP, }; enum actuator_type { Loading