1:上电成功之后读到了chip id = 0x1801,说明模组上电成功了
2:模组内部有pll来倍频,外部时钟是24M,设置内部时钟为48M,然后i2c控制切换到内部时钟,切换之后i2c无法通信了,一直提示总线忙,显示SDA一直为低
[ 36.797560] sensor_init
[ 36.797590] [i2c1] msgs.buf = 0x00
[ 36.797720] sun7i_i2c_core_process:twi_query_irq_status state = 0x8
[ 36.797785] sun7i_i2c_core_process:twi_query_irq_status state = 0x18
[ 36.797848] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.797914] sun7i_i2c_do_xfer:ret = 1
[ 36.797928] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = 1
[ 36.797942] [i2c1] msgs.buf = 0x00
[ 36.797953] [i2c1] msgs.buf = 0xef
[ 36.798073] sun7i_i2c_core_process:twi_query_irq_status state = 0x8
[ 36.798138] sun7i_i2c_core_process:twi_query_irq_status state = 0x40
[ 36.798200] sun7i_i2c_core_process:twi_query_irq_status state = 0x50
[ 36.798262] sun7i_i2c_core_process:twi_query_irq_status state = 0x58
[ 36.798302] sun7i_i2c_do_xfer:ret = 1
[ 36.798314] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = 1
[ 36.798335] ar0330 1-0048: MT9P031 is found, version 0x1801
[ 36.898827] [i2c1] msgs.buf = 0x10
[ 36.898845] [i2c1] msgs.buf = 0x00
[ 36.898856] [i2c1] msgs.buf = 0x51
[ 36.898981] sun7i_i2c_core_process:twi_query_irq_status state = 0x8
[ 36.899047] sun7i_i2c_core_process:twi_query_irq_status state = 0x18
[ 36.899111] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.899173] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.899235] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.899285] sun7i_i2c_do_xfer:ret = 1
[ 36.899298] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = 1
[ 36.899313] [i2c1] msgs.buf = 0x11
[ 36.899324] [i2c1] msgs.buf = 0x18
[ 36.899335] [i2c1] msgs.buf = 0x01
[ 36.899455] sun7i_i2c_core_process:twi_query_irq_status state = 0x8
[ 36.899518] sun7i_i2c_core_process:twi_query_irq_status state = 0x18
[ 36.899580] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.899642] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.899704] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.899741] sun7i_i2c_do_xfer:ret = 1
[ 36.899753] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = 1
[ 36.899767] [i2c1] msgs.buf = 0x12
[ 36.899778] [i2c1] msgs.buf = 0x00
[ 36.899790] [i2c1] msgs.buf = 0x05
[ 36.899910] sun7i_i2c_core_process:twi_query_irq_status state = 0x8
[ 36.899973] sun7i_i2c_core_process:twi_query_irq_status state = 0x18
[ 36.900035] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.900097] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.900158] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.900194] sun7i_i2c_do_xfer:ret = 1
[ 36.900206] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = 1
[ 36.912367] [i2c1] msgs.buf = 0x10
[ 36.912382] [i2c1] msgs.buf = 0x00
[ 36.912393] [i2c1] msgs.buf = 0x53 //这里往0x10寄存器写入0x0053,表示由外部时钟切换到内部时钟,执行成功之后,下一条i2c通信开始就一直失败
[ 36.912516] sun7i_i2c_core_process:twi_query_irq_status state = 0x8
[ 36.912580] sun7i_i2c_core_process:twi_query_irq_status state = 0x18
[ 36.912642] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.912704] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.912766] sun7i_i2c_core_process:twi_query_irq_status state = 0x28
[ 36.926443] [i2c1] i2c state isn't idle(0xf8)
[ 36.926455] [i2c1] STOP failed!
[ 36.926493] sun7i_i2c_do_xfer:ret = 1
[ 36.926773] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = 1
[ 37.130649] [i2c1] msgs.buf = 0x70
[ 37.130666] [i2c1] msgs.buf = 0x00
[ 37.130677] [i2c1] msgs.buf = 0x79
[ 37.130789] [i2c1] bus is busy, status = f9
[ 37.150663] [i2c1] SDA is still Stuck Low, failed.
[ 37.150682] sun7i_i2c_do_xfer:ret = -2
[ 37.150694] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = -2
[ 37.150707] [i2c1] Retrying transmission 2
[ 37.150818] [i2c1] msgs.buf = 0x70
[ 37.150829] [i2c1] msgs.buf = 0x00
[ 37.150840] [i2c1] msgs.buf = 0x79
[ 37.150952] [i2c1] bus is busy, status = f9
[ 37.170828] [i2c1] SDA is still Stuck Low, failed.
[ 37.170846] sun7i_i2c_do_xfer:ret = -2
[ 37.170858] sun7i_i2c_xfer:sun7i_i2c_do_xfer ret = -2
上面图片是内部时钟pll设置流程。具体代码如下:
ret = mt9p031_reg_write(client, 0x0d, 0x0001); // High
//ret = mt9p031_set_output_control(sd, 0,2);
mdelay(50);
ret |= mt9p031_reg_write(client, 0x0d, 0x0000); // Low
mdelay(50);
ret |= mt9p031_reg_write(client, 0x10, 0x0051); // PLL_CTRL; power up pll
// ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CONF1, 0x1801); // PLL_CONFIG_1: m=24, n=1
// ret |= mt9p031_reg_write(client, REG_MT9P031_PLL_CONF2, 0x0002); // PLL_CONFIG_2: p1=2, p2=0
ret |= mt9p031_reg_write(client, 0x11, (MT9P031_PLL_M << 8) | (MT9P031_PLL_N - 1));
ret |= mt9p031_reg_write(client, 0x12, MT9P031_PLL_P1 - 1);
mdelay(10); //wait 10 ms for VCO to lock
ret |= mt9p031_reg_write(client, 0x10, 0x0053); // PLL_CONTROL; use PLL
mdelay(200);
ret |= mt9p031_reg_write(client, 0x70, 0x0079); // RESERVED_CORE_70
大神们,求解
6 个解决方案
#1
楼主,实在不行的话,可以使用IO口模拟I2C, 在内核里有这样的控制器驱动(i2c-gpio.c).
#2
先谢谢回复,首先,i2c是通的,所以和模不模拟妹关系,只是在i2c操作外部ic的pll后,i2c才无法通信的,只要不操作pll,i2c通信没一点问题
#3
不好意思,是我跑偏了。
linux内核源码里有mt9p031的驱动,里面的函数与你贴出的函数有点不同。建议下载新版的内核源码, 用里面的驱动代码试试
#4
楼主,实在不行的话,可以使用IO口模拟I2C, 在内核里有这样的控制器驱动(i2c-gpio.c).
先谢谢回复,首先,i2c是通的,所以和模不模拟妹关系,只是在i2c操作外部ic的pll后,i2c才无法通信的,只要不操作pll,i2c通信没一点问题
不好意思,是我跑偏了。
linux内核源码里有mt9p031的驱动,里面的函数与你贴出的函数有点不同。建议下载新版的内核源码, 用里面的驱动代码试试
功能已经完成,i2c没问题,摄像头的问题
#5
楼主,我也遇到相同的问题,是什么原因啊
#6
楼主,我也遇到相同的问题,是什么原因啊
#1
楼主,实在不行的话,可以使用IO口模拟I2C, 在内核里有这样的控制器驱动(i2c-gpio.c).
#2
楼主,实在不行的话,可以使用IO口模拟I2C, 在内核里有这样的控制器驱动(i2c-gpio.c).
先谢谢回复,首先,i2c是通的,所以和模不模拟妹关系,只是在i2c操作外部ic的pll后,i2c才无法通信的,只要不操作pll,i2c通信没一点问题
#3
楼主,实在不行的话,可以使用IO口模拟I2C, 在内核里有这样的控制器驱动(i2c-gpio.c).
先谢谢回复,首先,i2c是通的,所以和模不模拟妹关系,只是在i2c操作外部ic的pll后,i2c才无法通信的,只要不操作pll,i2c通信没一点问题
不好意思,是我跑偏了。
linux内核源码里有mt9p031的驱动,里面的函数与你贴出的函数有点不同。建议下载新版的内核源码, 用里面的驱动代码试试
#4
楼主,实在不行的话,可以使用IO口模拟I2C, 在内核里有这样的控制器驱动(i2c-gpio.c).
先谢谢回复,首先,i2c是通的,所以和模不模拟妹关系,只是在i2c操作外部ic的pll后,i2c才无法通信的,只要不操作pll,i2c通信没一点问题
不好意思,是我跑偏了。
linux内核源码里有mt9p031的驱动,里面的函数与你贴出的函数有点不同。建议下载新版的内核源码, 用里面的驱动代码试试
功能已经完成,i2c没问题,摄像头的问题
#5
楼主,我也遇到相同的问题,是什么原因啊
#6
楼主,我也遇到相同的问题,是什么原因啊