aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/generic.c
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2007-02-20 16:58:15 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-20 20:10:16 -0500
commit3deac046e2883686a732960050ab74fca0db11fa (patch)
treede8e8b19148d201147f8be4084efba156f9e6709 /arch/arm/mach-pxa/generic.c
parent5d4675a811fb71fd922109d7ebae3f987401ace1 (diff)
[PATCH] GPIO API: PXA wrapper cleanup
Based on the discussion last december (http://lkml.org/lkml/2006/12/20/242), this patch: - moves the PXA_LAST_GPIO check into pxa_gpio_mode - fixes comment and includes in gpio.h - replaces the gpio_set/get_value macros with inline functions and adds a non-inline version to avoid code explosion when gpio is not a constant. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Nicolas Pitre <nico@cam.org> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/arm/mach-pxa/generic.c')
-rw-r--r--arch/arm/mach-pxa/generic.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 390524c4710f..b8cb79f899d5 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -36,6 +36,7 @@
36#include <asm/mach/map.h> 36#include <asm/mach/map.h>
37 37
38#include <asm/arch/pxa-regs.h> 38#include <asm/arch/pxa-regs.h>
39#include <asm/arch/gpio.h>
39#include <asm/arch/udc.h> 40#include <asm/arch/udc.h>
40#include <asm/arch/pxafb.h> 41#include <asm/arch/pxafb.h>
41#include <asm/arch/mmc.h> 42#include <asm/arch/mmc.h>
@@ -106,13 +107,16 @@ unsigned long long sched_clock(void)
106 * Handy function to set GPIO alternate functions 107 * Handy function to set GPIO alternate functions
107 */ 108 */
108 109
109void pxa_gpio_mode(int gpio_mode) 110int pxa_gpio_mode(int gpio_mode)
110{ 111{
111 unsigned long flags; 112 unsigned long flags;
112 int gpio = gpio_mode & GPIO_MD_MASK_NR; 113 int gpio = gpio_mode & GPIO_MD_MASK_NR;
113 int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8; 114 int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8;
114 int gafr; 115 int gafr;
115 116
117 if (gpio > PXA_LAST_GPIO)
118 return -EINVAL;
119
116 local_irq_save(flags); 120 local_irq_save(flags);
117 if (gpio_mode & GPIO_DFLT_LOW) 121 if (gpio_mode & GPIO_DFLT_LOW)
118 GPCR(gpio) = GPIO_bit(gpio); 122 GPCR(gpio) = GPIO_bit(gpio);
@@ -125,11 +129,33 @@ void pxa_gpio_mode(int gpio_mode)
125 gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2)); 129 gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2));
126 GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2)); 130 GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2));
127 local_irq_restore(flags); 131 local_irq_restore(flags);
132
133 return 0;
128} 134}
129 135
130EXPORT_SYMBOL(pxa_gpio_mode); 136EXPORT_SYMBOL(pxa_gpio_mode);
131 137
132/* 138/*
139 * Return GPIO level
140 */
141int pxa_gpio_get_value(unsigned gpio)
142{
143 return __gpio_get_value(gpio);
144}
145
146EXPORT_SYMBOL(pxa_gpio_get_value);
147
148/*
149 * Set output GPIO level
150 */
151void pxa_gpio_set_value(unsigned gpio, int value)
152{
153 __gpio_set_value(gpio, value);
154}
155
156EXPORT_SYMBOL(pxa_gpio_set_value);
157
158/*
133 * Routine to safely enable or disable a clock in the CKEN 159 * Routine to safely enable or disable a clock in the CKEN
134 */ 160 */
135void pxa_set_cken(int clock, int enable) 161void pxa_set_cken(int clock, int enable)