|
@@ -47,6 +47,7 @@ struct g_csiphy_data {
|
|
void __iomem *base_address;
|
|
void __iomem *base_address;
|
|
uint8_t is_3phase;
|
|
uint8_t is_3phase;
|
|
uint32_t cpas_handle;
|
|
uint32_t cpas_handle;
|
|
|
|
+ bool enable_aon_support;
|
|
struct cam_csiphy_aon_sel_params_t *aon_sel_param;
|
|
struct cam_csiphy_aon_sel_params_t *aon_sel_param;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -1220,6 +1221,39 @@ static int cam_csiphy_update_lane(
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int __csiphy_cpas_configure_for_main_or_aon(
|
|
|
|
+ bool get_access, uint32_t cpas_handle,
|
|
|
|
+ struct cam_csiphy_aon_sel_params_t *aon_sel_params)
|
|
|
|
+{
|
|
|
|
+ uint32_t aon_config = 0;
|
|
|
|
+
|
|
|
|
+ cam_cpas_reg_read(cpas_handle, CAM_CPAS_REG_CPASTOP,
|
|
|
|
+ aon_sel_params->aon_cam_sel_offset,
|
|
|
|
+ true, &aon_config);
|
|
|
|
+
|
|
|
|
+ if (get_access) {
|
|
|
|
+ aon_config &= ~(aon_sel_params->cam_sel_mask |
|
|
|
|
+ aon_sel_params->mclk_sel_mask);
|
|
|
|
+ CAM_DBG(CAM_CSIPHY,
|
|
|
|
+ "Selecting MainCamera over AON Camera");
|
|
|
|
+ } else if (!get_access) {
|
|
|
|
+ aon_config |= (aon_sel_params->cam_sel_mask |
|
|
|
|
+ aon_sel_params->mclk_sel_mask);
|
|
|
|
+ CAM_DBG(CAM_CSIPHY,
|
|
|
|
+ "Releasing MainCamera to AON Camera");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CAM_DBG(CAM_CSIPHY, "value of aon_config = %u", aon_config);
|
|
|
|
+ if (cam_cpas_reg_write(cpas_handle, CAM_CPAS_REG_CPASTOP,
|
|
|
|
+ aon_sel_params->aon_cam_sel_offset,
|
|
|
|
+ true, aon_config)) {
|
|
|
|
+ CAM_ERR(CAM_CSIPHY,
|
|
|
|
+ "CPAS AON sel register write failed");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
static int cam_csiphy_cpas_ops(
|
|
static int cam_csiphy_cpas_ops(
|
|
uint32_t cpas_handle, bool start)
|
|
uint32_t cpas_handle, bool start)
|
|
{
|
|
{
|
|
@@ -1261,10 +1295,24 @@ static int cam_csiphy_cpas_ops(
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int cam_csiphy_util_update_aon_registration
|
|
|
|
+ (uint32_t phy_idx, bool is_aon_user)
|
|
|
|
+{
|
|
|
|
+ /* aon support enable for the sensor associated with phy idx*/
|
|
|
|
+ if (phy_idx >= MAX_CSIPHY) {
|
|
|
|
+ CAM_ERR(CAM_CSIPHY,
|
|
|
|
+ "Invalid PHY index: %u", phy_idx);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ g_phy_data[phy_idx].enable_aon_support = is_aon_user;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
int cam_csiphy_util_update_aon_ops(
|
|
int cam_csiphy_util_update_aon_ops(
|
|
bool get_access, uint32_t phy_idx)
|
|
bool get_access, uint32_t phy_idx)
|
|
{
|
|
{
|
|
- uint32_t aon_config = 0;
|
|
|
|
uint32_t cpas_hdl = 0;
|
|
uint32_t cpas_hdl = 0;
|
|
struct cam_csiphy_aon_sel_params_t *aon_sel_params;
|
|
struct cam_csiphy_aon_sel_params_t *aon_sel_params;
|
|
int rc = 0;
|
|
int rc = 0;
|
|
@@ -1282,7 +1330,6 @@ int cam_csiphy_util_update_aon_ops(
|
|
cpas_hdl = g_phy_data[phy_idx].cpas_handle;
|
|
cpas_hdl = g_phy_data[phy_idx].cpas_handle;
|
|
aon_sel_params = g_phy_data[phy_idx].aon_sel_param;
|
|
aon_sel_params = g_phy_data[phy_idx].aon_sel_param;
|
|
|
|
|
|
- CAM_DBG(CAM_CSIPHY, "PHY idx: %d", phy_idx);
|
|
|
|
rc = cam_csiphy_cpas_ops(cpas_hdl, true);
|
|
rc = cam_csiphy_cpas_ops(cpas_hdl, true);
|
|
if (rc) {
|
|
if (rc) {
|
|
if (rc == -EPERM) {
|
|
if (rc == -EPERM) {
|
|
@@ -1294,28 +1341,15 @@ int cam_csiphy_util_update_aon_ops(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- cam_cpas_reg_read(cpas_hdl, CAM_CPAS_REG_CPASTOP,
|
|
|
|
- aon_sel_params->aon_cam_sel_offset,
|
|
|
|
- true, &aon_config);
|
|
|
|
-
|
|
|
|
- if (get_access) {
|
|
|
|
- aon_config &= ~(aon_sel_params->cam_sel_mask |
|
|
|
|
- aon_sel_params->mclk_sel_mask);
|
|
|
|
- CAM_DBG(CAM_CSIPHY,
|
|
|
|
- "Selecting MainCamera over AON Camera");
|
|
|
|
- } else if (!get_access) {
|
|
|
|
- aon_config |= (aon_sel_params->cam_sel_mask |
|
|
|
|
- aon_sel_params->mclk_sel_mask);
|
|
|
|
- CAM_DBG(CAM_CSIPHY,
|
|
|
|
- "Releasing MainCamera to AON Camera");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- CAM_DBG(CAM_CSIPHY, "value of aon_config = %u", aon_config);
|
|
|
|
- if (cam_cpas_reg_write(cpas_hdl, CAM_CPAS_REG_CPASTOP,
|
|
|
|
- aon_sel_params->aon_cam_sel_offset,
|
|
|
|
- true, aon_config)) {
|
|
|
|
- CAM_ERR(CAM_CSIPHY,
|
|
|
|
- "CPAS AON sel register write failed");
|
|
|
|
|
|
+ CAM_DBG(CAM_CSIPHY, "PHY idx: %d, AON_support is %s", phy_idx,
|
|
|
|
+ (get_access) ? "enable" : "disable");
|
|
|
|
+ rc = __csiphy_cpas_configure_for_main_or_aon(
|
|
|
|
+ get_access, cpas_hdl, aon_sel_params);
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_CSIPHY, "Configuration for AON ops failed: rc: %d",
|
|
|
|
+ rc);
|
|
|
|
+ cam_csiphy_cpas_ops(cpas_hdl, false);
|
|
|
|
+ return rc;
|
|
}
|
|
}
|
|
|
|
|
|
if (rc != -EPERM)
|
|
if (rc != -EPERM)
|
|
@@ -1652,6 +1686,16 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
|
|
g_phy_data[csiphy_dev->soc_info.index].is_3phase);
|
|
g_phy_data[csiphy_dev->soc_info.index].is_3phase);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (g_phy_data[csiphy_dev->soc_info.index].enable_aon_support) {
|
|
|
|
+ rc = cam_csiphy_util_update_aon_ops(true, csiphy_dev->soc_info.index);
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_CSIPHY,
|
|
|
|
+ "Error in setting up AON operation for phy_idx: %d, rc: %d",
|
|
|
|
+ csiphy_dev->soc_info.index, rc);
|
|
|
|
+ goto release_mutex;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
csiphy_dev->acquire_count++;
|
|
csiphy_dev->acquire_count++;
|
|
CAM_DBG(CAM_CSIPHY, "ACQUIRE_CNT: %d",
|
|
CAM_DBG(CAM_CSIPHY, "ACQUIRE_CNT: %d",
|
|
csiphy_dev->acquire_count);
|
|
csiphy_dev->acquire_count);
|
|
@@ -1805,6 +1849,15 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
|
|
|
|
|
|
if (csiphy_dev->acquire_count == 0) {
|
|
if (csiphy_dev->acquire_count == 0) {
|
|
CAM_DBG(CAM_CSIPHY, "All PHY devices released");
|
|
CAM_DBG(CAM_CSIPHY, "All PHY devices released");
|
|
|
|
+ if (g_phy_data[csiphy_dev->soc_info.index].enable_aon_support) {
|
|
|
|
+ rc = cam_csiphy_util_update_aon_ops(false, csiphy_dev->soc_info.index);
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_WARN(CAM_CSIPHY,
|
|
|
|
+ "Error in releasing AON operation for phy_idx: %d, rc: %d",
|
|
|
|
+ csiphy_dev->soc_info.index, rc);
|
|
|
|
+ rc = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
csiphy_dev->combo_mode = 0;
|
|
csiphy_dev->combo_mode = 0;
|
|
csiphy_dev->csiphy_state = CAM_CSIPHY_INIT;
|
|
csiphy_dev->csiphy_state = CAM_CSIPHY_INIT;
|
|
}
|
|
}
|
|
@@ -2063,6 +2116,8 @@ release_mutex:
|
|
|
|
|
|
void cam_csiphy_register_baseaddress(struct csiphy_device *csiphy_dev)
|
|
void cam_csiphy_register_baseaddress(struct csiphy_device *csiphy_dev)
|
|
{
|
|
{
|
|
|
|
+ int phy_idx;
|
|
|
|
+
|
|
if (!csiphy_dev) {
|
|
if (!csiphy_dev) {
|
|
CAM_WARN(CAM_CSIPHY, "Data is NULL");
|
|
CAM_WARN(CAM_CSIPHY, "Data is NULL");
|
|
return;
|
|
return;
|
|
@@ -2074,10 +2129,12 @@ void cam_csiphy_register_baseaddress(struct csiphy_device *csiphy_dev)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- g_phy_data[csiphy_dev->soc_info.index].base_address =
|
|
|
|
|
|
+ phy_idx = csiphy_dev->soc_info.index;
|
|
|
|
+ g_phy_data[phy_idx].base_address =
|
|
csiphy_dev->soc_info.reg_map[0].mem_base;
|
|
csiphy_dev->soc_info.reg_map[0].mem_base;
|
|
- g_phy_data[csiphy_dev->soc_info.index].cpas_handle =
|
|
|
|
|
|
+ g_phy_data[phy_idx].cpas_handle =
|
|
csiphy_dev->cpas_handle;
|
|
csiphy_dev->cpas_handle;
|
|
- g_phy_data[csiphy_dev->soc_info.index].aon_sel_param =
|
|
|
|
|
|
+ g_phy_data[phy_idx].aon_sel_param =
|
|
csiphy_dev->ctrl_reg->csiphy_reg.aon_sel_params;
|
|
csiphy_dev->ctrl_reg->csiphy_reg.aon_sel_params;
|
|
|
|
+ g_phy_data[phy_idx].enable_aon_support = false;
|
|
}
|
|
}
|