mirror of https://gitee.com/openkylin/linux.git
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: 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
e9b8d91d55
commit
45db339cd2
|
@ -85,8 +85,7 @@ int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev)
|
|||
sdiodev->irq_wake = true;
|
||||
|
||||
/* must configure SDIO_CCCR_IENx to enable irq */
|
||||
data = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_0,
|
||||
SDIO_CCCR_IENx, &ret);
|
||||
data = brcmf_sdio_regrb(sdiodev, SDIO_CCCR_IENx, &ret);
|
||||
data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1;
|
||||
brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_IENx,
|
||||
data, &ret);
|
||||
|
@ -158,29 +157,6 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev)
|
|||
}
|
||||
#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
|
||||
brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
|
||||
u8 data, int *err)
|
||||
|
|
|
@ -704,7 +704,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
|
|||
}
|
||||
|
||||
/* Check current status */
|
||||
clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
|
||||
clkctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_CHIPCLKCSR, &err);
|
||||
if (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)
|
|||
/* Go to pending and await interrupt if appropriate */
|
||||
if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) {
|
||||
/* Allow only clock-available interrupt */
|
||||
devctl = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
devctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_DEVICE_CTL, &err);
|
||||
if (err) {
|
||||
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)
|
|||
return 0;
|
||||
} else if (bus->clkstate == CLK_PENDING) {
|
||||
/* Cancel CA-only interrupt filter */
|
||||
devctl =
|
||||
brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
|
||||
devctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_DEVICE_CTL, &err);
|
||||
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
|
||||
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)
|
|||
timeout = jiffies +
|
||||
msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000);
|
||||
while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
|
||||
clkctl = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
clkctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_CHIPCLKCSR,
|
||||
&err);
|
||||
if (time_after(jiffies, timeout))
|
||||
|
@ -780,8 +777,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
|
|||
|
||||
if (bus->clkstate == CLK_PENDING) {
|
||||
/* Cancel CA-only interrupt filter */
|
||||
devctl = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
devctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_DEVICE_CTL, &err);
|
||||
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
|
||||
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)
|
|||
|
||||
/* Wait until the packet has been flushed (device/FIFO stable) */
|
||||
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);
|
||||
lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
|
||||
lo = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_RFRAMEBCLO, NULL);
|
||||
bus->f1regdata += 2;
|
||||
|
||||
|
@ -2184,14 +2180,10 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt,
|
|||
|
||||
for (i = 0; i < 3; i++) {
|
||||
u8 hi, lo;
|
||||
hi = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
SBSDIO_FUNC1_WFRAMEBCHI,
|
||||
NULL);
|
||||
lo = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
SBSDIO_FUNC1_WFRAMEBCLO,
|
||||
NULL);
|
||||
hi = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_WFRAMEBCHI, NULL);
|
||||
lo = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_WFRAMEBCLO, NULL);
|
||||
bus->f1regdata += 2;
|
||||
if ((hi == 0) && (lo == 0))
|
||||
break;
|
||||
|
@ -2310,7 +2302,7 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev)
|
|||
bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
|
||||
|
||||
/* 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);
|
||||
if (!err) {
|
||||
brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
|
||||
|
@ -2393,7 +2385,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
|
|||
|
||||
#ifdef DEBUG
|
||||
/* 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);
|
||||
if (err) {
|
||||
brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err);
|
||||
|
@ -2402,7 +2394,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
|
|||
#endif /* DEBUG */
|
||||
|
||||
/* 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);
|
||||
if (err) {
|
||||
brcmf_dbg(ERROR, "error reading CSR: %d\n",
|
||||
|
@ -2414,8 +2406,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
|
|||
devctl, clkctl);
|
||||
|
||||
if (SBSDIO_HTAV(clkctl)) {
|
||||
devctl = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
devctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_DEVICE_CTL, &err);
|
||||
if (err) {
|
||||
brcmf_dbg(ERROR, "error reading DEVCTL: %d\n",
|
||||
|
@ -2552,12 +2543,10 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
|
|||
|
||||
for (i = 0; i < 3; i++) {
|
||||
u8 hi, lo;
|
||||
hi = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
hi = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_WFRAMEBCHI,
|
||||
NULL);
|
||||
lo = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_1,
|
||||
lo = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_WFRAMEBCLO,
|
||||
NULL);
|
||||
bus->f1regdata += 2;
|
||||
|
@ -2892,12 +2881,10 @@ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len)
|
|||
|
||||
for (i = 0; i < 3; i++) {
|
||||
u8 hi, lo;
|
||||
hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
|
||||
SBSDIO_FUNC1_WFRAMEBCHI,
|
||||
NULL);
|
||||
lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
|
||||
SBSDIO_FUNC1_WFRAMEBCLO,
|
||||
NULL);
|
||||
hi = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_WFRAMEBCHI, NULL);
|
||||
lo = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_WFRAMEBCLO, NULL);
|
||||
bus->f1regdata += 2;
|
||||
if (hi == 0 && lo == 0)
|
||||
break;
|
||||
|
@ -3471,8 +3458,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
|
|||
goto exit;
|
||||
|
||||
/* 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);
|
||||
if (!err) {
|
||||
brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
|
||||
|
@ -3495,7 +3481,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
|
|||
timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY);
|
||||
ready = 0;
|
||||
while (enable != ready) {
|
||||
ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0,
|
||||
ready = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SDIO_CCCR_IORx, NULL);
|
||||
if (time_after(jiffies, timeout))
|
||||
break;
|
||||
|
@ -3605,8 +3591,8 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
|
|||
|
||||
if (!bus->dpc_sched) {
|
||||
u8 devpend;
|
||||
devpend = brcmf_sdcard_cfg_read(bus->sdiodev,
|
||||
SDIO_FUNC_0, SDIO_CCCR_INTx,
|
||||
devpend = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SDIO_CCCR_INTx,
|
||||
NULL);
|
||||
intstatus =
|
||||
devpend & (INTR_STATUS_FUNC1 |
|
||||
|
@ -3747,8 +3733,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva)
|
|||
SBSDIO_FUNC1_CHIPCLKCSR,
|
||||
BRCMF_INIT_CLKCTL1, &err);
|
||||
if (!err)
|
||||
clkctl =
|
||||
brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
|
||||
clkctl = brcmf_sdio_regrb(bus->sdiodev,
|
||||
SBSDIO_FUNC1_CHIPCLKCSR, &err);
|
||||
|
||||
if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) {
|
||||
|
|
|
@ -434,7 +434,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev)
|
|||
|
||||
/* If register supported, wait for ALPAvail and then force ALP */
|
||||
/* 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);
|
||||
|
||||
if ((clkval & ~SBSDIO_AVBITS) != clkset) {
|
||||
|
@ -443,7 +443,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev)
|
|||
return -EACCES;
|
||||
}
|
||||
|
||||
SPINWAIT(((clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1,
|
||||
SPINWAIT(((clkval = brcmf_sdio_regrb(sdiodev,
|
||||
SBSDIO_FUNC1_CHIPCLKCSR, NULL)),
|
||||
!SBSDIO_ALPAV(clkval)),
|
||||
PMU_MAX_TRANSITION_DLY);
|
||||
|
|
|
@ -174,8 +174,6 @@ extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
|
|||
* data: data byte to write
|
||||
* 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,
|
||||
u32 addr, u8 data, int *err);
|
||||
|
||||
|
|
Loading…
Reference in New Issue