allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / mips / au1000 / common / gpio.c
blobce55297dcb8c57e261cb6e7320e5c4d911f82b2c
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.
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.
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.
22 #include <linux/module.h>
23 #include <au1000.h>
24 #include <au1xxx_gpio.h>
26 #define gpio1 sys
27 #if !defined(CONFIG_SOC_AU1000)
28 static AU1X00_GPIO2 * const gpio2 = (AU1X00_GPIO2 *)GPIO2_BASE;
30 #define GPIO2_OUTPUT_ENABLE_MASK 0x00010000
32 int au1xxx_gpio2_read(int signal)
34 signal -= 200;
35 /* gpio2->dir &= ~(0x01 << signal); //Set GPIO to input */
36 return ((gpio2->pinstate >> signal) & 0x01);
39 void au1xxx_gpio2_write(int signal, int value)
41 signal -= 200;
43 gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << signal) |
44 (value << signal);
47 void au1xxx_gpio2_tristate(int signal)
49 signal -= 200;
50 gpio2->dir &= ~(0x01 << signal); /* Set GPIO to input */
52 #endif
54 int au1xxx_gpio1_read(int signal)
56 /* gpio1->trioutclr |= (0x01 << signal); */
57 return ((gpio1->pinstaterd >> signal) & 0x01);
60 void au1xxx_gpio1_write(int signal, int value)
62 if(value)
63 gpio1->outputset = (0x01 << signal);
64 else
65 gpio1->outputclr = (0x01 << signal); /* Output a Zero */
68 void au1xxx_gpio1_tristate(int signal)
70 gpio1->trioutclr = (0x01 << signal); /* Tristate signal */
74 int au1xxx_gpio_read(int signal)
76 if(signal >= 200)
77 #if defined(CONFIG_SOC_AU1000)
78 return 0;
79 #else
80 return au1xxx_gpio2_read(signal);
81 #endif
82 else
83 return au1xxx_gpio1_read(signal);
86 void au1xxx_gpio_write(int signal, int value)
88 if(signal >= 200)
89 #if defined(CONFIG_SOC_AU1000)
91 #else
92 au1xxx_gpio2_write(signal, value);
93 #endif
94 else
95 au1xxx_gpio1_write(signal, value);
98 void au1xxx_gpio_tristate(int signal)
100 if(signal >= 200)
101 #if defined(CONFIG_SOC_AU1000)
103 #else
104 au1xxx_gpio2_tristate(signal);
105 #endif
106 else
107 au1xxx_gpio1_tristate(signal);
110 void au1xxx_gpio1_set_inputs(void)
112 gpio1->pininputen = 0;
115 EXPORT_SYMBOL(au1xxx_gpio1_set_inputs);
116 EXPORT_SYMBOL(au1xxx_gpio_tristate);
117 EXPORT_SYMBOL(au1xxx_gpio_write);
118 EXPORT_SYMBOL(au1xxx_gpio_read);