aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/brcm80211
diff options
context:
space:
mode:
authorFranky Lin <frankyl@broadcom.com>2012-05-04 21:27:35 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-05-15 17:27:57 -0400
commite13ce26bd53296fdf2c78836ce7b880df75c6e6e (patch)
treebb28f47a69a80f6be8abd3ff1beaa59474b9b51d /drivers/net/wireless/brcm80211
parent79ae39570f82f96e2d899c100e32409129c6d62f (diff)
brcmfmac: replace brcmf_sdcard_reg_write with brcmf_sdio_regwl
Use the newly introduced brcmf_sdio_regwl to replace brcmf_sdcard_reg_write as part of the SDIO WiFi dongle register access interface clean up. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Reviewed-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Franky Lin <frankyl@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/brcm80211')
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c32
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c12
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c93
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h8
4 files changed, 50 insertions, 95 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index 54a935b27023..cd5f7d798d16 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -298,38 +298,6 @@ void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr,
298 *ret = retval; 298 *ret = retval;
299} 299}
300 300
301u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, u32 data)
302{
303 int status;
304 uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
305 int err = 0;
306
307 brcmf_dbg(INFO, "fun = 1, addr = 0x%x, uint32data = 0x%x\n",
308 addr, data);
309
310 if (bar0 != sdiodev->sbwad) {
311 err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0);
312 if (err)
313 return err;
314
315 sdiodev->sbwad = bar0;
316 }
317
318 addr &= SBSDIO_SB_OFT_ADDR_MASK;
319 addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
320 status =
321 brcmf_sdioh_request_word(sdiodev, SDIOH_WRITE, SDIO_FUNC_1,
322 addr, &data, 4);
323 sdiodev->regfail = (status != 0);
324
325 if (status == 0)
326 return 0;
327
328 brcmf_dbg(ERROR, "error writing 0x%08x to addr 0x%04x\n",
329 data, addr);
330 return 0xFFFFFFFF;
331}
332
333bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev) 301bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev)
334{ 302{
335 return sdiodev->regfail; 303 return sdiodev->regfail;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 1e96ebf01295..2c644a93c5bc 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -653,13 +653,13 @@ static void
653w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset, u32 *retryvar) 653w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset, u32 *retryvar)
654{ 654{
655 u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); 655 u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV);
656 int ret;
656 *retryvar = 0; 657 *retryvar = 0;
657 do { 658 do {
658 brcmf_sdcard_reg_write(bus->sdiodev, 659 brcmf_sdio_regwl(bus->sdiodev,
659 bus->ci->c_inf[idx].base + reg_offset, 660 bus->ci->c_inf[idx].base + reg_offset,
660 regval); 661 regval, &ret);
661 } while (brcmf_sdcard_regfail(bus->sdiodev) && 662 } while ((ret != 0) && (++(*retryvar) <= retry_limit));
662 (++(*retryvar) <= retry_limit));
663 if (*retryvar) { 663 if (*retryvar) {
664 bus->regfails += (*retryvar-1); 664 bus->regfails += (*retryvar-1);
665 if (*retryvar > retry_limit) 665 if (*retryvar > retry_limit)
@@ -3751,7 +3751,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva)
3751 reg_addr = bus->ci->c_inf[idx].base + 3751 reg_addr = bus->ci->c_inf[idx].base +
3752 offsetof(struct sdpcmd_regs, corecontrol); 3752 offsetof(struct sdpcmd_regs, corecontrol);
3753 reg_val = brcmf_sdio_regrl(bus->sdiodev, reg_addr, NULL); 3753 reg_val = brcmf_sdio_regrl(bus->sdiodev, reg_addr, NULL);
3754 brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, reg_val | CC_BPRESEN); 3754 brcmf_sdio_regwl(bus->sdiodev, reg_addr, reg_val | CC_BPRESEN, NULL);
3755 3755
3756 brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); 3756 brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
3757 3757
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
index c2ec99c5d648..f8e1f1c84d08 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
@@ -171,9 +171,8 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
171 */ 171 */
172 regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow), 172 regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
173 NULL); 173 NULL);
174 brcmf_sdcard_reg_write(sdiodev, 174 brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
175 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 175 regdata | SSB_TMSLOW_REJECT, NULL);
176 regdata | SSB_TMSLOW_REJECT);
177 176
178 regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow), 177 regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
179 NULL); 178 NULL);
@@ -196,9 +195,8 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
196 CORE_SB(base, sbimstate), 195 CORE_SB(base, sbimstate),
197 NULL); 196 NULL);
198 regdata |= SSB_IMSTATE_REJECT; 197 regdata |= SSB_IMSTATE_REJECT;
199 brcmf_sdcard_reg_write(sdiodev, 198 brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbimstate),
200 CORE_SB(ci->c_inf[idx].base, sbimstate), 199 regdata, NULL);
201 regdata);
202 regdata = brcmf_sdio_regrl(sdiodev, 200 regdata = brcmf_sdio_regrl(sdiodev,
203 CORE_SB(base, sbimstate), 201 CORE_SB(base, sbimstate),
204 NULL); 202 NULL);
@@ -210,10 +208,10 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
210 } 208 }
211 209
212 /* set reset and reject while enabling the clocks */ 210 /* set reset and reject while enabling the clocks */
213 brcmf_sdcard_reg_write(sdiodev, 211 regdata = SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
214 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 212 SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET;
215 (SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | 213 brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
216 SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); 214 regdata, NULL);
217 regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow), 215 regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
218 NULL); 216 NULL);
219 udelay(10); 217 udelay(10);
@@ -226,16 +224,14 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
226 CORE_SB(base, sbimstate), 224 CORE_SB(base, sbimstate),
227 NULL); 225 NULL);
228 regdata &= ~SSB_IMSTATE_REJECT; 226 regdata &= ~SSB_IMSTATE_REJECT;
229 brcmf_sdcard_reg_write(sdiodev, 227 brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbimstate),
230 CORE_SB(ci->c_inf[idx].base, sbimstate), 228 regdata, NULL);
231 regdata);
232 } 229 }
233 } 230 }
234 231
235 /* leave reset and reject asserted */ 232 /* leave reset and reject asserted */
236 brcmf_sdcard_reg_write(sdiodev, 233 brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
237 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 234 (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET), NULL);
238 (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET));
239 udelay(1); 235 udelay(1);
240} 236}
241 237
@@ -255,13 +251,13 @@ brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev,
255 if ((regdata & BCMA_RESET_CTL_RESET) != 0) 251 if ((regdata & BCMA_RESET_CTL_RESET) != 0)
256 return; 252 return;
257 253
258 brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 0); 254 brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 0, NULL);
259 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 255 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
260 NULL); 256 NULL);
261 udelay(10); 257 udelay(10);
262 258
263 brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 259 brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
264 BCMA_RESET_CTL_RESET); 260 BCMA_RESET_CTL_RESET, NULL);
265 udelay(1); 261 udelay(1);
266} 262}
267 263
@@ -285,9 +281,10 @@ brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev,
285 * set reset while enabling the clock and 281 * set reset while enabling the clock and
286 * forcing them on throughout the core 282 * forcing them on throughout the core
287 */ 283 */
288 brcmf_sdcard_reg_write(sdiodev, 284 brcmf_sdio_regwl(sdiodev,
289 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 285 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
290 SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); 286 SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET,
287 NULL);
291 regdata = brcmf_sdio_regrl(sdiodev, 288 regdata = brcmf_sdio_regrl(sdiodev,
292 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 289 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
293 NULL); 290 NULL);
@@ -298,30 +295,30 @@ brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev,
298 CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 295 CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
299 NULL); 296 NULL);
300 if (regdata & SSB_TMSHIGH_SERR) 297 if (regdata & SSB_TMSHIGH_SERR)
301 brcmf_sdcard_reg_write(sdiodev, 298 brcmf_sdio_regwl(sdiodev,
302 CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 0); 299 CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
300 0, NULL);
303 301
304 regdata = brcmf_sdio_regrl(sdiodev, 302 regdata = brcmf_sdio_regrl(sdiodev,
305 CORE_SB(ci->c_inf[idx].base, sbimstate), 303 CORE_SB(ci->c_inf[idx].base, sbimstate),
306 NULL); 304 NULL);
307 if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO)) 305 if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO))
308 brcmf_sdcard_reg_write(sdiodev, 306 brcmf_sdio_regwl(sdiodev,
309 CORE_SB(ci->c_inf[idx].base, sbimstate), 307 CORE_SB(ci->c_inf[idx].base, sbimstate),
310 regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO)); 308 regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO),
309 NULL);
311 310
312 /* clear reset and allow it to propagate throughout the core */ 311 /* clear reset and allow it to propagate throughout the core */
313 brcmf_sdcard_reg_write(sdiodev, 312 brcmf_sdio_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
314 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 313 SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK, NULL);
315 SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK);
316 regdata = brcmf_sdio_regrl(sdiodev, 314 regdata = brcmf_sdio_regrl(sdiodev,
317 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 315 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
318 NULL); 316 NULL);
319 udelay(1); 317 udelay(1);
320 318
321 /* leave clock enabled */ 319 /* leave clock enabled */
322 brcmf_sdcard_reg_write(sdiodev, 320 brcmf_sdio_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
323 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 321 SSB_TMSLOW_CLOCK, NULL);
324 SSB_TMSLOW_CLOCK);
325 regdata = brcmf_sdio_regrl(sdiodev, 322 regdata = brcmf_sdio_regrl(sdiodev,
326 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 323 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
327 NULL); 324 NULL);
@@ -341,16 +338,16 @@ brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev,
341 brcmf_sdio_ai_coredisable(sdiodev, ci, coreid); 338 brcmf_sdio_ai_coredisable(sdiodev, ci, coreid);
342 339
343 /* now do initialization sequence */ 340 /* now do initialization sequence */
344 brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 341 brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
345 BCMA_IOCTL_FGC | BCMA_IOCTL_CLK); 342 BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL);
346 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 343 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
347 NULL); 344 NULL);
348 brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 345 brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
349 0); 346 0, NULL);
350 udelay(1); 347 udelay(1);
351 348
352 brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 349 brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
353 BCMA_IOCTL_CLK); 350 BCMA_IOCTL_CLK, NULL);
354 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 351 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
355 NULL); 352 NULL);
356 udelay(1); 353 udelay(1);
@@ -536,10 +533,10 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev,
536 533
537 brcmf_sdio_chip_buscoresetup(sdiodev, ci); 534 brcmf_sdio_chip_buscoresetup(sdiodev, ci);
538 535
539 brcmf_sdcard_reg_write(sdiodev, 536 brcmf_sdio_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopullup),
540 CORE_CC_REG(ci->c_inf[0].base, gpiopullup), 0); 537 0, NULL);
541 brcmf_sdcard_reg_write(sdiodev, 538 brcmf_sdio_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopulldown),
542 CORE_CC_REG(ci->c_inf[0].base, gpiopulldown), 0); 539 0, NULL);
543 540
544 *ci_ptr = ci; 541 *ci_ptr = ci;
545 return 0; 542 return 0;
@@ -605,9 +602,8 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
605 } 602 }
606 } 603 }
607 604
608 brcmf_sdcard_reg_write(sdiodev, 605 brcmf_sdio_regwl(sdiodev, CORE_CC_REG(base, chipcontrol_addr),
609 CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 606 1, NULL);
610 1);
611 cc_data_temp = 607 cc_data_temp =
612 brcmf_sdio_regrl(sdiodev, 608 brcmf_sdio_regrl(sdiodev,
613 CORE_CC_REG(base, chipcontrol_addr), 609 CORE_CC_REG(base, chipcontrol_addr),
@@ -615,9 +611,8 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
615 cc_data_temp &= ~str_mask; 611 cc_data_temp &= ~str_mask;
616 drivestrength_sel <<= str_shift; 612 drivestrength_sel <<= str_shift;
617 cc_data_temp |= drivestrength_sel; 613 cc_data_temp |= drivestrength_sel;
618 brcmf_sdcard_reg_write(sdiodev, 614 brcmf_sdio_regwl(sdiodev, CORE_CC_REG(base, chipcontrol_addr),
619 CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 615 cc_data_temp, NULL);
620 cc_data_temp);
621 616
622 brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", 617 brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n",
623 drivestrength, cc_data_temp); 618 drivestrength, cc_data_temp);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
index 82d9dd1ea2b7..a14753512457 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
@@ -168,14 +168,6 @@ struct brcmf_sdio_dev {
168extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev); 168extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
169extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev); 169extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
170 170
171/* Synchronous access to device (client) core registers via CMD53 to F1.
172 * addr: backplane address (i.e. >= regsva from attach)
173 * size: register width in bytes (2 or 4)
174 * data: data for register write
175 */
176extern u32
177brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, u32 data);
178
179/* sdio device register access interface */ 171/* sdio device register access interface */
180extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret); 172extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
181extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret); 173extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);