|
@@ -20,16 +20,12 @@
|
|
|
|
|
|
struct cam_vfe_top_ver3_common_data {
|
|
|
struct cam_vfe_top_ver3_hw_info *hw_info;
|
|
|
- struct cam_hw_soc_info *soc_info;
|
|
|
struct cam_hw_intf *hw_intf;
|
|
|
struct cam_vfe_top_ver3_reg_offset_common *common_reg;
|
|
|
};
|
|
|
|
|
|
struct cam_vfe_top_ver3_priv {
|
|
|
struct cam_vfe_top_ver3_common_data common_data;
|
|
|
- unsigned long hw_clk_rate;
|
|
|
- unsigned long req_clk_rate[
|
|
|
- CAM_VFE_TOP_MUX_MAX];
|
|
|
struct cam_vfe_top_priv_common top_common;
|
|
|
};
|
|
|
|
|
@@ -63,7 +59,7 @@ static int cam_vfe_top_ver3_mux_get_base(struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
}
|
|
|
|
|
|
if (!cdm_args || !cdm_args->res || !top_priv ||
|
|
|
- !top_priv->common_data.soc_info) {
|
|
|
+ !top_priv->top_common.soc_info) {
|
|
|
CAM_ERR(CAM_ISP, "Error, Invalid args");
|
|
|
return -EINVAL;
|
|
|
}
|
|
@@ -85,9 +81,9 @@ static int cam_vfe_top_ver3_mux_get_base(struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
}
|
|
|
|
|
|
mem_base = CAM_SOC_GET_REG_MAP_CAM_BASE(
|
|
|
- top_priv->common_data.soc_info, VFE_CORE_BASE_IDX);
|
|
|
+ top_priv->top_common.soc_info, VFE_CORE_BASE_IDX);
|
|
|
CAM_DBG(CAM_ISP, "core %d mem_base 0x%x",
|
|
|
- top_priv->common_data.soc_info->index, mem_base);
|
|
|
+ top_priv->top_common.soc_info->index, mem_base);
|
|
|
|
|
|
cdm_util_ops->cdm_write_changebase(
|
|
|
cdm_args->cmd.cmd_buf_addr, mem_base);
|
|
@@ -96,58 +92,6 @@ static int cam_vfe_top_ver3_mux_get_base(struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int cam_vfe_top_ver3_set_hw_clk_rate(
|
|
|
- struct cam_vfe_top_ver3_priv *top_priv)
|
|
|
-{
|
|
|
- struct cam_hw_soc_info *soc_info = NULL;
|
|
|
- struct cam_vfe_soc_private *soc_private = NULL;
|
|
|
- struct cam_ahb_vote ahb_vote;
|
|
|
- int i, rc = 0, clk_lvl = -1;
|
|
|
- unsigned long max_clk_rate = 0;
|
|
|
-
|
|
|
- soc_info = top_priv->common_data.soc_info;
|
|
|
- soc_private =
|
|
|
- (struct cam_vfe_soc_private *)soc_info->soc_private;
|
|
|
-
|
|
|
- for (i = 0; i < top_priv->top_common.num_mux; i++) {
|
|
|
- if (top_priv->req_clk_rate[i] > max_clk_rate)
|
|
|
- max_clk_rate = top_priv->req_clk_rate[i];
|
|
|
- }
|
|
|
- if (max_clk_rate == top_priv->hw_clk_rate)
|
|
|
- return 0;
|
|
|
-
|
|
|
- CAM_DBG(CAM_PERF, "VFE: Clock name=%s idx=%d clk=%llu",
|
|
|
- soc_info->clk_name[soc_info->src_clk_idx],
|
|
|
- soc_info->src_clk_idx, max_clk_rate);
|
|
|
-
|
|
|
- rc = cam_soc_util_set_src_clk_rate(soc_info, max_clk_rate);
|
|
|
-
|
|
|
- if (!rc) {
|
|
|
- soc_private->ife_clk_src = max_clk_rate;
|
|
|
-
|
|
|
- top_priv->hw_clk_rate = max_clk_rate;
|
|
|
- rc = cam_soc_util_get_clk_level(soc_info, max_clk_rate,
|
|
|
- soc_info->src_clk_idx, &clk_lvl);
|
|
|
- if (rc) {
|
|
|
- CAM_WARN(CAM_ISP,
|
|
|
- "Failed to get clk level for %s with clk_rate %llu src_idx %d rc %d",
|
|
|
- soc_info->dev_name, max_clk_rate,
|
|
|
- soc_info->src_clk_idx, rc);
|
|
|
- rc = 0;
|
|
|
- goto end;
|
|
|
- }
|
|
|
-
|
|
|
- ahb_vote.type = CAM_VOTE_ABSOLUTE;
|
|
|
- ahb_vote.vote.level = clk_lvl;
|
|
|
- cam_cpas_update_ahb_vote(soc_private->cpas_handle, &ahb_vote);
|
|
|
- } else {
|
|
|
- CAM_ERR(CAM_PERF, "Set Clock rate failed, rc=%d", rc);
|
|
|
- }
|
|
|
-
|
|
|
-end:
|
|
|
- return rc;
|
|
|
-}
|
|
|
-
|
|
|
static int cam_vfe_top_fs_update(
|
|
|
struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
void *cmd_args, uint32_t arg_size)
|
|
@@ -161,56 +105,10 @@ static int cam_vfe_top_fs_update(
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int cam_vfe_top_ver3_clock_update(
|
|
|
- struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
- void *cmd_args, uint32_t arg_size)
|
|
|
-{
|
|
|
- struct cam_vfe_clock_update_args *clk_update = NULL;
|
|
|
- struct cam_isp_resource_node *res = NULL;
|
|
|
- struct cam_hw_info *hw_info = NULL;
|
|
|
- int i, rc = 0;
|
|
|
-
|
|
|
- clk_update =
|
|
|
- (struct cam_vfe_clock_update_args *)cmd_args;
|
|
|
- res = clk_update->node_res;
|
|
|
-
|
|
|
- if (!res || !res->hw_intf->hw_priv) {
|
|
|
- CAM_ERR(CAM_PERF, "Invalid input res %pK", res);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- hw_info = res->hw_intf->hw_priv;
|
|
|
-
|
|
|
- if (res->res_type != CAM_ISP_RESOURCE_VFE_IN ||
|
|
|
- res->res_id >= CAM_ISP_HW_VFE_IN_MAX) {
|
|
|
- CAM_ERR(CAM_PERF, "VFE:%d Invalid res_type:%d res id%d",
|
|
|
- res->hw_intf->hw_idx, res->res_type,
|
|
|
- res->res_id);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- for (i = 0; i < top_priv->top_common.num_mux; i++) {
|
|
|
- if (top_priv->top_common.mux_rsrc[i].res_id == res->res_id) {
|
|
|
- top_priv->req_clk_rate[i] = clk_update->clk_rate;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (hw_info->hw_state != CAM_HW_STATE_POWER_UP) {
|
|
|
- CAM_DBG(CAM_PERF,
|
|
|
- "VFE:%d Not ready to set clocks yet :%d",
|
|
|
- res->hw_intf->hw_idx,
|
|
|
- hw_info->hw_state);
|
|
|
- } else
|
|
|
- rc = cam_vfe_top_ver3_set_hw_clk_rate(top_priv);
|
|
|
-
|
|
|
- return rc;
|
|
|
-}
|
|
|
-
|
|
|
static int cam_vfe_top_ver3_dump_info(
|
|
|
struct cam_vfe_top_ver3_priv *top_priv, uint32_t cmd_type)
|
|
|
{
|
|
|
- struct cam_hw_soc_info *soc_info = top_priv->common_data.soc_info;
|
|
|
+ struct cam_hw_soc_info *soc_info = top_priv->top_common.soc_info;
|
|
|
|
|
|
if (!soc_info) {
|
|
|
CAM_ERR(CAM_ISP, "Null soc_info");
|
|
@@ -296,7 +194,7 @@ static int cam_vfe_top_wait_comp_event(struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
}
|
|
|
|
|
|
if (!cdm_args || !cdm_args->res || !top_priv ||
|
|
|
- !top_priv->common_data.soc_info) {
|
|
|
+ !top_priv->top_common.soc_info) {
|
|
|
CAM_ERR(CAM_ISP, "Error, Invalid args");
|
|
|
return -EINVAL;
|
|
|
}
|
|
@@ -341,7 +239,7 @@ static int cam_vfe_top_add_wait_trigger(struct cam_vfe_top_ver3_priv *top_priv,
|
|
|
}
|
|
|
|
|
|
if (!cdm_args || !cdm_args->res || !top_priv ||
|
|
|
- !top_priv->common_data.soc_info) {
|
|
|
+ !top_priv->top_common.soc_info) {
|
|
|
CAM_ERR(CAM_ISP, "Error, Invalid args");
|
|
|
return -EINVAL;
|
|
|
}
|
|
@@ -408,13 +306,13 @@ int cam_vfe_top_ver3_get_hw_caps(void *device_priv,
|
|
|
vfe_cap_info = (struct cam_vfe_hw_get_hw_cap *)args;
|
|
|
vfe_top_prv = (struct cam_vfe_top_ver3_priv *)device_priv;
|
|
|
|
|
|
- if (!vfe_top_prv->common_data.soc_info) {
|
|
|
+ if (!vfe_top_prv->top_common.soc_info) {
|
|
|
CAM_ERR(CAM_ISP, "soc_info is null");
|
|
|
return -EFAULT;
|
|
|
}
|
|
|
|
|
|
vfe_soc_private = (struct cam_vfe_soc_private *)
|
|
|
- vfe_top_prv->common_data.soc_info->soc_private;
|
|
|
+ vfe_top_prv->top_common.soc_info->soc_private;
|
|
|
|
|
|
vfe_cap_info->is_lite = (vfe_soc_private->is_ife_lite) ? true : false;
|
|
|
vfe_cap_info->incr =
|
|
@@ -433,7 +331,7 @@ int cam_vfe_top_ver3_init_hw(void *device_priv,
|
|
|
struct cam_vfe_top_ver3_priv *top_priv = device_priv;
|
|
|
struct cam_vfe_top_ver3_common_data common_data = top_priv->common_data;
|
|
|
|
|
|
- top_priv->hw_clk_rate = 0;
|
|
|
+ top_priv->top_common.hw_clk_rate = 0;
|
|
|
|
|
|
/**
|
|
|
* Auto clock gating is enabled by default, but no harm
|
|
@@ -441,20 +339,20 @@ int cam_vfe_top_ver3_init_hw(void *device_priv,
|
|
|
*/
|
|
|
CAM_DBG(CAM_ISP, "Enabling clock gating at IFE top");
|
|
|
|
|
|
- cam_soc_util_w_mb(common_data.soc_info, VFE_CORE_BASE_IDX,
|
|
|
+ cam_soc_util_w_mb(top_priv->top_common.soc_info, VFE_CORE_BASE_IDX,
|
|
|
common_data.common_reg->core_cgc_ovd_0, 0x0);
|
|
|
|
|
|
- cam_soc_util_w_mb(common_data.soc_info, VFE_CORE_BASE_IDX,
|
|
|
+ cam_soc_util_w_mb(top_priv->top_common.soc_info, VFE_CORE_BASE_IDX,
|
|
|
common_data.common_reg->core_cgc_ovd_1, 0x0);
|
|
|
|
|
|
- cam_soc_util_w_mb(common_data.soc_info, VFE_CORE_BASE_IDX,
|
|
|
+ cam_soc_util_w_mb(top_priv->top_common.soc_info, VFE_CORE_BASE_IDX,
|
|
|
common_data.common_reg->ahb_cgc_ovd, 0x0);
|
|
|
|
|
|
- cam_soc_util_w_mb(common_data.soc_info, VFE_CORE_BASE_IDX,
|
|
|
+ cam_soc_util_w_mb(top_priv->top_common.soc_info, VFE_CORE_BASE_IDX,
|
|
|
common_data.common_reg->noc_cgc_ovd, 0x0);
|
|
|
|
|
|
top_priv->top_common.hw_version =
|
|
|
- cam_io_r_mb(common_data.soc_info->reg_map[0].mem_base +
|
|
|
+ cam_io_r_mb(top_priv->top_common.soc_info->reg_map[0].mem_base +
|
|
|
common_data.common_reg->hw_version);
|
|
|
|
|
|
return 0;
|
|
@@ -475,7 +373,7 @@ int cam_vfe_top_ver3_reset(void *device_priv,
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- soc_info = top_priv->common_data.soc_info;
|
|
|
+ soc_info = top_priv->top_common.soc_info;
|
|
|
reg_common = top_priv->common_data.common_reg;
|
|
|
|
|
|
soc_private = soc_info->soc_private;
|
|
@@ -636,7 +534,7 @@ int cam_vfe_top_ver3_start(void *device_priv,
|
|
|
}
|
|
|
|
|
|
top_priv = (struct cam_vfe_top_ver3_priv *)device_priv;
|
|
|
- soc_info = top_priv->common_data.soc_info;
|
|
|
+ soc_info = top_priv->top_common.soc_info;
|
|
|
soc_private = soc_info->soc_private;
|
|
|
if (!soc_private) {
|
|
|
CAM_ERR(CAM_ISP, "Error soc_private NULL");
|
|
@@ -647,7 +545,7 @@ int cam_vfe_top_ver3_start(void *device_priv,
|
|
|
hw_info = (struct cam_hw_info *)mux_res->hw_intf->hw_priv;
|
|
|
|
|
|
if (hw_info->hw_state == CAM_HW_STATE_POWER_UP) {
|
|
|
- rc = cam_vfe_top_ver3_set_hw_clk_rate(top_priv);
|
|
|
+ rc = cam_vfe_top_set_hw_clk_rate(&top_priv->top_common);
|
|
|
if (rc) {
|
|
|
CAM_ERR(CAM_ISP,
|
|
|
"set_hw_clk_rate failed, rc=%d", rc);
|
|
@@ -695,10 +593,10 @@ int cam_vfe_top_ver3_stop(void *device_priv,
|
|
|
top_priv = (struct cam_vfe_top_ver3_priv *)device_priv;
|
|
|
mux_res = (struct cam_isp_resource_node *)stop_args;
|
|
|
hw_info = (struct cam_hw_info *)mux_res->hw_intf->hw_priv;
|
|
|
- soc_info = top_priv->common_data.soc_info;
|
|
|
+ soc_info = top_priv->top_common.soc_info;
|
|
|
soc_private = soc_info->soc_private;
|
|
|
|
|
|
- soc_info = top_priv->common_data.soc_info;
|
|
|
+ soc_info = top_priv->top_common.soc_info;
|
|
|
soc_private = soc_info->soc_private;
|
|
|
|
|
|
if (mux_res->res_id < CAM_ISP_HW_VFE_IN_MAX) {
|
|
@@ -712,7 +610,7 @@ int cam_vfe_top_ver3_stop(void *device_priv,
|
|
|
for (i = 0; i < top_priv->top_common.num_mux; i++) {
|
|
|
if (top_priv->top_common.mux_rsrc[i].res_id ==
|
|
|
mux_res->res_id) {
|
|
|
- top_priv->req_clk_rate[i] = 0;
|
|
|
+ top_priv->top_common.req_clk_rate[i] = 0;
|
|
|
memset(&top_priv->top_common.req_axi_vote[i],
|
|
|
0, sizeof(struct cam_axi_vote));
|
|
|
top_priv->top_common.axi_vote_control[i] =
|
|
@@ -753,7 +651,7 @@ int cam_vfe_top_ver3_process_cmd(void *device_priv, uint32_t cmd_type,
|
|
|
}
|
|
|
|
|
|
top_priv = (struct cam_vfe_top_ver3_priv *)device_priv;
|
|
|
- soc_info = top_priv->common_data.soc_info;
|
|
|
+ soc_info = top_priv->top_common.soc_info;
|
|
|
soc_private = soc_info->soc_private;
|
|
|
if (!soc_private) {
|
|
|
CAM_ERR(CAM_ISP, "Error soc_private NULL");
|
|
@@ -774,7 +672,7 @@ int cam_vfe_top_ver3_process_cmd(void *device_priv, uint32_t cmd_type,
|
|
|
arg_size);
|
|
|
break;
|
|
|
case CAM_ISP_HW_CMD_CLOCK_UPDATE:
|
|
|
- rc = cam_vfe_top_ver3_clock_update(top_priv, cmd_args,
|
|
|
+ rc = cam_vfe_top_clock_update(&top_priv->top_common, cmd_args,
|
|
|
arg_size);
|
|
|
break;
|
|
|
case CAM_ISP_HW_NOTIFY_OVERFLOW:
|
|
@@ -850,7 +748,7 @@ int cam_vfe_top_ver3_init(
|
|
|
}
|
|
|
|
|
|
vfe_top->top_priv = top_priv;
|
|
|
- top_priv->hw_clk_rate = 0;
|
|
|
+ top_priv->top_common.hw_clk_rate = 0;
|
|
|
if (ver3_hw_info->num_mux > CAM_VFE_TOP_MUX_MAX) {
|
|
|
CAM_ERR(CAM_ISP, "Invalid number of input rsrc: %d, max: %d",
|
|
|
ver3_hw_info->num_mux, CAM_VFE_TOP_MUX_MAX);
|
|
@@ -868,7 +766,7 @@ int cam_vfe_top_ver3_init(
|
|
|
top_priv->top_common.mux_rsrc[i].hw_intf = hw_intf;
|
|
|
top_priv->top_common.mux_rsrc[i].res_state =
|
|
|
CAM_ISP_RESOURCE_STATE_AVAILABLE;
|
|
|
- top_priv->req_clk_rate[i] = 0;
|
|
|
+ top_priv->top_common.req_clk_rate[i] = 0;
|
|
|
|
|
|
if (ver3_hw_info->mux_type[i] == CAM_VFE_CAMIF_VER_3_0) {
|
|
|
top_priv->top_common.mux_rsrc[i].res_id =
|
|
@@ -956,7 +854,7 @@ int cam_vfe_top_ver3_init(
|
|
|
vfe_top->hw_ops.process_cmd = cam_vfe_top_ver3_process_cmd;
|
|
|
*vfe_top_ptr = vfe_top;
|
|
|
|
|
|
- top_priv->common_data.soc_info = soc_info;
|
|
|
+ top_priv->top_common.soc_info = soc_info;
|
|
|
top_priv->common_data.hw_intf = hw_intf;
|
|
|
top_priv->top_common.hw_idx = hw_intf->hw_idx;
|
|
|
top_priv->common_data.common_reg = ver3_hw_info->common_reg;
|