1 commit 2da4c74dc3711275e82856e62884c99f7a45f541
2 Author: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Tue Nov 20 22:24:34 2012 +0000
5 MIPS: BCM47XX: remove GPIO driver
7 Instated of providing an own GPIO driver use the one provided by ssb and
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>
14 --- a/arch/mips/Kconfig
15 +++ b/arch/mips/Kconfig
16 @@ -101,6 +101,7 @@ config ATH79
19 bool "Broadcom BCM47XX based boards"
20 + select ARCH_WANT_OPTIONAL_GPIOLIB
23 select DMA_NONCOHERENT
24 @@ -108,7 +109,6 @@ config BCM47XX
26 select SYS_SUPPORTS_32BIT_KERNEL
27 select SYS_SUPPORTS_LITTLE_ENDIAN
29 select SYS_HAS_EARLY_PRINTK
32 --- a/arch/mips/bcm47xx/Kconfig
33 +++ b/arch/mips/bcm47xx/Kconfig
34 @@ -9,6 +9,7 @@ config BCM47XX_SSB
36 select SSB_B43_PCI_BRIDGE if PCI
37 select SSB_PCICORE_HOSTMODE if PCI
38 + select SSB_DRIVER_GPIO
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
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
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
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
67 - * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
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>
77 -#if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
78 -static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES);
80 -static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES);
83 -int gpio_request(unsigned gpio, const char *tag)
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))
92 - if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
93 - ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
96 - if (test_and_set_bit(gpio, gpio_in_use))
101 -#ifdef CONFIG_BCM47XX_BCMA
102 - case BCM47XX_BUS_TYPE_BCMA:
103 - if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
106 - if (test_and_set_bit(gpio, gpio_in_use))
114 -EXPORT_SYMBOL(gpio_request);
116 -void gpio_free(unsigned gpio)
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))
125 - if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
126 - ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
129 - clear_bit(gpio, gpio_in_use);
132 -#ifdef CONFIG_BCM47XX_BCMA
133 - case BCM47XX_BUS_TYPE_BCMA:
134 - if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
137 - clear_bit(gpio, gpio_in_use);
142 -EXPORT_SYMBOL(gpio_free);
144 -int gpio_to_irq(unsigned gpio)
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;
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;
163 -EXPORT_SYMBOL_GPL(gpio_to_irq);
164 --- a/arch/mips/bcm47xx/wgt634u.c
165 +++ b/arch/mips/bcm47xx/wgt634u.c
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
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);
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,
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
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.
203 - * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
205 +#ifndef __ASM_MIPS_MACH_BCM47XX_GPIO_H
206 +#define __ASM_MIPS_MACH_BCM47XX_GPIO_H
208 -#ifndef __BCM47XX_GPIO_H
209 -#define __BCM47XX_GPIO_H
210 +#include <asm-generic/gpio.h>
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
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
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);
227 -static inline int gpio_get_value(unsigned gpio)
228 +static inline int irq_to_gpio(unsigned int irq)
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);
235 -#ifdef CONFIG_BCM47XX_BCMA
236 - case BCM47XX_BUS_TYPE_BCMA:
237 - return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc,
244 -#define gpio_get_value_cansleep gpio_get_value
246 -static inline void gpio_set_value(unsigned gpio, int value)
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);
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);
264 -#define gpio_set_value_cansleep gpio_set_value
266 -static inline int gpio_cansleep(unsigned gpio)
271 -static inline int gpio_is_valid(unsigned gpio)
273 - return gpio < (BCM47XX_EXTIF_GPIO_LINES + BCM47XX_CHIPCO_GPIO_LINES);
277 -static inline int gpio_direction_input(unsigned gpio)
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);
285 -#ifdef CONFIG_BCM47XX_BCMA
286 - case BCM47XX_BUS_TYPE_BCMA:
287 - bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
295 -static inline int gpio_direction_output(unsigned gpio, int value)
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);
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,
321 -static inline int gpio_intmask(unsigned gpio, int value)
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);
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);
340 -static inline int gpio_polarity(unsigned gpio, int value)
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);
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);
360 -#endif /* __BCM47XX_GPIO_H */