// index: index of otp group. (1, 2, 3) 
// return: 0, group index is empty 
// 1, group index has invalid data 
// 2, group index has valid data 
int check_otp_lenc(uint index, struct msm_sensor_ctrl_t *s_ctrl) 
{ 
        int flag,  bank; 
        int address; 
        // select bank: index*4 =4,8,12
        bank = 0xc0 | (index*4); 
        ov8835_write_sccb16(0x3d84, bank,s_ctrl); 
        // read otp into buffer 
        ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
        msleep(5); 
        // read flag 
        address = 0x3d00; 
        flag = ov8835_read_sccb16(address,s_ctrl); 
	CDBG("otplenc %s  flag=0x%x",__func__,flag); 
        flag = flag & 0xc0; 
        // disable otp read 
        ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
        // clear otp buffer 
        clear_otp_buffer(s_ctrl); 
        if (flag==0) { 
        return 0; 
        } 
        else if (flag & 0x80) { 
        return 1; 
        } 
        else { 
        return 2; 
        } 
 
} 
Пример #2
0
int check_otp_lenc(uint index, struct msm_sensor_ctrl_t *s_ctrl) 
{ 
        int flag,  bank; 
        int address; 
        
        bank = 0xc0 | (index*4); 
        ov8835_write_sccb16(0x3d84, bank,s_ctrl); 
        
        ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
        msleep(5); 
        
        address = 0x3d00; 
        flag = ov8835_read_sccb16(address,s_ctrl); 
	pr_err("otplenc %s  flag=0x%x",__func__,flag); 
        flag = flag & 0xc0; 
        
        ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
        
        clear_otp_buffer(s_ctrl); 
        if (flag==0) { 
        return 0; 
        } 
        else if (flag & 0x80) { 
        return 1; 
        } 
        else { 
        return 2; 
        } 
 
} 
// index: index of otp group. (1, 2, 3) 
// return: 0 
int read_otp_lenc(uint index, struct otp_struct *otp_ptr, struct msm_sensor_ctrl_t *s_ctrl) 
{ 
 
int bank, i; 
int address; 
// select bank: index*4 
bank = 0xc0 | (index*4); 
ov8835_write_sccb16(0x3d84, bank,s_ctrl); 
// read otp into buffer 
ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d01; 
for(i=0;i<15;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
CDBG("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 
// disable otp read 
ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
// clear otp buffer 
clear_otp_buffer(s_ctrl); 
// select 2nd bank 
bank++; 
ov8835_write_sccb16(0x3d84, bank ,s_ctrl); 
// read otp 
ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
for(i=15;i<31;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
CDBG("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 
// disable otp read 
ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
// clear otp buffer 
clear_otp_buffer(s_ctrl); 
// select 3rd bank 
bank++; 
ov8835_write_sccb16(0x3d84, bank ,s_ctrl); 
// read otp 
ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
for(i=31;i<47;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
CDBG("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 
// disable otp read 
ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
// clear otp buffer 
clear_otp_buffer(s_ctrl); 
// select 4th bank 
bank++; 
ov8835_write_sccb16(0x3d84, bank ,s_ctrl); 
// read otp 
ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
for(i=47;i<62;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
CDBG("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 
// disable otp read 
ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
// clear otp buffer 
clear_otp_buffer(s_ctrl); 
return 0; 
} 
// index: index of otp group. ( 1, 2,3) 
// return: 0, 
int read_otp_wb(uint index, struct otp_struct *otp_ptr, struct msm_sensor_ctrl_t *s_ctrl) 
{ 
int  bank,address,temp; 

// select bank index 
bank = 0xc0 | index; 
ov8835_write_sccb16(0x3d84, bank,s_ctrl); 
// read otp into buffer 
ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
otp_ptr->module_id = ov8835_read_sccb16(address + 1,s_ctrl); 
otp_ptr->lens_id = ov8835_read_sccb16(address + 2,s_ctrl); 
otp_ptr->production_year = ov8835_read_sccb16(address + 3,s_ctrl);
otp_ptr->production_month = ov8835_read_sccb16(address + 4,s_ctrl);
otp_ptr->production_day = ov8835_read_sccb16(address + 5,s_ctrl);

temp=ov8835_read_sccb16(address + 10,s_ctrl); 

otp_ptr->rg_ratio = (ov8835_read_sccb16(address + 6,s_ctrl)<<2)+((temp>>6)&0x03); 
otp_ptr->bg_ratio =(ov8835_read_sccb16(address + 7,s_ctrl)<<2)+((temp>>4)&0x03); 
otp_ptr->light_rg = (ov8835_read_sccb16(address + 8,s_ctrl)<<2)+((temp>>2)&0x03); 
otp_ptr->light_bg = (ov8835_read_sccb16(address + 9,s_ctrl)<<2)+(temp&0x03); 

otp_ptr->user_data[0] = ov8835_read_sccb16(address + 11,s_ctrl); 
otp_ptr->user_data[1] = ov8835_read_sccb16(address + 12,s_ctrl); 
otp_ptr->user_data[2] = ov8835_read_sccb16(address + 13,s_ctrl); 
otp_ptr->user_data[3] = ov8835_read_sccb16(address + 14,s_ctrl); 
otp_ptr->user_data[4] = ov8835_read_sccb16(address + 15,s_ctrl); 
// disable otp read 
ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 
// clear otp buffer 
clear_otp_buffer(s_ctrl); 

return 0; 
} 
Пример #5
0
int read_otp_lenc(uint index, struct otp_struct *otp_ptr, struct msm_sensor_ctrl_t *s_ctrl) 
{ 
 
int bank, i; 
int address; 

bank = 0xc0 | (index*4); 
ov8835_write_sccb16(0x3d84, bank,s_ctrl); 

ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d01; 
for(i=0;i<15;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
pr_err("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 

ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 

clear_otp_buffer(s_ctrl); 

bank++; 
ov8835_write_sccb16(0x3d84, bank ,s_ctrl); 

ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
for(i=15;i<31;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
pr_err("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 

ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 

clear_otp_buffer(s_ctrl); 

bank++; 
ov8835_write_sccb16(0x3d84, bank ,s_ctrl); 

ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
for(i=31;i<47;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
pr_err("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 

ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 

clear_otp_buffer(s_ctrl); 

bank++; 
ov8835_write_sccb16(0x3d84, bank ,s_ctrl); 

ov8835_write_sccb16(0x3d81, 0x01,s_ctrl); 
msleep(5); 
address = 0x3d00; 
for(i=47;i<62;i++) { 
otp_ptr->lenc[i]=ov8835_read_sccb16(address,s_ctrl); 
pr_err("%s  lenc[%d]=0x%x",__func__,i,otp_ptr->lenc[i]); 
address++; 
} 

ov8835_write_sccb16(0x3d81, 0x00,s_ctrl); 

clear_otp_buffer(s_ctrl); 
return 0; 
}