How to set GPIO pin output value in device tree

0

I am using an iMX6 based board and I'd like to set the GPIO value of an arbirtrary ouput to 1 or 0 at boot using the Device Tree. Is it possible and how can I do that?

I wonder if I have to rely on the gpio-leds feature or if I can define a new node in the DT.

I found some topics on the internet saying I can do as below but doesn't work.

test {
    compatible = "gpio-leds";
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio_leds>;

    myout {
        label = "myoutlabel";
        gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
        default-state = "off";
    };
};

pinctrl_gpio_leds: gpioledsgrp {
    fsl,pins = <
        MX6QDL_PAD_GPIO_8__GPIO1_IO08  0x80000000   // My output
    >;
};

Any hint would be appreciated. TIA

linux
gpio
device-tree
imx6
asked on Stack Overflow Feb 22, 2019 by Marco

1 Answer

0

You can enable/disable the internal Pull-Up/Pull-Down resistor (along with other electrical characteristics) that is attached to that pin, thus forcing a logic 1/0 in the pin. You should seek the "pad control register" for that pad (IOMUXC_SW_PAD_CTL_PAD_GPIO_8) in the processor reference manual, and then look which characteristics you wish to enable/disable by setting the right bits to 1 or 0, as needed, in the aforementioned register. However, I'm not sure if this is exactly what you're looking for.

Maybe this can help to understand the operation: http://cache.freescale.com/files/32bit/doc/app_note/AN5078.pdf

answered on Stack Overflow May 6, 2019 by danlor • edited May 6, 2019 by danlor

User contributions licensed under CC BY-SA 3.0