Mapping "gpio-leds" to a 2nd chip (ath79 DTS question)?

Hi,

I believe I'm running into device tree syntax problems when configuring extra LEDs.

So, I have a board with 2 gpio chips as follows:

root@OpenWrt:/# cat /sys/kernel/debug/gpio 
gpiochip0: GPIOs 0-31, parent: platform/18040000.gpio, 18040000.gpio:
 gpio-4   (                    |rb4xx:yellow:user   ) out hi    
 gpio-7   (                    |1a000000.eth:mdio-gp) out lo    
 gpio-8   (                    |1a000000.eth:mdio-gp) in  hi    

gpiochip1: GPIOs 32-40, parent: spi/spi0.1, spi-rb4xx-cpld, can sleep:
root@OpenWrt:/#

And I can configure the main LED on gpio 4 (as shown above) like so:

leds {                                      
    compatible = "gpio-leds";               
                                            
    led_user_yellow: user_yellow {          
        label = "rb4xx:yellow:user";        
        gpios = <&gpio 4 GPIO_ACTIVE_HIGH>; 
        default-state = "on";               
    };

All good. However I have additional LEDs on gpio 32 and up. These I can turn on/off manually as so:

root@OpenWrt:/# echo 32 >/sys/class/gpio/export                       
root@OpenWrt:/# echo out >/sys/class/gpio/gpio32/direction            
root@OpenWrt:/# cat /sys/kernel/debug/gpio                            
gpiochip0: GPIOs 0-31, parent: platform/18040000.gpio, 18040000.gpio: 
 gpio-4   (                    |rb4xx:yellow:user   ) out hi          
 gpio-7   (                    |1a000000.eth:mdio-gp) out lo          
 gpio-8   (                    |1a000000.eth:mdio-gp) in  hi          
                                                                      
gpiochip1: GPIOs 32-40, parent: spi/spi0.1, spi-rb4xx-cpld, can sleep:
 gpio-32  (                    |sysfs               ) out hi          
                                                                      
root@OpenWrt:/# echo 0 >/sys/class/gpio/gpio32/value # LED on         
root@OpenWrt:/# echo 1 >/sys/class/gpio/gpio32/value # LED off

The problem

Adding this to the DTS section above results in zero LEDs being mapped. The yellow one is now gone. There are no messages at boot indicating problems either.

led_1_green: 1_green {                  
    label = "rb4xx:green:led1";         
    gpios = <&cpld 32 GPIO_ACTIVE_LOW>; 
};

The "&cpld" is defined as follows (under &spi) :

cpld: cpld@1 {                             
    compatible = "mikrotik,rb4xx-spi-cpld";
    reg = <1>;                             
    spi-max-frequency = <25000000>;        
                                           
    gpio-base = <32>;                      
                                           
    gpio-controller;                       
    #gpio-cells = <2>;                     
};

Any suggestions / pointers?

try gpios = <&cpld 0 GPIO_ACTIVE_LOW>;.

Just tried, however that registers it on gpiochip0 (and not gpiochip1).

Edit, I'm an idiot and forgot to change the label. It worked - thanks.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.