Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Altera DE0-Nano gpio

wchen50
Beginner
1,498 Views

In my testing, I want to access the fpga gpio. I can use set the fpga gpio pin from user space (open /dev/mem, then use mmap, etc). However I cannot set the fpga from kernel space.

In my kernel code, I tried to ioremap the gpio0 based, and then set the gpio pin, but it doesn't work as expected.

void *ptr = ioremap(0xff708000, 0x10 );

*(ptr+offset) = 0b1;

where offset is the memory mapped slave as shown in platform designer.

I tried many ways but it doesn't work.

Any suggestion?

 

0 Kudos
2 Replies
Fawaz_Al-Jubori
Employee
762 Views

Hello,

We are still investigating this case.

i will post my feedback once I find useful information.,

 

Thanks

 

Fawaz

0 Kudos
Fawaz_Al-Jubori
Employee
762 Views

Hello,

I found this useful link:

https://lwn.net/Articles/532714/

Please refer to it, the summary of accessing GPIO:

 

1- include the driver:

#include <linux/gpio.h>

 

2- GPIOs must be allocated before use:

int gpio_request(unsigned int gpio, const char *label);

 

3- And GPIO can be returned to the system with:

void gpio_free(unsigned int gpio);

 

4- Configure GPIO as Input/Output:

int gpio_direction_input(unsigned int gpio);

int gpio_direction_output(unsigned int gpio, int value);

 

5- Run GPIO:

int gpio_get_value(unsigned int gpio);

void gpio_set_value(unsigned int gpio, int value);

 

 

Hope this might help.

 

Thanks

0 Kudos
Reply