apex
apex

Reputation: 859

How to configure multiple I/O Expander PCF8574a in a device tree?

I am currently adding an I/O Expander PCF8574a in my device tree am335x-boneblack.dts. I have two I/O expander, one at 0x38 and another at 0x39.

The code below works fine for a single expander but if I add PCF8574a with address 0x39 in the similar manner, it shows an error.

&i2c1 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins_default>;
    status = "okay";
    clock-frequency = <400000>;

pcf8574a: pcf8574a@38 {
    compatible = "nxp,pcf8574a";
    reg = <0x38>;
    gpio-controller;            
    #gpio-cells = <2>;
};

};

Error log :

"Duplicate label 'pcf8574a' on /ocp/i2c@4802a000/pcf8574a@39 and /ocp/i2c@4802a000/pcf8574a@38" which I completely understand.

But I dont know how to add another node or say sub node to make this work. Any suggestions?

Upvotes: 0

Views: 600

Answers (1)

yashC
yashC

Reputation: 995

have you tried this

&i2c1 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins_default>;
    status = "okay";
    clock-frequency = <400000>;

pcf8574a_38: pcf8574a@38 {
    compatible = "nxp,pcf8574a";
    reg = <0x38>;
    gpio-controller;            
    #gpio-cells = <2>;
};
pcf8574a_39: pcf8574a@39 {
    compatible = "nxp,pcf8574a";
    reg = <0x39>;
    gpio-controller;            
    #gpio-cells = <2>;
};
};

Upvotes: 1

Related Questions