case GPIO_MODE:
ret = copy_from_user(&mdata, (struct gpio_data_mode __user *)arg, sizeof(struct gpio_data_mode));
if (ret != 0) {
printk(KERN_DEBUG "[MODE] Error copying data from userspace\n");
return -EFAULT;
}
//get struct from userspace
pin = mdata.pin;
//validate pin & access
val = readl(__io_address(GPIO_BASE + GPLEV0 + (pin/32)*4));
//clear the status
uint32_t newval = val & ~(7<<(((pin)%10)*3));
writel(newval, __io_address(GPIO_BASE + (pin/10)*4));
//if output set new value
if (mdata.data == MODE_INPUT) {
val = readl(__io_address(GPIO_BASE + GPLEV0 + (pin/32)*4));
newval = val | (1<<(((pin)%10)*3));
writel(newval, __io_address(GPIO_BASE + (pin/10)*4));
}
return 0;