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