The Digi I/O Expander provides up to 39 GPIOs that can be used to control external peripherals and read digital signals.

Kernel configuration

You can manage the I/O Expander GPIO driver support through the following kernel configuration option:

  • Digi ConnectCore SOMs Micro Controller Assist GPIO support (CONFIG_GPIO_MCA)

This option is enabled as built-in on the default ConnectCore 6UL kernel configuration file.

Kernel driver

The I/O Expander GPIO driver is located at:

File Description

drivers/gpio/gpio-mca.c

ConnectCore 6UL MCA GPIO driver

Device tree bindings and customization

The MCA GPIO device tree binding is documented at Documentation/devicetree/bindings/gpio/digi,mca-gpio.txt.

GPIO controller inside the I/O Expander

ConnectCore 6UL SBC Pro device tree
mca_ioexp: mca_io@6e {

	...

	mca_ioexp_gpio: gpio {
		compatible = "digi,mca-ioexp-gpio";
		gpio-controller;
		#gpio-cells = <2>;

		interrupt-parent = <&mca_cc6ul>;
		interrupt-controller;
		#interrupt-cells = <2>;
	};
};

Using the I/O Expander GPIOs

Some of the I/O Expander GPIO pins can be configured as ADC channels. When configured as ADC channel, a GPIO cannot be used as a standard GPIO.

For information about configuring an I/O Expander pin as ADC channel, see Analog-to-Digital Converter (ADC).

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 [gpio1] (32 lines)
gpiochip1 [gpio2] (32 lines)
gpiochip2 [gpio3] (32 lines)
gpiochip3 [gpio4] (32 lines)
gpiochip4 [gpio5] (32 lines)
gpiochip5 [mca-gpio] (8 lines)
gpiochip6 [ioexp-gpio] (39 lines)
Actual output may differ depending on your platform.

Information about a GPIO port

Use gpioinfo to list the lines of a given port:

~# gpioinfo ioexp-gpio
gpiochip6 - 39 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  output  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       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       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
	line  32:      unnamed       unused   input  active-high
	line  33:      unnamed       unused   input  active-high
	line  34:      unnamed       unused   input  active-high
	line  35:      unnamed       unused   input  active-high
	line  36:      unnamed       unused   input  active-high
	line  37:      unnamed       unused   input  active-high
	line  38:      unnamed       unused   input  active-high
Actual output may differ depending on your platform.

Set an output high/low

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

~# gpioset ioexp-gpio 3=1
~# gpioset ioexp-gpio 3=0

Read an input

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

~# gpioget ioexp-gpio 3
0

Use a GPIO as interrupt

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

~# gpiomon --num-events 1 --rising-edge ioexp-gpio 3

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 6UL platform.

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

See GPIO API for more information about the GPIO APIx.

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