int sif_lldesc_write_raw(struct esp_pub *epub, u8 *buf, u32 len) { struct esp_sdio_ctrl *sctrl = NULL; u32 write_len; if (epub == NULL || buf == NULL) { ESSERT(0); return -EINVAL; } sctrl = (struct esp_sdio_ctrl *)epub->sif; switch(sctrl->target_id) { case 0x100: write_len = len; break; case 0x600: write_len = roundup(len, sctrl->slc_blk_sz); break; default: write_len = len; break; } return sif_io_raw((epub), (sctrl->slc_window_end_addr - (len)), (buf), (write_len), SIF_TO_DEVICE | SIF_BYTE_BASIS | SIF_INC_ADDR); }
/*send cmd to target, if aborted is true, inform target stop scan, report scan complete imediately return 1: complete over, 0: success, still have next scan, -1: hardware failure */ int sip_send_scan(struct esp_pub *epub) { struct cfg80211_scan_request *scan_req = epub->wl.scan_req; struct sk_buff *skb = NULL; struct sip_cmd_scan *scancmd; u8 *ptr = NULL; int i; u8 append_len, ssid_len; ESSERT(scan_req != NULL); ssid_len = scan_req->n_ssids == 0 ? 0: (scan_req->n_ssids == 1 ? scan_req->ssids->ssid_len: scan_req->ssids->ssid_len + (scan_req->ssids + 1)->ssid_len); append_len = ssid_len + scan_req->n_channels + scan_req->ie_len; skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_scan) + sizeof(struct sip_hdr) + append_len, SIP_CMD_SCAN); if (!skb) return -EINVAL; ptr = skb->data; scancmd = (struct sip_cmd_scan *)(ptr + sizeof(struct sip_hdr)); ptr += sizeof(struct sip_hdr); scancmd->aborted= false; if (scancmd->aborted==false) { ptr += sizeof(struct sip_cmd_scan); if (scan_req->n_ssids <=0 || (scan_req->n_ssids == 1&& ssid_len == 0)) { scancmd->ssid_len = 0; } else { scancmd->ssid_len = ssid_len; if(scan_req->ssids->ssid_len == ssid_len) memcpy(ptr, scan_req->ssids->ssid, scancmd->ssid_len); else memcpy(ptr, (scan_req->ssids + 1)->ssid, scancmd->ssid_len); } ptr += scancmd->ssid_len; scancmd->n_channels=scan_req->n_channels; for (i=0; i<scan_req->n_channels; i++) ptr[i] = scan_req->channels[i]->hw_value; ptr += scancmd->n_channels; if (scan_req->ie_len && scan_req->ie != NULL) { scancmd->ie_len=scan_req->ie_len; memcpy(ptr, scan_req->ie, scan_req->ie_len); } else { scancmd->ie_len = 0; } //add a flag that support two ssids, if(scan_req->n_ssids > 1) scancmd->ssid_len |= 0x80; } return sip_cmd_enqueue(epub->sip, skb); }
void sif_platform_ack_interrupt(struct esp_pub *epub) { struct esp_sdio_ctrl *sctrl = NULL; struct sdio_func *func = NULL; if (epub == NULL) { ESSERT(epub != NULL); return; } sctrl = (struct esp_sdio_ctrl *)epub->sif; func = sctrl->func; if (func == NULL) { ESSERT(func != NULL); return; } sdmmc_ack_interrupt(func->card->host); }
int sif_io_sync(struct esp_pub *epub, u32 addr, u8 *buf, u32 len, u32 flag) { int err = 0; u8 * ibuf = NULL; bool need_ibuf = false; struct esp_sdio_ctrl *sctrl = NULL; struct sdio_func *func = NULL; if (epub == NULL || buf == NULL) { ESSERT(0); err = -EINVAL; goto _exit; } sctrl = (struct esp_sdio_ctrl *)epub->sif; func = sctrl->func; if (func == NULL) { ESSERT(0); err = -EINVAL; goto _exit; } if (bad_buf(buf)) { esp_dbg(ESP_DBG_TRACE, "%s dst 0x%08x, len %d badbuf\n", __func__, addr, len); need_ibuf = true; ibuf = sctrl->dma_buffer; } else { ibuf = buf; } if (flag & SIF_BLOCK_BASIS) { /* round up for block data transcation */ } if (flag & SIF_TO_DEVICE) { esp_dbg(ESP_DBG_TRACE, "%s to addr 0x%08x, len %d \n", __func__, addr, len); if (need_ibuf) memcpy(ibuf, buf, len); sdio_claim_host(func); if (flag & SIF_FIXED_ADDR) err = sdio_writesb(func, addr, ibuf, len); else if (flag & SIF_INC_ADDR) { err = sdio_memcpy_toio(func, addr, ibuf, len); } sif_platform_check_r1_ready(epub); sdio_release_host(func); } else if (flag & SIF_FROM_DEVICE) { esp_dbg(ESP_DBG_TRACE, "%s from addr 0x%08x, len %d \n", __func__, addr, len); sdio_claim_host(func); if (flag & SIF_FIXED_ADDR) err = sdio_readsb(func, ibuf, addr, len); else if (flag & SIF_INC_ADDR) { err = sdio_memcpy_fromio(func, ibuf, addr, len); } sdio_release_host(func); if (!err && need_ibuf) memcpy(buf, ibuf, len); } _exit: return err; }