acpiphp: Execute ACPI _REG method for hotadded devices
[linux/fpc-iii.git] / arch / arm / mach-sa1100 / gpio.c
blob0d3829a8c2c1df94cd2e8ceb3ef8aa751291a336
1 /*
2 * linux/arch/arm/mach-sa1100/gpio.c
4 * Generic SA-1100 GPIO handling
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/init.h>
12 #include <linux/module.h>
14 #include <asm/gpio.h>
15 #include <mach/hardware.h>
16 #include "generic.h"
18 static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset)
20 return GPLR & GPIO_GPIO(offset);
23 static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
25 if (value)
26 GPSR = GPIO_GPIO(offset);
27 else
28 GPCR = GPIO_GPIO(offset);
31 static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
33 unsigned long flags;
35 local_irq_save(flags);
36 GPDR &= ~GPIO_GPIO(offset);
37 local_irq_restore(flags);
38 return 0;
41 static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value)
43 unsigned long flags;
45 local_irq_save(flags);
46 sa1100_gpio_set(chip, offset, value);
47 GPDR |= GPIO_GPIO(offset);
48 local_irq_restore(flags);
49 return 0;
52 static struct gpio_chip sa1100_gpio_chip = {
53 .label = "gpio",
54 .direction_input = sa1100_direction_input,
55 .direction_output = sa1100_direction_output,
56 .set = sa1100_gpio_set,
57 .get = sa1100_gpio_get,
58 .base = 0,
59 .ngpio = GPIO_MAX + 1,
62 void __init sa1100_init_gpio(void)
64 gpiochip_add(&sa1100_gpio_chip);