The NXP {cpu-family} CPU has eight GPIO ports. Each port can generate and control 32 signals.
The MCA also features a number of GPIO pins (multiplexed with Analog-to-Digital Converter (ADC) functionality). See MCA I/O pads for a list of all available MCA IOs and their capabilities.
GPIOs on the ConnectCore 8X platforms
-
On the ConnectCore 8X system-on-module:
-
Many, but not all, of the {cpu-family} GPIO ports and pins are available at the system-on-module, multiplexed with other functions (labeled GPIOx_IOy where x is the port and y is the GPIO pin). See Hardware reference manuals for information about what GPIO ports and pins are available and their multiplexed functionality.
-
19 MCA GPIO pins are available (labeled MCA_IOx where x is the GPIO pin).
-
-
On the ConnectCore 8X SBC Pro, the expansion connector allows direct access to several {cpu-family} GPIOs and MCA GPIOs.
GPIOs on the SOM and carrier board are used for many purposes, such as:
-
Power enable line for transceivers
-
Reset line for controllers
-
LCD backlight control
-
Interrupt line
-
User LED
-
User button
Kernel configuration
Support for {cpu-family} GPIOs is automatically provided through the non-visible option CONFIG_GPIO_MXC
.
Kernel driver
The driver for the {cpu-family} GPIO is located at:
File | Description |
---|---|
{cpu-family} GPIO driver |
Device tree bindings and customization
The {cpu-family} GPIO device tree binding is documented at
Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt
.
One GPIO controller is defined for each {cpu-family} GPIO port in the common {cpu-family} device tree file:
gpio0: gpio@5d080000 {
compatible = "fsl,imx8qm-gpio", "fsl,imx35-gpio";
reg = <0x0 0x5d080000 0x0 0x10000>;
interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
gpio-controller;
#gpio-cells = <2>;
power-domains = <&pd_lsio_gpio0>;
interrupt-controller;
#interrupt-cells = <2>;
};
[...]
gpio7: gpio@5d0f0000 {
compatible = "fsl,imx8qm-gpio", "fsl,imx35-gpio";
reg = <0x0 0x5d0f0000 0x0 0x10000>;
interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
gpio-controller;
#gpio-cells = <2>;
power-domains = <&pd_lsio_gpio7>;
interrupt-controller;
#interrupt-cells = <2>;
};
The ConnectCore 8X device tree include file and the carrier board device tree files use the {cpu-family} GPIOs.
For example, on the ConnectCore 8X, GPIO3_IO09 is used to activate internal circuitry during the MCA firmware update:
mca_cc8x: mca@63 {
compatible = "digi,mca-cc8x";
reg = <0x63>;
interrupt-parent = <&wu>;
interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
interrupt-controller;
#interrupt-cells = <2>;
fw-update-gpio = <&gpio3 9 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mca_cc8x>;
[...]
};
For example, on the ConnectCore 8X SBC Pro, GPIO3_IO18 is used to reset the PHY of ENET1 Ethernet interface:
&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fec_mdio>,
<&pinctrl_fec_gpio>,
<&pinctrl_fec1_gpio>,
<&pinctrl_fec1>;
clocks = <&clk IMX8QXP_ENET0_IPG_CLK>,
<&clk IMX8QXP_ENET0_AHB_CLK>,
<&clk IMX8QXP_ENET0_REF_50MHZ_CLK>,
<&clk IMX8QXP_ENET0_PTP_CLK>,
<&clk IMX8QXP_ENET0_TX_CLK>;
phy-mode = "rgmii-id";
phy-handle = <ðphy1>;
phy-supply = <®_3v3_eth0>;
phy-reset-gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
phy-reset-duration = <1>;
fsl,magic-packet;
[...]
};
IOMUX configuration
You must configure the pads that are to be used as {cpu-family} GPIOs. See Pin multiplexing (IOMUX).
For GPIOs that are managed by other drivers, you must configure their pad IOMUX inside the driver node specific pinctrl-0
to work according to the specified interface functionalities.
On the ConnectCore 8X example from above, mca_cc8x
node configures pinctrl_mca_cc8x
:
pinctrl_mca_cc8x: mcagrp {
fsl,pins = <
[...]
/* MCA_FW_UPDATE */
SC_P_QSPI0A_DATA0_LSIO_GPIO3_IO09 0x06000021
>;
};
For GPIOs that are not associated with any interface or that can’t be handled by a driver, see Configure independent pin IOMUX and pad control. The following external pads are configured as GPIOs on the default device tree:
-
On the ConnectCore 8X SBC Pro expansion connector:
Pad Signal GPIO A7
GPIO4_21
GPIO4_IO21
B7
GPIO4_20
GPIO4_IO20
C4
SPI0_IRQ_N
GPIO1_IO01
C7
EXP_I2C_IRQ_N
GPIO3_IO15
C8
EXP_I2C_GPIO
GPIO3_IO14
C13
ADC_IN4
GPIO1_IO14
C14
ADC_IN5
GPIO1_IO13
C15
GPIO4_19
GPIO4_IO19
C18
GPIO0_12
GPIO0_IO12
D11
M40_UART_TX
GPIO1_IO11
D12
M40_UART_RX
GPIO1_IO12
D14
ADC_IN1
GPIO1_IO09
D19
GPIO5_09
GPIO5_IO09
GPIO pads power domains
The {cpu-family} GPIOs are configurable and can work at 1.8 V or 3.3 V depending on the power domain of the pad they are on.
To determine the working voltage of a given GPIO:
-
Locate the pad of a given signal on the ConnectCore 8X SBC Pro schematics. For instance, on the ConnectCore 8X SBC Pro, signal
GPIO5_09
comes from padENET0_REFCLK_125M_25M
of the ConnectCore 8X SOM: -
Locate this pad on the IMOUX section of the ConnectCore 8X Hardware Reference Manual. This table lists the associated GPIO of the pad, and the power domain it is on:
-
Locate the power domain (
VDD_ENET0
on the example) on the ConnectCore 8X SBC Pro schematics. Here you can tell the voltage of the power domain:
Using the GPIOs
The package libgpiod (added by packagegroup-dey-core) provides a set of tools (such as gpioset
, 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/admin-guide/gpio/sysfs.html. |
Detect GPIO ports
Use gpiodetect
to list the GPIO ports detected by the kernel:
# gpiodetect
gpiochip0 [gpio0] (32 lines)
gpiochip1 [gpio1] (32 lines)
gpiochip2 [gpio2] (32 lines)
gpiochip3 [gpio3] (32 lines)
gpiochip4 [gpio4] (32 lines)
gpiochip5 [gpio5] (32 lines)
gpiochip6 [58222000.gpio] (32 lines)
gpiochip7 [mca-gpio] (19 lines)
where:
-
Ports
gpio0
togpio5
are the {cpu-family} GPIO ports available on the ConnectCore 8X. -
Port
58222000.gpio
is the MIPI GPIO controller. -
Port
mca-gpio
is the MCA GPIO port.
Information about a GPIO port
Use gpioinfo
to list the lines of a given port:
# gpioinfo gpio0
gpiochip0 - 32 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 input 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 "5v_display" output active-high [used]
line 14: unnamed "3v3_audio" output active-high [used]
line 15: unnamed "3v3_usb_hub" output active-high [used]
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 "vcc" output active-high [used]
Set an output high/low
Use gpioset
to set a {cpu-family} GPIO as output, such as GPIO4_IO21.
Use =1
to set it high, or =0
to set it low:
# gpioset gpio4 21=1
# gpioset gpio4 21=0
Read an input
Use gpioget
to read the value of a {cpu-family} GPIO input, such as GPIO4_IO21:
# gpioget gpio4 21
0
Use a GPIO as interrupt
Use gpiomon
to wait for an event on a given GPIO, such as GPIO4_IO21:
# gpiomon --num-events 1 --rising-edge gpio4 21
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 8X platform.
Go to GitHub to see the application instructions and source code.
See GPIO API for more information about the GPIO APIx.
See MCA General Purpose Input/Output (GPIO) for additional information on MCA GPIOs.