Sdio Drive Summary

Source: Internet
Author: User

Sdio Drive Summary

by Dybinx

Kernel: Linux 2.6.35.7

Hardware: Samsung's s5pv210 Platform

The Sdio drive includes Sdio controller driver and Sdio card driver, which belongs to the master-slave structure type, and it is believed that friends who have seen the USB drive will be more likely to understand the Sdio driver framework.

In this paper, we analyze the call process of Sdio controller driver and Sdio card driver, and then make further analysis to Sdio. 1. SDIO Controller Driver

Samsung's s5pv210 platform uses the SDIO controller involved in the driver file main. \ drivers \mmc\host directory sdhci.c sdhci-s3c.c files, the main data structure is as follows:

Østruct sdhci_s3c

Østruct Sdhci_host

Østruct Mmc_host

The relationship between them is the following diagram:

struct Sdhci_host structure contains struct MMC_HOST structure pointer, and struct mmc_host body contains struct mmc_card structure, it is this nesting relationship that finally constructs the SDIO subsystem structure framework.

The SDIO controller is used as a platform device (Platform_device) and is registered in the platform bus when the system is initialized. In addition, the driver registration method is invoked when the platform driver is loaded, starting with the module initialization function of the sdhci-s3c.c file.

Driver registration, on the platform bus find you find Sdio controller device, if found, will call the Sdhci_s3c_probe (struct Platform_device*pdev) function, which completes the above mentioned three of the structure of the initialization and registration work, Eventually added to the device model.

Sdhci_s3c_probe (struct Platform_device*pdev) call procedure:

First, the platform resources are obtained through the incoming platform device, and then call

Sdhci_alloc_host (Dev, sizeof (struct sdhci_s3c)), which also invokes the mmc_alloc_host (sizeof struct) sdhci_host, dev) function, The final invocation of Kzalloc (sizeof (struct mmc_host) + Extra,gfp_kernel) allocates the memory space, as can be known from the parameters passed in, sdhci_alloc_host (Dev, sizeof (structsdhci_ S3C) function returns, the system allocates contiguous storage space for struct sdhci_s3c, struct sdhci_host, struct mmc_host, and struct in the structure. The host structure's private array store struct Sdhci_host, the latter's private storage struct sdhci_s3c, whose memory structure is as follows:

Another heavyweight function in the sdhci_s3c_probe (struct Platform_device*pdev) function is the Sdhci_add_host (host) function, an important function of which is to invoke REQUEST_IRQ ( HOST->IRQ, Sdhci_irq,irqf_shared,mmc_hostname (MMC), host), registration interrupt for SDIO controller, interrupt handler function for SDHCI_IRQ (int irq, void *dev_id), It completes the interrupt processing passed to the SDIO controller, which includes signal processing when the Sdio card device is plugged in or unplugged.

When the Sdio card device is plugged into the system, the hardware generates an interrupt signal, and finally calls SDHCI_IRQ (int irq, void *dev_id), which calls Tasklet_schedule (&host->card_tasklet) function, where Host->card_tasklet calls Device*dev in mmc_alloc_host (int extra, struct init_delayed_work) function (&host-> The detect, Mmc_rescan) function is initialized to the Mmc_rescan () function, which is the Mmc_rescan () function that handles the insert operation of the SDIO card device. This function calls different functions for Sdio, SD, and MMC card devices respectively. For sdio card devices, it calls the Mmc_attach_sdio (host, OCR) function, which calls Mmc_sdio_init_card (host, Host->ocr,null, 0) to initialize a sdio device, It then registers it on the MMC bus and invokes the Sdio_init_func (Host->card, i + 1) function to initialize the SDIO device and register it on the Sdio bus. Note that it is registered to the MMC bus is the struct mmc_card structure, registered to the Sdio bus is struct SDIO_FUNC structure, and Sdio_func contains mmc_card structure pointer, MMC_ The card structure body contains an array of struct SDIO_FUNC structure bodies, visible struct SDIO_FUNC structure is a subkey of the struct Mmc_card structure, or sdio_func represents a sdio device, which has MMC_ The function of the card device, compared to the Mmc_card equipment, Sdio_func is a more specific device.

Also the point is that the device is hooked on the bus, each controller at least for the ownership of a bus, then, the MMC subsystem of the bus when it is generated. In the Mmc\core subdirectory there is a core.c file, at the bottom of the file there is a section of code: Subsys_initcall (Mmc_init), to understand the system to start the process of the friend must be not unfamiliar with the Subsys_initcall, It is an index of the system initialization code snippet, the corresponding code of its parameter is called when the system starts, and the bus that the MMC subsystem uses is established in the Mmc_init function. Sdio Card Driver

According to different equipment also corresponding to different SDIO card driver, this paper mainly analyzes the Marvell 8688 SDIO WiFi driver registration process.

This file is in the. \drivers\net\wireless\libertas directory.

Since it is a bus device, the Sdio driver will undoubtedly register into the device model and call its probe function after the SDIO device is found, and then enter the long process of device initialization. How is the device initialized, from the If_sdio_probe function is not passed into a device structure (SDIO_FUNC) it. Why should I initialize the device structure? Just as nature cannot escape the diversity of species, the Linux kernel also needs device diversity. Sdio_func only represents a general-purpose sdio device, when the SDIO device is plugged into the system, the SDIO controller only knows the need to generate a SDIO_FUNC structure to represent the SDIO device, as for the device has any special features, it will not be able to control so much, This requires specific probe functions to handle, add special features to the device, specific to the WiFi device, the structure is If_sdio_card, and its relationship with Sdio_func can be seen from the If_sdio_card device structure, Contains a SDIO_FUNC structure body pointer. All in all, this function is to build a WiFi device-specific structure for the WiFi device until the if_sdio_probe is finished, when the Sdio WiFi is just on the right track and starting to work.

This article is just a brief introduction of the Sdio controller and SDIO equipment from scratch process, specific to the SDIO controller details, but also need a lot of work, including familiar with the corresponding bus protocol. And for the Sdio WiFi drive is only a head, for its details, will be a different area. Life is like a trip, care is not the destination, but the scenery along the way, and only careful thinking to realize the unique scenery of each place, the Linux kernel is not so. Regrets, the above analysis has the wrong place, please advise.

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.