diff options
author | Arnd Bergmann <arnd@arndb.de> | 2011-10-31 22:46:42 (GMT) |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2011-10-31 22:46:42 (GMT) |
commit | efa62e1355f0495f37f1296754b8880947c8da72 (patch) | |
tree | c07af29f8baf2e6f4ed3bedbe46d405924edd530 /drivers/gpio/gpio-sa1100.c | |
parent | 107532920226a37e595697959b2a6a823cfa2497 (diff) | |
parent | f55be1bf52aad524dc1bf556ae26c90262c87825 (diff) | |
download | linux-fsl-qoriq-efa62e1355f0495f37f1296754b8880947c8da72.tar.xz |
Merge branch 'depends/rmk/gpio' into next/devel
Conflicts:
arch/arm/mach-mxs/include/mach/gpio.h
arch/arm/plat-mxc/include/mach/gpio.h
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/gpio/gpio-sa1100.c')
-rw-r--r-- | drivers/gpio/gpio-sa1100.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c new file mode 100644 index 0000000..b6c1f6d --- /dev/null +++ b/drivers/gpio/gpio-sa1100.c @@ -0,0 +1,63 @@ +/* + * linux/arch/arm/mach-sa1100/gpio.c + * + * Generic SA-1100 GPIO handling + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include <linux/gpio.h> +#include <linux/init.h> +#include <linux/module.h> + +#include <mach/hardware.h> + +static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) +{ + return GPLR & GPIO_GPIO(offset); +} + +static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) +{ + if (value) + GPSR = GPIO_GPIO(offset); + else + GPCR = GPIO_GPIO(offset); +} + +static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset) +{ + unsigned long flags; + + local_irq_save(flags); + GPDR &= ~GPIO_GPIO(offset); + local_irq_restore(flags); + return 0; +} + +static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value) +{ + unsigned long flags; + + local_irq_save(flags); + sa1100_gpio_set(chip, offset, value); + GPDR |= GPIO_GPIO(offset); + local_irq_restore(flags); + return 0; +} + +static struct gpio_chip sa1100_gpio_chip = { + .label = "gpio", + .direction_input = sa1100_direction_input, + .direction_output = sa1100_direction_output, + .set = sa1100_gpio_set, + .get = sa1100_gpio_get, + .base = 0, + .ngpio = GPIO_MAX + 1, +}; + +void __init sa1100_init_gpio(void) +{ + gpiochip_add(&sa1100_gpio_chip); +} |