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 8X kernel configuration file.

Kernel driver

The MCA GPIO driver is located at:

File Description

drivers/gpio/gpio-mca.c

ConnectCore 8X MCA GPIO driver

Device tree bindings and customization

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

GPIO controller inside the MCA

ConnectCore 8X device tree
mca_cc8x: mca@63 {

	...

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

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

Using the MCA GPIOs

The MCA GPIO driver works as any other GPIO driver of the kernel. You can access the MCA GPIOs from the sysfs. Refer to the Linux kernel documentation at Documentation/gpio/sysfs.txt.

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

Determine the GPIO controller

The system creates a sysfs entry for the MCA GPIO controller and assigns it a GPIO base number.

You can determine the MCA GPIO controller by reading the label for the different controller entries in /sys/class/gpio/.

~# ls /sys/class/gpio/
export       gpio211      gpiochip205  gpiochip224  gpiochip256  gpiochip288  gpiochip320
gpiochip352  gpiochip384  gpiochip416  gpiochip448  gpiochip480  unexport
~# cat /sys/class/gpio/gpiochip205/label
mca-gpio

In this example, the MCA GPIO controller is /sys/class/gpio/gpiochip205.

Determine the number of GPIOs of the MCA

To determine the number of GPIO pins of the controller:

~# cat /sys/class/gpio/gpiochip205/ngpio
19

In this example, the MCA GPIO controller manages 19 GPIOs.

MCA GPIO indexes

The number of the gpiochip controller shows Linux base number for the MCA GPIOs (205 in the example). You can also determine the base number with:

~# cat /sys/class/gpio/gpiochip205/base
205

This means that the MCA_IO0 pin corresponds to GPIO index 205 in Linux, MCA_IO1 corresponds to 206, and so on.

MCA GPIO debounce

Bouncing is the effect by which a line is quickly pulled high/low at very short intervals for mechanical reasons, for example when connected to a button or switch. You can use a debounce filter to remove the bounce effect from IRQ-capable MCA GPIOs.

You can configure the debounce filter time in microseconds. For example, to configure a debounce filter time of one second on MCA_IO0 (Linux GPIO number 205):

~# echo 205 > /sys/class/gpio/export
~# echo rising > /sys/class/gpio/gpio205/edge
~# echo 1000000 > /sys/class/gpio/gpio205/debounce

A one second debounce means that any pulse shorter than one second will be filtered out and won’t produce an interrupt.

If you set a debounce time lower than 255 ms the step between values will be 1 ms, rounded down. If you set a debounce time higher than 255 ms the step between values will be 50 ms, rounded down.

The maximum allowed debounce value is 12750000 us (12.7 s).

Even though all GPIOs show the entry debounce in the sysfs, only those that are IRQ-capable support debounce. The debounce functionality only works with either rising or falling edge, but not with both.

MCA wake for 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_cc8x: mca@63 {

	...

	mca_gpio: 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_IO0 (Linux GPIO number 205) as rising-edge interrupt:

~# echo 205 > /sys/class/gpio/export
~# echo rising > /sys/class/gpio/gpio205/edge
~# poweroff

Once the GPIO is configured you can wake the system triggering the IRQ in 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 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 General Purpose Input/Output (GPIO) for additional information on CPU GPIOs.