diff options
Diffstat (limited to 'drivers/bcma/driver_chipcommon.c')
-rw-r--r-- | drivers/bcma/driver_chipcommon.c | 81 |
1 files changed, 76 insertions, 5 deletions
diff --git a/drivers/bcma/driver_chipcommon.c b/drivers/bcma/driver_chipcommon.c index dc96dd8ebff2..e461ad25fda4 100644 --- a/drivers/bcma/driver_chipcommon.c +++ b/drivers/bcma/driver_chipcommon.c | |||
@@ -114,6 +114,8 @@ void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc) | |||
114 | if (cc->early_setup_done) | 114 | if (cc->early_setup_done) |
115 | return; | 115 | return; |
116 | 116 | ||
117 | spin_lock_init(&cc->gpio_lock); | ||
118 | |||
117 | if (cc->core->id.rev >= 11) | 119 | if (cc->core->id.rev >= 11) |
118 | cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT); | 120 | cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT); |
119 | cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP); | 121 | cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP); |
@@ -202,28 +204,97 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask) | |||
202 | 204 | ||
203 | u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value) | 205 | u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value) |
204 | { | 206 | { |
205 | return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value); | 207 | unsigned long flags; |
208 | u32 res; | ||
209 | |||
210 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
211 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value); | ||
212 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
213 | |||
214 | return res; | ||
206 | } | 215 | } |
207 | 216 | ||
208 | u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value) | 217 | u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value) |
209 | { | 218 | { |
210 | return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value); | 219 | unsigned long flags; |
220 | u32 res; | ||
221 | |||
222 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
223 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value); | ||
224 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
225 | |||
226 | return res; | ||
211 | } | 227 | } |
212 | 228 | ||
229 | /* | ||
230 | * If the bit is set to 0, chipcommon controlls this GPIO, | ||
231 | * if the bit is set to 1, it is used by some part of the chip and not our code. | ||
232 | */ | ||
213 | u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value) | 233 | u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value) |
214 | { | 234 | { |
215 | return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value); | 235 | unsigned long flags; |
236 | u32 res; | ||
237 | |||
238 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
239 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value); | ||
240 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
241 | |||
242 | return res; | ||
216 | } | 243 | } |
217 | EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control); | 244 | EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control); |
218 | 245 | ||
219 | u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value) | 246 | u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value) |
220 | { | 247 | { |
221 | return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value); | 248 | unsigned long flags; |
249 | u32 res; | ||
250 | |||
251 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
252 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value); | ||
253 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
254 | |||
255 | return res; | ||
222 | } | 256 | } |
223 | 257 | ||
224 | u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value) | 258 | u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value) |
225 | { | 259 | { |
226 | return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value); | 260 | unsigned long flags; |
261 | u32 res; | ||
262 | |||
263 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
264 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value); | ||
265 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
266 | |||
267 | return res; | ||
268 | } | ||
269 | |||
270 | u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value) | ||
271 | { | ||
272 | unsigned long flags; | ||
273 | u32 res; | ||
274 | |||
275 | if (cc->core->id.rev < 20) | ||
276 | return 0; | ||
277 | |||
278 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
279 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value); | ||
280 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
281 | |||
282 | return res; | ||
283 | } | ||
284 | |||
285 | u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value) | ||
286 | { | ||
287 | unsigned long flags; | ||
288 | u32 res; | ||
289 | |||
290 | if (cc->core->id.rev < 20) | ||
291 | return 0; | ||
292 | |||
293 | spin_lock_irqsave(&cc->gpio_lock, flags); | ||
294 | res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value); | ||
295 | spin_unlock_irqrestore(&cc->gpio_lock, flags); | ||
296 | |||
297 | return res; | ||
227 | } | 298 | } |
228 | 299 | ||
229 | #ifdef CONFIG_BCMA_DRIVER_MIPS | 300 | #ifdef CONFIG_BCMA_DRIVER_MIPS |