Question

How should default settings to gpio pins be configured device tree - specifically on Freescale imx series.

So far I have only been able to configure gpios using the led interface:

gpioinit {
   compatible = "gpio-leds";
    pinctrl-names = "default";
    mykpp {
        gpios = <&gpio4 15 1>;
    };
};

The above code sets gpio 4 15 to 1 during boot which is what I want. However, I assume there is a better way doing this making this pin show up in sysfs as a general gpio and not a gpio-led

No correct solution

OTHER TIPS

If it's a GPIO, your dts file should show something like:

    gpio0: gpio@c00 {
        #address-cells = <1>;
        #size-cells = <0>;
        cell-index = <0>;
        compatible = "fsl,mpc8377-gpio";
        reg = <0xc00 0x100>;
        interrupts = <74 0x8>;
        interrupt-parent = <&ipic>;
        gpio-controller;

        gpio-pin@11 {
            compatible = "fsl,mpc8377-gpio-input";
            active_status = "low";
            gpios = <&gpio0>;
            pin = <11>;
        };
    }

This example is taken from MPC8377's dts file. You may want to have a look at /drivers/gpio/gpio-fsl.c

I needed to do this recently, but I found that a "pin hog" was the correct and more generic solution.

This is an excellent example here: Device Tree dependency between two nodes

Documentation: https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt

I just tested the following DT on a i.MX6 and Buildroot/Busybox, kernel v4.19.169. Here is the DT snippet that makes it work, BUT you can't use the pin anymore in user space. Note, by the way, the tricky syntax of the gpios = property. That one drove me nuts !

&gpio7 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio_en>;

    sysstat@11 {
        gpio-hog;
        gpios = <11 GPIO_ACTIVE_HIGH>;
        output-low;
        line-name = "SYS_STAT";
    };
};

&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpios>;

        pinctrl_gpio_en: gpiostatgrp {
            fsl,pins = <
                MX6QDL_PAD_GPIO_16__GPIO7_IO11      0x130b0
            >;
        };
};

0x130b0 means : hysteresis, 100K pull-down, PUE=1 (pull-up enable), PKE=1 (keeper enabled). This is enough to drive the pin low, even if the sysstat@11 is missing. But the pin is still configured as an input.

Check pin config (note the [used] string) :

# gpioinfo 6 | grep "line  11"                                                  
        line  11:      unnamed   "SYS_STAT"  output  active-high [used]         

An alternate way would be to delete the sysstat@11 node to just do the pin muxing and pin configuration. I'm not sure if it's very smart, though.

Yet another option, as the pin is configured as a GPIO by default, is to not alter the DT at all and use a /etc/init.d script instead, with the command gpioset 6 11=0. It works too, but it's not as fast as the DT option.

I think I'll go for the last option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top