aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-arm
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-arm')
-rw-r--r--include/asm-arm/arch-pxa/gpio.h42
-rw-r--r--include/asm-arm/arch-pxa/hardware.h12
-rw-r--r--include/asm-arm/arch-s3c2410/gpio.h21
-rw-r--r--include/asm-arm/arch-sa1100/gpio.h34
4 files changed, 61 insertions, 48 deletions
diff --git a/include/asm-arm/arch-pxa/gpio.h b/include/asm-arm/arch-pxa/gpio.h
index e67c23821017..3d348a351157 100644
--- a/include/asm-arm/arch-pxa/gpio.h
+++ b/include/asm-arm/arch-pxa/gpio.h
@@ -25,10 +25,8 @@
25#define __ASM_ARCH_PXA_GPIO_H 25#define __ASM_ARCH_PXA_GPIO_H
26 26
27#include <asm/arch/pxa-regs.h> 27#include <asm/arch/pxa-regs.h>
28#include <asm/arch/irqs.h> 28#include <asm/irq.h>
29#include <asm/arch/hardware.h> 29#include <asm/hardware.h>
30
31#include <asm/errno.h>
32 30
33static inline int gpio_request(unsigned gpio, const char *label) 31static inline int gpio_request(unsigned gpio, const char *label)
34{ 32{
@@ -42,26 +40,36 @@ static inline void gpio_free(unsigned gpio)
42 40
43static inline int gpio_direction_input(unsigned gpio) 41static inline int gpio_direction_input(unsigned gpio)
44{ 42{
45 if (gpio > PXA_LAST_GPIO) 43 return pxa_gpio_mode(gpio | GPIO_IN);
46 return -EINVAL;
47 pxa_gpio_mode(gpio | GPIO_IN);
48} 44}
49 45
50static inline int gpio_direction_output(unsigned gpio) 46static inline int gpio_direction_output(unsigned gpio)
51{ 47{
52 if (gpio > PXA_LAST_GPIO) 48 return pxa_gpio_mode(gpio | GPIO_OUT);
53 return -EINVAL;
54 pxa_gpio_mode(gpio | GPIO_OUT);
55} 49}
56 50
57/* REVISIT these macros are correct, but suffer code explosion 51static inline int __gpio_get_value(unsigned gpio)
58 * for non-constant parameters. Provide out-line versions too. 52{
59 */ 53 return GPLR(gpio) & GPIO_bit(gpio);
60#define gpio_get_value(gpio) \ 54}
61 (GPLR(gpio) & GPIO_bit(gpio)) 55
56#define gpio_get_value(gpio) \
57 (__builtin_constant_p(gpio) ? \
58 __gpio_get_value(gpio) : \
59 pxa_gpio_get_value(gpio))
60
61static inline void __gpio_set_value(unsigned gpio, int value)
62{
63 if (value)
64 GPSR(gpio) = GPIO_bit(gpio);
65 else
66 GPCR(gpio) = GPIO_bit(gpio);
67}
62 68
63#define gpio_set_value(gpio,value) \ 69#define gpio_set_value(gpio,value) \
64 ((value) ? (GPSR(gpio) = GPIO_bit(gpio)):(GPCR(gpio) = GPIO_bit(gpio))) 70 (__builtin_constant_p(gpio) ? \
71 __gpio_set_value(gpio, value) : \
72 pxa_gpio_set_value(gpio, value))
65 73
66#include <asm-generic/gpio.h> /* cansleep wrappers */ 74#include <asm-generic/gpio.h> /* cansleep wrappers */
67 75
diff --git a/include/asm-arm/arch-pxa/hardware.h b/include/asm-arm/arch-pxa/hardware.h
index 3e70bd95472c..e2bdc2fbede1 100644
--- a/include/asm-arm/arch-pxa/hardware.h
+++ b/include/asm-arm/arch-pxa/hardware.h
@@ -65,7 +65,17 @@
65/* 65/*
66 * Handy routine to set GPIO alternate functions 66 * Handy routine to set GPIO alternate functions
67 */ 67 */
68extern void pxa_gpio_mode( int gpio_mode ); 68extern int pxa_gpio_mode( int gpio_mode );
69
70/*
71 * Return GPIO level, nonzero means high, zero is low
72 */
73extern int pxa_gpio_get_value(unsigned gpio);
74
75/*
76 * Set output GPIO level
77 */
78extern void pxa_gpio_set_value(unsigned gpio, int value);
69 79
70/* 80/*
71 * Routine to enable or disable CKEN 81 * Routine to enable or disable CKEN
diff --git a/include/asm-arm/arch-s3c2410/gpio.h b/include/asm-arm/arch-s3c2410/gpio.h
index 67b8b9ab22e9..d47ae453f8ca 100644
--- a/include/asm-arm/arch-s3c2410/gpio.h
+++ b/include/asm-arm/arch-s3c2410/gpio.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/include/asm-arm/arch-pxa/gpio.h 2 * linux/include/asm-arm/arch-s3c2410/gpio.h
3 * 3 *
4 * S3C2400 GPIO wrappers for arch-neutral GPIO calls 4 * S3C2410 GPIO wrappers for arch-neutral GPIO calls
5 * 5 *
6 * Written by Philipp Zabel <philipp.zabel@gmail.com> 6 * Written by Philipp Zabel <philipp.zabel@gmail.com>
7 * 7 *
@@ -21,14 +21,12 @@
21 * 21 *
22 */ 22 */
23 23
24#ifndef __ASM_ARCH_PXA_GPIO_H 24#ifndef __ASM_ARCH_S3C2410_GPIO_H
25#define __ASM_ARCH_PXA_GPIO_H 25#define __ASM_ARCH_S3C2410_GPIO_H
26 26
27#include <asm/arch/pxa-regs.h> 27#include <asm/irq.h>
28#include <asm/arch/irqs.h> 28#include <asm/hardware.h>
29#include <asm/arch/hardware.h> 29#include <asm/arch/regs-gpio.h>
30
31#include <asm/errno.h>
32 30
33static inline int gpio_request(unsigned gpio, const char *label) 31static inline int gpio_request(unsigned gpio, const char *label)
34{ 32{
@@ -57,8 +55,11 @@ static inline int gpio_direction_output(unsigned gpio)
57 55
58#include <asm-generic/gpio.h> /* cansleep wrappers */ 56#include <asm-generic/gpio.h> /* cansleep wrappers */
59 57
60/* FIXME or maybe s3c2400_gpio_getirq() ... */ 58#ifdef CONFIG_CPU_S3C2400
59#define gpio_to_irq(gpio) s3c2400_gpio_getirq(gpio)
60#else
61#define gpio_to_irq(gpio) s3c2410_gpio_getirq(gpio) 61#define gpio_to_irq(gpio) s3c2410_gpio_getirq(gpio)
62#endif
62 63
63/* FIXME implement irq_to_gpio() */ 64/* FIXME implement irq_to_gpio() */
64 65
diff --git a/include/asm-arm/arch-sa1100/gpio.h b/include/asm-arm/arch-sa1100/gpio.h
index a331fe3f6e48..da7575b0e5d0 100644
--- a/include/asm-arm/arch-sa1100/gpio.h
+++ b/include/asm-arm/arch-sa1100/gpio.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/asm-arm/arch-pxa/gpio.h 2 * linux/include/asm-arm/arch-sa1100/gpio.h
3 * 3 *
4 * SA1100 GPIO wrappers for arch-neutral GPIO calls 4 * SA1100 GPIO wrappers for arch-neutral GPIO calls
5 * 5 *
@@ -24,11 +24,8 @@
24#ifndef __ASM_ARCH_SA1100_GPIO_H 24#ifndef __ASM_ARCH_SA1100_GPIO_H
25#define __ASM_ARCH_SA1100_GPIO_H 25#define __ASM_ARCH_SA1100_GPIO_H
26 26
27#include <asm/arch/SA-1100.h> 27#include <asm/hardware.h>
28#include <asm/arch/irqs.h> 28#include <asm/irq.h>
29#include <asm/arch/hardware.h>
30
31#include <asm/errno.h>
32 29
33static inline int gpio_request(unsigned gpio, const char *label) 30static inline int gpio_request(unsigned gpio, const char *label)
34{ 31{
@@ -40,26 +37,23 @@ static inline void gpio_free(unsigned gpio)
40 return; 37 return;
41} 38}
42 39
43static inline int gpio_direction_input(unsigned gpio) 40extern int gpio_direction_input(unsigned gpio);
41extern int gpio_direction_output(unsigned gpio);
42
43
44static inline int gpio_get_value(unsigned gpio)
44{ 45{
45 if (gpio > GPIO_MAX) 46 return GPLR & GPIO_GPIO(gpio);
46 return -EINVAL;
47 GPDR = (GPDR_In << gpio) 0
48} 47}
49 48
50static inline int gpio_direction_output(unsigned gpio) 49static inline void gpio_set_value(unsigned gpio, int value)
51{ 50{
52 if (gpio > GPIO_MAX) 51 if (value)
53 return -EINVAL; 52 GPSR = GPIO_GPIO(gpio);
54 GPDR = (GPDR_Out << gpio) 0 53 else
54 GPCR = GPIO_GPIO(gpio);
55} 55}
56 56
57#define gpio_get_value(gpio) \
58 (GPLR & GPIO_GPIO(gpio))
59
60#define gpio_set_value(gpio,value) \
61 ((value) ? (GPSR = GPIO_GPIO(gpio)) : (GPCR(gpio) = GPIO_GPIO(gpio)))
62
63#include <asm-generic/gpio.h> /* cansleep wrappers */ 57#include <asm-generic/gpio.h> /* cansleep wrappers */
64 58
65static inline unsigned gpio_to_irq(unsigned gpio) 59static inline unsigned gpio_to_irq(unsigned gpio)