brcmfmac: decouple set_sbaddr_window from register write interface
authorFranky Lin <frankyl@broadcom.com>
Sat, 5 May 2012 01:27:30 +0000 (18:27 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 15 May 2012 21:27:56 +0000 (17:27 -0400)
brcmf_sdcard_set_sbaddr_window configures 3 registers on SDIO
function misc bank to change current silicon backplane programming
window. This patch makes it call brcmf_sdioh_request_byte directly
in order to prepare for the write register interface unification.

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>
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c

index 7c9bc2b3001a6f6281983658730dd552ad94850f..f971fa8bdbf4ad8019401c2c810ac4d75ab2231d 100644 (file)
@@ -205,19 +205,30 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
 int
 brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address)
 {
-       int err = 0;
-       brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW,
-                        (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err);
-       if (!err)
-               brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
-                                      SBSDIO_FUNC1_SBADDRMID,
-                                      (address >> 16) & SBSDIO_SBADDRMID_MASK,
-                                      &err);
-       if (!err)
-               brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
-                                      SBSDIO_FUNC1_SBADDRHIGH,
-                                      (address >> 24) & SBSDIO_SBADDRHIGH_MASK,
-                                      &err);
+       int err = 0, i;
+       u8 addr[3];
+       s32 retry;
+
+       addr[0] = (address >> 8) & SBSDIO_SBADDRLOW_MASK;
+       addr[1] = (address >> 16) & SBSDIO_SBADDRMID_MASK;
+       addr[2] = (address >> 24) & SBSDIO_SBADDRHIGH_MASK;
+
+       for (i = 0; i < 3; i++) {
+               retry = 0;
+               do {
+                       if (retry)
+                               usleep_range(1000, 2000);
+                       err = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE,
+                                       SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW + i,
+                                       &addr[i]);
+               } while (err != 0 && retry++ < SDIOH_API_ACCESS_RETRY_LIMIT);
+
+               if (err) {
+                       brcmf_dbg(ERROR, "failed at addr:0x%0x\n",
+                                 SBSDIO_FUNC1_SBADDRLOW + i);
+                       break;
+               }
+       }
 
        return err;
 }