What is the GPIO base address? Solved


#1

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.

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


#2

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


#3

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.


#4

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


#5

Thank you it’s working