GPIO (Linux)
Introduction
Toradex BSP Layers and Reference Images for Yocto Project
libgpiod is supported and can be used on Toradex BSP Layers and Reference Images for Yocto Project from the release 3.0b3 onwards. The userspace tools and libraries are included in Toradex Reference Images. In this article, you will be able to learn how to use the command-line tools and the C API as well.
Torizon OS
Torizon OS is preferred for using libgpiod, due to ease-of-use and a smoother application development experience. Visit the article How to Use GPIO on Torizon OS.
GPIO - Libgpiod
Pin Standardization
Since the long famous sysfs GPIO interface (/sys/class/gpio
) has been deprecated, the GPIO Char Device API, also known as libgpiod
has been adopted by the Linux kernel community as the replacement. The sysfs interface is still supported by Toradex BSPs but you are discouraged to use it.
GPIO pins should be named using the edge connector name (SODIMM
on Colibri/Verdin and MXM3
on Apalis). That way, the user can easily identify and use GPIO pins by their names, instead of bank and number.
The access could be done via libgpiod
command-line tools:
# gpioinfo
gpiochip0 - 32 lines:
line 0: "SODIMM_43" "cd" input active-low [used]
line 1: "SODIMM_45" "Wake-Up" input active-high [used]
line 2: "SODIMM_135" unused input active-high
line 3: "SODIMM_22" unused input active-high
...
# gpiofind SODIMM_135
gpiochip0 2
Or using the libgpiod
library in a C/C++ program, as provided in the gpio-event.c and gpio-toggle.c examples.
If more meaningful names are required, the user can overwrite the GPIO names via device tree overlay. This feature should be implemented in the Linux BSP via the device tree.
Command Line Tools
Here we present how to use the command-line tools.
gpiodetect
Search for the GPIO banks, /dev/gpiochiop0 ... /dev/gpiochipX, and how many GPIO lines they have:
# gpiodetect
gpiochip0 [5d080000.gpio] (32 lines)
gpioinfo
Read and displays the information contained in the GPIO bank lines. All usable pins exposed on the edge connector - either SODIMM or MXM3 depending on the SoM family - are labelled as SODIMM_x
or MXM3_x
.
Pins labelled as unnamed
are not available for use on the SODIMM/MXM3 connector.
See the example below:
# gpioinfo
gpiochip0 - 32 lines:
line 0: "SODIMM_216" unused input active-high
line 1: "SODIMM_19" unused input active-high
line 2: unnamed unused input active-high
line 3: unnamed "interrupt" input active-high [used]
line 4: unnamed unused input active-high
line 5: unnamed "spi_imx" input active-high [used]
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
line 8: "SODIMM_220" unused input active-high
line 9: "SODIMM_222" unused input active-high
line 10: unnamed "interrupt" input active-high [used]
line 11: "SODIMM_218" unused input active-high
line 12: "SODIMM_155" "regulator-usb-otg1" output active-high [used]
line 13: "SODIMM_157" unused input active-high
line 14: "SODIMM_185" "regulator-usb-otg2" output active-high [used]
line 15: "SODIMM_187" unused input active-high
line 16: unnamed unused input active-high
line 17: unnamed unused input active-high
line 18: unnamed unused input active-high
line 19: unnamed unused input active-high
line 20: unnamed unused input active-high
line 21: unnamed unused input active-high
line 22: unnamed unused input active-high
line 23: unnamed unused input active-high
line 24: unnamed unused input active-high
line 25: unnamed unused input active-high
line 26: unnamed unused input active-high
line 27: unnamed unused input active-high
line 28: unnamed unused input active-high
line 29: unnamed unused input active-high
line 30: unnamed unused input active-high
line 31: unnamed unused input active-high
To see only available pins, you can filter the command output with grep
:
# gpioinfo | grep -e "SODIMM" -e "MXM3"
This command is useful to check which rows are being used, with their respective use descriptions, for a GPIO bank.
gpioset
Writes the output value of a certain line in a gpiochip passed by argument. The example set the GPIO bank 0 line 12 to output low:
# gpioset /dev/gpiochip0 12=0
You can also use only the GPIO bank index as a parameter:
# gpioset 0 12=0
Now the example to set the GPIO bank 0 line 12 to output high:
# gpioset 0 12=1
gpioget
Reads the value of input from a certain line in a gpiochip passed by argument:
# gpioget 0 13
1
The return of this command can be 1 if the input is high and 0 if the input is low.
# gpioget 0 13
0
gpiomon
Wait for events on GPIO rows passed by argument:
# gpiomon 0 13
event: FALLING EDGE offset: 13 timestamp: [1570281706.661390750]
event: FALLING EDGE offset: 13 timestamp: [1570281706.661435750]
event: RISING EDGE offset: 13 timestamp: [1570281706.661604000]
event: RISING EDGE offset: 13 timestamp: [1570281706.916220125]
event: FALLING EDGE offset: 13 timestamp: [1570281706.918247625]
This command is useful for polling the lines to expect incoming input events.
How to Replace sysfs Commands
The most important commands are gpioget
and gpioset
, though you could possibly use gpiomon
as well. Check out our example that writes and reads from GPIO pins. The sysfs commands are commented in the script:
C Language Examples
Some examples are provided in this chapter, illustrating how to use the C API from libgpiod. For both of the examples, include libgpiod library.
#include <gpiod.h>
GPIO Toggle
The example below uses the libgpiod API to access a GPIO bank and line that are the arguments to the program:
Here are some relevant highlights.
Pass the chip number and offset as arguments when calling the application, as shown below:
# gpio-toggle <gpio-number> <gpio-offset>
For example, for Apalis iMX8 GPIO3 - LSIO.GPIO0.IO12
:
# gpio-toggle 0 12
And in the source code, use snprintf
to get the GPIO chip and offset from the arguments argv[1]
and argv[2]
:
snprintf(chip, sizeof(chip), "gpiochip%s", argv[1]);
offset = atoi(argv[2]);
Toggle a GPIO:
while (1) {
line_value = !line_value;
gpiod_ctxless_set_value(chip, offset,line_value, false,"gpio-toggle",NULL,NULL);
sleep(1);
printf("Setting pin to %d\n", line_value);
}
To run this example you can build the application using SDK and deploy it to the module as described in Linux SDKs or create an application recipe as described in Custom meta layers, recipes and images in Yocto Project (hello-world examples) .
Read GPIO Using Events (Interrupt Driven)
This example uses the libgpiod API to register for an event (interrupt-driven) on a rising edge. For this example make sure to add 4 arguments, the first two specifying the bank and line number of the input GPIO and the next two for the bank and line number of the output GPIO:
Here are some relevant highlights.
Include libgpiod
library:
#include <gpiod.h>
Define GPIO chip and line structs:
struct gpiod_line *output_line;
struct gpiod_line *input_line;
Configure the GPIO structs using the get_gpio_line
function defined in the sample:
input_line = get_gpio_line(chip, offset);
output_line = get_gpio_line(chip, offset);
Request rising events notification:
ret = gpiod_line_request_rising_edge_events(input_line, "gpio-test");
ret = gpiod_line_request_output(output_line, "gpio-test", GPIOD_LINE_ACTIVE_STATE_HIGH);
Wait for an event to happen, read which event it was and validate that it's a rising event:
while (1) {
gpiod_line_event_wait(input_line, NULL);
if (gpiod_line_event_read(input_line, &event) != 0)
continue;
/* this should always be a rising event in our example */
if (event.event_type != GPIOD_LINE_EVENT_RISING_EDGE)
continue;
}
Pass the chip number and offset from input and output GPIOs as arguments when calling the application, as shown below:
# gpio-event <gpio-input-number> <gpio-input-offset> <gpio-output-number> <gpio-output-offset>
For example, for Apalis iMX8 GPIO2 - LSIO.GPIO0.IO9
as input and GPIO3 - LSIO.GPIO0.IO12
as output:
# gpio-event 0 9 0 12
To run this example you can build the application using SDK and deploy it to the module as described in Linux SDKs or create an application recipe as described in Custom meta layers, recipes and images in Yocto Project (hello-world examples) .
Makefile
To build your project with libgpiod
properly, you must link the libgpiod
library correctly.
You can create a Makefile
with the -lgpiod
flag. For the gpio-toggle.c
example the Makefile
can be as follows:
gpio-toggle: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) -lgpiod
.NET Examples
The article .NET Core Development and Debugging on Torizon Using Visual Studio Code explains how to use libgpiod with .NET.
Python Examples
Our samples repository on GitHub provides an example: Python libgpiod example The following articles can help you with enough context for running and extending the sample:
- Visual Studio Code Extension for Torizon
- Python Development and Debugging on Torizon OS Using Visual Studio Code
GPIO Sysfs
The GPIO sysfs is deprecated and has been discontinued. Its use for BSP 3.0 is discouraged and will be removed. For Torizon use the new char device API and libgpiod libraries and tools. See the GPIO Char Device API - libgpiod article for reference.
To use pins other than the already exported ones directly from userspace through sysfs
they first have to be exported as GPIOs.
How to find the pin number
Use the module datasheet to find what SoC pin(s) are routed to what module edge connector pin and the carrier board datasheet or schematic to find where those signals go to. The relationship between SOC GPIO names and the 'magic' numbers used here can be found on this page. The bank and line nomenclature can differ depending on the processor family.
For example, to verify the GPIO banks and lines for the Apalis i.MX8, check the Apalis i.MX8 datasheet on the section I/O Pins -> Functions List. For example, let's assume we need to access MXM3 X1 pin 5 (Apalis GPIO3) from an Apalis iMX8:
From the datasheet we can see that Apalis MXM3 X1 Pin 5 has the GPIO function on ALT3 accessible at LSIO.GPIO0_IO12. This means we need to access GPIO bank 0 line 12.
Apalis iMX6 starts enumerating GPIO banks with 1, while GPIO banks in Linux always start at 0. That means that GPIO2_IO6 on Apalis iMX6 is GPIO bank 1 line 6 on Linux. Either way, it is important to make sure that the pin is actually muxed as a GPIO in the device-tree or platform data. Failing to do so will not give any error. The pin will simply report 0 if configured as an input and not react to any state change if configured as an output.
The highlighted function in the datasheet indicates the default function of the given pin. If the GPIO function is not indicated as default, there is a high chance that you will need to define the pins you will be using as GPIO in a custom Device Tree Overlay. Find further documentation and examples on how to do so here: Device Tree Overlays
How to use GPIO Sysfs
In the following example, we are going to use SODIMM pin 100 of a Colibri T20. This makes for the following relationship:
SODIMM Pin Number | SODIMM Pin Name | SoC Pin Name | SoC GPIO Function Name | Kernel GPIO Number | Evaluation Board Connector |
---|---|---|---|---|---|
100 | nPXCVREN | SPI1_SCK | X5 | 189 | X9. 7 |
To export a particular pin as GPIO for user control proceed as follows:
# echo 189 > /sys/class/gpio/export
To change that GPIO pins direction to in/out:
# echo "in" > /sys/class/gpio/gpio189/direction
or
# echo "out" > /sys/class/gpio/gpio189/direction
To check the value (in case its direction is input):
On i.MX based modules one cannot read back the value which has been set to an output unless one did set the SION bit in the pin muxing.
# cat /sys/class/gpio/gpio189/value
To change its value (in case its direction is output):
# echo 1 > /sys/class/gpio/gpio189/value
or
# echo 0 > /sys/class/gpio/gpio189/value
To directly force a GPIO to output and set its initial value (e.g. glitch-free operation):
# echo high > /sys/class/gpio/gpio189/direction
or
# echo low > /sys/class/gpio/gpio189/direction
To configure a GPIO as an interrupt source:
If a GPIO is configured as an input, one can configure the GPIO as an interrupt source. Configure GPIO if the interrupt occurs when the GPIO signal has a rising edge, a falling edge, or interrupts on both rising and falling edges.
$ echo "rising" > /sys/class/gpio/gpio189/edge
Possible values:
- rising: Trigger on rising edge
- falling: Trigger on falling edge
- both: Trigger on both edges
- none: Disable interrupts on both edges
To un-export aka revert the exporting of a GPIO pin:
$ echo 189 > /sys/class/gpio/unexport
GPIOs which are already used in the drivers can not be controlled from sysfs, unless a driver explicitly exported that particular pins GPIO.
More information concerning the Linux' GPIO subsystem can be found in the following kernel documentation file:
https://git.toradex.com/cgit/linux-toradex.git/tree/Documentation/gpio.txt
GPIO Power Management Keys
Linux systems use key events to initiate a clean shutdown or suspend-to-memory sequence. On a typical PC, pressing the power button generates a key event which will lead to a shutdown of the system. For an embedded system, a GPIO with a key code assigned can be used to trigger key events. When the key is pressed (GPIO triggered), the system will initiate the sequence.
The systemd service systemd-logind is the user-space program listening to key events (if they are tagged with the string "power-switch", see below). Four key codes are supported:
- KEY_POWER = initiate shutdown
- KEY_POWER2 = initiate shutdown
- KEY_SLEEP = suspend-to-ram, commonly known as "suspend"
- KEY_SUSPEND = suspend-to-disk, commonly known as "hibernate"
There are two steps required:
- Declare a GPIO as an input device and assign a key code using the GPIO keyboard driver
- Use a udev rule to tag the GPIO input device
GPIO Keyboard Driver
For device tree enabled kernels, a node as follows can be used in the carrier board device tree file:
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpiokeys>;
power {
label = "Power-Key";
gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
linux,code = <KEY_POWER>;
debounce-interval = <10>;
};
};
For details on how to customise the device tree refer to the Device Tree Customization article.
Tag the GPIO Input Device
Use a udev rule to add the power-switch tag to the GPIO key event source. Store the file in a udev rules directory, e.g. /etc/udev/rules.d/power-key.rules
ACTION=="remove", GOTO="power_switch_end"
SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_PATH}=="platform-gpio-keys*", ATTRS{keys}=="*", TAG+="power-switch"
LABEL="power_switch_end"
With that, all keycodes get tagged as power-switch events, and systemd will interpret the relevant key codes. The exact behaviour can be fine-tuned through HandlePowerKey/HandleSuspendKey and HandleHibernateKey in /etc/systemd/logind.conf
.
GPIO Power-Off
To power off a system completely after shutdown, often a GPIO is needed to switch off the system. Newer Kernel provides a specific GPIO power-off driver to achieve this.
Our Colibri and Apalis Evaluation Boards have a push button power on/off controller (LTC2954) which has a GPIO input FORCE_OFF# (X4-5 on Colibri or X61-5 on Apalis). This signal makes sure that the DC-DC converters on the carrier board are switched-off completely as if the user pressed the on/off button. After connecting these signals to a GPIO, the GPIO power-off driver needs to be enabled. On device-tree based kernels (e.g. Colibri/Apalis iMX6), the driver CONFIG_POWER_RESET_GPIO
needs to be enabled (up to v2.3Beta5 this is not the case by default).
For i.MX6 based modules CONFIG_POWER_RESET_GPIO
must be set in the kernel configuration. Additionally, for the 3.10.17 kernel version, you will have to at least cherry-pick this commit
or use the toradex_imx_3.10.17_1.0.0_ga-next branch.
For i.MX8/8X based modules CONFIG_POWER_RESET_GPIO
must be set in the kernel configuration. You also need to correctly mux the GPIO pin that you choose to use. Here is an example of device tree that uses SO-DIMM 104 as power-off GPIO for Colibri iMX8X:
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri-eval-v3.dtsi b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri-eval-v3.dtsi
index 6fa5b6207c70b..2d8acb0c2ac33 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri-eval-v3.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri-eval-v3.dtsi
@@ -41,7 +41,10 @@
gpio-key,wakeup;
};
};
-
+ gpio-poweroff {
+ compatible = "gpio-poweroff";
+ gpios = <&gpio3 23 GPIO_ACTIVE_LOW>;
+ };
panel {
compatible = "panel-dpi";
backlight = <&backlight>;
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
index d6a46f06b6a05..effec9b844d4e 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
@@ -413,7 +413,7 @@
SC_P_QSPI0B_DATA3_LSIO_GPIO3_IO21 0x20 /* SODIMM 98 */
SC_P_SAI1_RXFS_LSIO_GPIO0_IO31 0x20 /* SODIMM 100 */
SC_P_QSPI0B_DQS_LSIO_GPIO3_IO22 0x20 /* SODIMM 102 */
- SC_P_QSPI0B_SS0_B_LSIO_GPIO3_IO23 0x20 /* SODIMM 104 */
+ SC_P_QSPI0B_SS0_B_LSIO_GPIO3_IO23 0x21 /* SODIMM 104 */
SC_P_QSPI0B_SS1_B_LSIO_GPIO3_IO24 0x20 /* SODIMM 106 */
>;
};
GPIO LED
The GPIO LED driver allows using a GPIO to control a LED. Using the Kernels LED driver framework has the advantage that triggers can be specified, which allow using an LED as a visual activity signal for various system activities.
leds {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_leds>;
led0: user1 {
label = "user1";
gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>; /* SODIMM 103 */
default-state = "off";
linux,default-trigger = "mmc0";
};
};
...
pinctrl_gpio_leds: gpioleds {
fsl,pins = <
VF610_PAD_PTC3__GPIO_48 0x2180
>;
};
You can also get a list of valid triggers (and configure the active trigger) through the sysfs file at /sys/class/leds/user1/trigger.
GPIO PPS
The GPIO PPS is a feature present in the Linux Kernel that allows the usage of a GPIO with a given Pulse-Per-Second (PPS) signal.
Starting from BSP 5, it's enabled by default in the kernel config on Toradex Reference Images for Yocto Project and Torizon OS:
CONFIG_PPS_CLIENT_GPIO
CONFIG_PPS_CLIENT_LDISC
Here is one example of a device tree for Colibri iMX7D 1GB. In addition to the example, you must also make sure to check the pin muxing, i.e. make sure that no other driver muxes and claims the pin function GPIO1_IO02, and to mux the pin to gpio as part of the pps node.
Also note that since pps
is a new node, it must be created somewhere in the tree under /
.
/ {
model = "Toradex Colibri iMX7D 1GB on Colibri Evaluation Board V3 Testing for custom carrier";
compatible = "toradex,colibri_imx7d_emmc-eval", "toradex,colibri_imx7d_emmc", \
"fsl,imx7d";
pps {
compatible = "pps-gpio";
gpios = <&gpio1 2 0>;
assert-falling-edge;
};
};
Please refer to the Linux kernel documentation on device tree bindings for more details: Device-Tree Bindings for a PPS Signal on GPIO
GPIO U-Boot
One can also access GPIOs from U-Boot. This allows one to implement functionality such as “Press button X and turn the device ON to upgrade firmware" using U-Boot scripts.
The GPIO driver can be used from within the U-Boot source code. Additionally, the GPIO driver has a corresponding gpio command-line interface that can be used to set and get GPIO values. Note that for the command-line interface to work the corresponding pin must be muxed to its GPIO functionality in the U-Boot code.
The relationship between SOC GPIO names and the numbers used here can be found on GPIO Alphanumeric to GPIO Numeric Assignment article.
Command Line Interface
# gpio help
gpio - query and control gpio pins
Usage:
gpio <input|set|clear|toggle> <pin>
- input/set/clear/toggle the specified pin
gpio status [-a] [<bank> | <pin>] - show [all/claimed] GPIOs
To set the GPIO:
> gpio set [gpio-number]
To clear the GPIO
> gpio clear [gpio-number]
To toggle the GPIO
> gpio toggle [gpio-number]
To read the state of GPIO:
> gpio input [gpio-number]
Usually, all GPIO pins are muxed as input in U-Boot. You can confirm it, for instance, with the command below:
> gpio status -a
Bank GPIO0_:
GPIO0_0: input: 0 [ ]
GPIO0_1: input: 0 [ ]
GPIO0_2: input: 0 [ ]
...
GPIO7_29: input: 0 [ ]
GPIO7_30: input: 0 [ ]
GPIO7_31: input: 0 [ ]
Example - Colibri iMX8X
This example has been tested on Colibri iMX8QXP + Colibri Evaluation Board V3.2 using the mainline master branch of U-Boot.
To calculate the pin number in U-Boot, use the formula below:
beware that this formula is different from the formula for the Linux user space provided in GPIO Alphanumeric to GPIO Numeric Assignment.
pin = 32 * GPIO_BANK + GPIO_LINE
For example, GPIO3_10:
pin = 32 * 3 + 10 = 106
Change the pinmux configuration in the U-Boot device tree, in the source code. The change below set the GPIO on SODIMM 45 as output:
diff --git a/arch/arm/dts/fsl-imx8qxp-colibri.dts b/arch/arm/dts/fsl-imx8qxp-colibri.dts
index 0c20edf2cf..562effb366 100644
--- a/arch/arm/dts/fsl-imx8qxp-colibri.dts
+++ b/arch/arm/dts/fsl-imx8qxp-colibri.dts
@@ -89,7 +89,7 @@
pinctrl_hog1: hog1grp {
fsl,pins = <
- SC_P_QSPI0A_DATA1_LSIO_GPIO3_IO10 0x00000020 /* 45 */
+ SC_P_QSPI0A_DATA1_LSIO_GPIO3_IO10 0x02000020 /* 45 */
SC_P_ENET0_RGMII_TXD3_LSIO_GPIO5_IO02 0x06000020 /* 65 */
SC_P_CSI_D07_CI_PI_D09 0x00000061
SC_P_QSPI0A_DATA2_LSIO_GPIO3_IO11 0x00000020 /* 69 */
Re-compile and deploy U-Boot, then toggle this GPIO from the U-Boot command-line:
> gpio set 106
gpio: pin 106 (gpio 106) value is 1
> gpio clear 106
gpio: pin 106 (gpio 106) value is 0
From Source Code
To access a GPIO earlier than what would be possible from the U-Boot command line or to include it in an algorithm written in source code using the GPIO API. In most cases this code would live in the board file (e.g. board/toradex/colibri_vf/colibri_vf.c
).
The GPIO's need to be configured only after the GPIO driver is loaded, if a GPIO gets configured before the driver has been loaded, the GPIO functions will have no effect. The 'board_init' function is called just after GPIO initialization and hence is an appropriate place to configure custom GPIO's.
E.g. To set GPIO_10 during boot from board file:
diff --git i/board/toradex/colibri_vf/colibri_vf.c w/board/toradex/colibri_vf/colibri_vf.c
index 3272733..ca30af8 100644
--- i/board/toradex/colibri_vf/colibri_vf.c
+++ w/board/toradex/colibri_vf/colibri_vf.c
@@ -478,6 +483,11 @@ int board_init(void)
*/
setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
+#ifdef CONFIG_VYBRID_GPIO
+ gpio_request(10, "SODIMM_PIN_23");
+ gpio_direction_output(10, 1);
+#endif
GPIO Debugging
All "free" Pins are configured as GPIOs by default and are already exported from within the board-specific platform configuration to be used from userspace through the sysfs interface.
To know what GPIOs are currently exported from the platform configuration resp. requested from drivers proceed as follows:
$ cat /sys/kernel/debug/gpio
Apalis iMX6
# cat /sys/kernel/debug/gpio
GPIOs 0-31, platform/209c000.gpio, 209c000.gpio:
gpio-0 (usb_host_vbus ) out lo
gpio-2 (PCIe reset ) out lo
gpio-4 (Wake-Up ) in hi
gpio-6 (sysfs ) in lo
gpio-25 (phy-reset ) out lo
gpio-28 (PCIe EP reset ) out lo
GPIOs 32-63, platform/20a0000.gpio, 20a0000.gpio:
gpio-36 (sysfs ) in lo
gpio-37 (sysfs ) in lo
gpio-38 (sysfs ) in lo
gpio-39 (sysfs ) in lo
gpio-58 (spi_imx ) out lo
gpio-62 (scl ) in hi
GPIOs 64-95, platform/20a4000.gpio, 20a4000.gpio:
gpio-80 (sda ) in hi
gpio-86 (usb_otg_vbus ) out lo
gpio-92 (usb_host_vbus_hub ) out lo
GPIOs 96-127, platform/20a8000.gpio, 20a8000.gpio:
gpio-116 (cd ) in hi
GPIOs 128-159, platform/20ac000.gpio, 20ac000.gpio:
gpio-153 (spi_imx ) out lo
GPIOs 160-191, platform/20b0000.gpio, 20b0000.gpio:
gpio-174 (cd ) in hi
GPIOs 192-223, platform/20b4000.gpio, 20b4000.gpio:
Apalis iMX8
# cat /sys/kernel/debug/gpio
gpiochip7: GPIOs 256-287, parent: platform/5d0f0000.gpio, 5d0f0000.gpio:
gpiochip6: GPIOs 288-319, parent: platform/5d0e0000.gpio, 5d0e0000.gpio:
gpiochip5: GPIOs 320-351, parent: platform/5d0d0000.gpio, 5d0d0000.gpio:
gpio-320 ( |reset ) out hi
gpiochip4: GPIOs 352-383, parent: platform/5d0c0000.gpio, 5d0c0000.gpio:
gpio-356 ( |VCC_USBH(2A|2C|2D|3|) out hi
gpio-364 ( |cd ) in hi IRQ
gpio-379 ( |ref-clock ) out hi
gpiochip3: GPIOs 384-415, parent: platform/5d0b0000.gpio, 5d0b0000.gpio:
gpio-412 ( |GPIO fan control ) out hi
gpiochip2: GPIOs 416-447, parent: platform/5d0a0000.gpio, 5d0a0000.gpio:
gpio-425 ( |cd ) in hi IRQ
gpio-436 ( |Wake-Up ) in hi IRQ
gpiochip1: GPIOs 448-479, parent: platform/5d090000.gpio, 5d090000.gpio:
gpio-449 ( |usb3503 intn ) out lo
gpio-450 ( |usb3503 reset ) out hi
gpio-452 ( |enable ) out hi
gpio-459 ( |phy-reset ) out hi
gpio-478 ( |HDMI_CTRL ) out hi
gpiochip0: GPIOs 480-511, parent: platform/5d080000.gpio, 5d080000.gpio:
gpio-511 ( |usb3503 connect ) out hi
Colibri iMX6
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:
gpio-37 ( |cd ) in hi IRQ
gpio-54 ( |Wake-Up ) in lo IRQ
gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio:
gpio-95 ( |usb_host_vbus ) out lo
gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:
gpio-108 ( |scl ) in hi
gpio-109 ( |sda ) in hi
gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
gpio-130 ( |spi_imx ) out hi
gpiochip5: GPIOs 160-191, parent: platform/20b0000.gpio, 20b0000.gpio:
gpiochip6: GPIOs 192-223, parent: platform/20b4000.gpio, 20b4000.gpio:
gpio-204 ( |id ) in hi IRQ
Colibri iMX6ULL
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
gpio-2 ( |VCC_USB[1-4] ) out lo
gpio-11 ( |enable ) out hi
gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:
gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio:
gpio-90 ( |spi_imx ) out hi
gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:
gpio-118 ( |sysfs ) in lo
gpio-120 ( |sysfs ) out lo
gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
gpio-128 ( |cd ) in hi
gpio-129 ( |Wake-Up ) in lo
gpio-130 ( |id ) in lo
gpio-139 ( |WIFI_PDN ) out hi
Colibri iMX7
# cat /sys/kernel/debug/gpio
GPIOs 0-31, platform/30200000.gpio, 30200000.gpio:
gpio-0 (cd ) in lo
gpio-1 (Wake-Up ) in lo
GPIOs 32-63, platform/30210000.gpio, 30210000.gpio:
GPIOs 64-95, platform/30220000.gpio, 30220000.gpio:
GPIOs 96-127, platform/30230000.gpio, 30230000.gpio:
gpio-103 (VCC_USB[1-4] ) out lo
gpio-107 (spi_imx ) out lo
GPIOs 128-159, platform/30240000.gpio, 30240000.gpio:
gpio-129 (enable ) out lo
GPIOs 160-191, platform/30250000.gpio, 30250000.gpio:
GPIOs 192-223, platform/30260000.gpio, 30260000.gpio:
gpio-206 (id ) in lo
Colibri iMX8X
# cat /sys/kernel/debug/gpio
gpiochip9: GPIOs 216-223, parent: i2c/16-0043, fxl6408, can sleep:
gpio-218 ( |power-on ) out lo
gpio-219 ( |clkreq ) out hi
gpio-220 ( |usb3503 reset ) out hi
gpio-221 ( |usb3503 bypass ) out hi
gpio-222 ( |disable ) out hi
gpiochip8: GPIOs 224-255, parent: platform/58222000.gpio, 58222000.gpio:
gpiochip7: GPIOs 256-287, parent: platform/5d0f0000.gpio, 5d0f0000.gpio:
gpiochip6: GPIOs 288-319, parent: platform/5d0e0000.gpio, 5d0e0000.gpio:
gpiochip5: GPIOs 320-351, parent: platform/5d0d0000.gpio, 5d0d0000.gpio:
gpio-329 ( |id ) in lo IRQ
gpiochip4: GPIOs 352-383, parent: platform/5d0c0000.gpio, 5d0c0000.gpio:
gpio-352 ( |reset ) out hi
gpio-355 ( |usbh_vbus ) out lo
gpio-371 ( |enable ) out hi
gpiochip3: GPIOs 384-415, parent: platform/5d0b0000.gpio, 5d0b0000.gpio:
gpio-388 ( |usb3503 intn ) out hi
gpio-393 ( |cd ) in hi IRQ
gpio-394 ( |Wake-Up ) in lo IRQ
gpio-396 ( |enable ) out hi
gpiochip2: GPIOs 416-447, parent: platform/5d0a0000.gpio, 5d0a0000.gpio:
gpiochip1: GPIOs 448-479, parent: platform/5d090000.gpio, 5d090000.gpio:
gpio-448 ( |fsl_lpspi ) out hi
gpiochip0: GPIOs 480-511, parent: platform/5d080000.gpio, 5d080000.gpio:
Verdin iMX8M Mini
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:
gpio-0 (SODIMM_216 )
gpio-1 (SODIMM_19 )
gpio-2 ( )
gpio-3 ( )
gpio-4 ( )
gpio-5 ( |spi_imx ) in hi
gpio-6 ( )
gpio-7 ( )
gpio-8 (SODIMM_220 )
gpio-9 (SODIMM_222 )
gpio-10 ( )
gpio-11 (SODIMM_218 )
gpio-12 (SODIMM_155 |usb_otg1_vbus ) out hi
gpio-13 (SODIMM_157 )
gpio-14 (SODIMM_185 |usb_otg2_vbus ) out hi
gpio-15 (SODIMM_187 )
gpiochip1: GPIOs 32-63, parent: platform/30210000.gpio, 30210000.gpio:
gpio-32 ( )
gpio-33 ( )
gpio-34 ( )
gpio-35 ( )
gpio-36 ( )
gpio-37 ( )
gpio-38 ( )
gpio-39 ( )
gpio-40 ( )
gpio-41 ( )
gpio-42 ( )
gpio-43 ( )
gpio-44 (SODIMM_84 |cd ) in hi IRQ
gpio-45 (SODIMM_78 )
gpio-46 (SODIMM_74 )
gpio-47 (SODIMM_80 )
gpio-48 (SODIMM_82 )
gpio-49 (SODIMM_70 )
gpio-50 (SODIMM_72 )
gpio-52 ( |V3.3_ETH ) out hi
gpiochip2: GPIOs 64-95, parent: platform/30220000.gpio, 30220000.gpio:
gpio-64 (SODIMM_52 )
gpio-65 (SODIMM_54 )
gpio-66 (SODIMM_64 )
gpio-67 (SODIMM_21 |enable ) out hi
gpio-68 (SODIMM_206 )
gpio-69 (SODIMM_76 |V3.3_SD ) out lo
gpio-70 (SODIMM_56 )
gpio-71 (SODIMM_58 )
gpio-72 (SODIMM_60 )
gpio-73 (SODIMM_62 )
gpio-74 ( )
gpio-75 ( )
gpio-76 ( )
gpio-77 ( )
gpio-78 (SODIMM_66 )
gpio-79 (SODIMM_17 |hpd ) in lo IRQ
gpio-80 ( )
gpio-81 ( )
gpio-82 ( )
gpio-83 (SODIMM_244 )
gpio-84 (SODIMM_250 )
gpio-85 (SODIMM_48 )
gpio-86 (SODIMM_44 )
gpio-87 (SODIMM_42 )
gpio-88 (SODIMM_46 )
gpio-89 ( |V3.3_WI-FI ) out hi
gpiochip3: GPIOs 96-127, parent: platform/30230000.gpio, 30230000.gpio:
gpio-96 (SODIMM_102 )
gpio-97 (SODIMM_90 )
gpio-98 (SODIMM_92 )
gpio-99 (SODIMM_94 )
gpio-100 (SODIMM_96 )
gpio-101 (SODIMM_100 )
gpio-102 ( )
gpio-103 ( )
gpio-104 ( )
gpio-105 (SODIMM_174 )
gpio-106 (SODIMM_120 )
gpio-107 (SODIMM_104 )
gpio-108 (SODIMM_106 )
gpio-109 (SODIMM_108 )
gpio-110 (SODIMM_112 )
gpio-111 (SODIMM_114 )
gpio-112 (SODIMM_116 )
gpio-113 ( )
gpio-114 (SODIMM_118 )
gpio-115 ( |SE050_ENABLE ) out hi
gpio-116 (SODIMM_88 )
gpio-117 (SODIMM_149 )
gpio-118 (SODIMM_147 )
gpio-119 (SODIMM_36 )
gpio-120 (SODIMM_32 )
gpio-121 (SODIMM_30 )
gpio-122 (SODIMM_34 )
gpio-123 (SODIMM_38 )
gpio-124 (SODIMM_252 |Wake-Up ) in hi IRQ
gpio-125 (SODIMM_133 )
gpio-126 (SODIMM_135 )
gpio-127 (SODIMM_129 )
gpiochip4: GPIOs 128-159, parent: platform/30240000.gpio, 30240000.gpio:
gpio-128 (SODIMM_131 )
gpio-129 ( |CTRL_SLEEP_MOCI# ) out hi
gpio-130 (SODIMM_91 )
gpio-131 (SODIMM_16 )
gpio-132 (SODIMM_15 )
gpio-133 (SODIMM_208 |reset ) in hi
gpio-134 (SODIMM_137 )
gpio-135 (SODIMM_139 )
gpio-136 (SODIMM_141 )
gpio-137 (SODIMM_143 )
gpio-138 (SODIMM_196 )
gpio-139 (SODIMM_200 )
gpio-140 (SODIMM_198 )
gpio-141 (SODIMM_202 |spi_imx ) out hi
gpio-142 ( )
gpio-143 ( )
gpio-144 (SODIMM_55 )
gpio-145 (SODIMM_53 )
gpio-146 (SODIMM_95 )
gpio-147 (SODIMM_93 )
gpio-148 (SODIMM_14 )
gpio-149 (SODIMM_12 )
gpio-150 ( )
gpio-151 ( )
gpio-152 ( )
gpio-153 ( |spi_imx ) out hi
gpio-154 (SODIMM_210 )
gpio-155 (SODIMM_212 )
gpio-156 (SODIMM_151 )
gpio-157 (SODIMM_153 )
gpiochip6: GPIOs 494-495, parent: spi/spi2.0, spi2.0, can sleep:
gpiochip5: GPIOs 496-511, parent: i2c/3-0021, pcal6416, can sleep:
Verdin iMX8M Plus
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:
gpio-0 ( )
gpiochip1: GPIOs 32-63, parent: platform/30210000.gpio, 30210000.gpio:
gpio-32 ( )
gpio-43 ( |regulator-wifi-en ) out hi
gpio-44 ( |cd ) in hi IRQ ACTIVE LOW
gpio-52 ( |regulator-module-eth) out hi
gpio-61 ( |CTRL_SLEEP_MOCI# ) out hi
gpiochip2: GPIOs 64-95, parent: platform/30220000.gpio, 30220000.gpio:
gpio-64 ( )
gpio-84 ( |hpd ) in lo IRQ
gpiochip3: GPIOs 96-127, parent: platform/30230000.gpio, 30230000.gpio:
gpio-96 ( |Wake-Up ) in hi IRQ ACTIVE LOW
gpio-118 ( |regulator-usdhc2 ) out lo
gpio-124 ( |reset ) in hi ACTIVE LOW
gpiochip4: GPIOs 128-159, parent: platform/30240000.gpio, 30240000.gpio:
gpio-128 ( )
gpio-137 ( |spi_imx ) out hi
gpio-142 ( |scl ) out lo
gpio-143 ( |sda ) in lo
gpio-146 ( |scl ) out lo
gpio-147 ( |sda ) in lo
gpio-148 ( |scl ) out lo
gpio-149 ( |sda ) in lo
gpiochip5: GPIOs 496-511, parent: i2c/3-0021, 3-0021, can sleep:
gpio-500 ( |regulator-eth2phy ) out hi