[LS1028A]:How to access devices,which are connected through I2C HUB ?.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[LS1028A]:How to access devices,which are connected through I2C HUB ?.

Jump to solution
3,598 Views
Amit_Keshri
Contributor III

Dear NXP Team,

In our LS1028A based custom board 5 different devices are connected through I2C hub (TCA9548APWR) in bus-2 as shown in attached file.

I am able to read and write in i2c devices connected through I2C Hub in U-Boot but same thing is not happening in Linux when i am trying to write and read through  i2ctransfer utility and separate application and getting Resource temporarily unavailable(using own app).

In U-Boot 1st i am writing in i2c hub to select devices connected to hub then i am writing in devices and getting correct data as shown below:

-----------------------
#TO check RTC:
i2c probe
i2c dev 2
i2c probe
i2c mw 0x71 0x0 0x1   (0x71 is I2C Hub address)
i2c probe
i2c mw 0x51 0xa2 0xe (0x51 in RTC address
i2c md 0x51 0xa2 0x1
------------------------
#TO check EEPROM2:
i2c mw 0x71 0x0 0x2
i2c probe
i2c mw 0x50 0x0 0xf
i2c md 0x50 0x0 0x1

 

But in linux with below i am using below utility:

i2ctransfer 2 w17@0x71 0x0 0xff-      (to write  0xff in i2c hub address 0x71 to enable all i2c hub                                                                                                                                                   devices)

2ctransfer 2 w1@0x71 0x0 r1              (to read in i2c hub address 0x71)

i2ctransfer 2 w17@0x51 0x0 0x77-    (to write  0x77 in RTC devices of hub address 0x51 )                                                                                                          

2ctransfer 2 w1@0x51 0x0 r1             (to read  RTC hub address 0x51)

But not getting proper data with utility.

I have attached required file with this post.

Below are my question:

With i2ctransfer utility i am able to read and write other EEPROM(@0x50) devices but why i could not able to read and write the devices which are connected through i2c hub,even after enabling i2c devices by writing in i2c hub?.

What changes are required in dts and .config file to access i2c hub devices ?.

Please help me on this.

Thanks & Regards,

Amit Keshri

 

0 Kudos
1 Solution
2,417 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

I2C Hub devices is working in linux and we are able to read and write without any hardware change and below are the changes in Software:

I2C Hub dts changes:

&i2c1 {
status = "okay";
/* i2c-sda-hold-time-ns = <1000>; */
/* clock-frequency = <0x186a0>; */

i2c-mux@71 {
/*compatible = "ti,tca9548"; */
compatible = "nxp,pca9548";
/* compatible = "ti,tca9539"; */
#address-cells = <1>;
#size-cells = <0>;
reg = <0x71>;

i2c@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x1>;

rtc_dev@51 {
#sound-dai-cells = <0>;
compatible = "nxp,pcf2129";
reg = <0x51>;
};
};

i2c@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x02>;

eeprom@50 {
compatible = "nxp,pca9847";
/*compatible = "nxp,24lc02"; */
reg = <0x50>;
#shunt-resistor = <500>;
};
};

i2c@3 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x3>;

pcie@38 {
compatible = "nxp,sa56004";
reg = <0x38>;
#vcc-supply = <&sb_3v3>;
};

};
i2c@4 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x4>;

temp-sensor@4d {
compatible = "nxp,sa56004";
reg = <0x4d>;
#vcc-supply = <&sb_3v3>;
};

};

i2c@5 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x5>;

xmc_conn:xmc@4d {
compatible = "nxp,sa56004";
reg = <0xd>;
#vcc-supply = <&sb_3v3>;
};

};
};
};

To Access I2C devices which are connected through I2C HUB:we are opening below device files name for read and write in our application:

for I2C HUB: "/dev/i2c-1"

RTC: "/dev/i2c-2"

EEPROM: "/dev/i2c-3

PCIe: "/dev/i2c-4"

Temperature sensor: "/dev/i2c-5"

we are writting 0xff to 0x0 register to I2C Hub(0x71) before to access above i2c hub devices.

Regards,

Amit Keshri

 

View solution in original post

