Commit 45db339c authored by Franky Lin's avatar Franky Lin Committed by John W. Linville

brcmfmac: replace brcmf_sdcard_cfg_read with brcmf_sdio_regrb

Use the newly introduced brcmf_sdio_regrb to replace
brcmf_sdcard_cfg_read as part of the SDIO WiFi dongle register
access interface clean up.
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e9b8d91d
...@@ -85,8 +85,7 @@ int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev) ...@@ -85,8 +85,7 @@ int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev)
sdiodev->irq_wake = true; sdiodev->irq_wake = true;
/* must configure SDIO_CCCR_IENx to enable irq */ /* must configure SDIO_CCCR_IENx to enable irq */
data = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_0, data = brcmf_sdio_regrb(sdiodev, SDIO_CCCR_IENx, &ret);
SDIO_CCCR_IENx, &ret);
data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1; data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1;
brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_IENx, brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_IENx,
data, &ret); data, &ret);
...@@ -158,29 +157,6 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev) ...@@ -158,29 +157,6 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev)
} }
#endif /* CONFIG_BRCMFMAC_SDIO_OOB */ #endif /* CONFIG_BRCMFMAC_SDIO_OOB */
u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
int *err)
{
int status;
s32 retry = 0;
u8 data = 0;
do {
if (retry) /* wait for 1 ms till bus get settled down */
udelay(1000);
status = brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, fnc_num,
addr, (u8 *) &data);
} while (status != 0
&& (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
if (err)
*err = status;
brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n",
fnc_num, addr, data);
return data;
}
void void
brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
u8 data, int *err) u8 data, int *err)
......
...@@ -704,7 +704,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) ...@@ -704,7 +704,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
} }
/* Check current status */ /* Check current status */
clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, clkctl = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (err) { if (err) {
brcmf_dbg(ERROR, "HT Avail read error: %d\n", err); brcmf_dbg(ERROR, "HT Avail read error: %d\n", err);
...@@ -714,8 +714,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) ...@@ -714,8 +714,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
/* Go to pending and await interrupt if appropriate */ /* Go to pending and await interrupt if appropriate */
if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) {
/* Allow only clock-available interrupt */ /* Allow only clock-available interrupt */
devctl = brcmf_sdcard_cfg_read(bus->sdiodev, devctl = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
if (err) { if (err) {
brcmf_dbg(ERROR, "Devctl error setting CA: %d\n", brcmf_dbg(ERROR, "Devctl error setting CA: %d\n",
...@@ -732,8 +731,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) ...@@ -732,8 +731,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
return 0; return 0;
} else if (bus->clkstate == CLK_PENDING) { } else if (bus->clkstate == CLK_PENDING) {
/* Cancel CA-only interrupt filter */ /* Cancel CA-only interrupt filter */
devctl = devctl = brcmf_sdio_regrb(bus->sdiodev,
brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
...@@ -744,8 +742,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) ...@@ -744,8 +742,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
timeout = jiffies + timeout = jiffies +
msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000); msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000);
while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, clkctl = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
&err); &err);
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
...@@ -780,8 +777,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) ...@@ -780,8 +777,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
if (bus->clkstate == CLK_PENDING) { if (bus->clkstate == CLK_PENDING) {
/* Cancel CA-only interrupt filter */ /* Cancel CA-only interrupt filter */
devctl = brcmf_sdcard_cfg_read(bus->sdiodev, devctl = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
...@@ -1046,9 +1042,9 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) ...@@ -1046,9 +1042,9 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx)
/* Wait until the packet has been flushed (device/FIFO stable) */ /* Wait until the packet has been flushed (device/FIFO stable) */
for (lastrbc = retries = 0xffff; retries > 0; retries--) { for (lastrbc = retries = 0xffff; retries > 0; retries--) {
hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, hi = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_FUNC1_RFRAMEBCHI, NULL); SBSDIO_FUNC1_RFRAMEBCHI, NULL);
lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, lo = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_FUNC1_RFRAMEBCLO, NULL); SBSDIO_FUNC1_RFRAMEBCLO, NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
...@@ -2184,14 +2180,10 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, ...@@ -2184,14 +2180,10 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt,
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
u8 hi, lo; u8 hi, lo;
hi = brcmf_sdcard_cfg_read(bus->sdiodev, hi = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCHI, NULL);
SBSDIO_FUNC1_WFRAMEBCHI, lo = brcmf_sdio_regrb(bus->sdiodev,
NULL); SBSDIO_FUNC1_WFRAMEBCLO, NULL);
lo = brcmf_sdcard_cfg_read(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCLO,
NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
if ((hi == 0) && (lo == 0)) if ((hi == 0) && (lo == 0))
break; break;
...@@ -2310,7 +2302,7 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev) ...@@ -2310,7 +2302,7 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev)
bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
/* Force clocks on backplane to be sure F2 interrupt propagates */ /* Force clocks on backplane to be sure F2 interrupt propagates */
saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, saveclk = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (!err) { if (!err) {
brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
...@@ -2393,7 +2385,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) ...@@ -2393,7 +2385,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
#ifdef DEBUG #ifdef DEBUG
/* Check for inconsistent device control */ /* Check for inconsistent device control */
devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, devctl = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
if (err) { if (err) {
brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err);
...@@ -2402,7 +2394,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) ...@@ -2402,7 +2394,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
#endif /* DEBUG */ #endif /* DEBUG */
/* Read CSR, if clock on switch to AVAIL, else ignore */ /* Read CSR, if clock on switch to AVAIL, else ignore */
clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, clkctl = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (err) { if (err) {
brcmf_dbg(ERROR, "error reading CSR: %d\n", brcmf_dbg(ERROR, "error reading CSR: %d\n",
...@@ -2414,8 +2406,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) ...@@ -2414,8 +2406,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
devctl, clkctl); devctl, clkctl);
if (SBSDIO_HTAV(clkctl)) { if (SBSDIO_HTAV(clkctl)) {
devctl = brcmf_sdcard_cfg_read(bus->sdiodev, devctl = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
if (err) { if (err) {
brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", brcmf_dbg(ERROR, "error reading DEVCTL: %d\n",
...@@ -2552,12 +2543,10 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) ...@@ -2552,12 +2543,10 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
u8 hi, lo; u8 hi, lo;
hi = brcmf_sdcard_cfg_read(bus->sdiodev, hi = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCHI, SBSDIO_FUNC1_WFRAMEBCHI,
NULL); NULL);
lo = brcmf_sdcard_cfg_read(bus->sdiodev, lo = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCLO, SBSDIO_FUNC1_WFRAMEBCLO,
NULL); NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
...@@ -2892,12 +2881,10 @@ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) ...@@ -2892,12 +2881,10 @@ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len)
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
u8 hi, lo; u8 hi, lo;
hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, hi = brcmf_sdio_regrb(bus->sdiodev,
SBSDIO_FUNC1_WFRAMEBCHI, SBSDIO_FUNC1_WFRAMEBCHI, NULL);
NULL); lo = brcmf_sdio_regrb(bus->sdiodev,
lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_WFRAMEBCLO, NULL);
SBSDIO_FUNC1_WFRAMEBCLO,
NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
if (hi == 0 && lo == 0) if (hi == 0 && lo == 0)
break; break;
...@@ -3471,8 +3458,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) ...@@ -3471,8 +3458,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
goto exit; goto exit;
/* Force clocks on backplane to be sure F2 interrupt propagates */ /* Force clocks on backplane to be sure F2 interrupt propagates */
saveclk = saveclk = brcmf_sdio_regrb(bus->sdiodev,
brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (!err) { if (!err) {
brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
...@@ -3495,7 +3481,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) ...@@ -3495,7 +3481,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY); timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY);
ready = 0; ready = 0;
while (enable != ready) { while (enable != ready) {
ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0, ready = brcmf_sdio_regrb(bus->sdiodev,
SDIO_CCCR_IORx, NULL); SDIO_CCCR_IORx, NULL);
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -3605,8 +3591,8 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) ...@@ -3605,8 +3591,8 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
if (!bus->dpc_sched) { if (!bus->dpc_sched) {
u8 devpend; u8 devpend;
devpend = brcmf_sdcard_cfg_read(bus->sdiodev, devpend = brcmf_sdio_regrb(bus->sdiodev,
SDIO_FUNC_0, SDIO_CCCR_INTx, SDIO_CCCR_INTx,
NULL); NULL);
intstatus = intstatus =
devpend & (INTR_STATUS_FUNC1 | devpend & (INTR_STATUS_FUNC1 |
...@@ -3747,8 +3733,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva) ...@@ -3747,8 +3733,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva)
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
BRCMF_INIT_CLKCTL1, &err); BRCMF_INIT_CLKCTL1, &err);
if (!err) if (!err)
clkctl = clkctl = brcmf_sdio_regrb(bus->sdiodev,
brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) {
......
...@@ -434,7 +434,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) ...@@ -434,7 +434,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev)
/* If register supported, wait for ALPAvail and then force ALP */ /* If register supported, wait for ALPAvail and then force ALP */
/* This may take up to 15 milliseconds */ /* This may take up to 15 milliseconds */
clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, clkval = brcmf_sdio_regrb(sdiodev,
SBSDIO_FUNC1_CHIPCLKCSR, NULL); SBSDIO_FUNC1_CHIPCLKCSR, NULL);
if ((clkval & ~SBSDIO_AVBITS) != clkset) { if ((clkval & ~SBSDIO_AVBITS) != clkset) {
...@@ -443,7 +443,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) ...@@ -443,7 +443,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev)
return -EACCES; return -EACCES;
} }
SPINWAIT(((clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, SPINWAIT(((clkval = brcmf_sdio_regrb(sdiodev,
SBSDIO_FUNC1_CHIPCLKCSR, NULL)), SBSDIO_FUNC1_CHIPCLKCSR, NULL)),
!SBSDIO_ALPAV(clkval)), !SBSDIO_ALPAV(clkval)),
PMU_MAX_TRANSITION_DLY); PMU_MAX_TRANSITION_DLY);
......
...@@ -174,8 +174,6 @@ extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev); ...@@ -174,8 +174,6 @@ extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
* data: data byte to write * data: data byte to write
* err: pointer to error code (or NULL) * err: pointer to error code (or NULL)
*/ */
extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint func,
u32 addr, int *err);
extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func, extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func,
u32 addr, u8 data, int *err); u32 addr, u8 data, int *err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment