SD/MMC驱动2(SD检测)

SD卡座资料(带检测引脚)

 

 

SD/MMC驱动2(SD检测)_第1张图片

 

可将CD引脚通过上拉电阻接到VDD用于SD的插入和拔出检测:

当拔出SD时,CD引脚的电压为VDD,否则为GND。

 

 

------------------------------------------

 

void mmc_rescan(struct work_struct *work)
{
 struct mmc_host *host =
  container_of(work, struct mmc_host, detect.work);
 u32 ocr;
 int err;

 mmc_bus_get(host);

 if (host->bus_ops == NULL) {  //When we find a MMC,when

 

......

/*
   * ...and finally MMC.
   */
  err = mmc_send_op_cond(host, 0, &ocr);
  if (!err) {
   if (mmc_attach_mmc(host, ocr))
    mmc_power_off(host);
   goto out; 
  }

  mmc_release_host(host);
  mmc_power_off(host);

 

 } else {  //remove the MMC
  if (host->bus_ops->detect && !host->bus_dead)
   host->bus_ops->detect(host);

  mmc_bus_put(host);
 }

 

 

(a).When we find a new MMC card:

mmc_attach_mmc->mmc_add_card->mmc_bus_probe->mmc_blk_probe

 

Add the MMC device node danamicly;

 

(b).When we remove a MMC card:

host->bus_ops->detect(host)->mmc_detect->mmc_remove->mmc_remove_card->mmc_bus_remove->mmc_blk_remove

Remove the MMC device node.

 

 

 

你可能感兴趣的:(SD/MMC驱动2(SD检测))