Table of Contents

Introduction

The Xilinx® LogiCORE™ IP AXI General Purpose Input/Output (GPIO) core provides a general purpose input/output interface to the AXI interface.
This 32-bit soft Intellectual Property (IP) core is designed to interface with the AXI4-Lite interface.The AXI GPIO design provides a general purpose
input/output interface to an AXI4-Lite interface. The AXI GPIO can be configured as either a single or a dual-channel device.
The width of each channel is independently configurable.

HW IP Features

  • Supports the AXI4-Lite interface specification
  • Supports configurable single or dual GPIO channel(s)
  • Supports configurable channel width for GPIO pins from 1 to 32 bits
  • Supports dynamic programming of each GPIO bit as input or output
  • Supports individual configuration of each channel
  • Supports independent reset values for each bit of all registers
  • Supports optional interrupt request generation

Features supported in driver

  • Supports the AXI4-Lite interface specification
  • Supports configurable single or dual GPIO channel(s)
  • Supports configurable channel width for GPIO pins from 1 to 32 bits
  • Supports dynamic programming of each GPIO bit as input or output
  • Supports individual configuration of each channel
  • Supports independent reset values for each bit of all registers
  • Supports optional interrupt request generation

Missing Features, Known Issues and Limitations

  • None

Kernel Configuration Options for Driver

To enable GPIO in the kernel, the following configuration options need to be enabled:

Devicetree


Test procedure on ZCU102 eval board

Using GPIO with SysFs:
The GPIO driver fits in the Linux GPIO framework. It does provide access to the GPIO by user space through the sysfs filesystem. For details please refer to - the above-mentioned - documentation. The following text is aimed to augment, not replace the existing documentation.

For the examples below, there are some important points with sysfs.
  1. The GPIO controllers are visible in /sys/class/gpio. Each controller controls a number of GPIO signals.
  2. The GPIO signals must be exported into the sysfs before they can be manipulated. The number of the GPIO signal must be written to the GPIO export file to cause this to happen.
  3. After exporting the GPIO signal a new directory based on the GPIO signal number will appear in /sys/class/gpio. Under that directory are direction and value files that can be read and written.
Mounting Sysfs:
The root file system being used may not have sysfs mounted and it cannot be used if it's not mounted. The directory /sys is also needed to mount the sysfs on. The root file system must be writable to do the following steps.

Expected Output


Addition of Dip Switches and Push Buttons to the node to generate interrupts on ZCU102 eval boards

This section covers process of modifying the device tree (DTS) by adding dip switches and push buttons subnodes to generate interrupts.
These are suitable for more complex applications involving handling interrupts.

Kernel Configuration for dip switches and push buttons

In order to use, the kernel must be configured correctly. Configure the kernel as described in Build Kernel, and then make sure the following options are enabled in menuconfig:
  • Device Drivers
    • GPIO Support
      • Memory Mapped GPIO Drivers
        • Xilinx GPIO support
        • Xilinx Zynq GPIO support
    • Input device support
      • Keyboards
        • GPIO Buttons
        • Polled GPIO buttons

Enable below kernel configuration options:
Dip Switches to the device tree
Dip Switches are available only for Input GPIO application. Each created subnode controls a single bit of GPIO.
Under "gpio-keys" node in the dts file, create subnodes for dip switches as per design with names shown below:
  • The Label refers to the descriptive name of the dip switch.
  • The string <&axi_gpio_0 0x0 0x0 0x0> references the AXI GPIO 0 controller and states that GPIO_DIP_SW0 is on pin 0, GPIO_DIP_SW1 is on pin 1 and same for remaining dip switches;  the 0 states that the device is active high.
  • The linux,code property determines which key will show up in the event.
  • gpio-key,wakeup will enable the GPIO to wake the system from suspend.
  • The autorepeat property allows holding the key to continuously generate events.
Full documentation can be found here Documentation/devicetree/bindings/input/gpio-keys.txt.

After this, boot the linux. We should able to see the label names of dip switches in cat /proc/interrupts. On and off any of the dip switches and view the trigger count of that dip switch using "cat /proc/interrupts".

Expected Output


Push buttons to the device tree

