u16 sd_read16(struct intf_hdl *pintfhdl, u32 addr, s32 *err) { PADAPTER padapter; struct dvobj_priv *psdiodev; PSDIO_DATA psdio; u16 v=0; struct sdio_func *func; bool claim_needed; _func_enter_; padapter = pintfhdl->padapter; psdiodev = pintfhdl->pintf_dev; psdio = &psdiodev->intf_data; if(padapter->bSurpriseRemoved){ //DBG_871X(" %s (padapter->bSurpriseRemoved )!!!\n",__FUNCTION__); return v; } func = psdio->func; claim_needed = rtw_sdio_claim_host_needed(func); if (claim_needed) sdio_claim_host(func); v = sdio_readw(func, addr, err); if (claim_needed) sdio_release_host(func); if (err && *err) DBG_871X(KERN_ERR "%s: FAIL!(%d) addr=0x%05x\n", __func__, *err, addr); _func_exit_; return v; }
int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, uint addr, u32 *word, uint nbytes) { int err_ret = -EIO; if (func == 0) { brcmf_dbg(ERROR, "Only CMD52 allowed to F0\n"); return -EINVAL; } brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", rw, func, addr, nbytes); brcmf_pm_resume_wait(sdiodev, &sdiodev->request_word_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; /* Claim host controller */ sdio_claim_host(sdiodev->func[func]); if (rw) { /* CMD52 Write */ if (nbytes == 4) sdio_writel(sdiodev->func[func], *word, addr, &err_ret); else if (nbytes == 2) sdio_writew(sdiodev->func[func], (*word & 0xFFFF), addr, &err_ret); else brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); } else { /* CMD52 Read */ if (nbytes == 4) *word = sdio_readl(sdiodev->func[func], addr, &err_ret); else if (nbytes == 2) *word = sdio_readw(sdiodev->func[func], addr, &err_ret) & 0xFFFF; else brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes); } /* Release host controller */ sdio_release_host(sdiodev->func[func]); if (err_ret) brcmf_dbg(ERROR, "Failed to %s word, Err: 0x%08x\n", rw ? "write" : "read", err_ret); return err_ret; }
u16 sd_read16(PSDIO_DATA psdio, u32 addr, s32 *err) { u16 v; struct sdio_func *func; _func_enter_; func = psdio->func; sdio_claim_host(func); v = sdio_readw(func, addr, err); sdio_release_host(func); if (err && *err) DBG_871X(KERN_ERR "%s: FAIL!(%d) addr=0x%05x\n", __func__, *err, addr); _func_exit_; return v; }
static u16 ssb_sdio_read16(struct ssb_device *dev, u16 offset) { struct ssb_bus *bus = dev->bus; u16 val = 0xffff; int error = 0; sdio_claim_host(bus->host_sdio); if (unlikely(ssb_sdio_switch_core(bus, dev))) goto out; offset |= bus->sdio_sbaddr & 0xffff; offset &= SBSDIO_SB_OFT_ADDR_MASK; val = sdio_readw(bus->host_sdio, offset, &error); if (error) { dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %04x, error %d\n", bus->sdio_sbaddr >> 16, offset, val, error); } out: sdio_release_host(bus->host_sdio); return val; }