Initialization of eMMC host and scan of devices connected to this host

Source: Internet
Author: User
The makefile and DW-related config below the driver/mmc/host are as follows:
obj-$ (CONFIG_MMC_DW) + + DW_MMC.O
obj-$ (CONFIG_MMC_DW_PLTFM) + + DW_MMC-PLTFM.O
obj-$ (Config_mmc_dw_exynos) + + DW_MMC-EXYNOS.O
obj-$ (CONFIG_MMC_DW_K3) + + DW_MMC-K3.O
obj-$ (CONFIG_MMC_DW_PCI) + + DW_MMC-PCI.O
obj-$ (config_mmc_dw_rockchip) + + DW_MMC-ROCKCHIP.O
I opened Config_mmc_dw and Config_mmc_dw_k3.
So the entry function of DW is in the DW_MMC-K3.C
static struct Platform_driver Dw_mci_k3_pltfm_driver = {
. Probe = Dw_mci_k3_probe,
. remove = Dw_mci_pltfm_remove,
. Driver = {
. Name = "Dwmmc_k3",
. of_match_table = Dw_mci_k3_match,
. PM = &dw_mci_k3_pmops,
},
};

Module_platform_driver (Dw_mci_k3_pltfm_driver);
If you detect in DTS
static const struct OF_DEVICE_ID dw_mci_k3_match[] = {
{. compatible = "HISILICON,HI4511-DW-MSHC",. Data = &k3_drv_data,},
{. compatible = "HISILICON,HI6220-DW-MSHC",. Data = &hi6220_data,},
{},
};

The two strings are called Dw_mci_k3_probe
static int dw_mci_k3_probe (struct platform_device *pdev)
{
const struct Dw_mci_drv_data *drv_data;
const struct OF_DEVICE_ID *match;
Get Drv_data In this case is K3_drv_data
Match = Of_match_node (Dw_mci_k3_match, Pdev->dev.of_node);
Drv_data = match->data;
Call Dw_mci_pltfm_register
Return Dw_mci_pltfm_register (Pdev, drv_data);
}
int Dw_mci_pltfm_register (struct platform_device *pdev,
const struct Dw_mci_drv_data *drv_data)
{
struct DW_MCI *host;
struct resource *regs;

Host = Devm_kzalloc (&pdev->dev, sizeof (struct DW_MCI), gfp_kernel);
if (!host)
Return-enomem;
Get an IRQ
HOST->IRQ = PLATFORM_GET_IRQ (Pdev, 0);
if (Host->irq < 0)
Return host->irq;

Host->drv_data = Drv_data;
Host->dev = &pdev->dev;
host->irq_flags = 0;
Host->pdata = pdev->dev.platform_data;
Get the register address of this host
Regs = Platform_get_resource (Pdev, Ioresource_mem, 0);
Do Ioremap to Reg so that you can access this register address in kernel
Host->regs = Devm_ioremap_resource (&pdev->dev, regs);
if (Is_err (Host->regs))
Return Ptr_err (Host->regs);

/* Get registers ' physical base address * *
Host->phy_regs = regs->start;
Save Drv_data
Platform_set_drvdata (Pdev, host);
Keep probe.
return Dw_mci_probe (host);
}
In Dw_mci_probe, other variables are parse from DTS such as: Ciu/biu
HOST-&GT;BIU_CLK = Devm_clk_get (Host->dev, "Biu");
if (Is_err (HOST-&GT;BIU_CLK)) {
dev_dbg (Host->dev, "Biu clock not available\n");
} else {
ret = clk_prepare_enable (HOST-&GT;BIU_CLK);
if (ret) {
Dev_err (Host->dev, "failed to enable Biu clock\n");
return ret;
}
}

But the final order is the following paragraph.
/* We need at least one slot to succeed * *
for (i = 0; i < host->num_slots; i++) {
RET = Dw_mci_init_slot (host, i);
if (ret)
dev_dbg (Host->dev, "slot%d init failed\n", i);
Else
init_slots++;
}
In Dw_mci_init_slot, call Mmc_alloc_host/mmc_add_host to add this MMC host to kernel.
The most important thing in Mmc_alloc_host is Init_delayed_work (&host->detect, Mmc_rescan), which can be found by Mmc_rescan to discover the devices connected to the host. The specific callstack are as follows:
[11.777356] [<ffffffc00008a438>] dump_backtrace+0x0/0x164
[11.782759] [<ffffffc00008a5b8>] show_stack+0x1c/0x28
[11.787816] [<ffffffc000bbca58>] dump_stack+0x78/0x98
[11.792870] [<ffffffc000bb9348>] panic+0xe8/0x244
[11.797577] [<ffffffc00092c564>] mmc_add_card+0xc0/0x228
[11.802894] [<ffffffc00092f71c>] mmc_attach_mmc+0xa8/0x18c
[11.808382] [<ffffffc00092bb8c>] Mmc_rescan+0x2a8/0x2f8
[11.813612] [<ffffffc0000d4ef4>] PROCESS_ONE_WORK+0X154/0X3BC
[11.819362] [<ffffffc0000d52a4>] worker_thread+0x148/0x49c
[11.824852] [<ffffffc0000db200>] Kthread+0xe0/0xf8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.