Show Contents

# MCA general purpose input/output (GPIO)

Note This section contains Linux BSP documentation for kernel v4.1. Click here for v4.9 BSP documentation.

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 6UL Micro Controller Assist GPIO support (CONFIG_GPIO_MCA_CC6UL)

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

## Platform driver mapping

The MCA GPIO driver is located at:

File | Description
--- | ---
drivers/gpio/gpio-mca-cc6ul.c | MCA GPIO driver

## Device tree bindings and customization

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

### GPIO controller inside the MCA

    Common ConnectCore 6UL device tree

    mca_cc6ul: mca@7e {

        ...

        mca_gpio: gpio {
            compatible = "digi,mca-cc6ul-gpio";
            gpio-controller;
            #gpio-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.

### 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       gpiochip0    gpiochip128  gpiochip32   gpiochip504  gpiochip64   gpiochip96   unexport
    ~# cat /sys/class/gpio/gpiochip504/label
    mca-cc6ul-gpio

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

### Determine the number of GPIOs of the MCA

To determine the number of GPIO pins of the controller:

    ~# cat /sys/class/gpio/gpiochip504/ngpio
    8

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

### MCA GPIO indexes

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

    ~# cat /sys/class/gpio/gpiochip504/base
    504

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

CAUTION! Some of the MCA 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 MCA pin as ADC channel, see Analog-to-Digital Converter (ADC).

© 2018 Digi International Inc. All rights reserved.
MCA general purpose input/output (GPIO) updated on 22 January 2018 02:43:37 PM