blob: eda436083417977ea8e60c2aa35436a2e7b71c73 [file] [log] [blame]
Lennert Buytenhek72edd842006-09-18 23:23:07 +01001/*
2 * arch/arm/plat-iop/gpio.c
3 * GPIO handling for Intel IOP3xx processors.
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12
13#include <linux/device.h>
14#include <asm/hardware/iop3xx.h>
15
16void gpio_line_config(int line, int direction)
17{
18 unsigned long flags;
19
20 local_irq_save(flags);
21 if (direction == GPIO_IN) {
22 *IOP3XX_GPOE |= 1 << line;
23 } else if (direction == GPIO_OUT) {
24 *IOP3XX_GPOE &= ~(1 << line);
25 }
26 local_irq_restore(flags);
27}
28EXPORT_SYMBOL(gpio_line_config);
29
30int gpio_line_get(int line)
31{
32 return !!(*IOP3XX_GPID & (1 << line));
33}
34EXPORT_SYMBOL(gpio_line_get);
35
36void gpio_line_set(int line, int value)
37{
38 unsigned long flags;
39
40 local_irq_save(flags);
41 if (value == GPIO_LOW) {
42 *IOP3XX_GPOD &= ~(1 << line);
43 } else if (value == GPIO_HIGH) {
44 *IOP3XX_GPOD |= 1 << line;
45 }
46 local_irq_restore(flags);
47}
48EXPORT_SYMBOL(gpio_line_set);