Hii Support team,
We are using i. MX8QM processor. We are experiencing an issue with i2c write.
The first I2C write will pass, but there is a problem with the second I2C write.
Below error we are getting for second i2c write.
mipi_test 4-003d: write_reg: error -110: reg=b3b3, val=21
Error setting pattern and resolution: Connection timed out
Any configuration required in imx i2c master side?
I tried to write with i2cset command and it showing below message
Error: Could not set address to 0x3d: Device or resource busy
Can you please provide the suggestion to solve this error?
Hi Chavira,
Can you provide I2c master flow diagram because slave is developed by us. So i can verify i2c master and slave flow is same.
The below i2c master driver used
drivers/i2c/busses/i2c-imx-lpi2c.c
Hi @shrithi!
The device was added to the device tree?
Are you using i2c-tools to communicate with the device?
can you send a log file using the command i2cdetect?
Best Regards!
Chavira
Hi Chavira
Yes, I have added slave device configuration in device-tree.
The slave address is ox3d.
i2cdetect -r -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I have tried with i2cset and i2cget commands but i got below error
i2cset -y 3 0x3d 0x0 0x1
Error: Could not set address to 0x3d: Device or resource busy
Thanks,
Shrithi
Hi @shrithi!
When a device shows UU instead of their direction under i2cdetect command, that means that device is being used by the kernel and that is the reason that you are getting the error.
I you want to use i2c tools to communicathe with the device you have to unload the module of the kernel that is using the device.
Try with the command insmod <name of module> and then you can use i2ctools.
Best regards!
Chavira
Hi Chavira,
The i2c slave is mipi camera.
I have tried to i2c write through application which will call mipi ioctl and perform i2c write operation from driver.
You can refer the below
./mipi_config video_resolution_pattern selection 2 2 1
[ 55.546036] mipi_s_custom_ctrl
[ 55.549211] cid = 3 val = 34 reg = 0xb3b3
Resolution and video data pattern successfully
./mipi_config video_resolution_pattern selection 2 1 1
[ 103.514784] mipi_s_custom_ctrl
[ 103.517860] cid = 3 val = 33 reg = 0xb3b3
[ 104.526383] mipi_cam 3-003d: mipi_write_reg: error -110: reg=b3b3, val=21
Error setting pattern and resolution: Connection timed out
Thanks,
Shrithi
Hi @shrithi!
Dou you have the driver loaded by the kernel under device tree and at the same time do you want to write in i2c bus on the c application in user space?
HI @shrithi!
For this case I recommend to adjust your custom drivers.
To acces to the i2c bus you have 2 options, disable the kernel module to use the i2c tools or access to the bus using ioctl in a c program or adapt your driver to send and read the bus all in kernel, you can't do both.
Best Regards!
Chavira
Hi Chavira,
I used the kernel to read and write i2c. I am facing an issue where the first I2C write will pass and the second I2C write will fail. Can you provide an I2C master flow diagram?
Thanks,
Shrithi
Hi @shrithi!
You can find a detailed flow described in Reference Manual on the chapter "5.8.2.2 Master Mode".
You can find a detailed description of the driver in our Linux Reference Manual on chapter "4.6 Inter-IC (I2C)".
https://www.nxp.com/docs/en/reference-manual/IMX_REFERENCE_MANUAL.pdf
Best Regards!
Chavira
Hi Chavira,
Can you give i2c write and read timing diagram?
Thanks,
Shrithi