0 Kudos
9 Replies
3,569 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to the following i2c switch example in Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt.

Example:

i2c-switch@74 {
compatible = "nxp,pca9548";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x74>;

interrupt-parent = <&ipic>;
interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
interrupt-controller;
#interrupt-cells = <2>;

i2c@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <2>;

eeprom@54 {
compatible = "atmel,24c08";
reg = <0x54>;
};
};

i2c@4 {
#address-cells = <1>;
#size-cells = <0>;
reg = <4>;

 rtc@51 {
compatible = "nxp,pcf8563";
reg = <0x51>;
};
};
};

Please refer to PCA954x I2C mux/switch driver in drivers/i2c/muxes/i2c-mux-pca954x.c.

0 Kudos
3,563 Views
Amit_Keshri
Contributor III

Dear NXP Support Team,

Thank you for your reply.

I will check and update You.

 

Regards,

Amit Keshri

0 Kudos
3,560 Views
Amit_Keshri
Contributor III

Dear NXP support Team,

I refer the dts file for i2c hub in  Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt and i also check  Documentation/devicetree/bindings/i2c/i2c-mux.txt folder and modified my dts file but still i couldn't able to access i2c hub device((TCA9548APWR) and when i am trying to write any data from i2c hub devices through it is showing  error as shown below:

root@TinyLinux:/usr/sbin# i2ctransfer 1 w17@0x71 0x0 0xff-
i2ctransfer: WARNING! This program can confuse your I2C bus
Continue? [y/N] y
i2ctransfer: I2C_RDWR: Resource temporarily unavailable

Below is my dts file for i2c_hub :

&i2c2 {
status = "okay";
i2c-sda-hold-time-ns = <1000>;
clock-frequency = <0x186a0>;

i2c-mux@71 {
compatible = "nxp,pca9548";
reg = <0x71>;
#address-cells = <1>;
#size-cells = <0>;

i2c@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x1>;

rtc:rtc_dev@51 {
#sound-dai-cells = <0>;
compatible = "nxp,pcf2129";
reg = <0x51>;
};
};

i2c@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x02>;

eeprom:eeprom@50 {
compatible = "nxp,24lc02";
reg = <0x50>;
#shunt-resistor = <500>;
};
};

i2c@4 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x4>;

temp_sensor:temp-sensor@4d {
compatible = "nxp,sa56004";
reg = <0x4d>;
#vcc-supply = <&sb_3v3>;
};

};

};

};

Please tell me where i am doing wrong ?.

What further modification is required ?.

Regards,

Amit Keshri

0 Kudos
3,543 Views
yipingwang
NXP TechSupport
NXP TechSupport

You need to follow drivers/i2c/muxes/i2c-mux-pca954x.c.to create i2c hub device driver for TCA9548APWR device. Then update "compatible" property in i2c-mux@71 device node.

0 Kudos
3,473 Views
Amit_Keshri
Contributor III

Hi yipingwang,

Thank you for your reply.

followed drivers/i2c/muxes/i2c-mux-pca954x.c and created i2c hub device driver for TCA9548APWR device as attached with this post.

Below is my dts modifuication:

&i2c2 {
status = "okay";
// i2c-sda-hold-time-ns = <1000>;
// clock-frequency = <0x186a0>;

i2c-mux@71 {
compatible = "ti,tca9548";
//compatible = "nxp,pca9548";

#address-cells = <1>;
#size-cells = <0>;
reg = <0x71>;

i2c@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x1>;

rtc:rtc_dev@51 {
#sound-dai-cells = <0>;
compatible = "nxp,pcf2129";
reg = <0x51>;
};
};

i2c@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x02>;

eeprom:eeprom@50 {
compatible = "nxp,24lc02";
reg = <0x50>;
#shunt-resistor = <500>;
};
};

i2c@3 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x3>;

pcie:pcie@38 {
compatible = "nxp,sa56004";
reg = <0x38>;
#vcc-supply = <&sb_3v3>;
};

};

i2c@4 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x4>;

temp_sensor:temp-sensor@4d {
compatible = "nxp,sa56004";
reg = <0x4d>;
#vcc-supply = <&sb_3v3>;
};

};
};
};

