Created
April 7, 2013 23:28
-
-
Save TechplexEngineer/eb366c16c01110be6a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment