BBB's eMMC Drive in DRIVERS\MMC\CARD\BLOCK.C, its mmc_dirver structure is as follows,
Based on the experience of the previous platform bus driver model, there should be a mmc_devices structure in the kernel, and
Its name is also "MMCBLK" so that its probe function will be called, but searching the entire kernel file does not find mmc_devices.
Now let's analyze when Mmc_blk_probe is called.
static struct Mmc_driver Mmc_driver = {. drv= {
. Name = "Mmcblk",
},
. Probe = Mmc_blk_probe,
. remove = Mmc_blk_remove,
. Suspend = Mmc_blk_suspend,
. Resume = Mmc_blk_resume,
};
static int __init mmc_blk_init (void)//drivers\mmc\card\block.c
{
res = Mmc_register_driver (&mmc_driver); Register Mmc_driver
}
int mmc_register_driver (struct mmc_driver *drv)//drivers\mmc\core\bus.c
{
Drv->drv.bus = &mmc_bus_type; MMC devices are mounted on the MMC bus
Return Driver_register (&DRV->DRV); Registering MMC drivers
}
int Driver_register (struct device_driver *drv)//drivers\base\driver.c
{
other = Driver_find (Drv->name, Drv->bus); Find out if this driver has been registered on the bus
if (other) {
Put_driver (other);
PRINTK (kern_err "Error:driver '%s ' is already registered,"
"aborting...\n", drv->name);
Return-ebusy;
}
ret = Bus_add_driver (DRV); If you have not registered, register this driver
}
int bus_add_driver (struct device_driver *drv)//drivers\base\bus.c
{
Error = Driver_attach (DRV);
Error = Driver_create_file (DRV, &driver_attr_uevent);
}
Try to bind driver to devices
int Driver_attach (struct device_driver *drv)//drivers/base/dd.c
{
Return Bus_for_each_dev (Drv->bus, NULL, DRV, __driver_attach);
The search for the device inside the __driver_attach is not clear yet.
}
static int __driver_attach (struct device *dev, void *data)//DRIVERS/BASE/DD.C
{
if (!driver_match_device (DRV, Dev))
return 0;
Driver_probe_device (DRV, Dev);
}
static inline int driver_match_device (struct device_driver *drv,//drivers/base/base.h
struct device *dev)
{
The match function for the MMC bus is called here
Return Drv->bus->match? Drv->bus->match (Dev, DRV): 1;
}
static int Mmc_bus_match (struct device *dev, struct device_driver *drv)//drivers\mmc\core\bus.c
{
The match for the MMC bus returned directly to 1
return 1;
}
int Driver_probe_device (struct device_driver *drv, struct device *dev)//drivers/base/dd.c
{
Really_probe (Dev, DRV);
}
static int really_probe (struct device *dev, struct device_driver *drv)//drivers/base/dd.c
{
Dev->bus->probe (Dev); The probe function of the bus is called here
}
static int mmc_bus_probe (struct device *dev)//drivers\mmc\core\bus.c
{
return Drv->probe (card); The probe function of the final MMC bus calls Mmc_driver's probe function
}