mirror of
https://github.com/commaai/agnos-kernel-sdm845.git
synced 2026-06-08 11:24:51 +08:00
camera:TOF
Repair eeprom bug. Issue-Id: task87654 Change-Id: I6185e5fe4679e95e0805b5a8622e74e005a7573e
This commit is contained in:
@@ -339,6 +339,14 @@
|
||||
cell-index = <1>;
|
||||
reg = <0x1>;
|
||||
compatible = "qcom,eeprom";
|
||||
eeprom-name = "pana_addi9033";
|
||||
slave-addr = <0xac>;
|
||||
num-blocks = <1>;
|
||||
i2c-freq-mode = <1>;
|
||||
|
||||
page0 = <0 0x0 2 0x0 1 0>;
|
||||
poll0 = <0 0x0 2 0x0 1 0>;
|
||||
mem0 = <0x870 0x0 2 0x0 1 0>;
|
||||
TOF-eeprom = <1>;
|
||||
/*if the regulator is NULL, camera probe would fail*/
|
||||
cam_vio-supply = <&pm8998_lvs1>;
|
||||
@@ -361,6 +369,11 @@
|
||||
gpio-req-tbl-flags = <1 0>;
|
||||
gpio-req-tbl-label = "CAMIF_MCLK1","CAM_RESET1";
|
||||
cci-master = <0>;
|
||||
qcom,cam-power-seq-type ="cam_reset","cam_vio","cam_clk","cam_reset";
|
||||
qcom,cam-power-seq-val = "cam_reset","cam_vio"
|
||||
,"cam_mclk","cam_reset";
|
||||
qcom,cam-power-seq-cfg-val = <0 1 24000000 1>;
|
||||
qcom,cam-power-seq-delay = <1 0 1 18>;
|
||||
status = "ok";
|
||||
clocks = <&clock_camcc CAM_CC_MCLK1_CLK>;
|
||||
clock-names = "cam_clk";
|
||||
|
||||
@@ -354,6 +354,10 @@ int32_t cam_eeprom_parse_read_memory_map(struct device_node *of_node,
|
||||
goto power_down;
|
||||
}
|
||||
|
||||
if(if_tof_sensor_check(e_ctrl) && check_kobj() == NULL){
|
||||
cam_eeprom_module_offload(e_ctrl,e_ctrl->cal_data.mapdata,0);
|
||||
}
|
||||
|
||||
rc = cam_eeprom_power_down(e_ctrl);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_EEPROM, "failed: eeprom power down rc %d", rc);
|
||||
@@ -783,15 +787,17 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg)
|
||||
switch (csl_packet->header.op_code & 0xFFFFFF) {
|
||||
case CAM_EEPROM_PACKET_OPCODE_INIT:
|
||||
if (e_ctrl->userspace_probe == false) {
|
||||
rc = cam_eeprom_parse_read_memory_map(
|
||||
e_ctrl->soc_info.dev->of_node, e_ctrl);
|
||||
if (rc < 0) {
|
||||
CAM_ERR(CAM_EEPROM, "Failed: rc : %d", rc);
|
||||
return rc;
|
||||
if(!if_tof_sensor_check(e_ctrl)){
|
||||
rc = cam_eeprom_parse_read_memory_map(
|
||||
e_ctrl->soc_info.dev->of_node, e_ctrl);
|
||||
if (rc < 0) {
|
||||
CAM_ERR(CAM_EEPROM, "Failed: rc : %d", rc);
|
||||
return rc;
|
||||
}
|
||||
rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
|
||||
vfree(e_ctrl->cal_data.mapdata);
|
||||
vfree(e_ctrl->cal_data.map);
|
||||
}
|
||||
rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
|
||||
vfree(e_ctrl->cal_data.mapdata);
|
||||
vfree(e_ctrl->cal_data.map);
|
||||
e_ctrl->cal_data.num_data = 0;
|
||||
e_ctrl->cal_data.num_map = 0;
|
||||
CAM_DBG(CAM_EEPROM,
|
||||
@@ -821,17 +827,18 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg)
|
||||
}
|
||||
|
||||
e_ctrl->cam_eeprom_state = CAM_EEPROM_CONFIG;
|
||||
rc = cam_eeprom_read_memory(e_ctrl, &e_ctrl->cal_data);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_EEPROM,
|
||||
"read_eeprom_memory failed");
|
||||
goto power_down;
|
||||
if(!(if_tof_sensor_check(e_ctrl) && check_kobj() != NULL)){
|
||||
rc = cam_eeprom_read_memory(e_ctrl, &e_ctrl->cal_data);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_EEPROM,
|
||||
"read_eeprom_memory failed");
|
||||
goto power_down;
|
||||
}
|
||||
}
|
||||
/*for tof camera Begin*/
|
||||
if(if_tof_sensor_check(e_ctrl)){
|
||||
CAM_INFO(CAM_EEPROM,"is tof sensor");
|
||||
if(if_tof_sensor_check(e_ctrl) && check_kobj() == NULL){
|
||||
tof_eeprom_ctrl
|
||||
= cam_eeprom_module_offload(e_ctrl,e_ctrl->cal_data.mapdata);
|
||||
= cam_eeprom_module_offload(e_ctrl,e_ctrl->cal_data.mapdata,1);
|
||||
if(tof_eeprom_ctrl != NULL){
|
||||
ret = cam_eeprom_create_list(e_ctrl,tof_eeprom_ctrl);
|
||||
if(ret == 0){
|
||||
@@ -840,8 +847,9 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg)
|
||||
}
|
||||
}
|
||||
/*for tof camera End*/
|
||||
|
||||
rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
|
||||
if(!if_tof_sensor_check(e_ctrl)){
|
||||
rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
|
||||
}
|
||||
rc = cam_eeprom_power_down(e_ctrl);
|
||||
e_ctrl->cam_eeprom_state = CAM_EEPROM_ACQUIRE;
|
||||
vfree(e_ctrl->cal_data.mapdata);
|
||||
|
||||
@@ -465,6 +465,10 @@ static int32_t cam_eeprom_platform_driver_probe(
|
||||
|
||||
e_ctrl->cam_eeprom_state = CAM_EEPROM_INIT;
|
||||
|
||||
if(if_tof_sensor_check(e_ctrl)){
|
||||
cam_eeprom_parse_read_memory_map(e_ctrl->soc_info.dev->of_node,e_ctrl);
|
||||
e_ctrl->userspace_probe = true;
|
||||
}
|
||||
return rc;
|
||||
free_soc:
|
||||
kfree(soc_private);
|
||||
|
||||
@@ -196,6 +196,11 @@ void tl_eeprom_create_node(void) {
|
||||
}
|
||||
}
|
||||
|
||||
struct kobject * check_kobj(void)
|
||||
{
|
||||
return eeprom_kobj;
|
||||
}
|
||||
|
||||
static void cam_eeprom_format_data_cnv_u16_c(uint16_t *p_in16,
|
||||
char *p_out8, uint16_t u16_num)
|
||||
{
|
||||
@@ -766,9 +771,9 @@ static TL_E_RESULT cam_eeprom_format_calibration_mode_data_read(
|
||||
|
||||
tof_eeprom->control_value = p_eep->pls_mod.control;
|
||||
|
||||
memcpy((void*)p_eep->pls_mod.val,
|
||||
(void*)(p_mode + TL_EEPROM_OFFSET(TL_EEPROM_PLS_MOD_VAL)),
|
||||
TL_EEPROM_ARY_SIZE(p_eep->pls_mod.val) * sizeof(uint16_t));
|
||||
// memcpy((void*)p_eep->pls_mod.val,
|
||||
// (void*)(p_mode + TL_EEPROM_OFFSET(TL_EEPROM_PLS_MOD_VAL)),
|
||||
// TL_EEPROM_ARY_SIZE(p_eep->pls_mod.val) * sizeof(uint16_t));
|
||||
for(i=0;i<TL_EEPROM_ARY_SIZE(p_eep->pls_mod.val);i++){
|
||||
p_eep->pls_mod.val[i]
|
||||
= TL_EEPROM_OFST_VAL(p_mode,TL_EEPROM_PLS_MOD_VAL + i * 2);
|
||||
@@ -868,32 +873,58 @@ static int cam_eeprom_read_init_data_from_file(tl_dev_eeprom_pup *tof_eeprom,uin
|
||||
|
||||
tl_dev_eeprom_pup* cam_eeprom_module_offload(
|
||||
struct cam_eeprom_ctrl_t *e_ctrl,
|
||||
uint8_t *mapdata)
|
||||
uint8_t *mapdata,int cmd)
|
||||
{
|
||||
uint32_t e_size,tmp_vc,pup_size;//,reg_val;
|
||||
int i;
|
||||
uint32_t e_size,tmp_vc,pup_size,idle_size;
|
||||
int i,j;
|
||||
uint16_t *p_cmn = (uint16_t *)mapdata;
|
||||
uint16_t *p_init = (uint16_t *)mapdata;
|
||||
tl_dev_rom_common *p_eep = NULL;
|
||||
TL_E_RESULT tl_ret = TL_E_SUCCESS;
|
||||
|
||||
|
||||
if(cmd == 0){
|
||||
tof_eeprom = kzalloc(sizeof(tl_dev_eeprom_pup),GFP_KERNEL);
|
||||
if(tof_eeprom == NULL)
|
||||
return NULL;
|
||||
|
||||
e_size = e_ctrl->cal_data.num_data/2;
|
||||
|
||||
for(i = 0; i <(int)e_size; i++){
|
||||
*(p_cmn + i)
|
||||
= (uint16_t)((uint16_t)(*(p_cmn + i) & 0x00FFU) << 8U)
|
||||
| ((uint16_t)(*(p_cmn + i) & 0xFF00U) >> 8U);
|
||||
tof_eeprom->p_cmn_mode[i] = *(p_cmn + i);
|
||||
}
|
||||
#if 0
|
||||
tof_eeprom->afe_reg.revision_addr = 0xC0FFU;
|
||||
for(j = 0;j < TL_E_MODE_MAX;j++){
|
||||
idle_size = TL_EEPROM_OFST_VAL(p_cmn+TL_EEPROM_MODE_TOP(j),TL_EEPROM_IDLE_PERI_NUM);
|
||||
for(i = 0;i < idle_size;i++){
|
||||
tof_eeprom->afe_reg.idle_reg[j].addr[i]
|
||||
= TL_EEPROM_OFST_VAL(p_cmn+TL_EEPROM_MODE_TOP(j),TL_EEPROM_IDLE_PERI_ADR1 + i * 2);
|
||||
}
|
||||
tof_eeprom->afe_reg.idle_reg[j].size = idle_size;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(cmd == 1){
|
||||
p_cmn = &tof_eeprom->p_cmn_mode[0];
|
||||
}
|
||||
if(e_ctrl->cal_data.num_data == 0){
|
||||
CAM_ERR(CAM_EEPROM,"failed,OTP/EEPROM empty");
|
||||
return NULL;
|
||||
}
|
||||
if(tof_eeprom){
|
||||
kfree(tof_eeprom);
|
||||
tof_eeprom = NULL;
|
||||
}
|
||||
tof_eeprom = kzalloc(sizeof(tl_dev_eeprom_pup),GFP_KERNEL);
|
||||
if(tof_eeprom == NULL)
|
||||
return NULL;
|
||||
|
||||
p_eep = &(tof_eeprom->eeprom.cmn);
|
||||
e_size = e_ctrl->cal_data.num_data/2;
|
||||
|
||||
for(i = 0; i <(int)e_size; i++){
|
||||
*(p_cmn + i)
|
||||
= (uint16_t)((uint16_t)(*(p_cmn + i) & 0x00FFU) << 8U)
|
||||
| ((uint16_t)(*(p_cmn + i) & 0xFF00U) >> 8U);
|
||||
*(p_init + i)
|
||||
= (uint16_t)((uint16_t)(*(p_init + i) & 0x00FFU) << 8U)
|
||||
| ((uint16_t)(*(p_init + i) & 0xFF00U) >> 8U);
|
||||
}
|
||||
//check version
|
||||
tl_ret = tl_dev_eeprom_check_map_version(
|
||||
@@ -901,7 +932,7 @@ tl_dev_eeprom_pup* cam_eeprom_module_offload(
|
||||
if(tl_ret != TL_E_SUCCESS){
|
||||
CAM_ERR(CAM_EEPROM,"failed check map version = %#x",
|
||||
(TL_EEPROM_OFST_VAL(p_cmn,TL_EEPROM_MAP_VER)));
|
||||
// goto free_kz;
|
||||
goto free_kz;
|
||||
}
|
||||
//check module type
|
||||
tl_ret = tl_dev_eeprom_check_module_type(
|
||||
@@ -926,8 +957,7 @@ tl_dev_eeprom_pup* cam_eeprom_module_offload(
|
||||
tof_eeprom->pup_size = pup_size/2;
|
||||
//pup
|
||||
|
||||
memcpy(tof_eeprom->pup_data,p_cmn
|
||||
+ TL_EEPROM_OFFSET(TL_EEPROM_PUP_TOP),pup_size);
|
||||
memcpy(tof_eeprom->pup_data,p_init,pup_size);
|
||||
|
||||
// read initial data from rom file if necessary
|
||||
// cam_eeprom_read_init_data_from_file(tof_eeprom,pup_size);
|
||||
@@ -953,9 +983,9 @@ tl_dev_eeprom_pup* cam_eeprom_module_offload(
|
||||
}
|
||||
}
|
||||
for(i = 0; i <(int)e_size; i++){
|
||||
*(p_cmn + i)
|
||||
= (uint16_t)((uint16_t)(*(p_cmn + i) & 0x00FFU) << 8U)
|
||||
| ((uint16_t)(*(p_cmn + i) & 0xFF00U) >> 8U);
|
||||
*(p_init + i)
|
||||
= (uint16_t)((uint16_t)(*(p_init + i) & 0x00FFU) << 8U)
|
||||
| ((uint16_t)(*(p_init + i) & 0xFF00U) >> 8U);
|
||||
}
|
||||
|
||||
return tof_eeprom;
|
||||
|
||||
@@ -139,11 +139,16 @@ int cam_eeprom_spi_parse_of(struct cam_sensor_spi_client *spi_dev)
|
||||
int cam_eeprom_parse_dt_memory_map(struct device_node *node,
|
||||
struct cam_eeprom_memory_block_t *data)
|
||||
{
|
||||
int i, rc = 0;
|
||||
int i, tof,rc = 0;
|
||||
char property[PROPERTY_MAXSIZE];
|
||||
uint32_t count = MSM_EEPROM_MEM_MAP_PROPERTIES_CNT;
|
||||
struct cam_eeprom_memory_map_t *map;
|
||||
|
||||
rc = of_property_read_u32(node, "TOF-eeprom",
|
||||
&tof);
|
||||
if (tof == 1) {
|
||||
count = 6;
|
||||
}
|
||||
snprintf(property, PROPERTY_MAXSIZE, "num-blocks");
|
||||
rc = of_property_read_u32(node, property, &data->num_map);
|
||||
if (rc < 0) {
|
||||
|
||||
@@ -217,6 +217,7 @@ typedef struct {
|
||||
uint16_t tof_seq_ini_ofst; /* Offset from the positive edge of HD to the start of exposure */
|
||||
uint16_t idle_peri_num; /* Number of idle*/
|
||||
uint16_t idle_peri_adr[4]; /* Each addr of idle*/
|
||||
uint16_t afe_idle_val[4];
|
||||
} tl_dev_rom_exp_prm;
|
||||
|
||||
/* mode : nonlinear correction */
|
||||
@@ -316,6 +317,7 @@ typedef struct {
|
||||
/* EEPROM data for device control */
|
||||
typedef struct {
|
||||
tl_dev_eeprom eeprom;
|
||||
uint16_t p_cmn_mode[TL_EEPROM_CMN_AREA_MAX_SIZE];
|
||||
/* Power-Up Sequenece data */
|
||||
uint16_t pup_data[TL_EEPROM_PUP_AREA_MAX_SIZE];
|
||||
bool list_create;
|
||||
@@ -324,11 +326,12 @@ typedef struct {
|
||||
uint16_t control_value;
|
||||
} tl_dev_eeprom_pup;
|
||||
|
||||
tl_dev_eeprom_pup* cam_eeprom_module_offload(struct cam_eeprom_ctrl_t *e_ctrl,uint8_t *mapdata);
|
||||
tl_dev_eeprom_pup* cam_eeprom_module_offload(struct cam_eeprom_ctrl_t *e_ctrl,uint8_t *mapdata,int cmd);
|
||||
|
||||
int cam_eeprom_create_list(struct cam_eeprom_ctrl_t *e_ctrl,tl_dev_eeprom_pup *tof_eeprom);
|
||||
|
||||
void tl_eeprom_create_node(void);
|
||||
void cam_eeprom_free_kobj(void);
|
||||
struct kobject * check_kobj(void);
|
||||
|
||||
#endif /* H_TL_DEV_EEPROM */
|
||||
|
||||
@@ -48,7 +48,9 @@ enum {
|
||||
#define TL_EEPROM_MODE_AREA_SIZE (624U)
|
||||
|
||||
/* size of Power-Up Sequence area(maximum) [byte] */
|
||||
#define TL_EEPROM_PUP_AREA_MAX_SIZE (7618U)
|
||||
#define TL_EEPROM_PUP_AREA_MAX_SIZE (4041U)
|
||||
#define TL_EEPROM_CMN_AREA_MAX_SIZE (1080U)
|
||||
#define TL_EEPROM_AFE_ADDR_MAX_SIZE (5U)
|
||||
|
||||
|
||||
/* start address of common area */
|
||||
|
||||
@@ -908,6 +908,8 @@ int cam_get_dt_power_setting_data(struct device_node *of_node,
|
||||
ps[i].seq_type = SENSOR_VANA;
|
||||
} else if (!strcmp(seq_name, "cam_clk")) {
|
||||
ps[i].seq_type = SENSOR_MCLK;
|
||||
} else if (!strcmp(seq_name, "cam_reset")) {
|
||||
ps[i].seq_type = SENSOR_RESET;
|
||||
} else {
|
||||
CAM_ERR(CAM_SENSOR, "unrecognized seq-type %s",
|
||||
seq_name);
|
||||
|
||||
Reference in New Issue
Block a user