欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

I.MX6 SD卡热插拔的识别过程

程序员文章站 2022-04-28 08:00:41
...

前言

内核版本:3.0,35


识别流程

**arch/arm/mach-mx6/board-mx6q_sabresd.c **

	imx6q_add_sdhci_usdhc_imx(2, &mx6q_sabresd_sd3_data);
		static const struct esdhc_platform_data mx6q_sabresd_sd3_data __initconst = {                                                                                       
		    .cd_gpio = SABRESD_SD3_CD,
		    //.wp_gpio = SABRESD_SD3_WP,
		    .wp_gpio = -EINVAL,
		    .keep_power_at_suspend = 1,
		    .support_8bit = 0,
		    .delay_line = 0,
		    .cd_type = ESDHC_CD_GPIO,
		    .runtime_pm = 1,
		};
#define SABRESD_SD3_CD      IMX_GPIO_NR(7, 1)	

需要将cd_gpio配置成GPIO模式

 arch/arm/mach-mx6/board-mx6q_sabresd.h
		MX6Q_PAD_SD3_DAT4__GPIO_7_1,            /* SD3_CD */
    流程:
            mmc/host/sdhci-esdhc-imx.c		//插入SD卡 就会触发中断cd_irq
                esdhc_pltfm_init()->request_irq(gpio_to_irq(boarddata->cd_gpio), cd_irq.....)-> cd_irq()->tasklet_schedule(&sdhost->card_tasklet)
            mmc/host/sdhci.c
                tasklet_init(&host->card_tasklet,sdhci_tasklet_card, (unsigned long)host) -> sdhci_tasklet_card() -> mmc_detect_change()
            mmc/core/core.c
                mmc_detect_change() -> mmc_schedule_delayed_work(&host->detect, delay)
            mmc/core/host.c
                mmc_alloc_host()-> INIT_DELAYED_WORK(&host->detect, mmc_rescan)
            mmc/core/core.c
                mmc_rescan()-> mmc_rescan_try_freq()-> mmc_attach_sd(host)
            mmc/core/sd.c
                mmc_attach_sd()->mmc_add_card()
            mmc/core/bus.c
                mmc_add_card()-> printk(KERN_INFO "%s: new %s%s%s card at address %04x\n"
                                mmc1: new high speed SDHC card at address 0001

android 自动挂载

device/fsl/sabresd_6dq/fstab.freescale

/devices/platform/sdhci-esdhc-imx.2/mmc_host/mmc1 /mnt/media_rw/extsd exfat defaults voldmanaged=extsd:auto