Push buttons are available only for Input GPIO application.
Each created subnode controls a single bit of GPIO. Under "gpio-keys" node in the dts file, create subnodes for Push buttons as per design with names shown below:
  • The Label refers to the descriptive name of the Push button.
  • The string <&axi_gpio_1 0x0 0x0> references the AXI GPIO 1 controller and states that SW15 is on pin 0, SW14 is on pin 1 and same for remaining Push buttons; the 0 states that the device is active high.
  • The linux,code property determines which key will show up in the event.
  • gpio-key,wakeup will enable the GPIO to wake the system from suspend.
  • The autorepeat property allows holding the key to continuously generate events.
Full documentation can be found here Documentation/devicetree/bindings/input/gpio-keys.txt.

After this, boot the linux. We should able to see the label names of push buttons in cat /proc/interrupts. Press any of the push buttons and view the trigger count of those push buttons in cat /proc/interrupts.

Expected Output


Mainline Status

This driver is currently in sync with mainline kernel except for the following:
  • gpio: xilinx: Use read/writel for ARM64
  • gpio: xilinx: Add clock adaptation support
  • gpio: Add simple remove and exit functions
  • gpio: xilinx: Fix the NULL pointer access
  • gpio: gpio-xilinx.c: Fix kernel doc warnings
  • gpio: gpio-xilinx: Fix warnings in the driver

Change Log

2016.3
Summary:
  • gpio: xilinx: Use read/writel for ARM64.
Commits:
  • c8105d8 gpio: xilinx: Use read/writel for ARM64.

2016.4
None

2017.1
Summary:
  • Merge tag 'v4.8' into master
  • gpio: xilinx: Add clock adaptation support
  • gpio: Add simple remove and exit functions
  • gpio: xilinx: Fix the NULL pointer access
Commits:
  • 15add85 Merge tag 'v4.8' into master
  • 34b6b71 gpio: xilinx: Add clock adaptation support
  • e469c51 gpio: Add simple remove and exit functions
  • 30b6bc6 gpio: xilinx: Fix the NULL pointer access

2017.2
None

2017.3
Summary:
  • gpio: gpio-xilinx.c: Fix kernel doc warnings
  • gpio: gpio-xilinx: Fix warnings in the driver
Commits:
  • 24132f8 gpio: gpio-xilinx.c: Fix kernel doc warnings
  • 3da7287 gpio: gpio-xilinx: Fix warnings in the driver

2017.4
  • None
2018.1

Summary:

  • gpio: xilinx: Add reset support
  • gpio:xilinx: defer probe if clock is not found

Commits:

  • 7ed822egpio: xilinx: Add reset support
  • 3bbc2fdgpio:xilinx: defer probe if clock is not found
2018.2
  • None


2018.3
Summary:

  • gpio: Fix the Dual Channel gpio driver removal issue
  • gpio: zynq: Fix the check for rising edge


Commits:

  • 7c9997c  gpio: Fix the Dual Channel gpio driver removal issue
  • ca21fbf  gpio: zynq: Fix the check for rising edge
  • ae16c64 gpio: gpio-xilinx: Fix unbalanced clock reference count

2019.1

  • Summary:
    • gpio: gpio-xilinx:consider -ve return values from of_irq_to_resource
  • commits:
    • c74fddcconsider -ve return values from of_irq_to_resource

2019.2

  • Summary
    • gpio: gpio-xilinx: Fix error condition for defer case
  • Commits
    • 60464eb3 gpio: gpio-xilinx: Fix error condition for defer case

2020.1

  • summary
    • gpio:gpio-xilinx: convert from OF GPIO to standard devm APIs
    • gpio:gpio-xilinx: Add clock adaptation support
    • gpio:gpio-xilinx:  Add irq support to the driver
    • gpio:gpio-xilinx : Use xilinx tested gpio driver
  • commits
    • 1ebd0687 :convert from OF GPIO to standard devm APIs
    • 35b74a9e : Add clock adaptation support
    • 256f37f6 : Add irq support to the driver
    • af0c19b6Use xilinx tested gpio driver

2020.2

  • None

Related Links

https://github.com/Xilinx/linux-xlnx/blob/master/drivers/gpio/gpio-xilinx.c