int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, uint regaddr, u8 *byte) { int err_ret; brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr); brcmf_pm_resume_wait(sdiodev, &sdiodev->request_byte_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; if (rw && func == 0) { /* handle F0 separately */ err_ret = brcmf_sdioh_f0_write_byte(sdiodev, regaddr, byte); } else { sdio_claim_host(sdiodev->func[func]); if (rw) /* CMD52 Write */ sdio_writeb(sdiodev->func[func], *byte, regaddr, &err_ret); else if (func == 0) { *byte = sdio_f0_readb(sdiodev->func[func], regaddr, &err_ret); } else { *byte = sdio_readb(sdiodev->func[func], regaddr, &err_ret); } sdio_release_host(sdiodev->func[func]); } if (err_ret) brcmf_dbg(ERROR, "Failed to %s byte F%d:@0x%05x=%02x, Err: %d\n", rw ? "write" : "read", func, regaddr, *byte, err_ret); return err_ret; }
/** * @brief This function reads updates the Cmd52 value in dev structure * * @param priv A pointer to bt_private structure * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sd_read_cmd52_val(bt_private * priv) { int ret = BT_STATUS_SUCCESS; u8 func, reg, val; struct sdio_mmc_card *card = (struct sdio_mmc_card *) priv->bt_dev.card; ENTER(); func = priv->bt_dev.cmd52_func; reg = priv->bt_dev.cmd52_reg; sdio_claim_host(card->func); if (func) val = sdio_readb(card->func, reg, &ret); else val = sdio_f0_readb(card->func, reg, &ret); sdio_release_host(card->func); if (ret) { PRINTM(ERROR, "Cannot read value from func %d reg %d\n", func, reg); } else { priv->bt_dev.cmd52_val = val; } LEAVE(); return ret; }
/** @brief This function dump the sdio register * * @param handle A Pointer to the moal_handle structure * @return N/A */ void woal_dump_sdio_reg(moal_handle *handle) { int ret = 0; t_u8 data, i; int fun0_reg[] = { 0x05, 0x04 }; t_u8 array_size = 0; int fun1_reg_8897[] = { 0x03, 0x04, 0x05, 0x06, 0x07, 0xC0, 0xC1 }; int fun1_reg_other[] = { 0x03, 0x04, 0x05, 0x60, 0x61 }; int *fun1_reg = NULL; for (i = 0; i < ARRAY_SIZE(fun0_reg); i++) { data = sdio_f0_readb(((struct sdio_mmc_card *)handle->card)-> func, fun0_reg[i], &ret); PRINTM(MMSG, "fun0: reg 0x%02x=0x%02x ret=%d\n", fun0_reg[i], data, ret); } if (handle->card_type == CARD_TYPE_SD8897) { fun1_reg = fun1_reg_8897; array_size = sizeof(fun1_reg_8897) / sizeof(int); } else { fun1_reg = fun1_reg_other; array_size = sizeof(fun1_reg_other) / sizeof(int); } for (i = 0; i < array_size; i++) { data = sdio_readb(((struct sdio_mmc_card *)handle->card)->func, fun1_reg[i], &ret); PRINTM(MMSG, "fun1: reg 0x%02x=0x%02x ret=%d\n", fun1_reg[i], data, ret); } return; }
/** @brief This function dump the sdio register * * @param handle A Pointer to the moal_handle structure * @return N/A */ void woal_dump_sdio_reg(moal_handle * handle) { int ret = 0; t_u8 data, i; int fun0_reg[] = { 0x05, 0x04 }; t_u8 array_size = 0; int fun1_reg[] = { 0x03, 0x04, 0x05, 0x60, 0x61 }; for (i = 0; i < ARRAY_SIZE(fun0_reg); i++) { data = sdio_f0_readb(((struct sdio_mmc_card *)handle-> card)->func, fun0_reg[i], &ret); PRINTM(MMSG, "fun0: reg 0x%02x=0x%02x ret=%d\n", fun0_reg[i], data, ret); } array_size = ARRAY_SIZE(fun1_reg); for (i = 0; i < array_size; i++) { data = sdio_readb(((struct sdio_mmc_card *)handle->card)->func, fun1_reg[i], &ret); PRINTM(MMSG, "fun1: reg 0x%02x=0x%02x ret=%d\n", fun1_reg[i], data, ret); } return; }
static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { int ret; struct sdio_func *func = wl_to_func(wl); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x", addr, ((u8 *)buf)[0]); } else { if (fixed) ret = sdio_readsb(func, buf, addr, len); else ret = sdio_memcpy_fromio(func, buf, addr, len); wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %zu bytes", addr, len); wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); } if (ret) wl1271_error("sdio read failed (%d)", ret); }
/** @brief This function dump the sdio register * * @param handle A Pointer to the moal_handle structure * @return N/A */ void woal_dump_sdio_reg(moal_handle * handle) { int ret = 0; t_u8 data, i, len; int fun0_reg[] = { 0x05, 0x04 }; int fun1_reg[] = { 0x03, 0x04, 0x05, 0x60, 0x61 }; len = sizeof(fun0_reg) / sizeof(fun0_reg[0]); for (i = 0; i < len; i++) { data = sdio_f0_readb(((struct sdio_mmc_card *)handle->card)-> func, fun0_reg[i], &ret); PRINTM(MMSG, "fun0: reg 0x%02x=0x%02x ret=%d\n", fun0_reg[i], data, ret); } len = sizeof(fun1_reg) / sizeof(fun1_reg[0]); for (i = 0; i < len; i++) { data = sdio_readb(((struct sdio_mmc_card *)handle->card)->func, fun1_reg[i], &ret); PRINTM(MMSG, "fun1: reg 0x%02x=0x%02x ret=%d\n", fun1_reg[i], data, ret); } return; }
u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) { PADAPTER padapter; struct dvobj_priv *psdiodev; PSDIO_DATA psdio; u8 v =0; struct sdio_func *func; bool claim_needed; padapter = pintfhdl->padapter; psdiodev = pintfhdl->pintf_dev; psdio = &psdiodev->intf_data; if (padapter->bSurpriseRemoved){ /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __FUNCTION__); */ return v; } func = psdio->func; claim_needed = rtw_sdio_claim_host_needed(func); if (claim_needed) sdio_claim_host(func); v = sdio_f0_readb(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); return v; }
static int generic_read_bytes(unsigned int uFunc, unsigned int uHwAddr, unsigned char *pData, unsigned int uLen, unsigned int bIncAddr, unsigned int bMore) { unsigned int i; int ret; PDEBUG("%s: uFunc %d uHwAddr %d pData %x uLen %d bIncAddr %d\n", __func__, uFunc, uHwAddr, (unsigned int)pData, uLen, bIncAddr); BUG_ON(uFunc != SDIO_CTRL_FUNC && uFunc != SDIO_WLAN_FUNC); for (i = 0; i < uLen; i++) { if (uFunc == 0) *pData = sdio_f0_readb(tiwlan_func[uFunc], uHwAddr, &ret); else *pData = sdio_readb(tiwlan_func[uFunc], uHwAddr, &ret); if (0 != ret) { printk(KERN_ERR "%s: function %d sdio error: %d\n", __func__, uFunc, ret); return -1; } pData++; if (bIncAddr) uHwAddr++; } return 0; }
u8 sdio_io_readb(struct esp_pub *epub, int addr, int *res) { struct esp_sdio_ctrl *sctrl = NULL; struct sdio_func *func = NULL; sctrl = (struct esp_sdio_ctrl *)epub->sif; func = sctrl->func; if(func->num == 0) return sdio_f0_readb(func, addr, res); else return sdio_readb(func, addr, res); }
int bcmsdio_cmd52(unsigned int data, unsigned addr, unsigned rw, unsigned func,int *perrval) { struct sdio_func *function = func_data[BCM_SDIO_FN1]->func; int ret = data; int count = 0; *perrval = 0; if (function == NULL) { BCM_DEBUG_PRINT(ERROR_LEVEL, KERN_ALERT " ** NULL FUNC PTR: x%x\n", func); return -ENON_INTF_ERR; } sdio_claim_host(function); if(func_data[BCM_SDIO_FN1]->bremoved) { ret = -ENON_INTF_ERR; BCM_DEBUG_PRINT(ERROR_LEVEL, KERN_ALERT "Error: bremoved is non zero :%d", func_data[BCM_SDIO_FN1]->bremoved); goto rel_host; } while ( count < SDIO_CMD_RETRIES ) { if (rw) { if(func != BCM_SDIO_FN0) sdio_writeb(function, data, addr,perrval); else sdio_f0_writeb(function, data, addr,perrval); } else { if(func != 0 ) ret = sdio_readb(function, addr,perrval); else ret = sdio_f0_readb(function,addr,perrval); } if(!(*perrval)) break; count++; } if(count) BCM_DEBUG_PRINT(debuglevel, "Count is higher than 0 for cmd52: %x\n", count); if(*perrval) { BCM_DEBUG_PRINT(debuglevel, "ERR IN CMD52 %d rw: %x addr: %x, count: %x\n", *perrval, rw, addr, count); } rel_host: sdio_release_host(function); return ret; }
/** * @brief This function updates card reg based on the Cmd52 value in dev structure * * @param handle A pointer to moal_handle structure * @param func A pointer to store func variable * @param reg A pointer to store reg variable * @param val A pointer to store val variable * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE */ int woal_sdio_read_write_cmd52(moal_handle *handle, int func, int reg, int val) { int ret = MLAN_STATUS_SUCCESS; struct sdio_mmc_card *card = (struct sdio_mmc_card *)handle->card; ENTER(); /* Save current func and reg for read */ handle->cmd52_func = func; handle->cmd52_reg = reg; sdio_claim_host(card->func); if (val >= 0) { /* Perform actual write only if val is provided */ if (func) sdio_writeb(card->func, val, reg, &ret); else sdio_f0_writeb(card->func, val, reg, &ret); if (ret) { PRINTM(MERROR, "Cannot write value (0x%x) to func %d reg 0x%x\n", val, func, reg); } else { PRINTM(MMSG, "write value (0x%x) to func %d reg 0x%x\n", (u8)val, func, reg); handle->cmd52_val = val; } } else { if (func) val = sdio_readb(card->func, reg, &ret); else val = sdio_f0_readb(card->func, reg, &ret); if (ret) { PRINTM(MERROR, "Cannot read value from func %d reg 0x%x\n", func, reg); } else { PRINTM(MMSG, "read value (0x%x) from func %d reg 0x%x\n", (u8)val, func, reg); handle->cmd52_val = val; } } sdio_release_host(card->func); LEAVE(); return ret; }
/** @brief This function dump the SDIO register * * @param priv A Pointer to the bt_private structure * * @return N/A */ void bt_dump_sdio_regs(bt_private *priv) { struct sdio_mmc_card *card = priv->bt_dev.card; int ret = BT_STATUS_SUCCESS; char buf[256], *ptr; u8 loop, func, data; unsigned int reg, reg_start, reg_end; u8 loop_num = 2; if (priv->adapter->ps_state) sbi_wakeup_firmware(priv); sdio_claim_host(card->func); for (loop = 0; loop < loop_num; loop++) { memset(buf, 0, sizeof(buf)); ptr = buf; if (loop == 0) { /* Read the registers of SDIO function0 */ func = loop; reg_start = 0; reg_end = 9; } else { func = 2; reg_start = 0; reg_end = 0x09; } ptr += sprintf(ptr, "SDIO Func%d (%#x-%#x): ", func, reg_start, reg_end); for (reg = reg_start; reg <= reg_end;) { if (func == 0) data = sdio_f0_readb(card->func, reg, &ret); else data = sdio_readb(card->func, reg, &ret); if (!ret) ptr += sprintf(ptr, "%02x ", data); else { ptr += sprintf(ptr, "ERR"); break; } reg++; } PRINTM(MSG, "%s\n", buf); } sdio_release_host(card->func); }
u8 sd_f0_read8(PSDIO_DATA psdio, u32 addr, s32 *err) { u8 v; struct sdio_func *func; _func_enter_; func = psdio->func; sdio_claim_host(func); v = sdio_f0_readb(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 int __must_check wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, size_t len, bool fixed) { int ret; struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); sdio_claim_host(func); if (unlikely(dump)) { printk(KERN_DEBUG "wlcore_sdio: READ from 0x%04x\n", addr); print_hex_dump(KERN_DEBUG, "wlcore_sdio: READ ", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false); } if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); dev_dbg(child->parent, "sdio read 52 addr 0x%x, byte 0x%02x\n", addr, ((u8 *)buf)[0]); } else { if (fixed) ret = sdio_readsb(func, buf, addr, len); else ret = sdio_memcpy_fromio(func, buf, addr, len); dev_dbg(child->parent, "sdio read 53 addr 0x%x, %zu bytes\n", addr, len); } sdio_release_host(func); if (WARN_ON(ret)) dev_err(child->parent, "sdio read failed (%d)\n", ret); return ret; }
static int cw1200_request_irq(struct hwbus_priv *self) { int ret; u8 cccr; cccr = sdio_f0_readb(self->func, SDIO_CCCR_IENx, &ret); if (WARN_ON(ret)) goto err; /* Master interrupt enable ... */ cccr |= BIT(0); /* ... for our function */ cccr |= BIT(self->func->num); sdio_f0_writeb(self->func, cccr, SDIO_CCCR_IENx, &ret); if (WARN_ON(ret)) goto err; ret = enable_irq_wake(self->pdata->irq); if (WARN_ON(ret)) goto err; /* Request the IRQ */ ret = request_threaded_irq(self->pdata->irq, cw1200_gpio_hardirq, cw1200_gpio_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "cw1200_wlan_irq", self); if (WARN_ON(ret)) goto err; return 0; err: return ret; }
static ssize_t iwm_debugfs_sdio_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { struct iwm_priv *iwm = filp->private_data; struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm); char *buf; u8 cccr; int buf_len = 4096, ret; size_t len = 0; if (*ppos != 0) return 0; if (count < sizeof(buf)) return -ENOSPC; buf = kzalloc(buf_len, GFP_KERNEL); if (!buf) return -ENOMEM; sdio_claim_host(hw->func); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IOEx, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_IOEx\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_IOEx: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IORx, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_IORx\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_IORx: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IENx, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_IENx\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_IENx: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_INTx, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_INTx\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_INTx: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_ABORT, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_ABORTx\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_ABORT: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IF, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_IF\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_IF: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_CAPS, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_CAPS\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_CAPS: 0x%x\n", cccr); cccr = sdio_f0_readb(hw->func, SDIO_CCCR_CIS, &ret); if (ret) { IWM_ERR(iwm, "Could not read SDIO_CCCR_CIS\n"); goto err; } len += snprintf(buf + len, buf_len - len, "CCCR_CIS: 0x%x\n", cccr); ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len); err: sdio_release_host(hw->func); kfree(buf); return ret; }