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>
This commit is contained in:
parent
79ae39570f
commit
e13ce26bd5
|
@ -298,38 +298,6 @@ void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr,
|
||||||
*ret = retval;
|
*ret = retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, u32 data)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
brcmf_dbg(INFO, "fun = 1, addr = 0x%x, uint32data = 0x%x\n",
|
|
||||||
addr, data);
|
|
||||||
|
|
||||||
if (bar0 != sdiodev->sbwad) {
|
|
||||||
err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
sdiodev->sbwad = bar0;
|
|
||||||
}
|
|
||||||
|
|
||||||
addr &= SBSDIO_SB_OFT_ADDR_MASK;
|
|
||||||
addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
|
|
||||||
status =
|
|
||||||
brcmf_sdioh_request_word(sdiodev, SDIOH_WRITE, SDIO_FUNC_1,
|
|
||||||
addr, &data, 4);
|
|
||||||
sdiodev->regfail = (status != 0);
|
|
||||||
|
|
||||||
if (status == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
brcmf_dbg(ERROR, "error writing 0x%08x to addr 0x%04x\n",
|
|
||||||
data, addr);
|
|
||||||
return 0xFFFFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev)
|
bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev)
|
||||||
{
|
{
|
||||||
return sdiodev->regfail;
|
return sdiodev->regfail;
|
||||||
|
|
|
@ -653,13 +653,13 @@ static void
|
||||||
w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset, u32 *retryvar)
|
w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset, u32 *retryvar)
|
||||||
{
|
{
|
||||||
u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV);
|
u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV);
|
||||||
|
int ret;
|
||||||
*retryvar = 0;
|
*retryvar = 0;
|
||||||
do {
|
do {
|
||||||
brcmf_sdcard_reg_write(bus->sdiodev,
|
brcmf_sdio_regwl(bus->sdiodev,
|
||||||
bus->ci->c_inf[idx].base + reg_offset,
|
bus->ci->c_inf[idx].base + reg_offset,
|
||||||
regval);
|
regval, &ret);
|
||||||
} while (brcmf_sdcard_regfail(bus->sdiodev) &&
|
} while ((ret != 0) && (++(*retryvar) <= retry_limit));
|
||||||
(++(*retryvar) <= retry_limit));
|
|
||||||
if (*retryvar) {
|
if (*retryvar) {
|
||||||
bus->regfails += (*retryvar-1);
|
bus->regfails += (*retryvar-1);
|
||||||
if (*retryvar > retry_limit)
|
if (*retryvar > retry_limit)
|
||||||
|
@ -3751,7 +3751,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva)
|
||||||
reg_addr = bus->ci->c_inf[idx].base +
|
reg_addr = bus->ci->c_inf[idx].base +
|
||||||
offsetof(struct sdpcmd_regs, corecontrol);
|
offsetof(struct sdpcmd_regs, corecontrol);
|
||||||
reg_val = brcmf_sdio_regrl(bus->sdiodev, reg_addr, NULL);
|
reg_val = brcmf_sdio_regrl(bus->sdiodev, reg_addr, NULL);
|
||||||
brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, reg_val | CC_BPRESEN);
|
brcmf_sdio_regwl(bus->sdiodev, reg_addr, reg_val | CC_BPRESEN, NULL);
|
||||||
|
|
||||||
brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
|
brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
|
||||||
|
|
||||||
|
|
|
@ -171,9 +171,8 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
|
||||||
*/
|
*/
|
||||||
regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
|
regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
|
||||||
NULL);
|
NULL);
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
regdata | SSB_TMSLOW_REJECT, NULL);
|
||||||
regdata | SSB_TMSLOW_REJECT);
|
|
||||||
|
|
||||||
regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
|
regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -196,9 +195,8 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
|
||||||
CORE_SB(base, sbimstate),
|
CORE_SB(base, sbimstate),
|
||||||
NULL);
|
NULL);
|
||||||
regdata |= SSB_IMSTATE_REJECT;
|
regdata |= SSB_IMSTATE_REJECT;
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbimstate),
|
||||||
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
regdata, NULL);
|
||||||
regdata);
|
|
||||||
regdata = brcmf_sdio_regrl(sdiodev,
|
regdata = brcmf_sdio_regrl(sdiodev,
|
||||||
CORE_SB(base, sbimstate),
|
CORE_SB(base, sbimstate),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -210,10 +208,10 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set reset and reject while enabling the clocks */
|
/* set reset and reject while enabling the clocks */
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
regdata = SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET;
|
||||||
(SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
|
brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
|
||||||
SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET));
|
regdata, NULL);
|
||||||
regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
|
regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
|
||||||
NULL);
|
NULL);
|
||||||
udelay(10);
|
udelay(10);
|
||||||
|
@ -226,16 +224,14 @@ brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
|
||||||
CORE_SB(base, sbimstate),
|
CORE_SB(base, sbimstate),
|
||||||
NULL);
|
NULL);
|
||||||
regdata &= ~SSB_IMSTATE_REJECT;
|
regdata &= ~SSB_IMSTATE_REJECT;
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbimstate),
|
||||||
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
regdata, NULL);
|
||||||
regdata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* leave reset and reject asserted */
|
/* leave reset and reject asserted */
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
(SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET), NULL);
|
||||||
(SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET));
|
|
||||||
udelay(1);
|
udelay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,13 +251,13 @@ brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev,
|
||||||
if ((regdata & BCMA_RESET_CTL_RESET) != 0)
|
if ((regdata & BCMA_RESET_CTL_RESET) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 0);
|
brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 0, NULL);
|
||||||
regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
||||||
NULL);
|
NULL);
|
||||||
udelay(10);
|
udelay(10);
|
||||||
|
|
||||||
brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
|
brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
|
||||||
BCMA_RESET_CTL_RESET);
|
BCMA_RESET_CTL_RESET, NULL);
|
||||||
udelay(1);
|
udelay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,9 +281,10 @@ brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev,
|
||||||
* set reset while enabling the clock and
|
* set reset while enabling the clock and
|
||||||
* forcing them on throughout the core
|
* forcing them on throughout the core
|
||||||
*/
|
*/
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
||||||
SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET);
|
SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET,
|
||||||
|
NULL);
|
||||||
regdata = brcmf_sdio_regrl(sdiodev,
|
regdata = brcmf_sdio_regrl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -298,30 +295,30 @@ brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
|
CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
|
||||||
NULL);
|
NULL);
|
||||||
if (regdata & SSB_TMSHIGH_SERR)
|
if (regdata & SSB_TMSHIGH_SERR)
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 0);
|
CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
|
||||||
|
0, NULL);
|
||||||
|
|
||||||
regdata = brcmf_sdio_regrl(sdiodev,
|
regdata = brcmf_sdio_regrl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
||||||
NULL);
|
NULL);
|
||||||
if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO))
|
if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO))
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
||||||
regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO));
|
regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO),
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* clear reset and allow it to propagate throughout the core */
|
/* clear reset and allow it to propagate throughout the core */
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK, NULL);
|
||||||
SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK);
|
|
||||||
regdata = brcmf_sdio_regrl(sdiodev,
|
regdata = brcmf_sdio_regrl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
||||||
NULL);
|
NULL);
|
||||||
udelay(1);
|
udelay(1);
|
||||||
|
|
||||||
/* leave clock enabled */
|
/* leave clock enabled */
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
SSB_TMSLOW_CLOCK, NULL);
|
||||||
SSB_TMSLOW_CLOCK);
|
|
||||||
regdata = brcmf_sdio_regrl(sdiodev,
|
regdata = brcmf_sdio_regrl(sdiodev,
|
||||||
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -341,16 +338,16 @@ brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev,
|
||||||
brcmf_sdio_ai_coredisable(sdiodev, ci, coreid);
|
brcmf_sdio_ai_coredisable(sdiodev, ci, coreid);
|
||||||
|
|
||||||
/* now do initialization sequence */
|
/* now do initialization sequence */
|
||||||
brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
||||||
BCMA_IOCTL_FGC | BCMA_IOCTL_CLK);
|
BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL);
|
||||||
regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
||||||
NULL);
|
NULL);
|
||||||
brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
|
brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
|
||||||
0);
|
0, NULL);
|
||||||
udelay(1);
|
udelay(1);
|
||||||
|
|
||||||
brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
||||||
BCMA_IOCTL_CLK);
|
BCMA_IOCTL_CLK, NULL);
|
||||||
regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
||||||
NULL);
|
NULL);
|
||||||
udelay(1);
|
udelay(1);
|
||||||
|
@ -536,10 +533,10 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev,
|
||||||
|
|
||||||
brcmf_sdio_chip_buscoresetup(sdiodev, ci);
|
brcmf_sdio_chip_buscoresetup(sdiodev, ci);
|
||||||
|
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopullup),
|
||||||
CORE_CC_REG(ci->c_inf[0].base, gpiopullup), 0);
|
0, NULL);
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopulldown),
|
||||||
CORE_CC_REG(ci->c_inf[0].base, gpiopulldown), 0);
|
0, NULL);
|
||||||
|
|
||||||
*ci_ptr = ci;
|
*ci_ptr = ci;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -605,9 +602,8 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_CC_REG(base, chipcontrol_addr),
|
||||||
CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr),
|
1, NULL);
|
||||||
1);
|
|
||||||
cc_data_temp =
|
cc_data_temp =
|
||||||
brcmf_sdio_regrl(sdiodev,
|
brcmf_sdio_regrl(sdiodev,
|
||||||
CORE_CC_REG(base, chipcontrol_addr),
|
CORE_CC_REG(base, chipcontrol_addr),
|
||||||
|
@ -615,9 +611,8 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
|
||||||
cc_data_temp &= ~str_mask;
|
cc_data_temp &= ~str_mask;
|
||||||
drivestrength_sel <<= str_shift;
|
drivestrength_sel <<= str_shift;
|
||||||
cc_data_temp |= drivestrength_sel;
|
cc_data_temp |= drivestrength_sel;
|
||||||
brcmf_sdcard_reg_write(sdiodev,
|
brcmf_sdio_regwl(sdiodev, CORE_CC_REG(base, chipcontrol_addr),
|
||||||
CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr),
|
cc_data_temp, NULL);
|
||||||
cc_data_temp);
|
|
||||||
|
|
||||||
brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n",
|
brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n",
|
||||||
drivestrength, cc_data_temp);
|
drivestrength, cc_data_temp);
|
||||||
|
|
|
@ -168,14 +168,6 @@ struct brcmf_sdio_dev {
|
||||||
extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
|
extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
|
||||||
extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
|
extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
|
||||||
|
|
||||||
/* Synchronous access to device (client) core registers via CMD53 to F1.
|
|
||||||
* addr: backplane address (i.e. >= regsva from attach)
|
|
||||||
* size: register width in bytes (2 or 4)
|
|
||||||
* data: data for register write
|
|
||||||
*/
|
|
||||||
extern u32
|
|
||||||
brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, u32 data);
|
|
||||||
|
|
||||||
/* sdio device register access interface */
|
/* sdio device register access interface */
|
||||||
extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
|
extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
|
||||||
extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
|
extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
|
||||||
|
|
Loading…
Reference in New Issue