What is the GPIO base address? Solved


I want to use the GPIO pins from c code but i need the GPIO base address to do that as seen from this manual. http://infocenter.arm.com/help/topic/com.arm.doc.ddi0190b/DDI0190.pdf

The Hikey960_SOC_Reference_Manual.pdf mentions that link in section 8.5.3 Register Description.

For the next persoon who looks for it it’s in section 2.9.1 of Hikey960_SOC_Reference_Manual.pdf.


Great, I assume this this is for bare-metal code.


Yes. Do you maybe have any experience with using the ARM primecell GPIO data register ? I don’t understand how to set my pin high.


Not really, from the doc it seems you need at least to set the GPIO direction (GPIODIR register) and then the value (GPIODATA register).

Pseudo code:

#define GPIODATA 0x000
#define GPIODIR    0x400
u8 *gpiodir = (u8 *)(BASE + GPIODIR);
u8 *gpiodata = (u8 *)(BASE + (1 << (gpio_idx + 2))); /* cf 2.3.3 of primecell ref manual */
*gpiodir = *gpiodir & (1 << gpio_idx);
*gpiodata = 1 << gpio_idx;

You can also have a look at the existing Linux driver: https://elixir.bootlin.com/linux/v3.0/source/drivers/gpio/pl061.c


Thank you it’s working