Device Tree GPIO Reset

0

I'm working on a board based on the iMX6 and am trying to configure a number of GPIOs that are being used as chip enable and reset lines. Based on the research I've done, the way to handle this is via the gpio-reset driver in the device tree. Following the documentation I've come up with the below code which compiles but I'm not sure how to then control these reset lines from user space.

The first device tree driver I used was the gpio-leds which created an leds folder in sys/class with nodes to control the LED. However I don't see anything similar for reset. So I have 2 questions:

1) Is GPIO-RESET the correct binding to use for controlling reset lines, enable lines, etc.

2) Is there documentation on how to handle this and other bindings from user space, similar to how I'm controlling the GPIO-LED?

Kernel: Linux buildroot 4.1.15

/dts-v1/;

#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/omap.h>
#include "imx6ul.dtsi"

/ {
    model = "Freescale i.MX6 UltraLite 14x14 EVK Board";
    compatible = "fsl,imx6ul-14x14-evk", "fsl,imx6ul";

    memory {
        reg = <0x80000000 0x20000000>;
    };

    /* Reset Line Configuration */
    gpio_resets {
        compatible = "linux,gpio-reset";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gpioreset>;

        gnss {
            gpios = <&gpio1 4 0>;
            asserted-state = <0>;
            duration-ms = <100>;
            auto;
        };
    };

    ...

};

&iomuxc {
  pinctrl-names = "default";
  imx6ul-evk {

    pinctrl_gpioreset:
    gpiorstgrp {
      fsl,pins = <
      MX6UL_PAD_GPIO1_IO04__GPIO1_IO04         0x000010B0  /* GNSS RESET_N */
      >;
    };

    ...

};
embedded-linux
device-tree
asked on Stack Overflow Aug 9, 2017 by Otus • edited Aug 10, 2017 by Otus

2 Answers

0

I'm not exactly sure about the gpio-reset sysfs interface as I couldn't find any information in bindings documentation, but for the normal gpio interface you need to export the gpio before it will show up in /sys/class/gpio/gpio*. Basically you just need to write the number of the gpio you wish to use to the export file underneath /sys/class/gpio. Here is an example of someone doing that. If you're just toggling the gpio on/off that interface should be enough.

answered on Stack Overflow Aug 12, 2017 by zeus_masta_funk
0
  1. Is GPIO-RESET the correct binding to use for controlling reset lines, enable lines, etc.

I have been looking for such a driver too.

I can see that there was a proposal for exactly this:

https://lwn.net/Articles/585145/

but I cannot find it in my kernel version (tracking the 5.4.y releases).

Only in some stale imx6 kernel: https://github.com/samnazarko/linux-imx6/blob/master/Documentation/devicetree/bindings/reset/gpio-reset.txt

So I will either

  • create a small driver to support the "delayed" function based on the above proposal (time of asserting the reset at boot).
  • use gpio-led with a default-state. Maybe using the "one-shot" trigger, to provide a single-write API to my apps. (Write once to the sysfs shot file results in a single toggle of the pin for a configurable time.)
  • Totally handle it from the userspace via libgpio or sysfs. (Maybe combined with gpio-led, to have at least a clearly defined state of the line during boot.)
answered on Stack Overflow Jan 20, 2021 by lnksz

User contributions licensed under CC BY-SA 3.0