主要平台imx6,wifi晶元為博通
寫資料
dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
dhd_sendpkt(&dhd->pub, ifidx, pktbuf);
dhd_bus_txdata(dhdp->bus, pktbuf);
dhdsdio_txpkt(bus, chan, &pkt, 1, true);
dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), sdio_func_2, f2sync,pktdata(osh, head_pkt), total_len, pkt_chain, null, null, txretries);
bcmsdh_send_buf(bus->sdh, addr, fn, flags, buf, nbytes,pkt, complete, handle);
bcmsdhsdio_set_sbaddr_window(bcmsdh, addr, false)sdioh_request_buffer(bcmsdh->sdioh, sdioh_data_pio, incr_fix,sdioh_write, fn, addr, width, nbytes, buf, pkt);
sdioh_buffer_tofrom_bus(sd, fix_inc, write, func, addr,pktdata(sd->osh, tmppkt), roundup(buf_len, (dma_align_mask+1)));
sdio_memcpy_toio(sd->func[func], addr, buf, len);
以上主要描述了驅動主要寫資料流程,下面具體分析
最後主要呼叫
int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz)
; struct mmc_command cmd = ;
struct mmc_data data = ;
struct scatterlist sg;
bug_on(!card);
bug_on(fn > 7);
bug_on(blocks == 1 && blksz > 512);
warn_on(blocks == 0);
warn_on(blksz == 0);
/* sanity check */
if (addr & ~0x1ffff)
return -einval;
mrq.cmd = &cmd;
mrq.data = &data;
cmd.opcode = sd_io_rw_extended; //cmd53
cmd.arg = write ? 0x80000000 : 0x00000000; //讀寫
cmd.arg |= fn << 28;//func->num
cmd.arg |= incr_addr ? 0x04000000 : 0x00000000;
cmd.arg |= addr << 9;//位址
if (blocks == 1 && blksz <= 512)
cmd.arg |= (blksz == 512) ? 0 : blksz; /* byte mode */
else
cmd.arg |= 0x08000000 | blocks; /* block mode */
cmd.flags = mmc_rsp_spi_r5 | mmc_rsp_r5 | mmc_cmd_adtc;
data.blksz = blksz;
data.blocks = blocks;
data.flags = write ? mmc_data_write : mmc_data_read;
data.sg = &sg;
data.sg_len = 1;
sg_init_one(&sg, buf, blksz * blocks);//初始化sg,找到buf對應的物理頁位址,為dma傳輸做準備
mmc_set_data_timeout(&data, card);
mmc_wait_for_req(card->host, &mrq);//傳送資料,並且等待返回
if (cmd.error)
return cmd.error;
if (data.error)
return data.error;
if (mmc_host_is_spi(card->host)) else
return 0;
}
呼叫host->ops->request(host, mrq);
即sdhci_request傳送資料
sdhci_send_command(host, mrq->cmd);呼叫
static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
//void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
static void sdhci_set_transfer_irqs(struct sdhci_host *host)
static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
sdhci_writew(host, sdhci_make_cmd(cmd->opcode, flags), sdhci_command);
準備好dma資料以後,寫sdhci_command為觸發中斷,呼叫host dma中斷處理資料sdhci_irq,
static irqreturn_t sdhci_irq(int irq, void *dev_id)
printk("*** %s got interrupt: 0x%08x\n",
mmc_hostname(host->mmc), intmask);
if (intmask & (sdhci_int_card_insert | sdhci_int_card_remove))
intmask &= ~(sdhci_int_card_insert | sdhci_int_card_remove);
if (intmask & sdhci_int_cmd_mask)
if (intmask & sdhci_int_data_mask)
intmask &= ~(sdhci_int_cmd_mask | sdhci_int_data_mask);
intmask &= ~sdhci_int_error;
if (intmask & sdhci_int_bus_power)
mmiowb();
mmiowb();//是為了保證編譯器順序編譯,防止編譯器優化打亂執行順序
讀資料和該流程類似。
WIFI SDIO 五問五答
1 在sd.c的檔案中定義的host max mclk是怎麼定義的?197000000對應的clk為多少hz?具體的換算公式是怎麼樣的?修改這個clk會影響哪些效能?define host max mclk 197000000 197mhz 在定義最快跑多少 假設max clk 在50mhz 但如果...
java讀寫資料
1 public class fileinputstream extends inputstream fileinputstream 從檔案系統中的某個檔案中獲得輸入位元組。哪些檔案可用取決於主機環境。fileinputstream 用於讀取諸如影象資料之類的原始位元組流。要讀取字元流,請考慮使用 ...
讀寫Excel資料
獲取odbc中excel驅動 include include cstring cxxdlg getexceldriver pszbuf strchr pszbuf,0 1 while pszbuf 1 0 return sdriver 寫入excel void cxxdlg onwriteexcel...