sparc64: Fix MSIQ HV call ordering in pci_sun4v_msiq_build_irq().
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / gpio / gpio-sa1100.c
blobb6c1f6d80649a93145daef13d6fcfd042fe20e47
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 */
10 #include <linux/gpio.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
14 #include <mach/hardware.h>
16 static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset)
18 return GPLR & GPIO_GPIO(offset);
21 static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
23 if (value)
24 GPSR = GPIO_GPIO(offset);
25 else
26 GPCR = GPIO_GPIO(offset);
29 static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
31 unsigned long flags;
33 local_irq_save(flags);
34 GPDR &= ~GPIO_GPIO(offset);
35 local_irq_restore(flags);
36 return 0;
39 static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value)
41 unsigned long flags;
43 local_irq_save(flags);
44 sa1100_gpio_set(chip, offset, value);
45 GPDR |= GPIO_GPIO(offset);
46 local_irq_restore(flags);
47 return 0;
50 static struct gpio_chip sa1100_gpio_chip = {
51 .label = "gpio",
52 .direction_input = sa1100_direction_input,
53 .direction_output = sa1100_direction_output,
54 .set = sa1100_gpio_set,
55 .get = sa1100_gpio_get,
56 .base = 0,
57 .ngpio = GPIO_MAX + 1,
60 void __init sa1100_init_gpio(void)
62 gpiochip_add(&sa1100_gpio_chip);