brcm47xx: add initial support for kernel 3.9
[openwrt.git] / target / linux / brcm47xx / patches-3.6 / 015-MIPS-BCM47XX-remove-GPIO-driver.patch
1 commit 2da4c74dc3711275e82856e62884c99f7a45f541
2 Author: Hauke Mehrtens <hauke@hauke-m.de>
3 Date:   Tue Nov 20 22:24:34 2012 +0000
4
5     MIPS: BCM47XX: remove GPIO driver
6     
7     Instated of providing an own GPIO driver use the one provided by ssb and
8     bcma.
9     
10     Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11     Patchwork: http://patchwork.linux-mips.org/patch/4592
12     Acked-by: Florian Fainelli <florian@openwrt.org>
13
14 --- a/arch/mips/Kconfig
15 +++ b/arch/mips/Kconfig
16 @@ -101,6 +101,7 @@ config ATH79
17  
18  config BCM47XX
19         bool "Broadcom BCM47XX based boards"
20 +       select ARCH_WANT_OPTIONAL_GPIOLIB
21         select CEVT_R4K
22         select CSRC_R4K
23         select DMA_NONCOHERENT
24 @@ -108,7 +109,6 @@ config BCM47XX
25         select IRQ_CPU
26         select SYS_SUPPORTS_32BIT_KERNEL
27         select SYS_SUPPORTS_LITTLE_ENDIAN
28 -       select GENERIC_GPIO
29         select SYS_HAS_EARLY_PRINTK
30         select CFE
31         help
32 --- a/arch/mips/bcm47xx/Kconfig
33 +++ b/arch/mips/bcm47xx/Kconfig
34 @@ -9,6 +9,7 @@ config BCM47XX_SSB
35         select SSB_EMBEDDED
36         select SSB_B43_PCI_BRIDGE if PCI
37         select SSB_PCICORE_HOSTMODE if PCI
38 +       select SSB_DRIVER_GPIO
39         default y
40         help
41          Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support.
42 @@ -23,6 +24,7 @@ config BCM47XX_BCMA
43         select BCMA_DRIVER_MIPS
44         select BCMA_HOST_PCI if PCI
45         select BCMA_DRIVER_PCI_HOSTMODE if PCI
46 +       select BCMA_DRIVER_GPIO
47         default y
48         help
49          Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus.
50 --- a/arch/mips/bcm47xx/Makefile
51 +++ b/arch/mips/bcm47xx/Makefile
52 @@ -3,5 +3,5 @@
53  # under Linux.
54  #
55  
56 -obj-y                          += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
57 +obj-y                          += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
58  obj-$(CONFIG_BCM47XX_SSB)      += wgt634u.o
59 --- a/arch/mips/bcm47xx/gpio.c
60 +++ /dev/null
61 @@ -1,102 +0,0 @@
62 -/*
63 - * This file is subject to the terms and conditions of the GNU General Public
64 - * License.  See the file "COPYING" in the main directory of this archive
65 - * for more details.
66 - *
67 - * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
68 - */
69 -
70 -#include <linux/export.h>
71 -#include <linux/ssb/ssb.h>
72 -#include <linux/ssb/ssb_driver_chipcommon.h>
73 -#include <linux/ssb/ssb_driver_extif.h>
74 -#include <asm/mach-bcm47xx/bcm47xx.h>
75 -#include <asm/mach-bcm47xx/gpio.h>
76 -
77 -#if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
78 -static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES);
79 -#else
80 -static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES);
81 -#endif
82 -
83 -int gpio_request(unsigned gpio, const char *tag)
84 -{
85 -       switch (bcm47xx_bus_type) {
86 -#ifdef CONFIG_BCM47XX_SSB
87 -       case BCM47XX_BUS_TYPE_SSB:
88 -               if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
89 -                   ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
90 -                       return -EINVAL;
91 -
92 -               if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
93 -                   ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
94 -                       return -EINVAL;
95 -
96 -               if (test_and_set_bit(gpio, gpio_in_use))
97 -                       return -EBUSY;
98 -
99 -               return 0;
100 -#endif
101 -#ifdef CONFIG_BCM47XX_BCMA
102 -       case BCM47XX_BUS_TYPE_BCMA:
103 -               if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
104 -                       return -EINVAL;
105 -
106 -               if (test_and_set_bit(gpio, gpio_in_use))
107 -                       return -EBUSY;
108 -
109 -               return 0;
110 -#endif
111 -       }
112 -       return -EINVAL;
113 -}
114 -EXPORT_SYMBOL(gpio_request);
115 -
116 -void gpio_free(unsigned gpio)
117 -{
118 -       switch (bcm47xx_bus_type) {
119 -#ifdef CONFIG_BCM47XX_SSB
120 -       case BCM47XX_BUS_TYPE_SSB:
121 -               if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
122 -                   ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
123 -                       return;
124 -
125 -               if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
126 -                   ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
127 -                       return;
128 -
129 -               clear_bit(gpio, gpio_in_use);
130 -               return;
131 -#endif
132 -#ifdef CONFIG_BCM47XX_BCMA
133 -       case BCM47XX_BUS_TYPE_BCMA:
134 -               if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
135 -                       return;
136 -
137 -               clear_bit(gpio, gpio_in_use);
138 -               return;
139 -#endif
140 -       }
141 -}
142 -EXPORT_SYMBOL(gpio_free);
143 -
144 -int gpio_to_irq(unsigned gpio)
145 -{
146 -       switch (bcm47xx_bus_type) {
147 -#ifdef CONFIG_BCM47XX_SSB
148 -       case BCM47XX_BUS_TYPE_SSB:
149 -               if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco))
150 -                       return ssb_mips_irq(bcm47xx_bus.ssb.chipco.dev) + 2;
151 -               else if (ssb_extif_available(&bcm47xx_bus.ssb.extif))
152 -                       return ssb_mips_irq(bcm47xx_bus.ssb.extif.dev) + 2;
153 -               else
154 -                       return -EINVAL;
155 -#endif
156 -#ifdef CONFIG_BCM47XX_BCMA
157 -       case BCM47XX_BUS_TYPE_BCMA:
158 -               return bcma_core_mips_irq(bcm47xx_bus.bcma.bus.drv_cc.core) + 2;
159 -#endif
160 -       }
161 -       return -EINVAL;
162 -}
163 -EXPORT_SYMBOL_GPL(gpio_to_irq);
164 --- a/arch/mips/bcm47xx/wgt634u.c
165 +++ b/arch/mips/bcm47xx/wgt634u.c
166 @@ -11,6 +11,7 @@
167  #include <linux/leds.h>
168  #include <linux/mtd/physmap.h>
169  #include <linux/ssb/ssb.h>
170 +#include <linux/ssb/ssb_embedded.h>
171  #include <linux/interrupt.h>
172  #include <linux/reboot.h>
173  #include <linux/gpio.h>
174 @@ -116,7 +117,8 @@ static irqreturn_t gpio_interrupt(int ir
175  
176         /* Interrupt are level triggered, revert the interrupt polarity
177            to clear the interrupt. */
178 -       gpio_polarity(WGT634U_GPIO_RESET, state);
179 +       ssb_gpio_polarity(&bcm47xx_bus.ssb, 1 << WGT634U_GPIO_RESET,
180 +                         state ? 1 << WGT634U_GPIO_RESET : 0);
181  
182         if (!state) {
183                 printk(KERN_INFO "Reset button pressed");
184 @@ -150,7 +152,9 @@ static int __init wgt634u_init(void)
185                                  gpio_interrupt, IRQF_SHARED,
186                                  "WGT634U GPIO", &bcm47xx_bus.ssb.chipco)) {
187                         gpio_direction_input(WGT634U_GPIO_RESET);
188 -                       gpio_intmask(WGT634U_GPIO_RESET, 1);
189 +                       ssb_gpio_intmask(&bcm47xx_bus.ssb,
190 +                                        1 << WGT634U_GPIO_RESET,
191 +                                        1 << WGT634U_GPIO_RESET);
192                         ssb_chipco_irq_mask(&bcm47xx_bus.ssb.chipco,
193                                             SSB_CHIPCO_IRQ_GPIO,
194                                             SSB_CHIPCO_IRQ_GPIO);
195 --- a/arch/mips/include/asm/mach-bcm47xx/gpio.h
196 +++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h
197 @@ -1,155 +1,17 @@
198 -/*
199 - * This file is subject to the terms and conditions of the GNU General Public
200 - * License.  See the file "COPYING" in the main directory of this archive
201 - * for more details.
202 - *
203 - * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
204 - */
205 +#ifndef __ASM_MIPS_MACH_BCM47XX_GPIO_H
206 +#define __ASM_MIPS_MACH_BCM47XX_GPIO_H
207  
208 -#ifndef __BCM47XX_GPIO_H
209 -#define __BCM47XX_GPIO_H
210 +#include <asm-generic/gpio.h>
211  
212 -#include <linux/ssb/ssb_embedded.h>
213 -#include <linux/bcma/bcma.h>
214 -#include <asm/mach-bcm47xx/bcm47xx.h>
215 +#define gpio_get_value __gpio_get_value
216 +#define gpio_set_value __gpio_set_value
217  
218 -#define BCM47XX_EXTIF_GPIO_LINES       5
219 -#define BCM47XX_CHIPCO_GPIO_LINES      16
220 +#define gpio_cansleep __gpio_cansleep
221 +#define gpio_to_irq __gpio_to_irq
222  
223 -extern int gpio_request(unsigned gpio, const char *label);
224 -extern void gpio_free(unsigned gpio);
225 -extern int gpio_to_irq(unsigned gpio);
226 -
227 -static inline int gpio_get_value(unsigned gpio)
228 +static inline int irq_to_gpio(unsigned int irq)
229  {
230 -       switch (bcm47xx_bus_type) {
231 -#ifdef CONFIG_BCM47XX_SSB
232 -       case BCM47XX_BUS_TYPE_SSB:
233 -               return ssb_gpio_in(&bcm47xx_bus.ssb, 1 << gpio);
234 -#endif
235 -#ifdef CONFIG_BCM47XX_BCMA
236 -       case BCM47XX_BUS_TYPE_BCMA:
237 -               return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc,
238 -                                          1 << gpio);
239 -#endif
240 -       }
241         return -EINVAL;
242  }
243  
244 -#define gpio_get_value_cansleep        gpio_get_value
245 -
246 -static inline void gpio_set_value(unsigned gpio, int value)
247 -{
248 -       switch (bcm47xx_bus_type) {
249 -#ifdef CONFIG_BCM47XX_SSB
250 -       case BCM47XX_BUS_TYPE_SSB:
251 -               ssb_gpio_out(&bcm47xx_bus.ssb, 1 << gpio,
252 -                            value ? 1 << gpio : 0);
253 -               return;
254 -#endif
255 -#ifdef CONFIG_BCM47XX_BCMA
256 -       case BCM47XX_BUS_TYPE_BCMA:
257 -               bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
258 -                                    value ? 1 << gpio : 0);
259 -               return;
260  #endif
261 -       }
262 -}
263 -
264 -#define gpio_set_value_cansleep gpio_set_value
265 -
266 -static inline int gpio_cansleep(unsigned gpio)
267 -{
268 -       return 0;
269 -}
270 -
271 -static inline int gpio_is_valid(unsigned gpio)
272 -{
273 -       return gpio < (BCM47XX_EXTIF_GPIO_LINES + BCM47XX_CHIPCO_GPIO_LINES);
274 -}
275 -
276 -
277 -static inline int gpio_direction_input(unsigned gpio)
278 -{
279 -       switch (bcm47xx_bus_type) {
280 -#ifdef CONFIG_BCM47XX_SSB
281 -       case BCM47XX_BUS_TYPE_SSB:
282 -               ssb_gpio_outen(&bcm47xx_bus.ssb, 1 << gpio, 0);
283 -               return 0;
284 -#endif
285 -#ifdef CONFIG_BCM47XX_BCMA
286 -       case BCM47XX_BUS_TYPE_BCMA:
287 -               bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
288 -                                      0);
289 -               return 0;
290 -#endif
291 -       }
292 -       return -EINVAL;
293 -}
294 -
295 -static inline int gpio_direction_output(unsigned gpio, int value)
296 -{
297 -       switch (bcm47xx_bus_type) {
298 -#ifdef CONFIG_BCM47XX_SSB
299 -       case BCM47XX_BUS_TYPE_SSB:
300 -               /* first set the gpio out value */
301 -               ssb_gpio_out(&bcm47xx_bus.ssb, 1 << gpio,
302 -                            value ? 1 << gpio : 0);
303 -               /* then set the gpio mode */
304 -               ssb_gpio_outen(&bcm47xx_bus.ssb, 1 << gpio, 1 << gpio);
305 -               return 0;
306 -#endif
307 -#ifdef CONFIG_BCM47XX_BCMA
308 -       case BCM47XX_BUS_TYPE_BCMA:
309 -               /* first set the gpio out value */
310 -               bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
311 -                                    value ? 1 << gpio : 0);
312 -               /* then set the gpio mode */
313 -               bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
314 -                                      1 << gpio);
315 -               return 0;
316 -#endif
317 -       }
318 -       return -EINVAL;
319 -}
320 -
321 -static inline int gpio_intmask(unsigned gpio, int value)
322 -{
323 -       switch (bcm47xx_bus_type) {
324 -#ifdef CONFIG_BCM47XX_SSB
325 -       case BCM47XX_BUS_TYPE_SSB:
326 -               ssb_gpio_intmask(&bcm47xx_bus.ssb, 1 << gpio,
327 -                                value ? 1 << gpio : 0);
328 -               return 0;
329 -#endif
330 -#ifdef CONFIG_BCM47XX_BCMA
331 -       case BCM47XX_BUS_TYPE_BCMA:
332 -               bcma_chipco_gpio_intmask(&bcm47xx_bus.bcma.bus.drv_cc,
333 -                                        1 << gpio, value ? 1 << gpio : 0);
334 -               return 0;
335 -#endif
336 -       }
337 -       return -EINVAL;
338 -}
339 -
340 -static inline int gpio_polarity(unsigned gpio, int value)
341 -{
342 -       switch (bcm47xx_bus_type) {
343 -#ifdef CONFIG_BCM47XX_SSB
344 -       case BCM47XX_BUS_TYPE_SSB:
345 -               ssb_gpio_polarity(&bcm47xx_bus.ssb, 1 << gpio,
346 -                                 value ? 1 << gpio : 0);
347 -               return 0;
348 -#endif
349 -#ifdef CONFIG_BCM47XX_BCMA
350 -       case BCM47XX_BUS_TYPE_BCMA:
351 -               bcma_chipco_gpio_polarity(&bcm47xx_bus.bcma.bus.drv_cc,
352 -                                         1 << gpio, value ? 1 << gpio : 0);
353 -               return 0;
354 -#endif
355 -       }
356 -       return -EINVAL;
357 -}
358 -
359 -
360 -#endif /* __BCM47XX_GPIO_H */