diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2012-11-20 17:24:34 -0500 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2012-12-12 12:57:49 -0500 |
commit | 2da4c74dc3711275e82856e62884c99f7a45f541 (patch) | |
tree | 4d557c633a005a86c4bedebb1bd4cd32752f93d9 /arch/mips | |
parent | ec43b08b5733494ad88aa618ecdf534320dd8207 (diff) |
MIPS: BCM47XX: remove GPIO driver
Instated of providing an own GPIO driver use the one provided by ssb and
bcma.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: http://patchwork.linux-mips.org/patch/4592
Acked-by: Florian Fainelli <florian@openwrt.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/Kconfig | 2 | ||||
-rw-r--r-- | arch/mips/bcm47xx/Kconfig | 2 | ||||
-rw-r--r-- | arch/mips/bcm47xx/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/bcm47xx/gpio.c | 102 | ||||
-rw-r--r-- | arch/mips/bcm47xx/wgt634u.c | 8 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-bcm47xx/gpio.h | 154 |
6 files changed, 18 insertions, 252 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index f569790e24e..1f495eb077d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -105,6 +105,7 @@ config ATH79 | |||
105 | 105 | ||
106 | config BCM47XX | 106 | config BCM47XX |
107 | bool "Broadcom BCM47XX based boards" | 107 | bool "Broadcom BCM47XX based boards" |
108 | select ARCH_WANT_OPTIONAL_GPIOLIB | ||
108 | select CEVT_R4K | 109 | select CEVT_R4K |
109 | select CSRC_R4K | 110 | select CSRC_R4K |
110 | select DMA_NONCOHERENT | 111 | select DMA_NONCOHERENT |
@@ -112,7 +113,6 @@ config BCM47XX | |||
112 | select IRQ_CPU | 113 | select IRQ_CPU |
113 | select SYS_SUPPORTS_32BIT_KERNEL | 114 | select SYS_SUPPORTS_32BIT_KERNEL |
114 | select SYS_SUPPORTS_LITTLE_ENDIAN | 115 | select SYS_SUPPORTS_LITTLE_ENDIAN |
115 | select GENERIC_GPIO | ||
116 | select SYS_HAS_EARLY_PRINTK | 116 | select SYS_HAS_EARLY_PRINTK |
117 | select CFE | 117 | select CFE |
118 | help | 118 | help |
diff --git a/arch/mips/bcm47xx/Kconfig b/arch/mips/bcm47xx/Kconfig index b311be45a72..d7af29f1fcf 100644 --- a/arch/mips/bcm47xx/Kconfig +++ b/arch/mips/bcm47xx/Kconfig | |||
@@ -9,6 +9,7 @@ config BCM47XX_SSB | |||
9 | select SSB_EMBEDDED | 9 | select SSB_EMBEDDED |
10 | select SSB_B43_PCI_BRIDGE if PCI | 10 | select SSB_B43_PCI_BRIDGE if PCI |
11 | select SSB_PCICORE_HOSTMODE if PCI | 11 | select SSB_PCICORE_HOSTMODE if PCI |
12 | select SSB_DRIVER_GPIO | ||
12 | default y | 13 | default y |
13 | help | 14 | help |
14 | Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support. | 15 | Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support. |
@@ -23,6 +24,7 @@ config BCM47XX_BCMA | |||
23 | select BCMA_DRIVER_MIPS | 24 | select BCMA_DRIVER_MIPS |
24 | select BCMA_HOST_PCI if PCI | 25 | select BCMA_HOST_PCI if PCI |
25 | select BCMA_DRIVER_PCI_HOSTMODE if PCI | 26 | select BCMA_DRIVER_PCI_HOSTMODE if PCI |
27 | select BCMA_DRIVER_GPIO | ||
26 | default y | 28 | default y |
27 | help | 29 | help |
28 | Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus. | 30 | Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus. |
diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile index 4389de182eb..1a3567f07e7 100644 --- a/arch/mips/bcm47xx/Makefile +++ b/arch/mips/bcm47xx/Makefile | |||
@@ -3,5 +3,5 @@ | |||
3 | # under Linux. | 3 | # under Linux. |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o sprom.o | 6 | obj-y += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o |
7 | obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o | 7 | obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o |
diff --git a/arch/mips/bcm47xx/gpio.c b/arch/mips/bcm47xx/gpio.c deleted file mode 100644 index 5ebdf62e96b..00000000000 --- a/arch/mips/bcm47xx/gpio.c +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> | ||
7 | */ | ||
8 | |||
9 | #include <linux/export.h> | ||
10 | #include <linux/ssb/ssb.h> | ||
11 | #include <linux/ssb/ssb_driver_chipcommon.h> | ||
12 | #include <linux/ssb/ssb_driver_extif.h> | ||
13 | #include <asm/mach-bcm47xx/bcm47xx.h> | ||
14 | #include <asm/mach-bcm47xx/gpio.h> | ||
15 | |||
16 | #if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES) | ||
17 | static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES); | ||
18 | #else | ||
19 | static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES); | ||
20 | #endif | ||
21 | |||
22 | int gpio_request(unsigned gpio, const char *tag) | ||
23 | { | ||
24 | switch (bcm47xx_bus_type) { | ||
25 | #ifdef CONFIG_BCM47XX_SSB | ||
26 | case BCM47XX_BUS_TYPE_SSB: | ||
27 | if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) && | ||
28 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | ||
29 | return -EINVAL; | ||
30 | |||
31 | if (ssb_extif_available(&bcm47xx_bus.ssb.extif) && | ||
32 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | ||
33 | return -EINVAL; | ||
34 | |||
35 | if (test_and_set_bit(gpio, gpio_in_use)) | ||
36 | return -EBUSY; | ||
37 | |||
38 | return 0; | ||
39 | #endif | ||
40 | #ifdef CONFIG_BCM47XX_BCMA | ||
41 | case BCM47XX_BUS_TYPE_BCMA: | ||
42 | if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) | ||
43 | return -EINVAL; | ||
44 | |||
45 | if (test_and_set_bit(gpio, gpio_in_use)) | ||
46 | return -EBUSY; | ||
47 | |||
48 | return 0; | ||
49 | #endif | ||
50 | } | ||
51 | return -EINVAL; | ||
52 | } | ||
53 | EXPORT_SYMBOL(gpio_request); | ||
54 | |||
55 | void gpio_free(unsigned gpio) | ||
56 | { | ||
57 | switch (bcm47xx_bus_type) { | ||
58 | #ifdef CONFIG_BCM47XX_SSB | ||
59 | case BCM47XX_BUS_TYPE_SSB: | ||
60 | if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) && | ||
61 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | ||
62 | return; | ||
63 | |||
64 | if (ssb_extif_available(&bcm47xx_bus.ssb.extif) && | ||
65 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | ||
66 | return; | ||
67 | |||
68 | clear_bit(gpio, gpio_in_use); | ||
69 | return; | ||
70 | #endif | ||
71 | #ifdef CONFIG_BCM47XX_BCMA | ||
72 | case BCM47XX_BUS_TYPE_BCMA: | ||
73 | if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) | ||
74 | return; | ||
75 | |||
76 | clear_bit(gpio, gpio_in_use); | ||
77 | return; | ||
78 | #endif | ||
79 | } | ||
80 | } | ||
81 | EXPORT_SYMBOL(gpio_free); | ||
82 | |||
83 | int gpio_to_irq(unsigned gpio) | ||
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 | return ssb_mips_irq(bcm47xx_bus.ssb.chipco.dev) + 2; | ||
90 | else if (ssb_extif_available(&bcm47xx_bus.ssb.extif)) | ||
91 | return ssb_mips_irq(bcm47xx_bus.ssb.extif.dev) + 2; | ||
92 | else | ||
93 | return -EINVAL; | ||
94 | #endif | ||
95 | #ifdef CONFIG_BCM47XX_BCMA | ||
96 | case BCM47XX_BUS_TYPE_BCMA: | ||
97 | return bcma_core_mips_irq(bcm47xx_bus.bcma.bus.drv_cc.core) + 2; | ||
98 | #endif | ||
99 | } | ||
100 | return -EINVAL; | ||
101 | } | ||
102 | EXPORT_SYMBOL_GPL(gpio_to_irq); | ||
diff --git a/arch/mips/bcm47xx/wgt634u.c b/arch/mips/bcm47xx/wgt634u.c index e9f9ec8d443..6c28f6d891d 100644 --- a/arch/mips/bcm47xx/wgt634u.c +++ b/arch/mips/bcm47xx/wgt634u.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/leds.h> | 11 | #include <linux/leds.h> |
12 | #include <linux/mtd/physmap.h> | 12 | #include <linux/mtd/physmap.h> |
13 | #include <linux/ssb/ssb.h> | 13 | #include <linux/ssb/ssb.h> |
14 | #include <linux/ssb/ssb_embedded.h> | ||
14 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
15 | #include <linux/reboot.h> | 16 | #include <linux/reboot.h> |
16 | #include <linux/gpio.h> | 17 | #include <linux/gpio.h> |
@@ -116,7 +117,8 @@ static irqreturn_t gpio_interrupt(int irq, void *ignored) | |||
116 | 117 | ||
117 | /* Interrupt are level triggered, revert the interrupt polarity | 118 | /* Interrupt are level triggered, revert the interrupt polarity |
118 | to clear the interrupt. */ | 119 | to clear the interrupt. */ |
119 | gpio_polarity(WGT634U_GPIO_RESET, state); | 120 | ssb_gpio_polarity(&bcm47xx_bus.ssb, 1 << WGT634U_GPIO_RESET, |
121 | state ? 1 << WGT634U_GPIO_RESET : 0); | ||
120 | 122 | ||
121 | if (!state) { | 123 | if (!state) { |
122 | printk(KERN_INFO "Reset button pressed"); | 124 | printk(KERN_INFO "Reset button pressed"); |
@@ -150,7 +152,9 @@ static int __init wgt634u_init(void) | |||
150 | gpio_interrupt, IRQF_SHARED, | 152 | gpio_interrupt, IRQF_SHARED, |
151 | "WGT634U GPIO", &bcm47xx_bus.ssb.chipco)) { | 153 | "WGT634U GPIO", &bcm47xx_bus.ssb.chipco)) { |
152 | gpio_direction_input(WGT634U_GPIO_RESET); | 154 | gpio_direction_input(WGT634U_GPIO_RESET); |
153 | gpio_intmask(WGT634U_GPIO_RESET, 1); | 155 | ssb_gpio_intmask(&bcm47xx_bus.ssb, |
156 | 1 << WGT634U_GPIO_RESET, | ||
157 | 1 << WGT634U_GPIO_RESET); | ||
154 | ssb_chipco_irq_mask(&bcm47xx_bus.ssb.chipco, | 158 | ssb_chipco_irq_mask(&bcm47xx_bus.ssb.chipco, |
155 | SSB_CHIPCO_IRQ_GPIO, | 159 | SSB_CHIPCO_IRQ_GPIO, |
156 | SSB_CHIPCO_IRQ_GPIO); | 160 | SSB_CHIPCO_IRQ_GPIO); |
diff --git a/arch/mips/include/asm/mach-bcm47xx/gpio.h b/arch/mips/include/asm/mach-bcm47xx/gpio.h index 2ef17e8df40..90daefa24a4 100644 --- a/arch/mips/include/asm/mach-bcm47xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h | |||
@@ -1,155 +1,17 @@ | |||
1 | /* | 1 | #ifndef __ASM_MIPS_MACH_BCM47XX_GPIO_H |
2 | * This file is subject to the terms and conditions of the GNU General Public | 2 | #define __ASM_MIPS_MACH_BCM47XX_GPIO_H |
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> | ||
7 | */ | ||
8 | 3 | ||
9 | #ifndef __BCM47XX_GPIO_H | 4 | #include <asm-generic/gpio.h> |
10 | #define __BCM47XX_GPIO_H | ||
11 | 5 | ||
12 | #include <linux/ssb/ssb_embedded.h> | 6 | #define gpio_get_value __gpio_get_value |
13 | #include <linux/bcma/bcma.h> | 7 | #define gpio_set_value __gpio_set_value |
14 | #include <asm/mach-bcm47xx/bcm47xx.h> | ||
15 | 8 | ||
16 | #define BCM47XX_EXTIF_GPIO_LINES 5 | 9 | #define gpio_cansleep __gpio_cansleep |
17 | #define BCM47XX_CHIPCO_GPIO_LINES 16 | 10 | #define gpio_to_irq __gpio_to_irq |
18 | 11 | ||
19 | extern int gpio_request(unsigned gpio, const char *label); | 12 | static inline int irq_to_gpio(unsigned int irq) |
20 | extern void gpio_free(unsigned gpio); | ||
21 | extern int gpio_to_irq(unsigned gpio); | ||
22 | |||
23 | static inline int gpio_get_value(unsigned gpio) | ||
24 | { | 13 | { |
25 | switch (bcm47xx_bus_type) { | ||
26 | #ifdef CONFIG_BCM47XX_SSB | ||
27 | case BCM47XX_BUS_TYPE_SSB: | ||
28 | return ssb_gpio_in(&bcm47xx_bus.ssb, 1 << gpio); | ||
29 | #endif | ||
30 | #ifdef CONFIG_BCM47XX_BCMA | ||
31 | case BCM47XX_BUS_TYPE_BCMA: | ||
32 | return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc, | ||
33 | 1 << gpio); | ||
34 | #endif | ||
35 | } | ||
36 | return -EINVAL; | 14 | return -EINVAL; |
37 | } | 15 | } |
38 | 16 | ||
39 | #define gpio_get_value_cansleep gpio_get_value | ||
40 | |||
41 | static inline void gpio_set_value(unsigned gpio, int value) | ||
42 | { | ||
43 | switch (bcm47xx_bus_type) { | ||
44 | #ifdef CONFIG_BCM47XX_SSB | ||
45 | case BCM47XX_BUS_TYPE_SSB: | ||
46 | ssb_gpio_out(&bcm47xx_bus.ssb, 1 << gpio, | ||
47 | value ? 1 << gpio : 0); | ||
48 | return; | ||
49 | #endif | ||
50 | #ifdef CONFIG_BCM47XX_BCMA | ||
51 | case BCM47XX_BUS_TYPE_BCMA: | ||
52 | bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio, | ||
53 | value ? 1 << gpio : 0); | ||
54 | return; | ||
55 | #endif | 17 | #endif |
56 | } | ||
57 | } | ||
58 | |||
59 | #define gpio_set_value_cansleep gpio_set_value | ||
60 | |||
61 | static inline int gpio_cansleep(unsigned gpio) | ||
62 | { | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static inline int gpio_is_valid(unsigned gpio) | ||
67 | { | ||
68 | return gpio < (BCM47XX_EXTIF_GPIO_LINES + BCM47XX_CHIPCO_GPIO_LINES); | ||
69 | } | ||
70 | |||
71 | |||
72 | static inline int gpio_direction_input(unsigned gpio) | ||
73 | { | ||
74 | switch (bcm47xx_bus_type) { | ||
75 | #ifdef CONFIG_BCM47XX_SSB | ||
76 | case BCM47XX_BUS_TYPE_SSB: | ||
77 | ssb_gpio_outen(&bcm47xx_bus.ssb, 1 << gpio, 0); | ||
78 | return 0; | ||
79 | #endif | ||
80 | #ifdef CONFIG_BCM47XX_BCMA | ||
81 | case BCM47XX_BUS_TYPE_BCMA: | ||
82 | bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio, | ||
83 | 0); | ||
84 | return 0; | ||
85 | #endif | ||
86 | } | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | |||
90 | static inline int gpio_direction_output(unsigned gpio, int value) | ||
91 | { | ||
92 | switch (bcm47xx_bus_type) { | ||
93 | #ifdef CONFIG_BCM47XX_SSB | ||
94 | case BCM47XX_BUS_TYPE_SSB: | ||
95 | /* first set the gpio out value */ | ||
96 | ssb_gpio_out(&bcm47xx_bus.ssb, 1 << gpio, | ||
97 | value ? 1 << gpio : 0); | ||
98 | /* then set the gpio mode */ | ||
99 | ssb_gpio_outen(&bcm47xx_bus.ssb, 1 << gpio, 1 << gpio); | ||
100 | return 0; | ||
101 | #endif | ||
102 | #ifdef CONFIG_BCM47XX_BCMA | ||
103 | case BCM47XX_BUS_TYPE_BCMA: | ||
104 | /* first set the gpio out value */ | ||
105 | bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio, | ||
106 | value ? 1 << gpio : 0); | ||
107 | /* then set the gpio mode */ | ||
108 | bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio, | ||
109 | 1 << gpio); | ||
110 | return 0; | ||
111 | #endif | ||
112 | } | ||
113 | return -EINVAL; | ||
114 | } | ||
115 | |||
116 | static inline int gpio_intmask(unsigned gpio, int value) | ||
117 | { | ||
118 | switch (bcm47xx_bus_type) { | ||
119 | #ifdef CONFIG_BCM47XX_SSB | ||
120 | case BCM47XX_BUS_TYPE_SSB: | ||
121 | ssb_gpio_intmask(&bcm47xx_bus.ssb, 1 << gpio, | ||
122 | value ? 1 << gpio : 0); | ||
123 | return 0; | ||
124 | #endif | ||
125 | #ifdef CONFIG_BCM47XX_BCMA | ||
126 | case BCM47XX_BUS_TYPE_BCMA: | ||
127 | bcma_chipco_gpio_intmask(&bcm47xx_bus.bcma.bus.drv_cc, | ||
128 | 1 << gpio, value ? 1 << gpio : 0); | ||
129 | return 0; | ||
130 | #endif | ||
131 | } | ||
132 | return -EINVAL; | ||
133 | } | ||
134 | |||
135 | static inline int gpio_polarity(unsigned gpio, int value) | ||
136 | { | ||
137 | switch (bcm47xx_bus_type) { | ||
138 | #ifdef CONFIG_BCM47XX_SSB | ||
139 | case BCM47XX_BUS_TYPE_SSB: | ||
140 | ssb_gpio_polarity(&bcm47xx_bus.ssb, 1 << gpio, | ||
141 | value ? 1 << gpio : 0); | ||
142 | return 0; | ||
143 | #endif | ||
144 | #ifdef CONFIG_BCM47XX_BCMA | ||
145 | case BCM47XX_BUS_TYPE_BCMA: | ||
146 | bcma_chipco_gpio_polarity(&bcm47xx_bus.bcma.bus.drv_cc, | ||
147 | 1 << gpio, value ? 1 << gpio : 0); | ||
148 | return 0; | ||
149 | #endif | ||
150 | } | ||
151 | return -EINVAL; | ||
152 | } | ||
153 | |||
154 | |||
155 | #endif /* __BCM47XX_GPIO_H */ | ||