aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/au1000/common/gpio.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-30 21:37:12 -0500
committerPaul Mackerras <paulus@samba.org>2005-10-30 21:37:12 -0500
commit23fd07750a789a66fe88cf173d52a18f1a387da4 (patch)
tree06fdd6df35fdb835abdaa9b754d62f6b84b97250 /arch/mips/au1000/common/gpio.c
parentbd787d438a59266af3c9f6351644c85ef1dd21fe (diff)
parented28f96ac1960f30f818374d65be71d2fdf811b0 (diff)
Merge ../linux-2.6 by hand
Diffstat (limited to 'arch/mips/au1000/common/gpio.c')
-rw-r--r--arch/mips/au1000/common/gpio.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/arch/mips/au1000/common/gpio.c b/arch/mips/au1000/common/gpio.c
new file mode 100644
index 000000000000..5f5915b83142
--- /dev/null
+++ b/arch/mips/au1000/common/gpio.c
@@ -0,0 +1,119 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
12 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
13 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
14 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
16 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22#include <linux/config.h>
23#include <linux/module.h>
24#include <au1000.h>
25#include <au1xxx_gpio.h>
26
27#define gpio1 sys
28#if !defined(CONFIG_SOC_AU1000)
29static AU1X00_GPIO2 * const gpio2 = (AU1X00_GPIO2 *)GPIO2_BASE;
30
31#define GPIO2_OUTPUT_ENABLE_MASK 0x00010000
32
33int au1xxx_gpio2_read(int signal)
34{
35 signal -= 200;
36/* gpio2->dir &= ~(0x01 << signal); //Set GPIO to input */
37 return ((gpio2->pinstate >> signal) & 0x01);
38}
39
40void au1xxx_gpio2_write(int signal, int value)
41{
42 signal -= 200;
43
44 gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << signal) |
45 (value << signal);
46}
47
48void au1xxx_gpio2_tristate(int signal)
49{
50 signal -= 200;
51 gpio2->dir &= ~(0x01 << signal); /* Set GPIO to input */
52}
53#endif
54
55int au1xxx_gpio1_read(int signal)
56{
57/* gpio1->trioutclr |= (0x01 << signal); */
58 return ((gpio1->pinstaterd >> signal) & 0x01);
59}
60
61void au1xxx_gpio1_write(int signal, int value)
62{
63 if(value)
64 gpio1->outputset = (0x01 << signal);
65 else
66 gpio1->outputclr = (0x01 << signal); /* Output a Zero */
67}
68
69void au1xxx_gpio1_tristate(int signal)
70{
71 gpio1->trioutclr = (0x01 << signal); /* Tristate signal */
72}
73
74
75int au1xxx_gpio_read(int signal)
76{
77 if(signal >= 200)
78#if defined(CONFIG_SOC_AU1000)
79 return 0;
80#else
81 return au1xxx_gpio2_read(signal);
82#endif
83 else
84 return au1xxx_gpio1_read(signal);
85}
86
87void au1xxx_gpio_write(int signal, int value)
88{
89 if(signal >= 200)
90#if defined(CONFIG_SOC_AU1000)
91 ;
92#else
93 au1xxx_gpio2_write(signal, value);
94#endif
95 else
96 au1xxx_gpio1_write(signal, value);
97}
98
99void au1xxx_gpio_tristate(int signal)
100{
101 if(signal >= 200)
102#if defined(CONFIG_SOC_AU1000)
103 ;
104#else
105 au1xxx_gpio2_tristate(signal);
106#endif
107 else
108 au1xxx_gpio1_tristate(signal);
109}
110
111void au1xxx_gpio1_set_inputs(void)
112{
113 gpio1->pininputen = 0;
114}
115
116EXPORT_SYMBOL(au1xxx_gpio1_set_inputs);
117EXPORT_SYMBOL(au1xxx_gpio_tristate);
118EXPORT_SYMBOL(au1xxx_gpio_write);
119EXPORT_SYMBOL(au1xxx_gpio_read);