i.MX6 Device Tree Entry for GPIO based LEDs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX6 Device Tree Entry for GPIO based LEDs

7,928 Views
Farrukh
Contributor II

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.

Labels (2)
Tags (2)
0 Kudos
3 Replies

2,924 Views
EricNelson
Senior Contributor II

Hi Farrukh,


I think you need a pinctrl reference to set up the pads appropriately.

You can find a working example for our Nitrogen6_Lite board here:

     linux-imx6/imx6qdl-nit6xlite.dtsi at boundary-imx_3.10.53_1.1.1_ga · boundarydevices/linux-imx6 · Gi...

0 Kudos

2,924 Views
igorpadykov
NXP Employee
NXP Employee

Hi Farrukh

could you change to gpios = <&gpio4 26 0>

and check if this will work.

Best regards

igor

0 Kudos

2,924 Views
Farrukh
Contributor II

Hi Igor,

I have tried this but didn't worked. My GPIO node is

            gpio4: gpio@020ac000 {

                compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";

                reg = <0x20ac000 0x4000>;

                interrupts = <0x0 0x4a 0x4 0x0 0x4b 0x4>;

                gpio-controller;

                #gpio-cells = <0x2>;

                interrupt-controller;

                #interrupt-cells = <0x2>;

            };  

But after this change I got following extra messages and I don't see anything in the /sys/class/leds anymore. Earlier gpios = <0x15 26 0> 0x15 was pointing to the wrong GPIO as you have pointed.

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

platform leds.27: Driver leds-gpio requests probe deferral

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

platform leds.27: Driver leds-gpio requests probe deferral

Thanks

Farrukh

0 Kudos