Add DTS for PCA9635 LED Driver



  • Hi All,

    for my custom hardware i need to drive some LED's and since the Software PWM wasn't stable enough I opted for an LED driver. I compiled a custom firmware (24.10) with the leds-pca963x kernel module and I can confirm that it's loaded. I have my PCA9635 connect to I2C on address 0x8 and can see it with i2cdetect.
    I try adding the device via sys/class like:

    echo pca9635 0x08 > /sys/class/i2c-dev/i2c-0/device/new_device
    

    running desmg afterwards shows that it tried to load the driver:

    [  949.521145] leds-pca963x 0-0008: Node (null) must define between 1 and 16 LEDs
    [  949.528588] leds-pca963x: probe of 0-0008 failed with error -22
    [  949.534638] i2c i2c-0: new_device: Instantiated device pca9635 at 0x08
    

    However it looks like it needs the LED's defined via DTS. I never used that so I forked the onion-dts-overlay and tried to add my own but that didn't work either.

    /dts-v1/;
    /plugin/;
    
    / {
        compatible = "onion,omega2";
    
        fragment@0 {
            target = <&i2c0>;  // adapt to your bus if needed
    
            __overlay__ {
                pca9635: pca9635@08 {
                    compatible = "nxp,pca9635";
                    reg = <0x08>;
                    #address-cells = <1>;
                    #size-cells = <0>;
    
                    led@0 {
                        label = "user:led0";
                        reg = <0>;
                    };
    
                    led@1 {
                        label = "user:led1";
                        reg = <1>;
                    };
                    // Add more as needed
                };
            };
        };
    };
    
    

    I'm not sure where to start. Ideally I'd add everything into one package for the firmware compilation but I'm lost where that should happen.



  • So I figured it out by now. It didn't really work with overlay but using the main .dtsi file worked.
    pca9635.dtsi

    &i2c {
        pca9635@8 {
            compatible = "nxp,pca9635";
            reg = <0x08>;
            #address-cells = <1>;
            #size-cells = <0>;
            status = "okay";
    
            led@0 {
                label = "led0";
                reg = <0>;
                default-state = "off";
            };
    
            led@1 {
                label = "led1";
                reg = <1>;
                default-state = "off";
            };
    
            led@2 {
                label = "led2";
                reg = <2>;
                default-state = "off";
            };
    
            led@3 {
                label = "led3";
                reg = <3>;
                default-state = "off";
            };
    
            led@4 {
                label = "led4";
                reg = <4>;
                default-state = "off";
            };
    
            led@5 {
                label = "led5";
                reg = <5>;
                default-state = "off";
            };
    
            led@6 {
                label = "led6";
                reg = <6>;
                default-state = "off";
            };
    
            led@7 {
                label = "led7";
                reg = <7>;
                default-state = "off";
            };
    
            led@8 {
                label = "led8";
                reg = <8>;
                default-state = "off";
            };
    
            led@9 {
                label = "led9";
                reg = <9>;
                default-state = "off";
            };
    
            led@10 {
                label = "led10";
                reg = <10>;
                default-state = "off";
            };
    
            led@11 {
                label = "led11";
                reg = <11>;
                default-state = "off";
            };
    
            led@12 {
                label = "led12";
                reg = <12>;
                default-state = "off";
            };
    
            led@13 {
                label = "led13";
                reg = <13>;
                default-state = "off";
            };
    
            led@14 {
                label = "led14";
                reg = <14>;
                default-state = "off";
            };
    
            led@15 {
                label = "led15";
                reg = <15>;
                default-state = "off";
            };
        };
    };
    
    

    placed in the build folder

    /home/thomas/openwrt-wallcontroller/target/linux/ramips/dts
    

    and lastly adding an include to the omega .dtsi

    mt7628an_onion_omega2.dtsi
    
    #include "mt7628an.dtsi"
    #include "pca9635.dtsi"
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/input/input.h>
    
    


Looks like your connection to Community was lost, please wait while we try to reconnect.