1 --- a/drivers/ssb/driver_chipcommon.c
2 +++ b/drivers/ssb/driver_chipcommon.c
5 return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask;
7 -EXPORT_SYMBOL(ssb_chipco_gpio_in);
9 u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value)
11 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value);
13 -EXPORT_SYMBOL(ssb_chipco_gpio_out);
15 u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value)
17 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value);
19 -EXPORT_SYMBOL(ssb_chipco_gpio_outen);
21 u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value)
23 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
25 -EXPORT_SYMBOL(ssb_chipco_gpio_control);
27 u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
29 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value);
31 -EXPORT_SYMBOL(ssb_chipco_gpio_intmask);
33 u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value)
35 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value);
37 -EXPORT_SYMBOL(ssb_chipco_gpio_polarity);
39 #ifdef CONFIG_SSB_SERIAL
40 int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
41 --- a/drivers/ssb/driver_extif.c
42 +++ b/drivers/ssb/driver_extif.c
45 return extif_read32(extif, SSB_EXTIF_GPIO_IN) & mask;
47 -EXPORT_SYMBOL(ssb_extif_gpio_in);
49 u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value)
51 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0),
54 -EXPORT_SYMBOL(ssb_extif_gpio_out);
56 u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value)
58 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0),
61 -EXPORT_SYMBOL(ssb_extif_gpio_outen);
63 u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value)
65 return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTPOL, mask, value);
67 -EXPORT_SYMBOL(ssb_extif_gpio_polarity);
69 u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value)
71 return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTMASK, mask, value);
73 -EXPORT_SYMBOL(ssb_extif_gpio_intmask);
74 --- a/drivers/ssb/embedded.c
75 +++ b/drivers/ssb/embedded.c
77 #include <linux/ssb/ssb.h>
78 #include <linux/ssb/ssb_embedded.h>
80 +#include "ssb_private.h"
83 int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks)
90 +u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
92 + unsigned long flags;
95 + spin_lock_irqsave(&bus->gpio_lock, flags);
96 + if (ssb_chipco_available(&bus->chipco))
97 + res = ssb_chipco_gpio_in(&bus->chipco, mask);
98 + else if (ssb_extif_available(&bus->extif))
99 + res = ssb_extif_gpio_in(&bus->extif, mask);
102 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
106 +EXPORT_SYMBOL(ssb_gpio_in);
108 +u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value)
110 + unsigned long flags;
113 + spin_lock_irqsave(&bus->gpio_lock, flags);
114 + if (ssb_chipco_available(&bus->chipco))
115 + res = ssb_chipco_gpio_out(&bus->chipco, mask, value);
116 + else if (ssb_extif_available(&bus->extif))
117 + res = ssb_extif_gpio_out(&bus->extif, mask, value);
120 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
124 +EXPORT_SYMBOL(ssb_gpio_out);
126 +u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value)
128 + unsigned long flags;
131 + spin_lock_irqsave(&bus->gpio_lock, flags);
132 + if (ssb_chipco_available(&bus->chipco))
133 + res = ssb_chipco_gpio_outen(&bus->chipco, mask, value);
134 + else if (ssb_extif_available(&bus->extif))
135 + res = ssb_extif_gpio_outen(&bus->extif, mask, value);
138 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
142 +EXPORT_SYMBOL(ssb_gpio_outen);
144 +u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value)
146 + unsigned long flags;
149 + spin_lock_irqsave(&bus->gpio_lock, flags);
150 + if (ssb_chipco_available(&bus->chipco))
151 + res = ssb_chipco_gpio_control(&bus->chipco, mask, value);
152 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
156 +EXPORT_SYMBOL(ssb_gpio_control);
158 +u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value)
160 + unsigned long flags;
163 + spin_lock_irqsave(&bus->gpio_lock, flags);
164 + if (ssb_chipco_available(&bus->chipco))
165 + res = ssb_chipco_gpio_intmask(&bus->chipco, mask, value);
166 + else if (ssb_extif_available(&bus->extif))
167 + res = ssb_extif_gpio_intmask(&bus->extif, mask, value);
170 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
174 +EXPORT_SYMBOL(ssb_gpio_intmask);
176 +u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value)
178 + unsigned long flags;
181 + spin_lock_irqsave(&bus->gpio_lock, flags);
182 + if (ssb_chipco_available(&bus->chipco))
183 + res = ssb_chipco_gpio_polarity(&bus->chipco, mask, value);
184 + else if (ssb_extif_available(&bus->extif))
185 + res = ssb_extif_gpio_polarity(&bus->extif, mask, value);
188 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
192 +EXPORT_SYMBOL(ssb_gpio_polarity);
193 --- a/include/linux/ssb/ssb.h
194 +++ b/include/linux/ssb/ssb.h
196 /* Contents of the SPROM. */
197 struct ssb_sprom sprom;
199 +#ifdef CONFIG_SSB_EMBEDDED
200 + /* Lock for GPIO register access. */
201 + spinlock_t gpio_lock;
202 +#endif /* EMBEDDED */
204 /* Internal-only stuff follows. Do not touch. */
205 struct list_head list;
206 #ifdef CONFIG_SSB_DEBUG
207 --- a/include/linux/ssb/ssb_embedded.h
208 +++ b/include/linux/ssb/ssb_embedded.h
211 extern int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks);
213 +/* Generic GPIO API */
214 +u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask);
215 +u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value);
216 +u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value);
217 +u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value);
218 +u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value);
219 +u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value);
221 #endif /* LINUX_SSB_EMBEDDED_H_ */
222 --- a/drivers/ssb/main.c
223 +++ b/drivers/ssb/main.c
226 spin_lock_init(&bus->bar_lock);
227 INIT_LIST_HEAD(&bus->list);
228 +#ifdef CONFIG_SSB_EMBEDDED
229 + spin_lock_init(&bus->gpio_lock);
232 /* Powerup the bus */
233 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);