UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor ngerber
Visitor
3,201 Views
Registered: ‎04-28-2016

GPIO Chip Base Address

Jump to solution

Hi,

 

Where does the base address of the GPIO chips shown in SYSFS come from? With base address I mean the number 42 in "/sys/class/gpio/gpiochip42/", so it can also be read as base index because it is not the physical base address of the GPIO.

 

Best,

 

Nicola

0 Kudos
1 Solution

Accepted Solutions
Voyager
Voyager
5,434 Views
Registered: ‎06-24-2013

Re: GPIO Chip Base Address

Jump to solution

Hey Nicola,

 

In the Linux kernel, the hardware driver for the GPIO chip calls gpiochip_add_data() (or similar) with a description of the detected GPIO chip including a suggested base address (which can be set to -1).

 

In case no address is given (i.e. address = -1), the GPIO subsystem calls gpiochip_find_base() which tries to locate a suitable place for the new GPIO range.

 

This address is then used to number all the GPIOs (ascending numbers) on the chip and also the chip itself in sysfs.

 

Hope that clarifies,

Herbert

-------------- Yes, I do this for fun!
4 Replies
Voyager
Voyager
5,435 Views
Registered: ‎06-24-2013

Re: GPIO Chip Base Address

Jump to solution

Hey Nicola,

 

In the Linux kernel, the hardware driver for the GPIO chip calls gpiochip_add_data() (or similar) with a description of the detected GPIO chip including a suggested base address (which can be set to -1).

 

In case no address is given (i.e. address = -1), the GPIO subsystem calls gpiochip_find_base() which tries to locate a suitable place for the new GPIO range.

 

This address is then used to number all the GPIOs (ascending numbers) on the chip and also the chip itself in sysfs.

 

Hope that clarifies,

Herbert

-------------- Yes, I do this for fun!
Adventurer
Adventurer
3,166 Views
Registered: ‎12-03-2015

Re: GPIO Chip Base Address

Jump to solution

It is determined by the kernel gpio driver and is dependent on the architecture. 

In .../drivers/gpio/gpiolib.c:

int base = ARCH_NR_GPIOS - ngpio;

For a Zynq it is:

base = ARCH_NR_GPIOS - ZYNQ_GPIO_NR_GPIOS;

         = 1024 - 118

         = 906

Visitor ngerber
Visitor
3,164 Views
Registered: ‎04-28-2016

Re: GPIO Chip Base Address

Jump to solution

Also from .../driver/gpio/gpiolib.c is the comment that "ARCH_NR_GPIOS is somewhat arbitrary". If I wanted to use more than 906 AXI GPIO (for example for configuring some core running in the FPGA), I could increase the ARCH_NR_GPIOS without risking having any problems on the Linux kernel side (besides the constraint of the data type) or is there any other limit to this constant? I just ask because some collegues once had problems when using too many AXI GPIOs and I think this might have been the problem.

0 Kudos
Adventurer
Adventurer
3,141 Views
Registered: ‎12-03-2015

Re: GPIO Chip Base Address

Jump to solution

I have never used that many but there isn't a limit to the number of GPIOs except for the fact the number is stored in an unsigned integer. The kernel documentation, ../Documentation/gpio/gpio-legacy.txt, says that GPIO numbers can go up to MAX_INT. Maybe time for an experiment.

0 Kudos