bangkk: Secondary supply flash driver ic compatible

details:
1.dts add distinguish-flash-supplier=<DevAddr,FlashIdRegAddr,FlashId>
2.ioctl query cap,distinguish flash.
3.if cci read FlashIdRegAddr is FlashId,this is sencondary,flash_supplier return 1.
4.if don't find distinguish-flash-supplier,flash_supplier is default

Change-Id: Ie48452465892ea4728272634010fd5c966b68986
Signed-off-by: tin_qiquan.zhou_tmp <tinno70@motorola.com>
Reviewed-on: https://gerrit.mot.com/2573829
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: <hezheng1@motorola.com>
Reviewed-by: <huqian4@motorola.com>
Reviewed-by: <yanglp10@motorola.com>
Reviewed-by: <leijing1@motorola.com>
Reviewed-by: Zhichao Chen <chenzc2@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
tin_qiquan.zhou_tmp 2023-04-12 18:05:32 +08:00 • committed by zhaoji1
commit eaea2579ad
4 changed files with 137 additions and 3 deletions

View file

@ -2117,3 +2117,98 @@ int cam_flash_apply_request(struct cam_req_mgr_apply_request *apply)
return rc;
}
#ifdef CONFIG_CAMERA_FLASH_IIC_COMPATIBLE
static int cam_flash_construct_power_vio_setting(
struct cam_sensor_power_ctrl_t *power_info)
{
int rc = 0;
power_info->power_setting_size = 2;
power_info->power_setting =
kzalloc(sizeof(struct cam_sensor_power_setting) * 2,
GFP_KERNEL);
if (!power_info->power_setting)
return -ENOMEM;
power_info->power_setting[0].seq_type = SENSOR_VIO;
power_info->power_setting[0].seq_val = CAM_VIO;
power_info->power_setting[0].config_val = 1;
power_info->power_setting[0].delay = 2;
power_info->power_setting[1].seq_type = SENSOR_CUSTOM_GPIO1;
power_info->power_setting[1].seq_val = 0;
power_info->power_setting[1].config_val = 1;
power_info->power_setting[1].delay = 0;
power_info->power_down_setting_size = 2;
power_info->power_down_setting =
kzalloc(sizeof(struct cam_sensor_power_setting) * 2,
GFP_KERNEL);
if (!power_info->power_down_setting) {
rc = -ENOMEM;
goto free_power_settings;
}
power_info->power_down_setting[0].seq_type = SENSOR_CUSTOM_GPIO1;
power_info->power_down_setting[0].seq_val = 0;
power_info->power_down_setting[0].config_val = 0;
power_info->power_down_setting[0].seq_type = SENSOR_VIO;
power_info->power_down_setting[0].seq_val = CAM_VIO;
power_info->power_down_setting[0].config_val = 0;
return rc;
free_power_settings:
kfree(power_info->power_setting);
power_info->power_setting = NULL;
power_info->power_setting_size = 0;
return rc;
}
int cam_flash_fill_vreg_setting(struct cam_flash_ctrl *fctrl)
{
int rc = 0;
rc = cam_flash_construct_power_vio_setting(
&fctrl->power_info);
if (rc) {
CAM_ERR(CAM_FLASH, "Failed Flash Power VIO Setting: rc=%d\n", rc);
return rc;
}
rc = msm_camera_fill_vreg_params(&fctrl->soc_info,
fctrl->power_info.power_setting,
fctrl->power_info.power_setting_size);
if(rc)
{
CAM_ERR(CAM_FLASH, "Failed Flash Fill Power Up Params: rc=%d\n", rc);
return rc;
}
rc = msm_camera_fill_vreg_params(&fctrl->soc_info,
fctrl->power_info.power_down_setting,
fctrl->power_info.power_down_setting_size);
if(rc)
{
CAM_ERR(CAM_FLASH, "Failed Flash Fill Power Down Params: rc=%d\n", rc);
return rc;
}
return rc;
}
int cam_flash_fill_i2c_default_setting(struct cam_flash_ctrl *fctrl, uint32_t slave_addr)
{
int rc = 0;
struct cam_cmd_i2c_info i2c_info={0};
i2c_info.slave_addr = slave_addr;
i2c_info.i2c_freq_mode = I2C_STANDARD_MODE;
rc = cam_flash_slaveInfo_pkt_parser(
fctrl, (uint32_t *)&i2c_info, sizeof(struct cam_cmd_i2c_info));
if (rc < 0) {
CAM_ERR(CAM_FLASH,
"Failed parsing slave info: rc: %d",
rc);
}
return rc;
}
#endif