while booting linux it is showing error as given below

 i2c /dev entries driver

tca954x 2-0071: probe failed

I tried to read and write in i2c hub switch as given below:

i2ctransfer 2 w17@0x71 0x4 0x56-
i2ctransfer 2 w1@0x71 0x4 r1

but it is showing "i2ctransfer: I2C_RDWR: Resource temporarily unavailable".

I have attached  for linux booting log file,tca9548 driver code .

Please suggest me what wrong i am doing ?.

Is my dts and driver file for TCA9548 i2c hub switch is correct?.

Regards,

Amit Keshri

0 Kudos
3,463 Views
yipingwang
NXP TechSupport
NXP TechSupport

In your driver code i2c-mux-tca954x.c, please do the following modification.

{ .compatible = "ti,tca9548", .data = &chips[tca_9548] },

Modify to 

{ .compatible = "ti,tca9548", .data = &chips[tca9548] },

0 Kudos
3,456 Views
Amit_Keshri
Contributor III

Hi @yipingwang 

Thank You for your reply.

As you suggestion i have added { .compatible = "ti,tca9548", .data = &chips[tca9548] }, in  drivers/i2c/muxes/i2c-mux-tca954x.c file and generated kernel image but it is showing below error while booting kernel:

[ 6.081838] i2c /dev entries driver
[ 6.086363] i2c_set_clientdata, data->client:0x5a071400
[ 6.091801] ret value of i2c_smbus_write_byte:-11
[ 6.096523] ret value of tca954x_init():-11
[ 6.100723] tca954x 1-0071: probe failed
[ 6.104696] i2c_set_clientdata, data->client:0x5a071000
[ 6.110126] ret value of i2c_smbus_write_byte:-11
[ 6.114845] ret value of tca954x_init():-11
[ 6.119041] tca954x 2-0071: probe failed

Note:

Except tca954x 2-0071: probe failed I have  added other print in tca954x.c for debugging.

Please check attached tca954x.c file and booting log file.

What i can do to solve this error?

Please suggest

Regards,

Amit  Keshri

0 Kudos
3,328 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please contact TI to require Linux driver for TCA9548APWR device.

0 Kudos
2,418 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

I2C Hub devices is working in linux and we are able to read and write without any hardware change and below are the changes in Software:

I2C Hub dts changes:

&i2c1 {
status = "okay";
/* i2c-sda-hold-time-ns = <1000>; */
/* clock-frequency = <0x186a0>; */

i2c-mux@71 {
/*compatible = "ti,tca9548"; */
compatible = "nxp,pca9548";
/* compatible = "ti,tca9539"; */
#address-cells = <1>;
#size-cells = <0>;
reg = <0x71>;

i2c@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x1>;

rtc_dev@51 {
#sound-dai-cells = <0>;
compatible = "nxp,pcf2129";
reg = <0x51>;
};
};

i2c@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x02>;

eeprom@50 {
compatible = "nxp,pca9847";
/*compatible = "nxp,24lc02"; */
reg = <0x50>;
#shunt-resistor = <500>;
};
};

i2c@3 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x3>;

pcie@38 {
compatible = "nxp,sa56004";
reg = <0x38>;
#vcc-supply = <&sb_3v3>;
};

};
i2c@4 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x4>;

temp-sensor@4d {
compatible = "nxp,sa56004";
reg = <0x4d>;
#vcc-supply = <&sb_3v3>;
};

};

i2c@5 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x5>;

xmc_conn:xmc@4d {
compatible = "nxp,sa56004";
reg = <0xd>;
#vcc-supply = <&sb_3v3>;
};

};
};
};

To Access I2C devices which are connected through I2C HUB:we are opening below device files name for read and write in our application:

for I2C HUB: "/dev/i2c-1"

RTC: "/dev/i2c-2"

EEPROM: "/dev/i2c-3

PCIe: "/dev/i2c-4"

Temperature sensor: "/dev/i2c-5"

we are writting 0xff to 0x0 register to I2C Hub(0x71) before to access above i2c hub devices.

Regards,

Amit Keshri

 

0 Kudos