SD卡驱动原理浅析


http://cupidove.blog.163.com/blog/static/10056622011749047499/


http://linux4u.wikidot.com/mmc-controller-driver


http://tw.myblog.yahoo.com/chimei-015/article?mid=487&sc=1


 



Kernel 啟動後:
----->[core/core.c] mmc_init
        對mmc進行初始化


----->[card/block.c] mmc_blk_init()
        對mmc block進行初始化,申請一個block


----->[host/s3cmci.c] s3cmci_probe
        掛載s3cmci驅動


----->[core/core.c] mmc_rescan
        這是一個delay工作(INIT_DELAYED_WORK)
        掃描看看SD裝置上的sdio設備,sd卡和mmc卡


卡片插入後:
觸發GPG2 cd ioport


----->[host/s3cmci.c] s3cmci_irq_cd


----->[core/core.c] mmc_rescan
        同樣掃描SD裝置上的sdio設備、sd卡和mmc卡
        掃描到什麼就呼叫什麼函式mmc_attach_sdio()、mmc_attach_sd()、mmc_attach_mmc()


----->[core/sd.c] mmc_attach_sd


----->[core/sd.c] mmc_sd_init_card


----->[core/Mmc_ops.c] mmc_go_idle
        CMD0 resets all cards to idle state


----->[core/sd_ops.c] mmc_send_if_cond
        CMD8 compare SD1.0 and SD2.0


----->[core/sd_ops.c] mmc_send_app_op_cond
        在sd卡中,驅動循環發送CMD55、ACMD41給卡,讀取OCR寄存器
        (在發送ACMD前一定要先發送CMD55) 
        目前讀取的OCR=0x100000(OCR是由s3cmci.c中的.ocr_avail    = MMC_VDD_32_33設定,是我們設定的) 
        在供應電壓時須等待74個Clocks,使電壓跑到可工作範圍,此時卡片回應不再BUSY,     
        response是0x80ff8000=1000 0000 1111 1111 1000 0000 0000 0000


----->[core/sd_ops.c] mmc_all_send_cid
        CMD2 asks any card to send the CID numbers on the CMD line (any card that is connected to the host will respond).


----->[core/sd_ops.c] mmc_send_relative_addr
        CMD3 ask the card to publish a new relative address (RCA) .


----->[core/Mmc_ops.c] mmc_send_csd
        CMD9 addressed card sends its card-specific data (CSD) on the CMD line.


----->[core/Mmc_ops.c] mmc_select_card
        CMD7 command toggles a card between the stand-by and transfer states or between the programming and  
        disconnect states. In both cases the card is selected by its own relative address and gets deselected by any other
        address; address 0 deselects all.


----->[core/sd_ops.c] mmc_app_send_scr
        ACMD51 Reads the SD Configuration Register(SCR).


********以上Class 0的工作都做完了,初始化也成功了********


----->[core/Bus.c] mmc_add_card
        Register a new MMC card with the driver model.


----->[card/Block.c] mmc_blk_probe


----->[card/Block.c] mmc_blk_set_blksize
        CMD16 sets the block length (in bytes) for all following block commands (read and write). Default block length is
        specified in the CSD. Supported only if Partial block RD/WR operation are allowed in CSD.


----->[card/Block.c] mmc_blk_issue_rq
        CMD18 continuously transfers data blocks from card to host until interrupted by a STOP_TRANSMISSION command.


----->[host/s3cmci.c] do_pio_read
        又回到patch的s3cmci.c,kernel應該是不會有問題,所以看來do_pio_read問題很大


另外


drivers/mmc/card/block.c 會先註冊 /dev/mmcblk 的 device


所以這邊可以限制最大的mmcblk 號碼


#define MMC_SHIFT 3
#define MMC_NUM_MINORS (256 >> MMC_SHIFT)


    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()