diff options
-rw-r--r-- | arch/x86/include/asm/mach-rdc321x/gpio.h | 60 | ||||
-rw-r--r-- | arch/x86/include/asm/rdc321x_defs.h (renamed from arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h) | 0 | ||||
-rw-r--r-- | arch/x86/mach-rdc321x/Makefile | 5 | ||||
-rw-r--r-- | arch/x86/mach-rdc321x/gpio.c | 194 | ||||
-rw-r--r-- | arch/x86/mach-rdc321x/platform.c | 69 | ||||
-rw-r--r-- | drivers/watchdog/rdc321x_wdt.c | 2 |
6 files changed, 1 insertions, 329 deletions
diff --git a/arch/x86/include/asm/mach-rdc321x/gpio.h b/arch/x86/include/asm/mach-rdc321x/gpio.h deleted file mode 100644 index c210ab5788b0..000000000000 --- a/arch/x86/include/asm/mach-rdc321x/gpio.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | #ifndef _ASM_X86_MACH_RDC321X_GPIO_H | ||
2 | #define _ASM_X86_MACH_RDC321X_GPIO_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | |||
6 | extern int rdc_gpio_get_value(unsigned gpio); | ||
7 | extern void rdc_gpio_set_value(unsigned gpio, int value); | ||
8 | extern int rdc_gpio_direction_input(unsigned gpio); | ||
9 | extern int rdc_gpio_direction_output(unsigned gpio, int value); | ||
10 | extern int rdc_gpio_request(unsigned gpio, const char *label); | ||
11 | extern void rdc_gpio_free(unsigned gpio); | ||
12 | extern void __init rdc321x_gpio_setup(void); | ||
13 | |||
14 | /* Wrappers for the arch-neutral GPIO API */ | ||
15 | |||
16 | static inline int gpio_request(unsigned gpio, const char *label) | ||
17 | { | ||
18 | return rdc_gpio_request(gpio, label); | ||
19 | } | ||
20 | |||
21 | static inline void gpio_free(unsigned gpio) | ||
22 | { | ||
23 | might_sleep(); | ||
24 | rdc_gpio_free(gpio); | ||
25 | } | ||
26 | |||
27 | static inline int gpio_direction_input(unsigned gpio) | ||
28 | { | ||
29 | return rdc_gpio_direction_input(gpio); | ||
30 | } | ||
31 | |||
32 | static inline int gpio_direction_output(unsigned gpio, int value) | ||
33 | { | ||
34 | return rdc_gpio_direction_output(gpio, value); | ||
35 | } | ||
36 | |||
37 | static inline int gpio_get_value(unsigned gpio) | ||
38 | { | ||
39 | return rdc_gpio_get_value(gpio); | ||
40 | } | ||
41 | |||
42 | static inline void gpio_set_value(unsigned gpio, int value) | ||
43 | { | ||
44 | rdc_gpio_set_value(gpio, value); | ||
45 | } | ||
46 | |||
47 | static inline int gpio_to_irq(unsigned gpio) | ||
48 | { | ||
49 | return gpio; | ||
50 | } | ||
51 | |||
52 | static inline int irq_to_gpio(unsigned irq) | ||
53 | { | ||
54 | return irq; | ||
55 | } | ||
56 | |||
57 | /* For cansleep */ | ||
58 | #include <asm-generic/gpio.h> | ||
59 | |||
60 | #endif /* _ASM_X86_MACH_RDC321X_GPIO_H */ | ||
diff --git a/arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h b/arch/x86/include/asm/rdc321x_defs.h index c8e9c8bed3d0..c8e9c8bed3d0 100644 --- a/arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h +++ b/arch/x86/include/asm/rdc321x_defs.h | |||
diff --git a/arch/x86/mach-rdc321x/Makefile b/arch/x86/mach-rdc321x/Makefile deleted file mode 100644 index 8325b4ca431c..000000000000 --- a/arch/x86/mach-rdc321x/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for the RDC321x specific parts of the kernel | ||
3 | # | ||
4 | obj-$(CONFIG_X86_RDC321X) := gpio.o platform.o | ||
5 | |||
diff --git a/arch/x86/mach-rdc321x/gpio.c b/arch/x86/mach-rdc321x/gpio.c deleted file mode 100644 index 247f33d3a407..000000000000 --- a/arch/x86/mach-rdc321x/gpio.c +++ /dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | /* | ||
2 | * GPIO support for RDC SoC R3210/R8610 | ||
3 | * | ||
4 | * Copyright (C) 2007, Florian Fainelli <florian@openwrt.org> | ||
5 | * Copyright (C) 2008, Volker Weiss <dev@tintuc.de> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | |||
24 | #include <linux/spinlock.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/module.h> | ||
28 | |||
29 | #include <asm/gpio.h> | ||
30 | #include <asm/mach-rdc321x/rdc321x_defs.h> | ||
31 | |||
32 | |||
33 | /* spin lock to protect our private copy of GPIO data register plus | ||
34 | the access to PCI conf registers. */ | ||
35 | static DEFINE_SPINLOCK(gpio_lock); | ||
36 | |||
37 | /* copy of GPIO data registers */ | ||
38 | static u32 gpio_data_reg1; | ||
39 | static u32 gpio_data_reg2; | ||
40 | |||
41 | static u32 gpio_request_data[2]; | ||
42 | |||
43 | |||
44 | static inline void rdc321x_conf_write(unsigned addr, u32 value) | ||
45 | { | ||
46 | outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR); | ||
47 | outl(value, RDC3210_CFGREG_DATA); | ||
48 | } | ||
49 | |||
50 | static inline void rdc321x_conf_or(unsigned addr, u32 value) | ||
51 | { | ||
52 | outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR); | ||
53 | value |= inl(RDC3210_CFGREG_DATA); | ||
54 | outl(value, RDC3210_CFGREG_DATA); | ||
55 | } | ||
56 | |||
57 | static inline u32 rdc321x_conf_read(unsigned addr) | ||
58 | { | ||
59 | outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR); | ||
60 | |||
61 | return inl(RDC3210_CFGREG_DATA); | ||
62 | } | ||
63 | |||
64 | /* configure pin as GPIO */ | ||
65 | static void rdc321x_configure_gpio(unsigned gpio) | ||
66 | { | ||
67 | unsigned long flags; | ||
68 | |||
69 | spin_lock_irqsave(&gpio_lock, flags); | ||
70 | rdc321x_conf_or(gpio < 32 | ||
71 | ? RDC321X_GPIO_CTRL_REG1 : RDC321X_GPIO_CTRL_REG2, | ||
72 | 1 << (gpio & 0x1f)); | ||
73 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
74 | } | ||
75 | |||
76 | /* initially setup the 2 copies of the gpio data registers. | ||
77 | This function must be called by the platform setup code. */ | ||
78 | void __init rdc321x_gpio_setup() | ||
79 | { | ||
80 | /* this might not be, what others (BIOS, bootloader, etc.) | ||
81 | wrote to these registers before, but it's a good guess. Still | ||
82 | better than just using 0xffffffff. */ | ||
83 | |||
84 | gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1); | ||
85 | gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2); | ||
86 | } | ||
87 | |||
88 | /* determine, if gpio number is valid */ | ||
89 | static inline int rdc321x_is_gpio(unsigned gpio) | ||
90 | { | ||
91 | return gpio <= RDC321X_MAX_GPIO; | ||
92 | } | ||
93 | |||
94 | /* request GPIO */ | ||
95 | int rdc_gpio_request(unsigned gpio, const char *label) | ||
96 | { | ||
97 | unsigned long flags; | ||
98 | |||
99 | if (!rdc321x_is_gpio(gpio)) | ||
100 | return -EINVAL; | ||
101 | |||
102 | spin_lock_irqsave(&gpio_lock, flags); | ||
103 | if (gpio_request_data[(gpio & 0x20) ? 1 : 0] & (1 << (gpio & 0x1f))) | ||
104 | goto inuse; | ||
105 | gpio_request_data[(gpio & 0x20) ? 1 : 0] |= (1 << (gpio & 0x1f)); | ||
106 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
107 | |||
108 | return 0; | ||
109 | inuse: | ||
110 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | EXPORT_SYMBOL(rdc_gpio_request); | ||
114 | |||
115 | /* release previously-claimed GPIO */ | ||
116 | void rdc_gpio_free(unsigned gpio) | ||
117 | { | ||
118 | unsigned long flags; | ||
119 | |||
120 | if (!rdc321x_is_gpio(gpio)) | ||
121 | return; | ||
122 | |||
123 | spin_lock_irqsave(&gpio_lock, flags); | ||
124 | gpio_request_data[(gpio & 0x20) ? 1 : 0] &= ~(1 << (gpio & 0x1f)); | ||
125 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
126 | } | ||
127 | EXPORT_SYMBOL(rdc_gpio_free); | ||
128 | |||
129 | /* read GPIO pin */ | ||
130 | int rdc_gpio_get_value(unsigned gpio) | ||
131 | { | ||
132 | u32 reg; | ||
133 | unsigned long flags; | ||
134 | |||
135 | spin_lock_irqsave(&gpio_lock, flags); | ||
136 | reg = rdc321x_conf_read(gpio < 32 | ||
137 | ? RDC321X_GPIO_DATA_REG1 : RDC321X_GPIO_DATA_REG2); | ||
138 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
139 | |||
140 | return (1 << (gpio & 0x1f)) & reg ? 1 : 0; | ||
141 | } | ||
142 | EXPORT_SYMBOL(rdc_gpio_get_value); | ||
143 | |||
144 | /* set GPIO pin to value */ | ||
145 | void rdc_gpio_set_value(unsigned gpio, int value) | ||
146 | { | ||
147 | unsigned long flags; | ||
148 | u32 reg; | ||
149 | |||
150 | reg = 1 << (gpio & 0x1f); | ||
151 | if (gpio < 32) { | ||
152 | spin_lock_irqsave(&gpio_lock, flags); | ||
153 | if (value) | ||
154 | gpio_data_reg1 |= reg; | ||
155 | else | ||
156 | gpio_data_reg1 &= ~reg; | ||
157 | rdc321x_conf_write(RDC321X_GPIO_DATA_REG1, gpio_data_reg1); | ||
158 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
159 | } else { | ||
160 | spin_lock_irqsave(&gpio_lock, flags); | ||
161 | if (value) | ||
162 | gpio_data_reg2 |= reg; | ||
163 | else | ||
164 | gpio_data_reg2 &= ~reg; | ||
165 | rdc321x_conf_write(RDC321X_GPIO_DATA_REG2, gpio_data_reg2); | ||
166 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
167 | } | ||
168 | } | ||
169 | EXPORT_SYMBOL(rdc_gpio_set_value); | ||
170 | |||
171 | /* configure GPIO pin as input */ | ||
172 | int rdc_gpio_direction_input(unsigned gpio) | ||
173 | { | ||
174 | if (!rdc321x_is_gpio(gpio)) | ||
175 | return -EINVAL; | ||
176 | |||
177 | rdc321x_configure_gpio(gpio); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | EXPORT_SYMBOL(rdc_gpio_direction_input); | ||
182 | |||
183 | /* configure GPIO pin as output and set value */ | ||
184 | int rdc_gpio_direction_output(unsigned gpio, int value) | ||
185 | { | ||
186 | if (!rdc321x_is_gpio(gpio)) | ||
187 | return -EINVAL; | ||
188 | |||
189 | gpio_set_value(gpio, value); | ||
190 | rdc321x_configure_gpio(gpio); | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | EXPORT_SYMBOL(rdc_gpio_direction_output); | ||
diff --git a/arch/x86/mach-rdc321x/platform.c b/arch/x86/mach-rdc321x/platform.c deleted file mode 100644 index 4f4e50c3ad3b..000000000000 --- a/arch/x86/mach-rdc321x/platform.c +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* | ||
2 | * Generic RDC321x platform devices | ||
3 | * | ||
4 | * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | * Boston, MA 02110-1301, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/list.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/leds.h> | ||
29 | |||
30 | #include <asm/gpio.h> | ||
31 | |||
32 | /* LEDS */ | ||
33 | static struct gpio_led default_leds[] = { | ||
34 | { .name = "rdc:dmz", .gpio = 1, }, | ||
35 | }; | ||
36 | |||
37 | static struct gpio_led_platform_data rdc321x_led_data = { | ||
38 | .num_leds = ARRAY_SIZE(default_leds), | ||
39 | .leds = default_leds, | ||
40 | }; | ||
41 | |||
42 | static struct platform_device rdc321x_leds = { | ||
43 | .name = "leds-gpio", | ||
44 | .id = -1, | ||
45 | .dev = { | ||
46 | .platform_data = &rdc321x_led_data, | ||
47 | } | ||
48 | }; | ||
49 | |||
50 | /* Watchdog */ | ||
51 | static struct platform_device rdc321x_wdt = { | ||
52 | .name = "rdc321x-wdt", | ||
53 | .id = -1, | ||
54 | .num_resources = 0, | ||
55 | }; | ||
56 | |||
57 | static struct platform_device *rdc321x_devs[] = { | ||
58 | &rdc321x_leds, | ||
59 | &rdc321x_wdt | ||
60 | }; | ||
61 | |||
62 | static int __init rdc_board_setup(void) | ||
63 | { | ||
64 | rdc321x_gpio_setup(); | ||
65 | |||
66 | return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs)); | ||
67 | } | ||
68 | |||
69 | arch_initcall(rdc_board_setup); | ||
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c index bf92802f2bbe..36e221beedcd 100644 --- a/drivers/watchdog/rdc321x_wdt.c +++ b/drivers/watchdog/rdc321x_wdt.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/io.h> | 37 | #include <linux/io.h> |
38 | #include <linux/uaccess.h> | 38 | #include <linux/uaccess.h> |
39 | 39 | ||
40 | #include <asm/mach-rdc321x/rdc321x_defs.h> | 40 | #include <asm/rdc321x_defs.h> |
41 | 41 | ||
42 | #define RDC_WDT_MASK 0x80000000 /* Mask */ | 42 | #define RDC_WDT_MASK 0x80000000 /* Mask */ |
43 | #define RDC_WDT_EN 0x00800000 /* Enable bit */ | 43 | #define RDC_WDT_EN 0x00800000 /* Enable bit */ |