enable USB root hub transaction translators
[openwrt.git] / target / linux / adm5120 / files / include / asm-mips / mach-adm5120 / gpio.h
index 684d86c..7ba7efc 100644 (file)
@@ -1,30 +1,20 @@
 /*
- *  $Id$
- *
  *  ADM5120 GPIO wrappers for arch-neutral GPIO calls
  *
- *  Copyright (C) 2007 OpenWrt.org
- *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public License
- *  as published by the Free Software Foundation; either version 2
- *  of the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ *  Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the
- *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- *  Boston, MA  02110-1301, USA.
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
  *
  */
 
-#ifndef _ADM5120_GPIO_H_
-#define _ADM5120_GPIO_H_
+#ifndef _ASM_MIPS_MACH_ADM5120_GPIO_H
+#define _ASM_MIPS_MACH_ADM5120_GPIO_H
+
+#define ARCH_NR_GPIOS  64
+
+#include <asm-generic/gpio.h>
 
 #include <asm/mach-adm5120/adm5120_switch.h>
 
 #define ADM5120_GPIO_10M_ACT   (ADM5120_GPIO_SWITCH | LED_MODE_10M_ACT)
 #define ADM5120_GPIO_100M_ACT  (ADM5120_GPIO_SWITCH | LED_MODE_100M_ACT)
 
-extern int adm5120_gpio_direction_input(unsigned gpio);
-extern int adm5120_gpio_direction_output(unsigned gpio, int value);
-extern int adm5120_gpio_get_value(unsigned gpio);
-extern void adm5120_gpio_set_value(unsigned gpio, int value);
-extern int adm5120_gpio_request(unsigned gpio, const char *label);
-extern void adm5120_gpio_free(unsigned gpio);
-extern int adm5120_gpio_to_irq(unsigned gpio);
-extern int adm5120_irq_to_gpio(unsigned irq);
-
-/*
- * Wrappers for the generic GPIO layer
- */
-static inline int gpio_direction_input(unsigned gpio)
-{
-       return adm5120_gpio_direction_input(gpio);
-}
-
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
-       return adm5120_gpio_direction_output(gpio,value);
-}
+extern int  __adm5120_gpio0_get_value(unsigned gpio);
+extern void __adm5120_gpio0_set_value(unsigned gpio, int value);
+extern int  __adm5120_gpio1_get_value(unsigned gpio);
+extern void __adm5120_gpio1_set_value(unsigned gpio, int value);
+extern int  adm5120_gpio_to_irq(unsigned gpio);
+extern int  adm5120_irq_to_gpio(unsigned irq);
 
 static inline int gpio_get_value(unsigned gpio)
 {
-       return adm5120_gpio_get_value(gpio);
+       int ret;
+
+       switch (gpio) {
+       case ADM5120_GPIO_PIN0 ... ADM5120_GPIO_PIN7:
+               ret = __adm5120_gpio0_get_value(gpio);
+               break;
+       case ADM5120_GPIO_P0L0 ... ADM5120_GPIO_P4L2:
+               ret = __adm5120_gpio1_get_value(gpio - ADM5120_GPIO_P0L0);
+               break;
+       default:
+               ret = __gpio_get_value(gpio);
+               break;
+       }
+
+       return ret;
 }
 
 static inline void gpio_set_value(unsigned gpio, int value)
 {
-       adm5120_gpio_set_value(gpio, value);
-}
-
-static inline int gpio_request(unsigned gpio, const char *label)
-{
-       return adm5120_gpio_request(gpio, label);
-}
-
-static inline void gpio_free(unsigned gpio)
-{
-       adm5120_gpio_free(gpio);
+       switch (gpio) {
+       case ADM5120_GPIO_PIN0 ... ADM5120_GPIO_PIN7:
+               __adm5120_gpio0_set_value(gpio, value);
+               break;
+       case ADM5120_GPIO_P0L0 ... ADM5120_GPIO_P4L2:
+               __adm5120_gpio1_set_value(gpio - ADM5120_GPIO_P0L0, value);
+               break;
+       default:
+               __gpio_set_value(gpio, value);
+               break;
+       }
 }
 
 static inline int gpio_to_irq(unsigned gpio)
@@ -121,6 +110,6 @@ static inline int irq_to_gpio(unsigned irq)
        return adm5120_irq_to_gpio(irq);
 }
 
-#include <asm-generic/gpio.h> /* cansleep wrappers */
+#define gpio_cansleep  __gpio_cansleep
 
-#endif
+#endif /* _ASM_MIPS_MACH_ADM5120_GPIO_H */
This page took 0.026179 seconds and 4 git commands to generate.