AnsweredAssumed Answered

i.MX6 Device Tree Entry for GPIO based LEDs

Question asked by Farrukh Arshad on May 27, 2015
Latest reply on May 28, 2015 by Eric Nelson

Greetings All,

 

I have a custom board based on i.MX6Q and I am running Freescale Linux 3.10.53. I have two user LEDs on GPIO with given configuration. I can start using these LEDs with gpio_led driver by providing following configuration in the machine file (/arch/arm/mach-imx/mach-imx6q.c)

 

#define GREEN_LED_CLOUD     IMX_GPIO_NR(4, 26)

#define GREEN_LED_POWER     IMX_GPIO_NR(4, 28)

#define RED_LED_CLOUD       IMX_GPIO_NR(4, 27)

#define RED_LED_POWER       IMX_GPIO_NR(4, 29)

 

 

static const struct gpio_led my_leds[] __initconst = {

    {  

        .name   = "led-cloud:green",

        .active_low = 1,

        .gpio   = GREEN_LED_CLOUD,

    }, {

        .name   = "led-cloud:red",

        .active_low = 1,

        .gpio   = RED_LED_CLOUD,

    }, {

        .name   = "led-power:green",

        .default_trigger = "heartbeat",

        .active_low = 1,

        .gpio   = GREEN_LED_POWER,

    }, {

        .name   = "led-power:red",

        .active_low = 1,

        .gpio   = RED_LED_POWER,

    }, 

};

static const struct gpio_led_platform_data my_led_pdata __initconst = {

    .num_leds   = ARRAY_SIZE(my_leds),

    .leds       = my_leds,

};

 

..

 

gpio_led_register_device(-1, &my_led_pdata);

 

But I want to configure these LEDs via Device Tree file. I am not sure exactly how I will add these entries in the Device Tree file. As per my current understanding I have created following node in the Device Tree file.

 

    leds {

        compatible = "gpio-leds";

 

        led-green-1 {

            label = "Green1";

            gpios = <0x15 26 0>;          /* 0x15 is defined as GPIO4 */

            linux,default-trigger = "heartbeat";

            linux,default-state = "on";

        };  

 

 

        led-green-2 {

            label = "Green2";

            gpios = <0x15 28 0>;          /* 0x15 is defined as GPIO4 */

            linux,default-trigger = "heartbeat";

            linux,default-state = "on";

        };  

 

 

        led-red-1 {

            label = "Red1";

            gpios = <0x15 27 0>;          /* 0x15 is defined as GPIO4 */

            linux,default-trigger = "heartbeat";

            linux,default-state = "on";

        };

   };

 

When I start my system, I receive following message for 3 LEDS I have defined in DT file.


leds-gpio leds.26: pins are not configured from the driver

and I can not use LEDs via /sys/class/leds/Green1. If I do echo 1 > /sys/class/leds/Green1/birghtness nothing happens with the LEDs. I suppose I have to define the GPIO muxing somewhere but I can't get where ?

 

Any help is appreciated.

 

Regards,

Farrukh Arshad.

Outcomes