Unable to hook my GPIO into gpio-leds driver

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

Unable to hook my GPIO into gpio-leds driver

2,234 Views
colinhelliwell
Contributor III

I'm attempting to modify a Device Tree for an off-the-shelf i.MX6 Solo dev board. I'll need drivers to control my own IO signals, but to start with (and to avoid added problems with my own driver code!), I'm trying to just hook a GPIO onto the gpio-leds driver, e.g. to show 'heartbeat'.
I'm working with the Yocto build envoronment, and have created my own top-level dts, including the chip/soc/board include files which are used in the manufacturer's own example dts.

The board boots fine with the new tree. I can see cpuLed1 in /sys/class/leds; I can see the pin in /sys/kernel/debug/pinctrl/20e0000.iomuxc/pinmux-pins ("pin 110 (MX6DL_PAD_EIM_DA7): 20e0000.iomuxc (GPIO UNCLAIMED) (HOG) function iomuxc group hoggrp")
But I can't get the pin to do anything but sit high - I've tried writing to 'trigger' and to 'brightness'. I also tried it on a different pin (GPIO4_29), and that seems to just sit low.

Anyone spot what I've got wrong? Or can give me some tips on how/where to further debug what is/isn't getting set up?
I'm not even sure whether the gpio-leds driver is starting up (though the 'compatible' means it should?) - the build is currently putting all drivers statically into the uImage, even ones set as M in the config. But that's another story...

The manufacturer's imx6qdl-tx6.dtsi file sets up another heartbeat LED (GPIO2_20), which I've followed in setting up mine. Not yet able to see if theirs is flashing or not (microscope needed).


/dts-v1/;
#include "imx6dl.dtsi"
#include "imx6qdl-tx6.dtsi"

/

{
    model = "MyBoard";
    compatible = "karo,imx6dl-tx6dl", "fsl,imx6dl";

    cpus {
        /delete-node/ cpu@1;
    };


    leds {
        compatible = "gpio-leds";

        cpuLed1 {
            label = "cpuLed1";
            gpios = <&gpio3 7 GPIO_ACTIVE_HIGH>; // J7-26
            linux,default-trigger = "heartbeat";
        };
    };

};

&iomuxc {

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

    // delete the inherited hoggrp and re-create here with extra pin

    /delete-node/ hoggrp;

    pinctrl_hog: hoggrp {
    fsl,pins = <
        MX6QDL_PAD_EIM_A18__GPIO2_IO20 0x1b0b1 /* LED */
        MX6QDL_PAD_SD3_DAT2__GPIO7_IO06 0x1b0b1 /* ETN PHY RESET */
        MX6QDL_PAD_SD3_DAT4__GPIO7_IO01 0x1b0b1 /* ETN PHY INT */
        MX6QDL_PAD_EIM_A25__GPIO5_IO02 0x1b0b1 /* PWR BTN */
        MX6QDL_PAD_EIM_DA7__GPIO3_IO07 0x1b0b1
    >;


    };

    pinctrl_usdhc4: usdhc4grp {
        fsl,pins = <
            MX6QDL_PAD_SD4_CMD__SD4_CMD 0x070b1
            MX6QDL_PAD_SD4_CLK__SD4_CLK 0x070b1
            MX6QDL_PAD_SD4_DAT0__SD4_DATA0 0x070b1
            MX6QDL_PAD_SD4_DAT1__SD4_DATA1 0x070b1
            MX6QDL_PAD_SD4_DAT2__SD4_DATA2 0x070b1
            MX6QDL_PAD_SD4_DAT3__SD4_DATA3 0x070b1
            MX6QDL_PAD_NANDF_ALE__SD4_RESET 0x0b0b1
        >;
    };

};

&usdhc4 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_usdhc4>;
    bus-width = <4>;
    non-removable;
    no-1-8-v;
    fsl,wp-controller;
    status = "okay";
};

Labels (2)
0 Kudos
4 Replies

1,264 Views
igorpadykov
NXP Employee
NXP Employee

Hi colinhelliwell

please check detailed description of gpio dts usage on

https://www.kosagi.com/w/index.php?title=Definitive_GPIO_guide

Any examples on how to modify the .dts (device tree) source for custom hardware? 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,264 Views
colinhelliwell
Contributor III

Thanks for the info, that helped.

I have a follow-on question: I'm writing my own device driver for some of my GPIOs. I have been able to find the pins in the device tree using 'of_get_named_gpio_flags()' when they are at a top level, but for neatness I would prefer to group them hierarchically e.g.

    rfctrl: rfctrl {
        compatible = "wg2xx-rfctrl";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_rfctrl>;
        status = "okay";

        //test-name = <&gpio4 26 0>;
        jn {
            jnProgN = <JNPROG_GPIO 0>;
        };
        alt {
            altGpio0 = <ALTGPIO0_GPIO 0 >;
            altGpio1 = <ALTGPIO1_GPIO 0 >;
            altGpio2 = <ALTGPIO2_GPIO 0 >;
            altGpio3 = <ALTGPIO3_GPIO 0 >;
        };
    };

Is there a way to search into the subtree ("jn" or "alt"), or descend into it?

0 Kudos

1,264 Views
igorpadykov
NXP Employee
NXP Employee

please post this on special device tree forum

Device Tree - eLinux.org 

Best regards
igor

0 Kudos

1,264 Views
colinhelliwell
Contributor III

Hi Igor,

I've subscribed and posted on that mailing list, but it seems to be almost entirely used for patching specific machines' device trees, rather than about *using* device trees. Can you give any more suggestions for somewhere to find help with my question?

Thanks.

0 Kudos