I2C write timeout for second time write

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I2C write timeout for second time write

899件の閲覧回数
shrithi
Contributor I

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?

 

0 件の賞賛
返信
12 返答(返信)

821件の閲覧回数
shrithi
Contributor I

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

0 件の賞賛
返信

862件の閲覧回数
Chavira
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信

841件の閲覧回数
shrithi
Contributor I

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

0 件の賞賛
返信

830件の閲覧回数
Chavira
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信

824件の閲覧回数
shrithi
Contributor I

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

0 件の賞賛
返信

817件の閲覧回数
Chavira
NXP TechSupport
NXP TechSupport

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?

 

 

0 件の賞賛
返信

815件の閲覧回数
shrithi
Contributor I
Hi Chavira,
 
Yes, the mipi camera is configured through I2C. Configuring through i2c is necessary whenever camera-related configurations are needed. The Ov5640 camera is an example.
 
The below is device-tree configuration
/* FPGA MIPI configuration */
&mipi_csi_0 { /* MIPI_CSI0: FPGA L MIPI TX */
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
 
port@0 {
reg = <0>;
mipi_csi0_ep: endpoint {
remote-endpoint = <&fpga_L_mipi_ep>;
data-lanes = <1 2 3 4>;
bus-type = <4>;
};
};
};
 
&i2c_mipi_csi0 { /* MIPI_CSI0: FPGA L TX */
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c_mipi_csi0>;
clock-frequency = <400000>;
status = "okay";
 
fpga_L_mipi: fpga_L_mipi@3d {
compatible = "iw,iw_mipi";
reg = <0x3D>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mipi_csi0>;
mipi_csi;
status = "okay";
port {
fpga_L_mipi_ep: endpoint {
remote-endpoint = <&mipi_csi0_ep>;
data-lanes = <1 2 3 4>;
clocks-lanes = <0>;
};
};
};
};
 
Thanks,
Shrithi

 

 

0 件の賞賛
返信

771件の閲覧回数
Chavira
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信

720件の閲覧回数
shrithi
Contributor I

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

0 件の賞賛
返信

683件の閲覧回数
Chavira
NXP TechSupport
NXP TechSupport

Hi @shrithi!

You can find a detailed flow described in Reference Manual on the chapter "5.8.2.2 Master Mode".

Chavira_0-1724078124800.png

 

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

0 件の賞賛
返信

663件の閲覧回数
shrithi
Contributor I

Hi Chavira,

Can you give i2c write and read timing diagram?

Thanks,
Shrithi

0 件の賞賛
返信

630件の閲覧回数
Chavira
NXP TechSupport
NXP TechSupport

Hi @shrithi!

 

You can find the table in datasheet.

 

Chavira_0-1724162147079.png

 

Chavira_1-1724162172764.png

 

Chavira_2-1724162207306.png

 

Best Regards!

Chavira

0 件の賞賛
返信