add i2c expander PCA9535 using device tree

1,828 views
Skip to first unread message

malkowki_belgium

unread,
Feb 2, 2016, 5:54:55 AM2/2/16
to BeagleBoard
Hello all,

I am trying to add the PCA 9535 expander on the i2c2 bus on P9. 23 and P9.24 using the device tree but I cannot detect it when booting the board with the kernel 4.1.15.
below the way I declare the device on the DTS.

Do you know what I am doing wrong?

&omap3_pmx_core {
    pinctrl-names = "default";
    pinctrl-0 = <
            &hsusb2_pins
    >;
             i2c2_pins: pinmux_i2c_pins {
                pinctrl-single,pins = <
                        0x18E (PIN_INPUT_PULLUP | MUX_MODE0) /* i2c2_scl.gpio_168 */
                        0x190 (PIN_INPUT_PULLUP | MUX_MODE0) /* i2c2_sda.gpio_136 */
       
       >;
};

&i2c2 {
   
    clock-frequency = <400000>;
   
    pca9535: gpio@20 {
        compatible = "nxp, pca9535";
        gpio-controller;
        #gpio-cell = <2>;
        reg = <0x20>;
        status = "okay";
       
            };

                   gpio@21 {
                        compatible = "nxp, pca9535";
                        gpio-controller;
                        #gpio-cell = <2>;
                        reg = <0x21>;
                        status = "okay";
                       
                 };
                             gpio@22 {
                            compatible = "nxp, pca9535";
                            gpio-controller;
                            status = "okay";
                            #gpio-cell = <2>;
                            reg = <0x22>;
                           
                                     };
                                 gpio@24 {
                            compatible = "nxp, pca9535";
                            gpio-controller;
                            status = "okay";
                            #gpio-cell = <2>;
                            reg = <0x24>;
                           
                                     };
};

&gpio5 {
    pinctrl-names = "defaults";
    pinctrl-0 = <
                &gpio_pins
                &i2c2_pins
               
        >;
};


Graham

unread,
Feb 2, 2016, 4:32:08 PM2/2/16
to BeagleBoard
You didn't say which version of OS you were running.
The I2C busses were renumbered in later OS.
Since you mentioned kernel 4.1.15, I will assume that you are running Debian 8

In Debian 8, I2C2 is pinned out to P9-19 and P9-20 by default. (No device tree changes necessary.)
Hook your expander there and see if you can see it with i2cdetect.

--- Graham

==

Beninio Mbila

unread,
Feb 3, 2016, 6:16:56 AM2/3/16
to beagl...@googlegroups.com
Hello Graham,
Thanks for tour quick reply, I am using Debian 8 Jessie indeed.
 
I have modified my dts as following and it is working fine expect the expander at adress 0x20 I don't know why?

&i2c2 {
   
    clock-frequency = <400000>;
    status = "okay";
   
    pca953x_0:gpio@20 {
        compatible = "nxp, pca9535";
        reg = <0x20>;   
      }
;
    pca953x_1:gpio@21 {
        compatible = "nxp,pca9535";
        reg = <0x21>;
    };

    pca953x_2:gpio@22 {
        compatible = "nxp,pca9535";
        reg = <0x22>;
    };

    pca953x_3gpio@24 {
        compatible = "nxp,pca9535";
        reg = <0x24>;
    };
It looks like the gpio adress from 1024 to gpio1040 are forbidden? see my log below:

GPIOs 976-991, i2c/1-0024, pca9535, can sleep:
 gpio-976 (sysfs               ) in  lo   
 gpio-977 (sysfs               ) in  lo   
 gpio-978 (sysfs               ) in  lo   
 gpio-979 (sysfs               ) in  lo   
 gpio-980 (sysfs               ) in  lo   
 gpio-981 (sysfs               ) in  lo   
 gpio-982 (sysfs               ) in  lo   
 gpio-983 (sysfs               ) in  lo   
 gpio-984 (sysfs               ) in  lo   
 gpio-985 (sysfs               ) in  lo   
 gpio-986 (sysfs               ) in  lo   
 gpio-987 (sysfs               ) in  lo   
 gpio-989 (sysfs               ) in  lo   
 gpio-990 (sysfs               ) in  hi   
 gpio-991 (sysfs               ) in  lo   

GPIOs 992-1007, i2c/1-0022, pca9535, can sleep:
 gpio-992 (sysfs               ) in  lo   
 gpio-993 (sysfs               ) in  lo   
 gpio-994 (sysfs               ) in  lo   
 gpio-995 (sysfs               ) in  lo   
 gpio-996 (sysfs               ) in  lo   
 gpio-997 (sysfs               ) in  lo   
 gpio-998 (sysfs               ) in  lo   
 gpio-999 (sysfs               ) in  lo   
 gpio-1000 (sysfs               ) in  lo   
 gpio-1001 (sysfs               ) in  lo   
 gpio-1002 (sysfs               ) in  lo   
 gpio-1003 (sysfs               ) in  lo   
 gpio-1004 (sysfs               ) in  lo   
 gpio-1005 (sysfs               ) in  lo   
 gpio-1006 (sysfs               ) in  lo   
 gpio-1007 (sysfs               ) in  lo   

GPIOs 1008-1023, i2c/1-0021, pca9535, can sleep:
 gpio-1008 (sysfs               ) in  lo   
 gpio-1009 (sysfs               ) in  lo   
 gpio-1010 (sysfs               ) in  lo   
 gpio-1011 (sysfs               ) in  lo   
 gpio-1012 (sysfs               ) in  lo   
 gpio-1013 (sysfs               ) in  lo   
 gpio-1014 (sysfs               ) in  lo   
 gpio-1015 (sysfs               ) in  lo   
 gpio-1016 (sysfs               ) in  lo   
 gpio-1017 (sysfs               ) in  lo   
 gpio-1018 (sysfs               ) in  lo   
 gpio-1019 (sysfs               ) in  lo   
 gpio-1020 (sysfs               ) in  lo   
 gpio-1021 (sysfs               ) in  lo   
 gpio-1022 (sysfs               ) in  lo   
 gpio-1023 (sysfs               ) out hi   


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/QsC0kgXXYw4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Beninio Mbila

Beninio Mbila

unread,
Feb 3, 2016, 6:24:02 AM2/3/16
to beagl...@googlegroups.com
my i2cdetect show the following and we can see that expand 20 is still free:

WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 UU UU -- UU -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Graham

unread,
Feb 3, 2016, 4:42:26 PM2/3/16
to BeagleBoard
I am not sure why the system is not acquiring address 0x20.

I would try removing the space after the comma, in line   'compatible = "nxp, pca9535";'
for address 20 so that it is identical to the lines that do working.

--- Graham

==

Beninio Mbila

unread,
Feb 4, 2016, 3:19:39 AM2/4/16
to beagl...@googlegroups.com
Thank you Graham, indeed that was the issue. kind of stupid mistake! 😔

Reply all
Reply to author
Forward
0 new messages