Merge "msm: cpp: Use regulator APIs for gdsc reg access"
This commit is contained in:
commit
7bf4e176b4
5 changed files with 87 additions and 24 deletions
|
@ -686,6 +686,50 @@ error:
|
|||
}
|
||||
EXPORT_SYMBOL(msm_camera_regulator_enable);
|
||||
|
||||
/* set regulator mode */
|
||||
int msm_camera_regulator_set_mode(struct msm_cam_regulator *vdd_info,
|
||||
int cnt, bool mode)
|
||||
{
|
||||
int i;
|
||||
int rc;
|
||||
struct msm_cam_regulator *tmp = vdd_info;
|
||||
|
||||
if (!tmp) {
|
||||
pr_err("Invalid params");
|
||||
return -EINVAL;
|
||||
}
|
||||
CDBG("cnt : %d\n", cnt);
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
if (tmp && !IS_ERR_OR_NULL(tmp->vdd)) {
|
||||
CDBG("name : %s, enable : %d\n", tmp->name, mode);
|
||||
if (mode) {
|
||||
rc = regulator_set_mode(tmp->vdd,
|
||||
REGULATOR_MODE_FAST);
|
||||
if (rc < 0) {
|
||||
pr_err("regulator enable failed %d\n",
|
||||
i);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
rc = regulator_set_mode(tmp->vdd,
|
||||
REGULATOR_MODE_NORMAL);
|
||||
if (rc < 0)
|
||||
pr_err("regulator disable failed %d\n",
|
||||
i);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
error:
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_camera_regulator_set_mode);
|
||||
|
||||
|
||||
/* Put regulators regulators */
|
||||
void msm_camera_put_regulators(struct platform_device *pdev,
|
||||
struct msm_cam_regulator **vdd_info, int cnt)
|
||||
|
|
|
@ -247,6 +247,23 @@ int msm_camera_get_regulator_info(struct platform_device *pdev,
|
|||
int msm_camera_regulator_enable(struct msm_cam_regulator *vdd_info,
|
||||
int cnt, int enable);
|
||||
|
||||
/**
|
||||
* @brief : set the regultors mode
|
||||
*
|
||||
* This function sets the regulators for a specific
|
||||
* mode. say:REGULATOR_MODE_FAST/REGULATOR_MODE_NORMAL
|
||||
*
|
||||
* @param vdd_info: Pointer to list of regulators
|
||||
* @param cnt: Number of regulators to enable/disable
|
||||
* @param mode: Flags specifies either enable/disable
|
||||
*
|
||||
* @return Status of operation. Negative in case of error. Zero otherwise.
|
||||
*/
|
||||
|
||||
int msm_camera_regulator_set_mode(struct msm_cam_regulator *vdd_info,
|
||||
int cnt, bool mode);
|
||||
|
||||
|
||||
/**
|
||||
* @brief : Release the regulators
|
||||
*
|
||||
|
|
|
@ -1372,6 +1372,7 @@ static int cpp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
|||
mutex_unlock(&cpp_dev->mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
cpp_dev->state = CPP_STATE_IDLE;
|
||||
|
||||
CPP_DBG("Invoking msm_ion_client_create()\n");
|
||||
|
@ -4184,27 +4185,22 @@ static int msm_cpp_update_gdscr_status(struct cpp_device *cpp_dev,
|
|||
bool status)
|
||||
{
|
||||
int rc = 0;
|
||||
int value = 0;
|
||||
|
||||
uint32_t msm_cpp_reg_idx;
|
||||
if (!cpp_dev) {
|
||||
pr_err("%s: cpp device invalid\n", __func__);
|
||||
rc = -EINVAL;
|
||||
goto end;
|
||||
}
|
||||
msm_cpp_reg_idx = msm_cpp_get_regulator_index(cpp_dev, "vdd");
|
||||
if (msm_cpp_reg_idx < 0) {
|
||||
pr_err(" Fail to regulator index\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
rc = msm_camera_regulator_set_mode(cpp_dev->cpp_vdd +
|
||||
msm_cpp_reg_idx, 1, status);
|
||||
if (rc < 0)
|
||||
pr_err("update cpp gdscr status failed\n");
|
||||
|
||||
if (cpp_dev->camss_cpp_base) {
|
||||
value = msm_camera_io_r(cpp_dev->camss_cpp_base);
|
||||
pr_debug("value from camss cpp %x, status %d\n", value, status);
|
||||
if (status) {
|
||||
value &= CPP_GDSCR_SW_COLLAPSE_ENABLE;
|
||||
value |= CPP_GDSCR_HW_CONTROL_ENABLE;
|
||||
} else {
|
||||
value |= CPP_GDSCR_HW_CONTROL_DISABLE;
|
||||
value &= CPP_GDSCR_SW_COLLAPSE_DISABLE;
|
||||
}
|
||||
pr_debug("value %x after camss cpp mask\n", value);
|
||||
msm_camera_io_w(value, cpp_dev->camss_cpp_base);
|
||||
}
|
||||
end:
|
||||
return rc;
|
||||
}
|
||||
|
@ -4313,14 +4309,6 @@ static int cpp_probe(struct platform_device *pdev)
|
|||
memset(&cpp_vbif, 0, sizeof(struct msm_cpp_vbif_data));
|
||||
cpp_dev->vbif_data = &cpp_vbif;
|
||||
|
||||
cpp_dev->camss_cpp_base =
|
||||
msm_camera_get_reg_base(pdev, "camss_cpp", true);
|
||||
if (!cpp_dev->camss_cpp_base) {
|
||||
rc = -ENOMEM;
|
||||
pr_err("failed to get camss_cpp_base\n");
|
||||
goto camss_cpp_base_failed;
|
||||
}
|
||||
|
||||
cpp_dev->base =
|
||||
msm_camera_get_reg_base(pdev, "cpp", true);
|
||||
if (!cpp_dev->base) {
|
||||
|
@ -4492,7 +4480,7 @@ vbif_base_failed:
|
|||
cpp_base_failed:
|
||||
msm_camera_put_reg_base(pdev, cpp_dev->camss_cpp_base,
|
||||
"camss_cpp", true);
|
||||
camss_cpp_base_failed:
|
||||
|
||||
kfree(cpp_dev);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -289,6 +289,8 @@ struct cpp_device {
|
|||
int msm_cpp_set_micro_clk(struct cpp_device *cpp_dev);
|
||||
int msm_update_freq_tbl(struct cpp_device *cpp_dev);
|
||||
int msm_cpp_get_clock_index(struct cpp_device *cpp_dev, const char *clk_name);
|
||||
int msm_cpp_get_regulator_index(struct cpp_device *cpp_dev,
|
||||
const char *regulator_name);
|
||||
long msm_cpp_set_core_clk(struct cpp_device *cpp_dev, long rate, int idx);
|
||||
void msm_cpp_fetch_dt_params(struct cpp_device *cpp_dev);
|
||||
int msm_cpp_read_payload_params_from_dt(struct cpp_device *cpp_dev);
|
||||
|
|
|
@ -71,6 +71,18 @@ int msm_cpp_get_clock_index(struct cpp_device *cpp_dev, const char *clk_name)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
int msm_cpp_get_regulator_index(struct cpp_device *cpp_dev,
|
||||
const char *regulator_name)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
|
||||
for (i = 0; i < cpp_dev->num_reg; i++) {
|
||||
if (!strcmp(regulator_name, cpp_dev->cpp_vdd[i].name))
|
||||
return i;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int cpp_get_clk_freq_tbl_dt(struct cpp_device *cpp_dev)
|
||||
{
|
||||
uint32_t i, count, min_clk_rate;
|
||||
|
|
Loading…
Add table
Reference in a new issue