Controlling SAMA5D27-SOM1-EK1 Board LEDS using DEV

2019-08-28 01:28发布

问题:

I have SAMA5D27-SOM1-EK1 Board. It has 3 Leds ( Red connected to PA10 pin , green connected to PB1 pin , blue connected to PA31 pin ) and 4 buttons, one of them is user push button (PB4) connected to PIO PA29, and optionally to PIOBU1.

This is a link to device-tree file for my linux kernel : https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/at91-sama5d27_som1_ek.dts

You can find a part which describing LED and User Push Button :

leds {
        compatible = "gpio-leds";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_led_gpio_default>;
        status = "okay"; /* Conflict with pwm0. */

        red {
            label = "red";
            gpios = <&pioA PIN_PA10 GPIO_ACTIVE_HIGH>;
        };

        green {
            label = "green";
            gpios = <&pioA PIN_PB1 GPIO_ACTIVE_HIGH>;
        };

        blue {
            label = "blue";
            gpios = <&pioA PIN_PA31 GPIO_ACTIVE_HIGH>;
            linux,default-trigger = "heartbeat";
        };

gpio_keys {
        compatible = "gpio-keys";

        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_key_gpio_default>;

        pb4 {
            label = "USER";
            gpios = <&pioA PIN_PA29 GPIO_ACTIVE_LOW>;
            linux,code = <0x104>;
            wakeup-source;
        };

I want to take the control of one of the three leds with the button : When I push the button it lights My question is : How can I take the control of any Led of the three leds with the user button ? How can I modify the device-tree file for this ?