Index: linux-2.6/include/asm-arm/arch-sa1100/gpio.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6/include/asm-arm/arch-sa1100/gpio.h 2006-12-22 08:07:08.000000000 +0100 @@ -0,0 +1,95 @@ +/* + * linux/include/asm-arm/arch-pxa/gpio.h + * + * SA1100 GPIO wrappers for arch-neutral GPIO calls + * + * Written by Philipp Zabel + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ASM_ARCH_SA1100_GPIO_H +#define __ASM_ARCH_SA1100_GPIO_H + +#include +#include + +#include + +static inline int gpio_request(unsigned gpio, const char *label) +{ + return 0; +} + +static inline void gpio_free(unsigned gpio) +{ + return; +} + +static inline int gpio_direction_input(unsigned gpio) +{ + if (gpio > GPIO_MAX) + return -EINVAL; + GPDR = (GPDR_In << gpio); +} + +static inline int gpio_direction_output(unsigned gpio) +{ + if (gpio > GPIO_MAX) + return -EINVAL; + GPDR = (GPDR_Out << gpio); +} + +static inline int __gpio_get_value(unsigned gpio) +{ + return GPLR & GPIO_GPIO(gpio); +} + +#define gpio_get_value(gpio) \ + (__builtin_constant_p(gpio) ? \ + __gpioe_get_value(gpio) : \ + sa1100_gpio_get_value(gpio)) + +static inline void __gpio_set_value(unsigned gpio, int value) +{ + if (value) + GPSR = GPIO_GPIO(gpio); + else + GPCR = GPIO_GPIO(gpio); +} + +#define gpio_set_value(gpio,value) \ + (__builtin_constant_p(gpio) ? \ + __gpio_set_value(gpio, value) : \ + sa1100_gpio_set_value(gpio, value)) + +static inline unsigned gpio_to_irq(unsigned gpio) +{ + if (gpio < 11) + return IRQ_GPIO0 + gpio; + else + return IRQ_GPIO11 - 11 + gpio; +} + +static inline unsigned irq_to_gpio(unsigned irq) +{ + if (irq < IRQ_GPIO11_27) + return irq - IRQ_GPIO0; + else + return irq - IRQ_GPIO11 + 11; +} + +#endif Index: linux-2.6/arch/arm/mach-sa1100/generic.c =================================================================== --- linux-2.6.orig/arch/arm/mach-sa1100/generic.c 2006-12-22 07:57:46.000000000 +0100 +++ linux-2.6/arch/arm/mach-sa1100/generic.c 2006-12-22 08:12:51.000000000 +0100 @@ -28,6 +28,8 @@ #include #include +#include + #include "generic.h" #define NR_FREQS 16 @@ -139,6 +141,26 @@ } /* + * Return GPIO level + */ +int sa1100_gpio_get_value(unsigned gpio) +{ + return __gpio_get_value(gpio); +} + +EXPORT_SYMBOL(sa1100_gpio_get_value); + +/* + * Set output GPIO level + */ +void sa1100_gpio_set_value(unsigned gpio, int value) +{ + __gpio_set_value(gpio, value); +} + +EXPORT_SYMBOL(sa1100_gpio_set_value); + +/* * Default power-off for SA1100 */ static void sa1100_power_off(void) Index: linux-2.6/include/asm-arm/arch-sa1100/hardware.h =================================================================== --- linux-2.6.orig/include/asm-arm/arch-sa1100/hardware.h 2006-12-22 07:58:13.000000000 +0100 +++ linux-2.6/include/asm-arm/arch-sa1100/hardware.h 2006-12-22 08:02:23.000000000 +0100 @@ -48,6 +48,16 @@ #endif +/* + * Return GPIO level, nonzero means high, zero is low + */ +extern int sa1100_gpio_get_value(unsigned gpio); + +/* + * Set output GPIO level + */ +void sa1100_gpio_set_value(unsigned gpio, int value); + #include "SA-1100.h" #ifdef CONFIG_SA1101