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 IO Expander (CONFIG_MFD_MCA_IOEXP)

Kernel driver

The I/O Expander GPIO driver is located at:

File Description

drivers/gpio/gpio-mca-common.c

Common codebase for GPIO driver (shared with MCA GPIOs)

drivers/gpio/gpio-mca-ioexp.c

I/O Expander GPIO driver

Device tree bindings and customization

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

The 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>;
	};
};

Using the I/O Expander GPIOs

The I/O Expander GPIO driver works as any other GPIO driver of the kernel. Its GPIOs can be accessed from the sysfs. See Documentation/gpio/sysfs.txt for more information.

Determine the GPIO controller

The system creates a sysfs entry for the I/O Expander GPIO controller and assigns it a GPIO base number.

You can tell the I/O Expander GPIO controller by reading the label of the different controller entries in /sys/class/gpio/.

~# ls /sys/class/gpio/
export       gpiochip0    gpiochip128  gpiochip32   gpiochip456 gpiochip504  gpiochip64   gpiochip96   unexport
~# cat /sys/class/gpio/gpiochip465/label
mca-gpio

In this example, the I/O Expander GPIO controller is /sys/class/gpio/gpiochip465.

Determine the number of GPIOs of the I/O Expander

To determine the number of GPIO pins of the controller:

~# cat /sys/class/gpio/gpiochip465/ngpio
39

In this example, the I/O Expander GPIO controller manages 39 GPIOs.

Identify I/O Expander GPIO indexes

The number of the gpiochip controller shows Linux base number for the I/O Expander GPIOs (465 in the example). You can also tell the base number with:

~# cat /sys/class/gpio/gpiochip465/base
465

This means that IOEXP_IO0 pin corresponds in Linux to GPIO index 465, IOEXP_IO1 corresponds to 466, and so on.

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

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