d1debcfe3a92cc720490d3cd85805487fa664058
[openwrt.git] / target / linux / brcm47xx / patches-2.6.23 / 621-ssb-common-gpio-api.patch
1 Index: linux-2.6.23.16/drivers/ssb/driver_chipcommon.c
2 ===================================================================
3 --- linux-2.6.23.16.orig/drivers/ssb/driver_chipcommon.c 2008-02-19 15:50:42.000000000 +0100
4 +++ linux-2.6.23.16/drivers/ssb/driver_chipcommon.c 2008-02-19 15:50:44.000000000 +0100
5 @@ -361,37 +361,31 @@ u32 ssb_chipco_gpio_in(struct ssb_chipco
6 {
7 return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask;
8 }
9 -EXPORT_SYMBOL(ssb_chipco_gpio_in);
10
11 u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value)
12 {
13 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value);
14 }
15 -EXPORT_SYMBOL(ssb_chipco_gpio_out);
16
17 u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value)
18 {
19 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value);
20 }
21 -EXPORT_SYMBOL(ssb_chipco_gpio_outen);
22
23 u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value)
24 {
25 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
26 }
27 -EXPORT_SYMBOL(ssb_chipco_gpio_control);
28
29 u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
30 {
31 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value);
32 }
33 -EXPORT_SYMBOL(ssb_chipco_gpio_intmask);
34
35 u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value)
36 {
37 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value);
38 }
39 -EXPORT_SYMBOL(ssb_chipco_gpio_polarity);
40
41 #ifdef CONFIG_SSB_SERIAL
42 int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
43 Index: linux-2.6.23.16/drivers/ssb/driver_extif.c
44 ===================================================================
45 --- linux-2.6.23.16.orig/drivers/ssb/driver_extif.c 2008-02-19 15:50:42.000000000 +0100
46 +++ linux-2.6.23.16/drivers/ssb/driver_extif.c 2008-02-19 15:50:44.000000000 +0100
47 @@ -122,30 +122,25 @@ u32 ssb_extif_gpio_in(struct ssb_extif *
48 {
49 return extif_read32(extif, SSB_EXTIF_GPIO_IN) & mask;
50 }
51 -EXPORT_SYMBOL(ssb_extif_gpio_in);
52
53 u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value)
54 {
55 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0),
56 mask, value);
57 }
58 -EXPORT_SYMBOL(ssb_extif_gpio_out);
59
60 u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value)
61 {
62 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0),
63 mask, value);
64 }
65 -EXPORT_SYMBOL(ssb_extif_gpio_outen);
66
67 u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value)
68 {
69 return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTPOL, mask, value);
70 }
71 -EXPORT_SYMBOL(ssb_extif_gpio_polarity);
72
73 u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value)
74 {
75 return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTMASK, mask, value);
76 }
77 -EXPORT_SYMBOL(ssb_extif_gpio_intmask);
78 Index: linux-2.6.23.16/drivers/ssb/embedded.c
79 ===================================================================
80 --- linux-2.6.23.16.orig/drivers/ssb/embedded.c 2008-02-19 15:50:42.000000000 +0100
81 +++ linux-2.6.23.16/drivers/ssb/embedded.c 2008-02-19 15:51:01.000000000 +0100
82 @@ -11,6 +11,8 @@
83 #include <linux/ssb/ssb.h>
84 #include <linux/ssb/ssb_embedded.h>
85
86 +#include "ssb_private.h"
87 +
88
89 int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks)
90 {
91 @@ -24,3 +26,107 @@ int ssb_watchdog_timer_set(struct ssb_bu
92 }
93 return -ENODEV;
94 }
95 +
96 +u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
97 +{
98 + unsigned long flags;
99 + u32 res = 0;
100 +
101 + spin_lock_irqsave(&bus->gpio_lock, flags);
102 + if (ssb_chipco_available(&bus->chipco))
103 + res = ssb_chipco_gpio_in(&bus->chipco, mask);
104 + else if (ssb_extif_available(&bus->extif))
105 + res = ssb_extif_gpio_in(&bus->extif, mask);
106 + else
107 + SSB_WARN_ON(1);
108 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
109 +
110 + return res;
111 +}
112 +EXPORT_SYMBOL(ssb_gpio_in);
113 +
114 +u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value)
115 +{
116 + unsigned long flags;
117 + u32 res = 0;
118 +
119 + spin_lock_irqsave(&bus->gpio_lock, flags);
120 + if (ssb_chipco_available(&bus->chipco))
121 + res = ssb_chipco_gpio_out(&bus->chipco, mask, value);
122 + else if (ssb_extif_available(&bus->extif))
123 + res = ssb_extif_gpio_out(&bus->extif, mask, value);
124 + else
125 + SSB_WARN_ON(1);
126 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
127 +
128 + return res;
129 +}
130 +EXPORT_SYMBOL(ssb_gpio_out);
131 +
132 +u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value)
133 +{
134 + unsigned long flags;
135 + u32 res = 0;
136 +
137 + spin_lock_irqsave(&bus->gpio_lock, flags);
138 + if (ssb_chipco_available(&bus->chipco))
139 + res = ssb_chipco_gpio_outen(&bus->chipco, mask, value);
140 + else if (ssb_extif_available(&bus->extif))
141 + res = ssb_extif_gpio_outen(&bus->extif, mask, value);
142 + else
143 + SSB_WARN_ON(1);
144 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
145 +
146 + return res;
147 +}
148 +EXPORT_SYMBOL(ssb_gpio_outen);
149 +
150 +u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value)
151 +{
152 + unsigned long flags;
153 + u32 res = 0;
154 +
155 + spin_lock_irqsave(&bus->gpio_lock, flags);
156 + if (ssb_chipco_available(&bus->chipco))
157 + res = ssb_chipco_gpio_control(&bus->chipco, mask, value);
158 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
159 +
160 + return res;
161 +}
162 +EXPORT_SYMBOL(ssb_gpio_control);
163 +
164 +u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value)
165 +{
166 + unsigned long flags;
167 + u32 res = 0;
168 +
169 + spin_lock_irqsave(&bus->gpio_lock, flags);
170 + if (ssb_chipco_available(&bus->chipco))
171 + res = ssb_chipco_gpio_intmask(&bus->chipco, mask, value);
172 + else if (ssb_extif_available(&bus->extif))
173 + res = ssb_extif_gpio_intmask(&bus->extif, mask, value);
174 + else
175 + SSB_WARN_ON(1);
176 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
177 +
178 + return res;
179 +}
180 +EXPORT_SYMBOL(ssb_gpio_intmask);
181 +
182 +u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value)
183 +{
184 + unsigned long flags;
185 + u32 res = 0;
186 +
187 + spin_lock_irqsave(&bus->gpio_lock, flags);
188 + if (ssb_chipco_available(&bus->chipco))
189 + res = ssb_chipco_gpio_polarity(&bus->chipco, mask, value);
190 + else if (ssb_extif_available(&bus->extif))
191 + res = ssb_extif_gpio_polarity(&bus->extif, mask, value);
192 + else
193 + SSB_WARN_ON(1);
194 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
195 +
196 + return res;
197 +}
198 +EXPORT_SYMBOL(ssb_gpio_polarity);
199 Index: linux-2.6.23.16/include/linux/ssb/ssb.h
200 ===================================================================
201 --- linux-2.6.23.16.orig/include/linux/ssb/ssb.h 2008-02-19 15:50:42.000000000 +0100
202 +++ linux-2.6.23.16/include/linux/ssb/ssb.h 2008-02-19 15:50:44.000000000 +0100
203 @@ -283,6 +283,11 @@ struct ssb_bus {
204 /* Contents of the SPROM. */
205 struct ssb_sprom sprom;
206
207 +#ifdef CONFIG_SSB_EMBEDDED
208 + /* Lock for GPIO register access. */
209 + spinlock_t gpio_lock;
210 +#endif /* EMBEDDED */
211 +
212 /* Internal-only stuff follows. Do not touch. */
213 struct list_head list;
214 #ifdef CONFIG_SSB_DEBUG
215 Index: linux-2.6.23.16/include/linux/ssb/ssb_embedded.h
216 ===================================================================
217 --- linux-2.6.23.16.orig/include/linux/ssb/ssb_embedded.h 2008-02-19 15:50:42.000000000 +0100
218 +++ linux-2.6.23.16/include/linux/ssb/ssb_embedded.h 2008-02-19 15:50:44.000000000 +0100
219 @@ -7,4 +7,12 @@
220
221 extern int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks);
222
223 +/* Generic GPIO API */
224 +u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask);
225 +u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value);
226 +u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value);
227 +u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value);
228 +u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value);
229 +u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value);
230 +
231 #endif /* LINUX_SSB_EMBEDDED_H_ */
232 Index: linux-2.6.23.16/drivers/ssb/main.c
233 ===================================================================
234 --- linux-2.6.23.16.orig/drivers/ssb/main.c 2008-02-19 15:50:42.000000000 +0100
235 +++ linux-2.6.23.16/drivers/ssb/main.c 2008-02-19 15:50:44.000000000 +0100
236 @@ -571,6 +571,9 @@ static int ssb_bus_register(struct ssb_b
237
238 spin_lock_init(&bus->bar_lock);
239 INIT_LIST_HEAD(&bus->list);
240 +#ifdef CONFIG_SSB_EMBEDDED
241 + spin_lock_init(&bus->gpio_lock);
242 +#endif
243
244 /* Powerup the bus */
245 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);
This page took 0.05646 seconds and 3 git commands to generate.