Skip to content

GPIO Chip Allocation

Use the GPIO resource plug-in to make general-purpose I/O (GPIO) chips available to applications. Applications access GPIO chips through the kernel character devices /dev/gpiochip*. For this reason, make sure that the host system includes the required GPIO drivers before applications allocate GPIO chips.

To detect the GPIO chips in the system, use gpiodetect and gpioinfo from libgpiod. On Debian, these tools are available in the gpiod package:

$ gpiodetect
gpiochip0 [pinctrl-bcm2711] (58 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)
$ gpioinfo raspberrypi-exp-gpio
gpiochip1 - 8 lines:
    line   0:      "BT_ON"   "shutdown"  output  active-high [used]
    line   1:      "WL_ON"       unused  output  active-high
    line   2: "PWR_LED_OFF" "PWR" output active-low [used]
    line   3: "GLOBAL_RESET" unused output active-high
    line   4: "VDD_SD_IO_SEL" "vdd-sd-io" output active-high [used]
    line   5:   "CAM_GPIO" "cam1_regulator" output active-high [used]
    line   6:  "SD_PWR_ON" "regulator-sd-vcc" output active-high [used]
    line   7:    "SD_OC_N"       unused   input  active-high

The GPIO resource plug-in identifies GPIO chips by their labels, for example pinctrl-bcm2711 and raspberrypi-exp-gpio in the example above.

Configuring GPIO chip allocation

You can control how GPIO chips are allocated. Define the device-builder default configuration in /usr/lib/ie-gpio-resource-plugin/ie-gpio-resource-plugin.yaml. During operation, changes are written only to /etc/ie-resource-plugins/ie-gpio-resource-plugin.yaml.

The GPIO plug-in reads the static parameters from the device-builder configuration and the non-static parameters from the user configuration. Users can change only the non-static parameters. The plug-in merges both sets into the effective configuration. After a firmware update, the system keeps the user configuration and merges it with the updated device-builder configuration.

NOTICE

Make sure that /etc/ie-resource-plugins/ is empty before shipping the image.

The following settings are currently supported:

gpiochips:
  - name: pinctrl-bcm2711
    labels:
      - label1
gpiochips_ignore_static:
  - raspberrypi-exp-gpio

Use the gpiochips field to assign optional labels to GPIO chips. Operators can add labels in the Resource Manager user interface. For more information, see the Get Started & Operate section.

The device-builder-specific configuration setting is gpiochips_ignore_static. Use it to exclude GPIO chips from allocation to Industrial Edge applications. Users and operators cannot override this setting. The list can contain non-existent chips. The system ignores these entries silently.