aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Vossen <rvossen@broadcom.com>2011-06-01 07:44:53 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-07 15:36:44 -0400
commit6a9a25eec0b55ea45e22710a9bcaf9690cb42fe6 (patch)
tree80614a72f1e9a0be282f0b127b8b6afcc2abfb74
parent0a0ad7d255d6e84fb265f61ac090ff1c1e546444 (diff)
staging: brcm80211: replaced #ifdef __mips__ sections by W_REG_FLUSH
Code cleanup. A read-after-write construct is present in the code to ensure write order for certain Broadcom chips. Those chips are: bcm4706, bcm4716, bcm4717, bcm4718. All these chips contain a MIPS processor. This patch gets rid of several #ifdef __mips__ sections by defining a new macro in a header file. This patch does not introduce behavioral changes and is purely meant for code cleanup. The __mips__ define will be made more specific in a future patch. Signed-off-by: Roland Vossen <rvossen@broadcom.com> Reviewed-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c63
-rw-r--r--drivers/staging/brcm80211/include/bcmutils.h11
2 files changed, 24 insertions, 50 deletions
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
index f45628ae95a..07a5bcb0915 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
@@ -247,16 +247,10 @@ u16 read_radio_reg(phy_info_t *pi, u16 addr)
247 if ((D11REV_GE(pi->sh->corerev, 24)) || 247 if ((D11REV_GE(pi->sh->corerev, 24)) ||
248 (D11REV_IS(pi->sh->corerev, 22) 248 (D11REV_IS(pi->sh->corerev, 22)
249 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { 249 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) {
250 W_REG(&pi->regs->radioregaddr, addr); 250 W_REG_FLUSH(&pi->regs->radioregaddr, addr);
251#ifdef __mips__
252 (void)R_REG(&pi->regs->radioregaddr);
253#endif
254 data = R_REG(&pi->regs->radioregdata); 251 data = R_REG(&pi->regs->radioregdata);
255 } else { 252 } else {
256 W_REG(&pi->regs->phy4waddr, addr); 253 W_REG_FLUSH(&pi->regs->phy4waddr, addr);
257#ifdef __mips__
258 (void)R_REG(&pi->regs->phy4waddr);
259#endif
260 254
261#ifdef __ARM_ARCH_4T__ 255#ifdef __ARM_ARCH_4T__
262 __asm__(" .align 4 "); 256 __asm__(" .align 4 ");
@@ -281,16 +275,10 @@ void write_radio_reg(phy_info_t *pi, u16 addr, u16 val)
281 (D11REV_IS(pi->sh->corerev, 22) 275 (D11REV_IS(pi->sh->corerev, 22)
282 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { 276 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) {
283 277
284 W_REG(&pi->regs->radioregaddr, addr); 278 W_REG_FLUSH(&pi->regs->radioregaddr, addr);
285#ifdef __mips__
286 (void)R_REG(&pi->regs->radioregaddr);
287#endif
288 W_REG(&pi->regs->radioregdata, val); 279 W_REG(&pi->regs->radioregdata, val);
289 } else { 280 } else {
290 W_REG(&pi->regs->phy4waddr, addr); 281 W_REG_FLUSH(&pi->regs->phy4waddr, addr);
291#ifdef __mips__
292 (void)R_REG(&pi->regs->phy4waddr);
293#endif
294 W_REG(&pi->regs->phy4wdatalo, val); 282 W_REG(&pi->regs->phy4wdatalo, val);
295 } 283 }
296 284
@@ -312,29 +300,17 @@ static u32 read_radio_id(phy_info_t *pi)
312 if (D11REV_GE(pi->sh->corerev, 24)) { 300 if (D11REV_GE(pi->sh->corerev, 24)) {
313 u32 b0, b1, b2; 301 u32 b0, b1, b2;
314 302
315 W_REG(&pi->regs->radioregaddr, 0); 303 W_REG_FLUSH(&pi->regs->radioregaddr, 0);
316#ifdef __mips__
317 (void)R_REG(&pi->regs->radioregaddr);
318#endif
319 b0 = (u32) R_REG(&pi->regs->radioregdata); 304 b0 = (u32) R_REG(&pi->regs->radioregdata);
320 W_REG(&pi->regs->radioregaddr, 1); 305 W_REG_FLUSH(&pi->regs->radioregaddr, 1);
321#ifdef __mips__
322 (void)R_REG(&pi->regs->radioregaddr);
323#endif
324 b1 = (u32) R_REG(&pi->regs->radioregdata); 306 b1 = (u32) R_REG(&pi->regs->radioregdata);
325 W_REG(&pi->regs->radioregaddr, 2); 307 W_REG_FLUSH(&pi->regs->radioregaddr, 2);
326#ifdef __mips__
327 (void)R_REG(&pi->regs->radioregaddr);
328#endif
329 b2 = (u32) R_REG(&pi->regs->radioregdata); 308 b2 = (u32) R_REG(&pi->regs->radioregdata);
330 309
331 id = ((b0 & 0xf) << 28) | (((b2 << 8) | b1) << 12) | ((b0 >> 4) 310 id = ((b0 & 0xf) << 28) | (((b2 << 8) | b1) << 12) | ((b0 >> 4)
332 & 0xf); 311 & 0xf);
333 } else { 312 } else {
334 W_REG(&pi->regs->phy4waddr, RADIO_IDCODE); 313 W_REG_FLUSH(&pi->regs->phy4waddr, RADIO_IDCODE);
335#ifdef __mips__
336 (void)R_REG(&pi->regs->phy4waddr);
337#endif
338 id = (u32) R_REG(&pi->regs->phy4wdatalo); 314 id = (u32) R_REG(&pi->regs->phy4wdatalo);
339 id |= (u32) R_REG(&pi->regs->phy4wdatahi) << 16; 315 id |= (u32) R_REG(&pi->regs->phy4wdatahi) << 16;
340 } 316 }
@@ -397,10 +373,7 @@ u16 read_phy_reg(phy_info_t *pi, u16 addr)
397 373
398 regs = pi->regs; 374 regs = pi->regs;
399 375
400 W_REG(&regs->phyregaddr, addr); 376 W_REG_FLUSH(&regs->phyregaddr, addr);
401#ifdef __mips__
402 (void)R_REG(&regs->phyregaddr);
403#endif
404 377
405 pi->phy_wreg = 0; 378 pi->phy_wreg = 0;
406 return R_REG(&regs->phyregdata); 379 return R_REG(&regs->phyregdata);
@@ -413,8 +386,7 @@ void write_phy_reg(phy_info_t *pi, u16 addr, u16 val)
413 regs = pi->regs; 386 regs = pi->regs;
414 387
415#ifdef __mips__ 388#ifdef __mips__
416 W_REG(&regs->phyregaddr, addr); 389 W_REG_FLUSH(&regs->phyregaddr, addr);
417 (void)R_REG(&regs->phyregaddr);
418 W_REG(&regs->phyregdata, val); 390 W_REG(&regs->phyregdata, val);
419 if (addr == 0x72) 391 if (addr == 0x72)
420 (void)R_REG(&regs->phyregdata); 392 (void)R_REG(&regs->phyregdata);
@@ -436,10 +408,7 @@ void and_phy_reg(phy_info_t *pi, u16 addr, u16 val)
436 408
437 regs = pi->regs; 409 regs = pi->regs;
438 410
439 W_REG(&regs->phyregaddr, addr); 411 W_REG_FLUSH(&regs->phyregaddr, addr);
440#ifdef __mips__
441 (void)R_REG(&regs->phyregaddr);
442#endif
443 412
444 W_REG(&regs->phyregdata, (R_REG(&regs->phyregdata) & val)); 413 W_REG(&regs->phyregdata, (R_REG(&regs->phyregdata) & val));
445 pi->phy_wreg = 0; 414 pi->phy_wreg = 0;
@@ -451,10 +420,7 @@ void or_phy_reg(phy_info_t *pi, u16 addr, u16 val)
451 420
452 regs = pi->regs; 421 regs = pi->regs;
453 422
454 W_REG(&regs->phyregaddr, addr); 423 W_REG_FLUSH(&regs->phyregaddr, addr);
455#ifdef __mips__
456 (void)R_REG(&regs->phyregaddr);
457#endif
458 424
459 W_REG(&regs->phyregdata, (R_REG(&regs->phyregdata) | val)); 425 W_REG(&regs->phyregdata, (R_REG(&regs->phyregdata) | val));
460 pi->phy_wreg = 0; 426 pi->phy_wreg = 0;
@@ -466,10 +432,7 @@ void mod_phy_reg(phy_info_t *pi, u16 addr, u16 mask, u16 val)
466 432
467 regs = pi->regs; 433 regs = pi->regs;
468 434
469 W_REG(&regs->phyregaddr, addr); 435 W_REG_FLUSH(&regs->phyregaddr, addr);
470#ifdef __mips__
471 (void)R_REG(&regs->phyregaddr);
472#endif
473 436
474 W_REG(&regs->phyregdata, 437 W_REG(&regs->phyregdata,
475 ((R_REG(&regs->phyregdata) & ~mask) | (val & mask))); 438 ((R_REG(&regs->phyregdata) & ~mask) | (val & mask)));
diff --git a/drivers/staging/brcm80211/include/bcmutils.h b/drivers/staging/brcm80211/include/bcmutils.h
index 17683f2f785..d7f531e2b83 100644
--- a/drivers/staging/brcm80211/include/bcmutils.h
+++ b/drivers/staging/brcm80211/include/bcmutils.h
@@ -366,6 +366,17 @@ extern void bcm_prpkt(const char *msg, struct sk_buff *p0);
366 } while (0) 366 } while (0)
367#endif /* __BIG_ENDIAN */ 367#endif /* __BIG_ENDIAN */
368 368
369#ifdef __mips__
370/*
371 * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
372 * transactions. As a fix, a read after write is performed on certain places
373 * in the code. Older chips and the newer 5357 family don't require this fix.
374 */
375#define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); })
376#else
377#define W_REG_FLUSH(r, v) W_REG((r), (v))
378#endif /* __mips__ */
379
369#define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) 380#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
370#define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) 381#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
371 382