The NXP i.MX8QXP CPU has eight GPIO ports. Each port can generate and control 32 signals.

The MCA also features a number of GPIO pins (multiplexed with Analog-to-Digital Converter (ADC) functionality). See MCA I/O pads for a list of all available MCA IOs and their capabilities.

GPIOs on the ConnectCore 8X platforms

  • On the ConnectCore 8X system-on-module:

    • Many of the i.MX8QXP GPIOs are available at the system-on-module, multiplexed with other functions (labeled GPIOx_IOy where x is the port and y is the GPIO pin). See Hardware reference manuals for information about GPIO pins and their multiplexed functionality.

    • 19 MCA GPIO pins are available (labeled MCA_IOx where x is the GPIO pin).

  • On the ConnectCore 8X SBC Pro, the expansion connector allows direct access to several i.MX8QXP GPIOs and MCA GPIOs.

GPIOs on the SOM and carrier board are used for many purposes, such as:

  • Power enable line for transceivers

  • Reset line for controllers

  • LCD backlight control

  • Interrupt line

  • User LED

  • User button

Kernel configuration

Support for i.MX8QXP GPIOs is automatically provided through the non-visible option CONFIG_GPIO_MXC.

Kernel driver

The driver for the i.MX8QXP GPIO is located at:

File Description

drivers/gpio/gpio-mxc.c

i.MX8QXP GPIO driver

Device tree bindings and customization

The i.MX8QXP GPIO device tree binding is documented at Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt.

One GPIO controller is defined for each i.MX8QXP GPIO port in the common i.MX8QXP device tree file:

i.MX8QXP device tree
	gpio0: gpio@5d080000 {
		compatible = "fsl,imx8qm-gpio", "fsl,imx35-gpio";
		reg = <0x0 0x5d080000 0x0 0x10000>;
		interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
		gpio-controller;
		#gpio-cells = <2>;
		power-domains = <&pd_lsio_gpio0>;
		interrupt-controller;
		#interrupt-cells = <2>;
	};
 
[...]
 
	gpio7: gpio@5d0f0000 {
		compatible = "fsl,imx8qm-gpio", "fsl,imx35-gpio";
		reg = <0x0 0x5d0f0000 0x0 0x10000>;
		interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
		gpio-controller;
		#gpio-cells = <2>;
		power-domains = <&pd_lsio_gpio7>;
		interrupt-controller;
		#interrupt-cells = <2>;
	};

The ConnectCore 8X device tree include file and the carrier board device tree files use the i.MX8QXP GPIOs.

For example, on the ConnectCore 8X, GPIO3_IO09 is used to activate internal circuitry during the MCA firmware update:

ConnectCore 8X device tree
	mca_cc8x: mca@63 {
		compatible = "digi,mca-cc8x";
		reg = <0x63>;
		interrupt-parent = <&wu>;
		interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-controller;
		#interrupt-cells = <2>;
		fw-update-gpio = <&gpio3 9 GPIO_ACTIVE_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_mca_cc8x>;
 
		[...]
};

For example, on the ConnectCore 8X SBC Pro, GPIO3_IO18 is used to reset the PHY of ENET1 Ethernet interface:

ConnectCore 8X SBC Pro device tree
&fec1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_fec_mdio>,
		    <&pinctrl_fec_gpio>,
		    <&pinctrl_fec1_gpio>,
		    <&pinctrl_fec1>;
	clocks = <&clk IMX8QXP_ENET0_IPG_CLK>,
		 <&clk IMX8QXP_ENET0_AHB_CLK>,
		 <&clk IMX8QXP_ENET0_REF_50MHZ_CLK>,
		 <&clk IMX8QXP_ENET0_PTP_CLK>,
		 <&clk IMX8QXP_ENET0_TX_CLK>;
	phy-mode = "rgmii-id";
	phy-handle = <&ethphy1>;
	phy-supply = <&reg_3v3_eth0>;
	phy-reset-gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <1>;
	fsl,magic-packet;
 
	[...]
};

IOMUX configuration

You must configure the pads that are to be used as i.MX8QXP GPIOs. See Pin multiplexing (IOMUX).

For GPIOs that are managed by other drivers, you must configure their pad IOMUX inside the driver node specific pinctrl-0 to work according to the specified interface functionalities.

On the ConnectCore 8X example from above, mca_cc8x node configures pinctrl_mca_cc8x:

ConnectCore 8X device tree
pinctrl_mca_cc8x: mcagrp {
	fsl,pins = <
		[...]

		/* MCA_FW_UPDATE */
		SC_P_QSPI0A_DATA0_LSIO_GPIO3_IO09	0x06000021
	>;
};

