diff options
author | GuanXuetao <gxt@mprc.pku.edu.cn> | 2011-02-26 08:21:18 -0500 |
---|---|---|
committer | GuanXuetao <gxt@mprc.pku.edu.cn> | 2011-03-16 21:19:19 -0400 |
commit | e5abf78b57199a417eb01ff922a5ea6ff9e10b61 (patch) | |
tree | 6f72a13d44c0dc8c4d575d84885f5694c16ed1da /arch/unicore32/include | |
parent | 4517366d870b89d6fb8c0c90deb6c73d975908af (diff) |
unicore32 io: redefine __REG(x) and re-use readl/writel funcs
-- by advice of Arnd Bergmann
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/unicore32/include')
-rw-r--r-- | arch/unicore32/include/asm/gpio.h | 9 | ||||
-rw-r--r-- | arch/unicore32/include/mach/dma.h | 11 | ||||
-rw-r--r-- | arch/unicore32/include/mach/hardware.h | 8 |
3 files changed, 15 insertions, 13 deletions
diff --git a/arch/unicore32/include/asm/gpio.h b/arch/unicore32/include/asm/gpio.h index 3aaa41e9e413..2716f14e3ff6 100644 --- a/arch/unicore32/include/asm/gpio.h +++ b/arch/unicore32/include/asm/gpio.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #ifndef __UNICORE_GPIO_H__ | 13 | #ifndef __UNICORE_GPIO_H__ |
14 | #define __UNICORE_GPIO_H__ | 14 | #define __UNICORE_GPIO_H__ |
15 | 15 | ||
16 | #include <linux/io.h> | ||
16 | #include <asm/irq.h> | 17 | #include <asm/irq.h> |
17 | #include <mach/hardware.h> | 18 | #include <mach/hardware.h> |
18 | #include <asm-generic/gpio.h> | 19 | #include <asm-generic/gpio.h> |
@@ -66,7 +67,7 @@ | |||
66 | static inline int gpio_get_value(unsigned gpio) | 67 | static inline int gpio_get_value(unsigned gpio) |
67 | { | 68 | { |
68 | if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX)) | 69 | if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX)) |
69 | return GPIO_GPLR & GPIO_GPIO(gpio); | 70 | return readl(GPIO_GPLR) & GPIO_GPIO(gpio); |
70 | else | 71 | else |
71 | return __gpio_get_value(gpio); | 72 | return __gpio_get_value(gpio); |
72 | } | 73 | } |
@@ -75,9 +76,9 @@ static inline void gpio_set_value(unsigned gpio, int value) | |||
75 | { | 76 | { |
76 | if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX)) | 77 | if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX)) |
77 | if (value) | 78 | if (value) |
78 | GPIO_GPSR = GPIO_GPIO(gpio); | 79 | writel(GPIO_GPIO(gpio), GPIO_GPSR); |
79 | else | 80 | else |
80 | GPIO_GPCR = GPIO_GPIO(gpio); | 81 | writel(GPIO_GPIO(gpio), GPIO_GPCR); |
81 | else | 82 | else |
82 | __gpio_set_value(gpio, value); | 83 | __gpio_set_value(gpio, value); |
83 | } | 84 | } |
@@ -86,7 +87,7 @@ static inline void gpio_set_value(unsigned gpio, int value) | |||
86 | 87 | ||
87 | static inline unsigned gpio_to_irq(unsigned gpio) | 88 | static inline unsigned gpio_to_irq(unsigned gpio) |
88 | { | 89 | { |
89 | if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & GPIO_GPIR)) | 90 | if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR))) |
90 | return IRQ_GPIOLOW0 + gpio; | 91 | return IRQ_GPIOLOW0 + gpio; |
91 | else | 92 | else |
92 | return IRQ_GPIO0 + gpio; | 93 | return IRQ_GPIO0 + gpio; |
diff --git a/arch/unicore32/include/mach/dma.h b/arch/unicore32/include/mach/dma.h index 3e3224a10525..d655c1b6e083 100644 --- a/arch/unicore32/include/mach/dma.h +++ b/arch/unicore32/include/mach/dma.h | |||
@@ -35,7 +35,14 @@ extern int puv3_request_dma(char *name, | |||
35 | 35 | ||
36 | extern void puv3_free_dma(int dma_ch); | 36 | extern void puv3_free_dma(int dma_ch); |
37 | 37 | ||
38 | #define puv3_stop_dma(ch) (DMAC_CONFIG(ch) &= ~DMAC_CONFIG_EN) | 38 | static inline void puv3_stop_dma(int ch) |
39 | #define puv3_resume_dma(ch) (DMAC_CONFIG(ch) |= DMAC_CONFIG_EN) | 39 | { |
40 | writel(readl(DMAC_CONFIG(ch)) & ~DMAC_CONFIG_EN, DMAC_CONFIG(ch)); | ||
41 | } | ||
42 | |||
43 | static inline void puv3_resume_dma(int ch) | ||
44 | { | ||
45 | writel(readl(DMAC_CONFIG(ch)) | DMAC_CONFIG_EN, DMAC_CONFIG(ch)); | ||
46 | } | ||
40 | 47 | ||
41 | #endif /* __MACH_PUV3_DMA_H__ */ | 48 | #endif /* __MACH_PUV3_DMA_H__ */ |
diff --git a/arch/unicore32/include/mach/hardware.h b/arch/unicore32/include/mach/hardware.h index c7d3dd6b4eff..b71405ab6de6 100644 --- a/arch/unicore32/include/mach/hardware.h +++ b/arch/unicore32/include/mach/hardware.h | |||
@@ -22,13 +22,7 @@ | |||
22 | 22 | ||
23 | #ifndef __ASSEMBLY__ | 23 | #ifndef __ASSEMBLY__ |
24 | 24 | ||
25 | # define __REG(x) (*((volatile unsigned long *)io_p2v(x))) | 25 | # define __REG(x) (void __iomem *)io_p2v(x) |
26 | # define __PREG(x) (io_v2p((unsigned long)&(x))) | ||
27 | |||
28 | #else | ||
29 | |||
30 | # define __REG(x) io_p2v(x) | ||
31 | # define __PREG(x) io_v2p(x) | ||
32 | 26 | ||
33 | #endif | 27 | #endif |
34 | 28 | ||