The MCA has several pads that work as GPIOs. The number of GPIO pins depends on the firmware programmed on the MCA.

Kernel configuration

You can manage the MCA 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 8M Mini kernel configuration file.

Kernel driver

The MCA GPIO driver is located at:

File Description

drivers/gpio/gpio-mca.c

ConnectCore 8M Mini 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 MCA

ConnectCore 8M Mini device tree
mca_cc8m: mca@63 {

	[...]

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

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

		/* Disable all mca GPIOs as power off wake up sources */
		pwroff-wakeup-capable-ios = <>;
	};
};

Using the MCA GPIOs

The MCA GPIO driver works as any other GPIO driver of the kernel.

See MCA I/O pads for a list of all available MCA IOs and their capabilities.

The package libgpiod (added by packagegroup-dey-core) provides a set of tools (such as gpioget, gpioget, etc.) 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/userspace-api/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 [gpio6] (32 lines)
gpiochip6 [gpio7] (32 lines)
gpiochip7 [gpio8] (32 lines)
gpiochip8 [gpio9] (32 lines)
gpiochip9 [mca-gpio] (19 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 mca-gpio
gpiochip9 - 19 lines:
        line   0:      unnamed       unused   input  active-high
        line   1:      unnamed   "mca-uart"   input  active-high [used]
        line   2:      unnamed   "mca-uart"   input  active-high [used]
        line   3:      unnamed   "mca-uart"   input  active-high [used]
        line   4:      unnamed   "mca-uart"   input  active-high [used]
        line   5:      unnamed "regulators:regulator@1" output active-high [used]
        line   6:      unnamed "regulators:regulator@2" output active-high [used]
        line   7:      unnamed       unused   input  active-high
        line   8:      unnamed       unused   input  active-high
        line   9:      unnamed "regulators:regulator@9" output active-high [used]
        line  10:      unnamed       unused   input  active-high
        line  11:      unnamed       unused  output  active-high
        line  12:      unnamed       unused   input  active-high
        line  13:      unnamed "power:green" output active-high [used]
        line  14:      unnamed       unused   input  active-high
        line  15:      unnamed       unused  output  active-high
        line  16:      unnamed       unused   input  active-high
        line  17:      unnamed       unused   input  active-high
        line  18:      unnamed       unused   input  active-high
Actual output may differ depending on your platform.
Although ConnectCore 8M Mini MCA reports 19 GPIOs, MCA_IO5, MCA_IO6, MCA_IO7 and MCA_IO8 are not routed externally.

Set an output high/low

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

# gpioset mca-gpio 3=1
# gpioset mca-gpio 3=0

Read an input

Use gpioget to read the value of a i.MX8M Mini GPIO input, such as MCA_IO3:

# gpioget mca-gpio 3
0

Use a GPIO as interrupt

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

# gpiomon --num-events 1 --rising-edge mca-gpio 3

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

MCA wake from power off

IRQ-capable MCA GPIOs can wake the system from power-off state. This feature is disabled on the default device tree. To enable it, use the property pwroff-wakeup-capable-ios to list the IRQ-capable MCA GPIOs you want to use as wake-up sources. For example, to configure MCA_IO0 as wake-up source:

&mca_gpio {
	pwroff-wakeup-capable-ios = <0>;
};

This change in the device tree just enables the wake-up capability of the MCA GPIO. You still need to configure the GPIO as an interrupt on a running system. For example, to configure MCA_IO3 as rising-edge one-shot interrupt, use gpiomon with an ampersand at the end to send the task to the background. Then, power off:

# gpiomon --num-events 1 --rising-edge mca-gpio 3 &
# poweroff -f
The -f argument is necessary to prevent the poweroff sequence from closing gpiomon.

Now you can wake the system triggering the IRQ on that GPIO.

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 8M Mini 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.