For GPIOs that are not associated with any interface or that can’t be handled by a driver, see Configure independent pin IOMUX and pad control. The following external pads are configured as GPIOs on the default device tree:

  • On the ConnectCore 8X SBC Pro expansion connector:

    Pad Signal GPIO

    A7

    GPIO4_21

    GPIO4_IO21

    B7

    GPIO4_20

    GPIO4_IO20

    C4

    SPI0_IRQ_N

    GPIO1_IO01

    C7

    EXP_I2C_IRQ_N

    GPIO3_IO15

    C8

    EXP_I2C_GPIO

    GPIO3_IO14

    C13

    ADC_IN4

    GPIO1_IO14

    C14

    ADC_IN5

    GPIO1_IO13

    C15

    GPIO4_19

    GPIO4_IO19

    C18

    GPIO0_12

    GPIO0_IO12

    D11

    M40_UART_TX

    GPIO1_IO11

    D12

    M40_UART_RX

    GPIO1_IO12

    D14

    ADC_IN1

    GPIO1_IO09

    D19

    GPIO5_09

    GPIO5_IO09

GPIO pads power domains

The i.MX8QXP GPIOs are configurable and can work at 1.8V or 3.3V depending on the power domain of the pad they are on.

To determine the working voltage of a given GPIO:

  1. Locate the pad of a given signal on the ConnectCore 8X SBC Pro schematics. For instance, on the ConnectCore 8X SBC Pro, signal GPIO5_09 comes from pad ENET0_REFCLK_125M_25M of the ConnectCore 8X SOM:

    dwg gpiopad sch 8x

  2. Locate this pad on the IMOUX section of the ConnectCore 8X Hardware Reference Manual. This table lists the associated GPIO of the pad, and the power domain it is on:

    dwg gpiopad hrm som 8x

  3. Locate the power domain (VDD_ENET0 on the example) on the ConnectCore 8X SBC Pro schematics. Here you can tell the voltage of the power domain:

    dwg power domain sch 8x

Using the GPIOs

The package libgpiod (added by packagegroup-dey-core) provides a set of tools (gpioset, gpioget…​) for controlling the GPIOs from user space.

You can still control the GPIOs from the sysfs, but this ABI is not recommended. See https://www.kernel.org/doc/html/latest/admin-guide/gpio/sysfs.html.

Detect GPIO ports

Use gpiodetect to list the GPIO ports detected by the kernel:

~# gpiodetect
gpiochip0 [gpio0] (32 lines)
gpiochip1 [gpio1] (32 lines)
gpiochip2 [gpio2] (32 lines)
gpiochip3 [gpio3] (32 lines)
gpiochip4 [gpio4] (32 lines)
gpiochip5 [gpio5] (32 lines)
gpiochip6 [gpio6] (32 lines)
gpiochip7 [gpio7] (32 lines)
gpiochip8 [58222000.gpio] (32 lines)
gpiochip9 [mca-gpio] (19 lines)

where:

  • Ports gpio0 to gpio7 are the i.MX8QXP GPIO ports.

  • Port 58222000.gpio is the MIPI GPIO controller.

  • Port mca-gpio is the MCA GPIO port.

Information about a GPIO port

Use gpioinfo to list the lines of a given port:

~# gpioinfo gpio0
gpiochip0 - 32 lines:
	line   0:      unnamed       unused   input  active-high
	line   1:      unnamed       unused   input  active-high
	line   2:      unnamed       unused   input  active-high
	line   3:      unnamed       unused   input  active-high
	line   4:      unnamed       unused   input  active-high
	line   5:      unnamed       unused   input  active-high
	line   6:      unnamed       unused   input  active-high
	line   7:      unnamed       unused   input  active-high
	line   8:      unnamed       unused   input  active-high
	line   9:      unnamed       unused   input  active-high
	line  10:      unnamed       unused   input  active-high
	line  11:      unnamed       unused   input  active-high
	line  12:      unnamed       unused   input  active-high
	line  13:      unnamed "5v_display"  output  active-high [used]
	line  14:      unnamed  "3v3_audio"  output  active-high [used]
	line  15:      unnamed "3v3_usb_hub" output active-high [used]
	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        "vcc"  output  active-high [used]

Set an output high/low

Use gpioset to set a i.MX8QXP GPIO as output, such as GPIO4_IO21. Use =1 to set it high, or =0 to set it low:

~# gpioset gpio4 21=1
~# gpioset gpio4 21=0

Read an input

Use gpioget to read the value of a i.MX8QXP GPIO input, such as GPIO4_IO21:

~# gpioget gpio4 21
0

Use a GPIO as interrupt

Use gpiomon to wait for an event on a given GPIO, such as GPIO4_IO21:

~# gpiomon --num-events 1 --rising-edge gpio4 21

See the README of libgpiod for more information on the usage of these tools.

Sample application

An example application called apix-gpio-example is included in the dey-examples-digiapix recipe (part of dey-examples package) of meta-digi layer. This application shows how to manage GPIO lines using the Digi APIx library on the ConnectCore 8X platform.

Go to GitHub to see the application instructions and source code.

See GPIO API for more information about the GPIO APIx.

See MCA General Purpose Input/Output (GPIO) for additional information on MCA GPIOs.