X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/17c7b6c3fdc48301e50d22cc6138ede16bd1be24..a3945d7bcf1256fedc4b9013952ec15ab242da97:/target/linux/adm5120/files/include/asm-mips/mach-adm5120/gpio.h?ds=inline diff --git a/target/linux/adm5120/files/include/asm-mips/mach-adm5120/gpio.h b/target/linux/adm5120/files/include/asm-mips/mach-adm5120/gpio.h index 684d86cd4..7ba7efca1 100644 --- a/target/linux/adm5120/files/include/asm-mips/mach-adm5120/gpio.h +++ b/target/linux/adm5120/files/include/asm-mips/mach-adm5120/gpio.h @@ -1,30 +1,20 @@ /* - * $Id$ - * * ADM5120 GPIO wrappers for arch-neutral GPIO calls * - * Copyright (C) 2007 OpenWrt.org - * Copyright (C) 2007 Gabor Juhos - * - * 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 * - * 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 #include @@ -69,46 +59,45 @@ #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 /* cansleep wrappers */ +#define gpio_cansleep __gpio_cansleep -#endif +#endif /* _ASM_MIPS_MACH_ADM5120_GPIO_H */