diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-08-26 20:17:51 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-08-26 20:24:28 -0400 |
commit | b855192c08fcb14adbc5d3a7cab182022d433cca (patch) | |
tree | 3a10cafbfbf98cafacf667eb218c71300b351bfa /arch/mips/include/asm/mach-ar7/gpio.h | |
parent | d886c73cd4cf02a71e1650cbcb6176799d78aac1 (diff) | |
parent | 3e0e1e9c5a327d4dba8490d83ef55c0564e6e8a7 (diff) |
Merge branch 'x86/urgent' into x86/pat
Reason: Change to is_new_memtype_allowed() in x86/urgent
Resolved semantic conflicts in:
arch/x86/mm/pat.c
arch/x86/mm/ioremap.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/mips/include/asm/mach-ar7/gpio.h')
-rw-r--r-- | arch/mips/include/asm/mach-ar7/gpio.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h new file mode 100644 index 000000000000..cbe9c4f126df --- /dev/null +++ b/arch/mips/include/asm/mach-ar7/gpio.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | #ifndef __AR7_GPIO_H__ | ||
20 | #define __AR7_GPIO_H__ | ||
21 | |||
22 | #include <asm/mach-ar7/ar7.h> | ||
23 | |||
24 | #define AR7_GPIO_MAX 32 | ||
25 | |||
26 | extern int gpio_request(unsigned gpio, const char *label); | ||
27 | extern void gpio_free(unsigned gpio); | ||
28 | |||
29 | /* Common GPIO layer */ | ||
30 | static inline int gpio_get_value(unsigned gpio) | ||
31 | { | ||
32 | void __iomem *gpio_in = | ||
33 | (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT); | ||
34 | |||
35 | return readl(gpio_in) & (1 << gpio); | ||
36 | } | ||
37 | |||
38 | static inline void gpio_set_value(unsigned gpio, int value) | ||
39 | { | ||
40 | void __iomem *gpio_out = | ||
41 | (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT); | ||
42 | unsigned tmp; | ||
43 | |||
44 | tmp = readl(gpio_out) & ~(1 << gpio); | ||
45 | if (value) | ||
46 | tmp |= 1 << gpio; | ||
47 | writel(tmp, gpio_out); | ||
48 | } | ||
49 | |||
50 | static inline int gpio_direction_input(unsigned gpio) | ||
51 | { | ||
52 | void __iomem *gpio_dir = | ||
53 | (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); | ||
54 | |||
55 | if (gpio >= AR7_GPIO_MAX) | ||
56 | return -EINVAL; | ||
57 | |||
58 | writel(readl(gpio_dir) | (1 << gpio), gpio_dir); | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static inline int gpio_direction_output(unsigned gpio, int value) | ||
64 | { | ||
65 | void __iomem *gpio_dir = | ||
66 | (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); | ||
67 | |||
68 | if (gpio >= AR7_GPIO_MAX) | ||
69 | return -EINVAL; | ||
70 | |||
71 | gpio_set_value(gpio, value); | ||
72 | writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir); | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static inline int gpio_to_irq(unsigned gpio) | ||
78 | { | ||
79 | return -EINVAL; | ||
80 | } | ||
81 | |||
82 | static inline int irq_to_gpio(unsigned irq) | ||
83 | { | ||
84 | return -EINVAL; | ||
85 | } | ||
86 | |||
87 | /* Board specific GPIO functions */ | ||
88 | static inline int ar7_gpio_enable(unsigned gpio) | ||
89 | { | ||
90 | void __iomem *gpio_en = | ||
91 | (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE); | ||
92 | |||
93 | writel(readl(gpio_en) | (1 << gpio), gpio_en); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static inline int ar7_gpio_disable(unsigned gpio) | ||
99 | { | ||
100 | void __iomem *gpio_en = | ||
101 | (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE); | ||
102 | |||
103 | writel(readl(gpio_en) & ~(1 << gpio), gpio_en); | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | #include <asm-generic/gpio.h> | ||
109 | |||
110 | #endif | ||