aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/au1000/common/gpio.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2008-09-16 13:12:16 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-10-11 11:18:50 -0400
commite8c7c482347574ecdd45c43e32c332d5fc2ece61 (patch)
treec741aa6cdb4e897df9f9476d83a816a7a2b058dd /arch/mips/au1000/common/gpio.c
parent8d2d91e86b4153cc2305ec86fe908048f459ff7f (diff)
MIPS: Alchemy: rename directory
It's more than the au1000 these days. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/au1000/common/gpio.c')
-rw-r--r--arch/mips/au1000/common/gpio.c148
1 files changed, 0 insertions, 148 deletions
diff --git a/arch/mips/au1000/common/gpio.c b/arch/mips/au1000/common/gpio.c
deleted file mode 100644
index e660ddd611c4..000000000000
--- a/arch/mips/au1000/common/gpio.c
+++ /dev/null
@@ -1,148 +0,0 @@
1/*
2 * Copyright (C) 2007, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
3 * Architecture specific GPIO support
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
13 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
14 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
15 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
16 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
17 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Notes :
26 * au1000 SoC have only one GPIO line : GPIO1
27 * others have a second one : GPIO2
28 */
29
30#include <linux/module.h>
31
32#include <asm/mach-au1x00/au1000.h>
33#include <asm/gpio.h>
34
35#define gpio1 sys
36#if !defined(CONFIG_SOC_AU1000)
37
38static struct au1x00_gpio2 *const gpio2 = (struct au1x00_gpio2 *) GPIO2_BASE;
39#define GPIO2_OUTPUT_ENABLE_MASK 0x00010000
40
41static int au1xxx_gpio2_read(unsigned gpio)
42{
43 gpio -= AU1XXX_GPIO_BASE;
44 return ((gpio2->pinstate >> gpio) & 0x01);
45}
46
47static void au1xxx_gpio2_write(unsigned gpio, int value)
48{
49 gpio -= AU1XXX_GPIO_BASE;
50
51 gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
52}
53
54static int au1xxx_gpio2_direction_input(unsigned gpio)
55{
56 gpio -= AU1XXX_GPIO_BASE;
57 gpio2->dir &= ~(0x01 << gpio);
58 return 0;
59}
60
61static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
62{
63 gpio -= AU1XXX_GPIO_BASE;
64 gpio2->dir |= 0x01 << gpio;
65 gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
66 return 0;
67}
68
69#endif /* !defined(CONFIG_SOC_AU1000) */
70
71static int au1xxx_gpio1_read(unsigned gpio)
72{
73 return (gpio1->pinstaterd >> gpio) & 0x01;
74}
75
76static void au1xxx_gpio1_write(unsigned gpio, int value)
77{
78 if (value)
79 gpio1->outputset = (0x01 << gpio);
80 else
81 /* Output a zero */
82 gpio1->outputclr = (0x01 << gpio);
83}
84
85static int au1xxx_gpio1_direction_input(unsigned gpio)
86{
87 gpio1->pininputen = (0x01 << gpio);
88 return 0;
89}
90
91static int au1xxx_gpio1_direction_output(unsigned gpio, int value)
92{
93 gpio1->trioutclr = (0x01 & gpio);
94 au1xxx_gpio1_write(gpio, value);
95 return 0;
96}
97
98int au1xxx_gpio_get_value(unsigned gpio)
99{
100 if (gpio >= AU1XXX_GPIO_BASE)
101#if defined(CONFIG_SOC_AU1000)
102 return 0;
103#else
104 return au1xxx_gpio2_read(gpio);
105#endif
106 else
107 return au1xxx_gpio1_read(gpio);
108}
109EXPORT_SYMBOL(au1xxx_gpio_get_value);
110
111void au1xxx_gpio_set_value(unsigned gpio, int value)
112{
113 if (gpio >= AU1XXX_GPIO_BASE)
114#if defined(CONFIG_SOC_AU1000)
115 ;
116#else
117 au1xxx_gpio2_write(gpio, value);
118#endif
119 else
120 au1xxx_gpio1_write(gpio, value);
121}
122EXPORT_SYMBOL(au1xxx_gpio_set_value);
123
124int au1xxx_gpio_direction_input(unsigned gpio)
125{
126 if (gpio >= AU1XXX_GPIO_BASE)
127#if defined(CONFIG_SOC_AU1000)
128 return -ENODEV;
129#else
130 return au1xxx_gpio2_direction_input(gpio);
131#endif
132
133 return au1xxx_gpio1_direction_input(gpio);
134}
135EXPORT_SYMBOL(au1xxx_gpio_direction_input);
136
137int au1xxx_gpio_direction_output(unsigned gpio, int value)
138{
139 if (gpio >= AU1XXX_GPIO_BASE)
140#if defined(CONFIG_SOC_AU1000)
141 return -ENODEV;
142#else
143 return au1xxx_gpio2_direction_output(gpio, value);
144#endif
145
146 return au1xxx_gpio1_direction_output(gpio, value);
147}
148EXPORT_SYMBOL(au1xxx_gpio_direction_output);