现在的位置: 首页 > 综合 > 正文

I2C不通的分析思路

2018年04月16日 ⁄ 综合 ⁄ 共 2546字 ⁄ 字号 评论关闭
[DESCRIPTION]

在camera porting的过程中,有很多原因会导致Camera I2C不通
此篇FAQ的目的是为camera i2c没通的情况,提供一个大概的思路
 

[SOLUTION]
I2C不通,有两种原因,一种是device端(也就是我们的camera sensor)本身就没有回ACK,另一中就是在master端(也就是我们的baseband端),如果我们的,master端就本身异常。那么I2C不通就不足为奇了
 
我们可以从kernel log里面搜索I2C的关键字,无非是“I2C_TIMEOUT”和“I2C_ACKERR”。。
如果您搜索到了I2C_ACKERR,那么问题多半在slave端,您需要检查您的上电时需是否符合sensor spec的规范,和模组厂的工程师或者sensor厂的工程师一起修改sensor的上电时需,
如果您搜索到的是I2C_TIMEOUT,那么问题多半在master端。


[DESCRIPTION]

        I2C as the bridge which communicate during the image sensor and BB. It used to send and rececive command / data interaction with its fundamental role, especially importante
in the porting process, i2c is the first step when porting a new sensor.
 

[SOLUTION]
     I2C ACK error scenario as follows:
Condition1:   pin reverse(HW)
    1) SCL and SDA pin is reversed.
    2) So I2C controller only send out address waveform.
 
Condition2: Slave device is not connected to host(HW)
    1) SCL/SDA default level is high
    2) I2C controller only send out address waveform.
    3) Slave can not response action
 
Condition 3: Slave address is wrong(SW)
    1) The same as not exit
    
Condition 4: Slave device is connected to host but not in right ststus.
    1) Slave is busy, can not process host date.
    2) Continue sending dummy data to draw back slave status
    3) Reset slave device.
 
Condition 5: This case include slave is not power on
    1) Check the power supply of device.
 
Conidtion 6: This case include slave is not enable
    1) Check if the chip select is active.
 
Condition 7: Some special device need work in WR mode.
    1) need use WR mode after send the Camera ID Command. If not suit it the device will send ACK error to Baseband.
    client->addr |= I2C_RS_FLAG | I2C_WR_FLAG;


[DESCRIPTION]

在开机过程中,感觉开机的时间过长,发现是search sensor导致的。
如果您从kernel_log.boot中搜索关键字I2C_TIMEOUT,若搜索到如下图所示,您可以参考这篇FAQ
1

[SOLUTION]
 从上图所示,在开机过程中因为I2C_TIMEOUT,就浪费了4s多的时间
 至于是代码的那个地方造成的I2C_TIMEOUT,我们得根据具体问题具体分析,
 但是,我们只需要把握一点,就是出现I2C_TIMEOUT的rootcause来推测这个问题,我们的问题就迎刃而解
 出现I2C_TIMEOUT的rootcause之一是,在I2C bus上没有电的情况下去操作I2C,就会出现timeout
 一般来说,我们正常的follow:  Camera Power On --> Write/Read I2C ---> Camera Power Off
 在下面的follow下,就会有I2C timeout: Camera Power Off --> Write/Read I2C
 我们根据上述条件,通过代码和log去跟踪camera  power on/off和write/read I2C的follow,找出异常点,那么这个问题就迎刃而解
 
P.S I2C timeraout的root cause有很多,但是在I2C bus上没有电的情况下去操作I2C是最常见的

[DESCRIPTION]

关于I2C 传输时相关flag的说明

 

[SOLUTION]

i2c传输前需要对 client->ext_flag 做设定,或上相关标志,各个flag解释如下:

 

 I2C_DMA_FLAG
–开启DMA传输,default 为fifo mode传输
I2C_WR_FLAG
 –Enable write and read tranfer mode, Must set I2C_RS_FLAG ,Don’t support in DMA mode
I2C_RS_FLAG  
 –Enable REPEATED-START
I2C_HS_FLAG 
–Enable high speed mode,default 为低速和快速
 I2C_PUSHPULL_FLAG
–使能pushpull mode,default 为open drain
I2C_ENEXT_FLAG 
–Allows slaves to hold the SCL line low if it is not yet ready for further processing ,Open open-drain mode of the SCL line

抱歉!评论已关闭.