View file

@ -141,7 +141,10 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
}
case CAM_QUERY_CAP: {
struct cam_flash_query_cap_info flash_cap = {0};
#ifdef CONFIG_CAMERA_FLASH_IIC_COMPATIBLE
uint32_t flash_iic_supplier[3];
uint32_t flashid=0;
#endif
CAM_DBG(CAM_FLASH, "CAM_QUERY_CAP");
flash_cap.slot_info = fctrl->soc_info.index;
flash_cap.flash_type = soc_private->flash_type;
@ -159,7 +162,39 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
for (i = 0; i < fctrl->torch_num_sources; i++)
flash_cap.max_current_torch[i] =
soc_private->torch_max_current[i];
#ifdef CONFIG_CAMERA_FLASH_IIC_COMPATIBLE
rc = of_property_read_u32_array(fctrl->of_node, "distinguish-flash-supplier",
flash_iic_supplier, 3);
if (!rc) {
CAM_DBG(CAM_FLASH, "Distinguish IIC Flash Supplier dev:0x%x addr:0x%x data:0x%x",
flash_iic_supplier[0],flash_iic_supplier[1],flash_iic_supplier[2]);
if (cam_flash_fill_vreg_setting(fctrl)){
CAM_ERR(CAM_FLASH, "Flash Fill Vreg Failed");
goto release_mutex;
}
if (fctrl->func_tbl.power_ops(fctrl, true)){
CAM_ERR(CAM_FLASH, "Power Up Failed");
goto release_mutex;
}
if (cam_flash_fill_i2c_default_setting(fctrl, flash_iic_supplier[0])){
CAM_ERR(CAM_FLASH, "Failed Flash Fill I2C Setting rc =%d",rc);
goto release_mutex;
}
rc = camera_io_dev_read(&(fctrl->io_master_info),
flash_iic_supplier[1],&flashid,
CAMERA_SENSOR_I2C_TYPE_BYTE,
CAMERA_SENSOR_I2C_TYPE_BYTE);
CAM_DBG(CAM_FLASH, "flashid=%d",flashid);
if ((!rc) && (flashid == flash_iic_supplier[2]))
flash_cap.flash_supplier = 1;
else
flash_cap.flash_supplier = 0;
if (fctrl->func_tbl.power_ops(fctrl, false)){
CAM_ERR(CAM_FLASH, "Power Down Failed");
goto release_mutex;
}
}
#endif
if (copy_to_user(u64_to_user_ptr(cmd->handle),
&flash_cap, sizeof(struct cam_flash_query_cap_info))) {
CAM_ERR(CAM_FLASH, "Failed Copy to User");

View file

@ -242,7 +242,10 @@ int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl,
enum cam_flash_flush_type, uint64_t req_id);
void cam_flash_shutdown(struct cam_flash_ctrl *fctrl);
int cam_flash_release_dev(struct cam_flash_ctrl *fctrl);
#ifdef CONFIG_CAMERA_FLASH_IIC_COMPATIBLE
int cam_flash_fill_i2c_default_setting(struct cam_flash_ctrl *fctrl, uint32_t slave_addr);
int cam_flash_fill_vreg_setting(struct cam_flash_ctrl *fctrl);
#endif
/**
* @brief : API to register FLASH hw to platform framework.
* @return struct platform_device pointer on on success, or ERR_PTR() on error.

View file

@ -508,6 +508,7 @@ struct cam_flash_query_cap_info {
__u32 max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
__u32 max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
__u32 flash_type;
__u32 flash_supplier;
} __attribute__ ((packed));
#endif