aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/generic.c')
-rw-r--r--arch/arm/mach-pxa/generic.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 0ccc91c92c44..3126a35aa002 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -26,8 +26,9 @@
26#include <asm/mach/map.h> 26#include <asm/mach/map.h>
27#include <asm/mach-types.h> 27#include <asm/mach-types.h>
28 28
29#include <mach/pxa-regs.h>
30#include <mach/reset.h> 29#include <mach/reset.h>
30#include <mach/gpio.h>
31#include <mach/pxa2xx-gpio.h>
31 32
32#include "generic.h" 33#include "generic.h"
33 34
@@ -127,3 +128,33 @@ void __init pxa_map_io(void)
127 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc)); 128 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
128 get_clk_frequency_khz(1); 129 get_clk_frequency_khz(1);
129} 130}
131
132/*
133 * Configure pins for GPIO or other functions
134 */
135int pxa_gpio_mode(int gpio_mode)
136{
137 unsigned long flags;
138 int gpio = gpio_mode & GPIO_MD_MASK_NR;
139 int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8;
140 int gafr;
141
142 if (gpio > pxa_last_gpio)
143 return -EINVAL;
144
145 local_irq_save(flags);
146 if (gpio_mode & GPIO_DFLT_LOW)
147 GPCR(gpio) = GPIO_bit(gpio);
148 else if (gpio_mode & GPIO_DFLT_HIGH)
149 GPSR(gpio) = GPIO_bit(gpio);
150 if (gpio_mode & GPIO_MD_MASK_DIR)
151 GPDR(gpio) |= GPIO_bit(gpio);
152 else
153 GPDR(gpio) &= ~GPIO_bit(gpio);
154 gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2));
155 GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2));
156 local_irq_restore(flags);
157
158 return 0;
159}
160EXPORT_SYMBOL(pxa_gpio_mode);