From f8d9ddc7a4febf5c430d72f9267055aaea14526e Mon Sep 17 00:00:00 2001 From: Jigar Agrawal Date: Thu, 10 Mar 2022 15:24:05 -0800 Subject: [PATCH] msm: camera: csiphy: Add support for multiple AON Cameras Add support for more than one AON cameras for SM8650 target. CRs-Fixed: 3149294 Change-Id: I842317ab59812109785a026fd0f728baf837b27f Signed-off-by: Jigar Agrawal --- .../cam_csiphy/cam_csiphy_core.c | 30 ++++++++++++------- .../cam_csiphy/cam_csiphy_core.h | 5 ++-- .../cam_csiphy/cam_csiphy_dev.h | 2 +- .../include/cam_csiphy_2_1_0_hwreg.h | 3 +- .../include/cam_csiphy_2_1_2_hwreg.h | 3 +- .../include/cam_csiphy_2_1_3_hwreg.h | 3 +- .../cam_sensor/cam_sensor_core.c | 4 +-- .../cam_sensor/cam_sensor_dev.h | 8 ++--- .../cam_sensor/cam_sensor_soc.c | 16 ++++------ .../cam_sensor_utils/cam_sensor_util.h | 7 +++-- dt-bindings/msm-camera.h | 6 ++++ 11 files changed, 51 insertions(+), 36 deletions(-) diff --git a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c index 0ddfea42c9..685eb852f9 100644 --- a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c +++ b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c @@ -47,7 +47,7 @@ struct g_csiphy_data { uint32_t cpas_handle; bool is_configured_for_main; uint64_t data_rate_aux_mask; - bool enable_aon_support; + uint8_t aon_cam_id; struct cam_csiphy_aon_sel_params_t *aon_sel_param; }; @@ -1312,6 +1312,17 @@ static int __csiphy_cpas_configure_for_main_or_aon( uint32_t aon_config = 0; uint32_t cpas_handle = g_phy_data[phy_idx].cpas_handle; + if (g_phy_data[phy_idx].aon_cam_id == NOT_AON_CAM) { + CAM_ERR(CAM_CSIPHY, "Not an AON Camera"); + return -EINVAL; + } + + if (!aon_sel_params->aon_cam_sel_offset[g_phy_data[phy_idx].aon_cam_id]) { + CAM_ERR(CAM_CSIPHY, "Mux register offset can not be 0. AON_Cam_ID: %u", + g_phy_data[phy_idx].aon_cam_id); + return -EINVAL; + } + if (get_access == g_phy_data[phy_idx].is_configured_for_main) { CAM_DBG(CAM_CSIPHY, "Already Configured/Released for %s", get_access ? "Main" : "AON"); @@ -1325,7 +1336,7 @@ static int __csiphy_cpas_configure_for_main_or_aon( } cam_cpas_reg_read(cpas_handle, CAM_CPAS_REG_CPASTOP, - aon_sel_params->aon_cam_sel_offset, + aon_sel_params->aon_cam_sel_offset[g_phy_data[phy_idx].aon_cam_id], true, &aon_config); if (get_access && !g_phy_data[phy_idx].is_configured_for_main) { @@ -1344,7 +1355,7 @@ static int __csiphy_cpas_configure_for_main_or_aon( CAM_DBG(CAM_CSIPHY, "value of aon_config = %u", aon_config); rc = cam_cpas_reg_write(cpas_handle, CAM_CPAS_REG_CPASTOP, - aon_sel_params->aon_cam_sel_offset, + aon_sel_params->aon_cam_sel_offset[g_phy_data[phy_idx].aon_cam_id], true, aon_config); if (rc) CAM_ERR(CAM_CSIPHY, "CPAS AON sel register write failed"); @@ -1354,8 +1365,7 @@ static int __csiphy_cpas_configure_for_main_or_aon( return rc; } -int cam_csiphy_util_update_aon_registration - (uint32_t phy_idx, bool is_aon_user) +int cam_csiphy_util_update_aon_registration(uint32_t phy_idx, uint8_t aon_cam_id) { /* aon support enable for the sensor associated with phy idx*/ if (phy_idx >= MAX_CSIPHY) { @@ -1369,7 +1379,7 @@ int cam_csiphy_util_update_aon_registration return -EINVAL; } - g_phy_data[phy_idx].enable_aon_support = is_aon_user; + g_phy_data[phy_idx].aon_cam_id = aon_cam_id; return 0; } @@ -1401,7 +1411,7 @@ int cam_csiphy_util_update_aon_ops( mutex_lock(&main_aon_selection); - CAM_DBG(CAM_CSIPHY, "PHY idx: %d, AON_support is %s", phy_idx, + CAM_DBG(CAM_CSIPHY, "PHY idx: %d, AON_support %s", phy_idx, (get_access) ? "enable" : "disable"); rc = __csiphy_cpas_configure_for_main_or_aon( @@ -1863,7 +1873,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev, g_phy_data[soc_info->index].is_3phase); } - if (g_phy_data[soc_info->index].enable_aon_support) { + if (g_phy_data[soc_info->index].aon_cam_id != NOT_AON_CAM) { rc = cam_csiphy_util_update_aon_ops(true, soc_info->index); if (rc) { CAM_ERR(CAM_CSIPHY, @@ -2048,7 +2058,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev, if (csiphy_dev->acquire_count == 0) { CAM_DBG(CAM_CSIPHY, "All PHY devices released"); - if (g_phy_data[soc_info->index].enable_aon_support) { + if (g_phy_data[soc_info->index].aon_cam_id != NOT_AON_CAM) { rc = cam_csiphy_util_update_aon_ops(false, soc_info->index); if (rc) { CAM_WARN(CAM_CSIPHY, @@ -2361,7 +2371,7 @@ int cam_csiphy_register_baseaddress(struct csiphy_device *csiphy_dev) csiphy_dev->cpas_handle; g_phy_data[phy_idx].aon_sel_param = csiphy_dev->ctrl_reg->csiphy_reg->aon_sel_params; - g_phy_data[phy_idx].enable_aon_support = false; + g_phy_data[phy_idx].aon_cam_id = NOT_AON_CAM; g_phy_data[phy_idx].is_configured_for_main = false; g_phy_data[phy_idx].data_rate_aux_mask = 0; diff --git a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.h b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.h index 05fc078587..2ce054328a 100644 --- a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.h +++ b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.h @@ -84,11 +84,12 @@ void cam_csiphy_update_auxiliary_mask(struct csiphy_device *csiphy_dev); int cam_csiphy_dump_status_reg(struct csiphy_device *csiphy_dev); /** - * @phy_idx : To acquire the correct PHY hw to do the operation with + * @phy_idx : To acquire the correct PHY hw to do the operation with + * @aon_camera_id : AON Camera ID * * This API provides Utility/helper function to register AON Hw supprot for * correct PHY hw. * */ -int cam_csiphy_util_update_aon_registration(uint32_t phy_idx, bool is_aon_user); +int cam_csiphy_util_update_aon_registration(uint32_t phy_idx, uint8_t aon_camera_id); #endif /* _CAM_CSIPHY_CORE_H_ */ diff --git a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h index 77ec191e39..57898156f6 100644 --- a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h +++ b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h @@ -96,7 +96,7 @@ enum cam_csiphy_common_reg_program { * @mclk_sel_mask : MCLK select mask. */ struct cam_csiphy_aon_sel_params_t { - uint32_t aon_cam_sel_offset; + uint32_t aon_cam_sel_offset[MAX_AON_CAM]; uint32_t cam_sel_mask; uint32_t mclk_sel_mask; }; diff --git a/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_0_hwreg.h b/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_0_hwreg.h index f9b0c4cc79..6b2bee07f9 100644 --- a/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_0_hwreg.h +++ b/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_0_hwreg.h @@ -10,7 +10,8 @@ #include "../cam_csiphy_dev.h" struct cam_csiphy_aon_sel_params_t aon_cam_select_params = { - .aon_cam_sel_offset = 0x01E0, + .aon_cam_sel_offset[0] = 0x01E0, + .aon_cam_sel_offset[1] = 0, .cam_sel_mask = BIT(0), .mclk_sel_mask = BIT(8), }; diff --git a/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_2_hwreg.h b/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_2_hwreg.h index 00f354c971..f9ad2f1882 100644 --- a/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_2_hwreg.h +++ b/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_2_hwreg.h @@ -9,7 +9,8 @@ #include "../cam_csiphy_dev.h" struct cam_csiphy_aon_sel_params_t aon_cam_select_params_2_1_2 = { - .aon_cam_sel_offset = 0x01E0, + .aon_cam_sel_offset[0] = 0x01E0, + .aon_cam_sel_offset[1] = 0, .cam_sel_mask = BIT(0), .mclk_sel_mask = BIT(8), }; diff --git a/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_3_hwreg.h b/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_3_hwreg.h index 411dd21657..c96cfdf6d8 100644 --- a/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_3_hwreg.h +++ b/drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_3_hwreg.h @@ -10,7 +10,8 @@ #include "../cam_csiphy_dev.h" struct cam_csiphy_aon_sel_params_t aon_cam_select_params_2_1_3 = { - .aon_cam_sel_offset = 0x01E0, + .aon_cam_sel_offset[0] = 0x01E0, + .aon_cam_sel_offset[1] = 0, .cam_sel_mask = BIT(0), .mclk_sel_mask = BIT(8), }; diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c index f4ff63757e..01542e2ae6 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c @@ -1379,7 +1379,7 @@ int cam_sensor_power_up(struct cam_sensor_ctrl_t *s_ctrl) } } - if (s_ctrl->is_aon_user) { + if (s_ctrl->aon_camera_id != NOT_AON_CAM) { CAM_INFO(CAM_SENSOR, "Setup for Main Camera with csiphy index: %d", s_ctrl->sensordata->subdev_id[SUB_MODULE_CSIPHY]); @@ -1442,7 +1442,7 @@ int cam_sensor_power_down(struct cam_sensor_ctrl_t *s_ctrl) return rc; } - if (s_ctrl->is_aon_user) { + if (s_ctrl->aon_camera_id != NOT_AON_CAM) { CAM_INFO(CAM_SENSOR, "Setup for AON FW with csiphy index: %d", s_ctrl->sensordata->subdev_id[SUB_MODULE_CSIPHY]); diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h b/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h index 76181cc7d9..5473f53872 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_SENSOR_DEV_H_ @@ -86,7 +87,7 @@ struct sensor_intf_params { * @last_flush_req: Last request to flush * @pipeline_delay: Sensor pipeline delay * @sensor_name: Sensor name - * @is_aon_user: To determine whether sensor is AON user or not + * @aon_camera_id: AON Camera ID associated with this sensor */ struct cam_sensor_ctrl_t { char device_name[ @@ -114,9 +115,8 @@ struct cam_sensor_ctrl_t { bool bob_pwm_switch; uint32_t last_flush_req; uint16_t pipeline_delay; - char sensor_name[ - CAM_SENSOR_NAME_MAX_SIZE]; - bool is_aon_user; + char sensor_name[CAM_SENSOR_NAME_MAX_SIZE]; + uint8_t aon_camera_id; }; /** diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c b/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c index 32f8333581..73e574f4e8 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -242,21 +243,14 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl) sensordata->pos_yaw = 360; } - if (!of_property_read_bool(of_node, "aon-user")) { - CAM_DBG(CAM_SENSOR, - "SENSOR cell_idx: %d not use for AON usecase", - s_ctrl->soc_info.index); - s_ctrl->is_aon_user = false; - } else { - CAM_DBG(CAM_SENSOR, - "SENSOR cell_idx: %d is user for AON usecase", - s_ctrl->soc_info.index); - s_ctrl->is_aon_user = true; + if (of_property_read_u8(of_node, "aon-camera-id", &s_ctrl->aon_camera_id)) { + CAM_DBG(CAM_SENSOR, "cell_idx: %d is not used for AON usecase", soc_info->index); + s_ctrl->aon_camera_id = NOT_AON_CAM; } rc = cam_sensor_util_aon_registration( s_ctrl->sensordata->subdev_id[SUB_MODULE_CSIPHY], - s_ctrl->is_aon_user); + s_ctrl->aon_camera_id); if (rc) { CAM_ERR(CAM_SENSOR, "Aon registration failed, rc: %d", rc); goto FREE_SENSOR_DATA; diff --git a/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h b/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h index 251a7f0065..75b35450df 100644 --- a/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h +++ b/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_SENSOR_UTIL_H_ @@ -89,10 +90,10 @@ static inline int cam_sensor_util_aon_ops(bool get_access, uint32_t phy_idx) return cam_csiphy_util_update_aon_ops(get_access, phy_idx); } -static inline int cam_sensor_util_aon_registration(uint32_t phy_idx, bool aon_user) +static inline int cam_sensor_util_aon_registration(uint32_t phy_idx, uint8_t aon_camera_id) { - CAM_DBG(CAM_SENSOR, "Regsiter phy_idx: %u for AON operatoin: %d", phy_idx, aon_user); - return cam_csiphy_util_update_aon_registration(phy_idx, aon_user); + CAM_DBG(CAM_SENSOR, "Register phy_idx: %u for AON_Camera_ID: %d", phy_idx, aon_camera_id); + return cam_csiphy_util_update_aon_registration(phy_idx, aon_camera_id); } #endif /* _CAM_SENSOR_UTIL_H_ */ diff --git a/dt-bindings/msm-camera.h b/dt-bindings/msm-camera.h index f867acc631..e4f25ad0df 100644 --- a/dt-bindings/msm-camera.h +++ b/dt-bindings/msm-camera.h @@ -106,4 +106,10 @@ #define CCI_MASTER_1 1 #define CCI_MASTER_MAX 2 +/* AON Camera IDs*/ +#define AON_CAM1 0 +#define AON_CAM2 1 +#define MAX_AON_CAM 2 +#define NOT_AON_CAM 255 + #endif