aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/generic.c
diff options
context:
space:
mode:
authorSascha Hauer <sascha@saschahauer.de>2005-10-04 18:17:52 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-10-04 18:17:52 -0400
commit0a5b0aa8a331f4346b4b02bc653107304a6abdc5 (patch)
tree10476f4758b174a86a133493da992d6fb7adc636 /arch/arm/mach-imx/generic.c
parentd78795b6930956fb66238d4d26242482d4a31470 (diff)
[ARM] 2950/1: i.MX gpio setup function
Patch from Sascha Hauer Current implementation of imx_gpio_mode does not allow to configure all alternate routing possibilities of the i.MX. With this patch every bit in the gpio setup registers has a corresponding bit in the gpio_mode parameter, so every routing should be possible now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-imx/generic.c')
-rw-r--r--arch/arm/mach-imx/generic.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index 41e5849ae8da..f8a742bb2d5b 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -28,14 +28,15 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <asm/arch/imxfb.h> 29#include <asm/arch/imxfb.h>
30#include <asm/hardware.h> 30#include <asm/hardware.h>
31#include <asm/arch/imx-regs.h>
31 32
32#include <asm/mach/map.h> 33#include <asm/mach/map.h>
33 34
34void imx_gpio_mode(int gpio_mode) 35void imx_gpio_mode(int gpio_mode)
35{ 36{
36 unsigned int pin = gpio_mode & GPIO_PIN_MASK; 37 unsigned int pin = gpio_mode & GPIO_PIN_MASK;
37 unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> 5; 38 unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
38 unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> 10; 39 unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT;
39 unsigned int tmp; 40 unsigned int tmp;
40 41
41 /* Pullup enable */ 42 /* Pullup enable */
@@ -57,7 +58,7 @@ void imx_gpio_mode(int gpio_mode)
57 GPR(port) &= ~(1<<pin); 58 GPR(port) &= ~(1<<pin);
58 59
59 /* use as gpio? */ 60 /* use as gpio? */
60 if( ocr == 3 ) 61 if(gpio_mode & GPIO_GIUS)
61 GIUS(port) |= (1<<pin); 62 GIUS(port) |= (1<<pin);
62 else 63 else
63 GIUS(port) &= ~(1<<pin); 64 GIUS(port) &= ~(1<<pin);
@@ -72,20 +73,20 @@ void imx_gpio_mode(int gpio_mode)
72 tmp |= (ocr << (pin*2)); 73 tmp |= (ocr << (pin*2));
73 OCR1(port) = tmp; 74 OCR1(port) = tmp;
74 75
75 if( gpio_mode & GPIO_AOUT ) 76 ICONFA1(port) &= ~( 3<<(pin*2));
76 ICONFA1(port) &= ~( 3<<(pin*2)); 77 ICONFA1(port) |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2);
77 if( gpio_mode & GPIO_BOUT ) 78 ICONFB1(port) &= ~( 3<<(pin*2));
78 ICONFB1(port) &= ~( 3<<(pin*2)); 79 ICONFB1(port) |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << (pin * 2);
79 } else { 80 } else {
80 tmp = OCR2(port); 81 tmp = OCR2(port);
81 tmp &= ~( 3<<((pin-16)*2)); 82 tmp &= ~( 3<<((pin-16)*2));
82 tmp |= (ocr << ((pin-16)*2)); 83 tmp |= (ocr << ((pin-16)*2));
83 OCR2(port) = tmp; 84 OCR2(port) = tmp;
84 85
85 if( gpio_mode & GPIO_AOUT ) 86 ICONFA2(port) &= ~( 3<<((pin-16)*2));
86 ICONFA2(port) &= ~( 3<<((pin-16)*2)); 87 ICONFA2(port) |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << ((pin-16) * 2);
87 if( gpio_mode & GPIO_BOUT ) 88 ICONFB2(port) &= ~( 3<<((pin-16)*2));
88 ICONFB2(port) &= ~( 3<<((pin-16)*2)); 89 ICONFB2(port) |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << ((pin-16) * 2);
89 } 90 }
90} 91}
91 92