Project

General

Profile

Linux GPIO Chip Mapping

The following forum post describes how to use an HPS GPIO from within Linux in detail (https://support.criticallink.com/redmine/boards/45/topics/4148?r=4149#message-4149). Below is some quick reference information on how to map Linux GPIO numbers to the specific HPS GPIO or GPI number.

Section 22 of the "Cyclone V HPS Technical Reference Manual" (http://www.altera.com/literature/hb/cyclone-v/cv_5v4.pdf) details the GPIO subsystem.

GPIO Mapping

If adding Soft PIO cores to the FPGA and mapping to device tree the GPIO numbers will shift down by the number of GPIO's specified in the PIO core.

Virtual gpio base Linux GPIO # <---> Hardware (HPS) gpio
gpiochip227 227 to 255 <---> GPIO0 to GPIO28
gpiochip198 198 to 226 <---> GPIO29 to GPIO57
gpiochip171 184 to 197 <---> GPI0 to GPI13 - Inputs and on SoM ONLY
gpiochip171 171 to 179 <---> GPIO58 to GPIO66

Input/Output (HPS 0 to 66) example:

GPIO 53 would be # 222
GPIO 50 would be # 219
GPIO 49 would be # 218
GPIO 48 would be # 217

Input Only GPI's (14 total) example:

GPI 0 would be # 184
GPI 9 would be # 193

Note that the 14 GPI's are used for on-module functions only (Hardware Revision wiki page). These GPI's do not need to be a part of a Quartus project to be read/utilized as they cannot be configured in any other manner than Inputs.

Using memtool to access FPGA GPIO

The Critical Link development kits included SD cards can also access the FPGA GPIO's using the memtool utility from Linux.

Example of access Pins 199 and 201 on an expanded IO module. In order to do so you need to reference the top level .vhd file to determine which PIO block the signals are contained in, in this case it is PIO3, 17 & 18.

  1. Set the PIO3 GPIO bank as outputs
    memtool 0xFF200084=0x60000   
    
  2. Make PIO317 and PIO318 high
    memtool 0xFF200080=0x60000
    
  3. Make all PIO3 GPIO's low
    memtool 0xFF200080=0x00000
    

Other PIO bank base addresses:

PIO0 = 0xFF200020
PIO1 = 0xFF200040
PIO2 = 0xFF200060

Go to top
Add picture from clipboard (Maximum size: 1 GB)