The following is an initialization process analysis of the MMC host Controller drive on the Qualcomm 8x50.
Analysis based on kernel version 2.6.29 (the main code is DRIVER/MMC/MSM_SDCC.C and msm_sdcc.h and Arch Code)
1. Types of buses involved in MMC
The code in the MMC directory mainly involves three kinds of buses, one is platform bus, the MMC host controller as a kind of platform device, it is need to register to the platform on.
The other two are the two types of bus that MMC creates, one is the MMC bus type and the other is the Sdio bus type. They are created in Mmc_init (). Registers an MMC bus by calling Mmc_register_bus () to register the SDIO bus by calling Sdio_register_bus ().
Of course, MMC Bus and Sdio bus are not used in the initialization of MMC host controller driver.
1.1 Platform Bus
The definition is in DRIVER/BASE/PLATFORM.C
struct Bus_type Platform_bus_type = {
. Name = "Platform",
. Dev_attrs = Platform_dev_attrs,
. match = Platform_match,
. uevent = Platform_uevent,
. PM = platform_pm_ops_ptr,
};
1.3 Sdio Bus Type
static struct Bus_type Sdio_bus_type = {
. Name = "Sdio",
. Dev_attrs = Sdio_dev_attrs,
. match = Sdio_bus_match,
. uevent = Sdio_bus_uevent,
. Probe = Sdio_bus_probe,
. remove = Sdio_bus_remove,
};
For devices on a platform bus, the process that is typically initialized is:
A. Register platform device on platform bus.
B. Register platform driver on platform bus.
C. If the device and driver on the platform bus match each other, call its probe () function for initialization.
The same is true for SD host controller devices.
2. MMC Host controller Device registration
The hardware of the MMC host controller is embedded in the entire AP chip. So if you enable the configuration of this MMC host controller in kernel, MMC host controller device will be injected in kernel initialization Book.
In arch/arm/mach-xxx/<board-name>.c, such as Qualcomm's 8x50, the corresponding file is BOARD-QSD8X50.C, the registration process for the device is as follows:
Qsd8x50_init ()-> qsd8x50_init_mmc ()-> MSM_ADD_SDCC ()-> platform_device_register () to register platform bus.
The registered device data structure is as follows, which defines some resources for the device. such as MEM, IRQ, DMA.
struct Platform_device MSM_DEVICE_SDC1 = {
. Name = "MSM_SDCC",
. id = 1,
. num_resources = Array_size (RESOURCES_SDC1),
. resource = RESOURCES_SDC1,
. Dev = {
. Coherent_dma_mask = 0xFFFFFFFF,
},
};
3. MMC Host Controller Driver registration
In the driver/mmc/host/msm_sdcc.c file,
Msmsdcc_init ()-> platform_driver_register () to register it with platform bus.
static struct Platform_driver Msmsdcc_driver = {
. Probe = Msmsdcc_probe,
. remove = Msmsdcc_remove,
. Suspend = Msmsdcc_suspend,
. Resume = Msmsdcc_resume,
. Driver = {
. Name = "MSM_SDCC",
},
};
The Platform_driver_register call process is as follows:
Platform_driver_register ()
Driver_register ()
Bus_add_driver ()
Driver_attach ()
Bus_for_each_dev ()
__driver_attach ()
Driver_probe_device ()
In the Driver_probe_device () function, it will call the match function of the bus. If match, it will call the Really_probe function, in which the bus and driver probe functions are actually invoked.
4. Probe () function
The probe () function in the MMC host controller driver is Msmsdcc_probe (). Its processing flow is as follows.
A. Get resource.
B. Setup MSM SDCC host structure.
C. Setup DMA.
D. Setup main peripheral bus clock.
E. Setup SDC MMC clock.
F. Setup MMC Hsot structure.
G. Setup card detect change.
H. Setup a command timer.
In general, it is initializing the associated data structure and making some initialization settings.
The following figure is a diagram of the main data structures in an MMC, and the probe () function is primarily to initialize the msmsdcc_host and MMC_HOST data structures.
5. MMC Host Controller Driver external interface
5.1 interface to the upper layer
Msmsdcc_ops ()
MSMSDCC_STATUS_NOTIFY_CB ()
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.