Page 1 of 1

Configuring LEDs as a PWM with variable brightness on SAMA5D27

Posted: Mon Jul 13, 2020 10:46 pm
by sramnath
Hello all,

I am setting up the device tree for a custom board which will have the SAMAD27-SIP on the board. I'm testing out certain changes on an ATSAMA5D27-SOM1-EK.

in the device tree file for the evaluation board, i.e. at91-sama5d27_som1_ek.dts, there is an 'leds' module that allows me to configure the red,blue and green leds on the board. if enabled, I should see the leds in /sys/class/leds on my board once the boot process is up and I've logged in to the board. I am able to turn the leds on and off, but as I expect, I cannot vary the brightness of the LEDs.

How do I configure the LEDs so that I can change the brightness and dim the LEDs?

Here are the relevant portions of the at91-sama5d27_som1_ek.dts file ( I am modifying the at91-sama5d27_som1_ek.dts file using patches which I am applying to the Yocto build using a bbappend file, and can confirm that the patches are being applied as I expect them to be):

Code: Select all

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

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

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

                blue {
                        label = "blue";
                        gpios = <&pioA PIN_PB7 GPIO_ACTIVE_HIGH>;

                        label = "status_red";
                        gpios = <&pioA PIN_PA31 GPIO_ACTIVE_HIGH>;
I see up there that I am using compatible with 'gpio-leds' and tried changing it to be compatible 'pwm-leds' - however I got a 'cannot request pwm for <PIN>' error in the boot log and I could not see any of my leds in /sys/class/leds.

How should I change the device tree configuration so that I can vary the brightness of the LEDs from /sys/class/leds (and not from /sys/class/pwm/pwmchip0, which was when I disabled the leds module and enabled pwm0 instead with the relevant pinmuxing)?

Re: Configuring LEDs as a PWM with variable brightness on SAMA5D27

Posted: Tue Jul 14, 2020 12:06 am
by sramnath
Solved -

Following syntax given here: ... _interface