飞思卡尔开发板留有可插拨的SD卡卡槽,BSP包中提供了热插拨的检测机制。在sdhci_probe_slot函数中,gpio_sdhc_active函数初始化SD卡相关的GPIO口,包括SD卡检测脚的初始化。下面的程序实现SD卡检测中断号的申请,以及中断的触发方式:
host->detect_irq = platform_get_irq(pdev, 1);//申请卡检测中断号
if (!host->detect_irq)
{
host->flags &= ~SDHCI_CD_PRESENT;
if ((pdev->id >= 0) && (pdev->id < MXC_SDHCI_NUM))
mxc_fix_chips[pdev->id] = chip;
goto no_detect_irq;
}
do
{
ret = host->plat_data->status(host->mmc->parent);//获取SD卡的存在状态
if (ret)//根据当前SD卡存在状态设置卡检测中断触发类型
set_irq_type(host->detect_irq, IRQF_TRIGGER_FALLING);
else
set_irq_type(host->detect_irq, IRQF_TRIGGER_RISING);
} while (ret != host->plat_data->status(host->mmc->parent));
ret = host->plat_data->status(host->mmc->parent);
程序首先使用platform_get_irq