How to acces GPIO's from programme without using sysfs?

I want to access the GPIO, set its value, get its value but I don;t want to use the sysfs.
which library functions I can use to access the GPIO’s in i.MX6?

So far we do not have any user space library suitable for direct GPIO control. That said even if we did have any such it would probably still use sysfs at least for the older kernel versions.

I am also wondering what exactly you have against the sysfs interface. Do you have any special requirements which mandate anything else?

From within the Linux kernel itself one can access the GPIOs via so called gpiolib (see Documentation/gpio/consumer.txt) which could also be used to write its own driver to pass this on to the user space e.g. via a custom character device.

Header:

/* 7. November 2017 size_t */

extern unsigned long* Pointer_Register_gpt;
extern unsigned long* Pointer_Register_gpio1;
extern unsigned long* Pointer_Register_gpio2;
extern unsigned long* Pointer_Register_gpio3;
extern unsigned long* Pointer_Register_gpio4;
extern unsigned long* Pointer_Register_gpio5;
extern unsigned long* Pointer_Register_gpio6;
extern unsigned long* Pointer_Register_gpio7;

size_t init_register_mapping (void);

Routine :

/* 7. November 2017 */

#include
#include
#include
#include
#include
#include
#include “Mapping.h”

#define BLOCK_SIZE 0x400

unsigned long* Pointer_Register_gpt = NULL;
unsigned long* Pointer_Register_gpio1 = NULL;
unsigned long* Pointer_Register_gpio2 = NULL;
unsigned long* Pointer_Register_gpio3 = NULL;
unsigned long* Pointer_Register_gpio4 = NULL;
unsigned long* Pointer_Register_gpio5 = NULL;
unsigned long* Pointer_Register_gpio6 = NULL;
unsigned long* Pointer_Register_gpio7 = NULL;

static int fd = -1;

size_t init_register_mapping (void)
{
size_t error;

error = (size_t)(-1);

if ((fd = open (“/dev/mem”, O_RDWR | O_SYNC | O_CLOEXEC)) < 0) {
printf (“%s\n”, “Unable to open /dev/mem”);
goto END_init_register_mapping;
}

Pointer_Register_gpt = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x2098000); // gpt;
Pointer_Register_gpio1 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x209C000); // gpio1;
Pointer_Register_gpio2 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x20A0000); // gpio2;
Pointer_Register_gpio3 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x20A4000); // gpio3;
Pointer_Register_gpio4 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x20A8000); // gpio4;
Pointer_Register_gpio5 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x20AC000); // gpio5;
Pointer_Register_gpio6 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x20B0000); // gpio6;
Pointer_Register_gpio7 = mmap (NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x20B4000); // gpio7;

if ((long)Pointer_Register_gpio1 == -1) {
printf (“%s\n”, “Init: GPIO-Pointer failed”);
goto END_init_register_mapping;
}

error = 0;

END_init_register_mapping:
if (fd != -1) {
close (fd);
fd = -1;
}

return error;
}

This breaks the kernel defined interface for access and is not recommended.