The NXP i.MX91 CPU has four GPIO ports. The number of GPIOs that each port can generate and control varies:

  • GPIO1: 16 signals

  • GPIO2: 30 signals

  • GPIO3: 32 signals

  • GPIO4: 30 signals

GPIOs on the ConnectCore 91 platforms

  • On the ConnectCore 91 system-on-module:

    • Many of the i.MX91 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.

  • On the ConnectCore 93 Development Kit, the expansion connectors allow direct access to some of the i.MX91 GPIOs.

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

  • Power enable line for transceivers

  • Reset line for controllers

  • Interrupt line

  • User LED

  • User button

The GPIO lines GPIO4_IO16, GPIO4_IO17, GPIO4_IO22, GPIO4_IO23 (USER2 button/LED), GPIO4_IO25 and GPIO4_IO27 are multiplexed with other functionality through a group of jumpers on the ConnectCore 93 Development Kit. Make sure the appropriate jumpers are connected when using these GPIOs on the ConnectCore 93 Development Kit.

See Hardware reference manuals for information on the jumper connections and the multiplexed functionality they select.

Kernel configuration

Support for i.MX91 GPIOs is automatically provided through the non-visible option CONFIG_GPIO_VF610.

Kernel driver

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

File Description

drivers/gpio/gpio-vf610.c

i.MX91 GPIO driver

Device tree bindings and customization

The i.MX91 GPIO device tree binding is documented at Documentation/devicetree/bindings/gpio/gpio-vf610.yaml.

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

i.MX91 device tree
		gpio1: gpio@47400080 {
			compatible = "fsl,imx93-gpio", "fsl,imx7ulp-gpio";
			reg = <0x47400080 0x1000>, <0x47400040 0x40>;
			gpio-controller;
			#gpio-cells = <2>;
			interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-controller;
			#interrupt-cells = <2>;
			clocks = <&clk IMX93_CLK_GPIO1_GATE>,
				 <&clk IMX93_CLK_GPIO1_GATE>;
			clock-names = "gpio", "port";
			gpio-ranges = <&iomuxc 0 92 16>;
			npgios = <16>;
		};

		[...]

		gpio4: gpio@43830080 {
			compatible = "fsl,imx93-gpio", "fsl,imx7ulp-gpio";
			reg = <0x43830080 0x1000>, <0x43830040 0x40>;
			gpio-controller;
			#gpio-cells = <2>;
			interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-controller;
			#interrupt-cells = <2>;
			clocks = <&clk IMX93_CLK_GPIO4_GATE>,
				 <&clk IMX93_CLK_GPIO4_GATE>;
			clock-names = "gpio", "port";
			gpio-ranges = <&iomuxc 0 38 28>, <&iomuxc 28 36 2>;
			ngpios = <30>;
		};

For example, on the ConnectCore 93 Development Kit, GPIO2_IO22 is used to reset the camera:

ConnectCore 93 Development Kit device tree
	/* MIPI-CSI camera */
	ov5640_mipi: ov5640_mipi@3c {
		compatible = "ovti,ov5640";
		reg = <0x3c>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_mipi>;
		clocks = <&mipi_csi_xtal24m>;
		clock-names = "xclk";
		csi_id = <0>;
		powerdown-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
		mclk = <24000000>;
		mclk_source = <0>;
	[...]
};

IOMUX configuration

You must configure the pads that are to be used as i.MX91 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. 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.

  • ULED/BUTTON1 is GPIO3_IO07

  • ULED/BUTTON2 is GPIO4_IO23

GPIO pads power domains

The i.MX91 GPIOs may work at 1.8 V or 3.3 V 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 93 Development Kit schematics. For instance, on the ConnectCore 93 Development Kit, signal CAN2_STBY comes from pad SPI1_SCK (pad E17) of the ConnectCore 91 SOM:

    dwg gpiopad sch 93dvk

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

    dwg gpiopad hrm som 93dvk

  3. In the example, the power domain is 3V3. If a different power domain applies, locate it on the ConnectCore 93 Development Kit schematics to determine its voltage.

Use the GPIOs

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

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

Detect GPIO ports

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

# gpiodetect
gpiochip0 [47400080.gpio] (16 lines)
gpiochip1 [43810080.gpio] (30 lines)
gpiochip2 [43820080.gpio] (32 lines)
gpiochip3 [43830080.gpio] (30 lines)

where:

  • Ports gpiochip0 to gpiochip3 are the i.MX91 GPIO ports.

This nomenclature corresponds with GPIO1 to GPIO4, as shown in the i.MX91 reference manual.

Information about a GPIO port

Use gpioinfo to list the lines of a given port:

# gpioinfo gpiochip1
gpiochip1 - 30 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      "reset"  output   active-low [used]
        line   8:      unnamed       unused   input  active-high
        line   9:      unnamed       unused   input  active-high
        line  10:      unnamed "rs485-rts-gpio" output active-high [used]
        line  11:      unnamed       unused   input  active-high
        line  12:      unnamed   "spi0 CS0"  output   active-low [used]
        line  13:      unnamed       unused   input  active-high
        line  14:      unnamed       unused   input  active-high
        line  15:      unnamed       unused   input  active-high
        line  16:      unnamed       unused   input  active-high
        line  17:      unnamed       unused   input  active-high
        line  18:      unnamed  "interrupt"   input  active-high [used]
        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  output  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  "interrupt"   input  active-high [used]

Set an output high/low

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

# gpioset gpiochip1 27=1
# gpioset gpiochip1 27=0

Read an input

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

# gpioget gpiochip1 27
0

Use a GPIO as interrupt

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

# gpiomon --num-events 1 --rising-edge gpiochip1 27

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 the meta-digi layer. This application shows how to manage GPIO lines using the Digi APIx library on the ConnectCore 91 platform.

By default, the Get Started with ConnectCore Cloud Services demo application seizes the user button. To use the example, stop the cccs-gs-demo with the following command:

# systemctl stop cccs-gs-demo

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

See GPIO API for more information about the GPIO APIx.