淺析Linux下sdio介面對sd卡硬體檢測流程

來源:互聯網
上載者:User

淺析Linux下sdio介面對sd卡硬體檢測流程

static struct pxamci_platform_data luther_mci_platform_data = {
    .detect_delay    = 20,//檢測到sd裝置插入之後,延時detect_delay個tick之後,執行函數
    .ocr_mask    = MMC_VDD_32_33|MMC_VDD_33_34,

    .init         = luther_mci_init,
    .setpower    = luther_mci_setpower,
    .exit        = luther_mci_exit,
};

在luther_init()->
//luther_mmc_slot[0].gpio_cd = mfp_to_gpio(MFP_CFG_PIN(GPIO8_GPIO_MMC_DETECT));
所以設定GPIO8作為sd卡插入的中斷檢測IO
//pxamci_probe()->該函數是和platform的裝置匹配上之後,會立即調用的probe
//host->pdata->init(&pdev->dev, pxamci_detect_irq, mmc); 將mmc作為devid的傳遞參數
//就是調用裝置函數luther_mci_platform_data->luther_mci_init()
//request_irq(cd_irq, luther_detect_int,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,"MMC card detect", data);
//這樣將中斷註冊到了物理硬體系統
當GPIO8檢測到電平變化,將觸發pxamci_detect_irq()中斷處理函數,
該函數會繼續調用mmc_detect_change()->mmc_schedule_delayed_work(&host->detect, delay);調度該host的自動檢測函數

對於host->detect的初始化是這樣完成的:
pxamci_probe()->mmc_alloc_host()申請平台SD單元對應的mmc_host結構體->
INIT_DELAYED_WORK(&host->detect, mmc_rescan)建立該平台SD單元對應的sdio裝置插入
檢測核心work_queue工作隊列函數mmc_rescan->mmc_rescan()這是一個共用函數,如果有4個SD卡控制器在你的arm平台上,
那麼4個SD控制器將分別對應4個mmc_host結構體,分別對應4個sdio裝置插入檢測核心work_queue工作隊列,
但工作隊列都將調用mmc_rescan()這1個函數,所以linux核心的物件導向的類共用機製做得很好->

使用mmc_alloc_host()函數申請的平台mmc_host結構體,沒有對其分配bus匯流排指標,僅分配了它所屬的parent,即這個
mmc不屬於某個bus,所以這個mmc_host對應的dev也不會從任何bus匯流排上分配到任何driver驅動,這也是應該的.

mmc_attach_sdio()->mmc_attach_bus(host, &mmc_sdio_ops);
mmc_sdio_init_card()->sdio_init_func()->sdio_alloc_func()->這樣當detect到sdio裝置之後,
將分配dev對應的sdio_func結構題,

調用sdio_read_func_cis()的cistpl_manfid()來填充sd卡的vendor,這樣當wlan驅動probe的時候,
就會和wlan驅動的id表中的vendor嘗試匹配,如果成功,那麼wlan驅動將接管該檢測到的sd卡[gliethttp_20080626].

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.