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.
11 #include <linux/init.h>
12 #include <linux/module.h>
15 #include <mach/hardware.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
)
26 GPSR
= GPIO_GPIO(offset
);
28 GPCR
= GPIO_GPIO(offset
);
31 static int sa1100_direction_input(struct gpio_chip
*chip
, unsigned offset
)
35 local_irq_save(flags
);
36 GPDR
&= ~GPIO_GPIO(offset
);
37 local_irq_restore(flags
);
41 static int sa1100_direction_output(struct gpio_chip
*chip
, unsigned offset
, int value
)
45 local_irq_save(flags
);
46 sa1100_gpio_set(chip
, offset
, value
);
47 GPDR
|= GPIO_GPIO(offset
);
48 local_irq_restore(flags
);
52 static struct gpio_chip sa1100_gpio_chip
= {
54 .direction_input
= sa1100_direction_input
,
55 .direction_output
= sa1100_direction_output
,
56 .set
= sa1100_gpio_set
,
57 .get
= sa1100_gpio_get
,
59 .ngpio
= GPIO_MAX
+ 1,
62 void __init
sa1100_init_gpio(void)
64 gpiochip_add(&sa1100_gpio_chip
);