MMC Subsystem Learning notes four structural organization of MMC subsystems

Source: Internet
Author: User

From this section, we formally entered the MMC subsystem to learn notes, this side walfred based on their own point of view, organized a Linux under the MMC subsystem structure framework, I believe that with this framework to understand the learning MMC subsystem should play a good effect. The following is the structure organization of the MMC subsystem:

In Linux, the MMC subsystem in the system itself does not have any readme documentation, so this is a "help document." It will involve 3 bus, 2 pieces of equipment, 2 drivers.

three-line bus

Bus name

Platform

Mmc

Sdio

Type

struct BUS_TYPE

Variable name

Platform_bus

Mmc_bus_type

Sdio_bus_type

We can view this in/sys/bus.

two pieces of equipment

Device Name

Msm_sdcc

Mmc_card

Type

struct Platform_device

struct Mmc_card

Note

MSM_SDCC (Soc)

Driven by the former SDCC, the unified abstraction of Mmc/sd/sdio

MSM_SDCC (full name should be Sdcardcontroller integrated to the SOC, so it is platform_device, the advantage has good portability and security), Mmc_card (SDCC by the former driver, the unified abstraction of Mmc/sd/sdio) ;

two groups of drivers

Driver name

Msmsdcc_driver

Mmc_driver

Type

struct Platform_driver

struct Mmc_driver

Note

Corresponding with the above 2 pieces of equipment, respectively, is msmsdcc_driver,mmc_driver;

the relationship between them

With regard to the Platform bus, the following main line of research

Drive Msmsdcc_driver, and the device MSM_SDCC are associated through Platform_bus.

For the MMC bus, the following main Line II

Drive Mmc_driver, and the device Mmc_card is connected through this bus

About Sdio Bus

Not too much research, here for the time being and consider. will be supplemented in the future.

related structural bodies

This is a description of a platform device.

struct Platform_device {

const char * name;

int id;

struct device dev;

U32 num_resources;

struct resource * resource;

const struct PLATFORM_DEVICE_ID *id_entry;

* Arch Specific Additions * *

struct Pdev_archdata archdata;

};

This is MSM_DEVICE_SDC equipment.

struct Platform_device MSM_DEVICE_SDC1 = {

. Name = "MSM_SDCC",//platform_device name

. id = 1,

. num_resources = Array_size (RESOURCES_SDC1),//Number of resources

. resource = resources_sdc1,//Pointer to resource

. Dev = {

. Coherent_dma_mask = 0xFFFFFFFF,

},

};

Platform driver This is a description of a msmsdcc_driver device driven

static struct Platform_driver Msmsdcc_driver = {

. Probe = Msmsdcc_probe,

. Suspend = Msmsdcc_suspend,

. Resume = Msmsdcc_resume,

. Driver = {

. Name = "MSM_SDCC",

},

};

Structure that describes the MMC card

/*

* MMC Device

*/

struct Mmc_card {

struct Mmc_host *host; /* The host this device belongs to/*

struct device dev; * * the device * *

unsigned int RCA; /* Relative card address of device * *

unsigned int type; /* Card Type * *

#define MMC_TYPE_MMC 0/* MMC Card * *

#define MMC_TYPE_SD 1/* SD Card * *

#define MMC_TYPE_SDIO 2/* SDIO Card * *

unsigned int state; /* [Our] card state * *

#define Mmc_state_present (1<<0)//PRESENT in SYSFS * *

#define MMC_STATE_READONLY (1<<1)/* Card is read-only * *

#define MMC_STATE_HIGHSPEED (1<<2)/* Card are in speed mode * *

#define MMC_STATE_BLOCKADDR (1<<3)/card uses block-addressing * *

unsigned int quirks; * Card Quirks * *

#define MMC_QUIRK_LENIENT_FN0 (1<<0)/* Allow SDIO FN0 writes outside of the VS CCCR range * *

#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1)/* Use func->cur_blksize * *

/* for byte mode */

U32 Raw_cid[4]; /* RAW Card CID * *

U32 Raw_csd[4]; /* Raw Card CSD/*

U32 raw_scr[2]; /* Raw Card SCR/*

struct MMC_CID CID; * Card Identification * *

struct MMC_CSD CSD; * Card Specific * *

struct MMC_EXT_CSD EXT_CSD; /* MMC v4 extended Card Specific * *

struct SD_SCR scr; /* Extra SD information * *

struct Sd_switch_caps sw_caps; /* SWITCH (CMD6) caps * *

unsigned int sdio_funcs; /* Number of SDIO functions * *

struct SDIO_CCCR cccr; /* Common Card info * *

struct SDIO_CIS cis; /* Common Tuple info */

struct Sdio_func *sdio_func[sdio_max_funcs]; /* SDIO Functions (Devices) * *

unsigned num_info; /* Number of info strings * *

const char **info; /* Info Strings *

struct Sdio_func_tuple *tuples; /* Unknown Common tuples * *

struct Dentry *debugfs_root;

};

Describe the MMC card-driven structure

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,

};

Control of the structural body

struct Msmsdcc_host {

struct resource *cmd_irqres;

struct resource *pio_irqres;

struct resource *memres;

struct resource *dmares;

void __iomem *base;

int pdev_id;

unsigned int stat_irq;

struct Msmsdcc_curr_req Curr;

struct Mmc_host *mmc;

struct CLK *clk; /* Main MMC bus clock * *

struct CLK *pclk; * SDCC Peripheral Bus Clock * *

unsigned int clks_on; /* Set if clocks are enabled */

struct Timer_list busclk_timer;

unsigned int eject; /* Eject State * *

spinlock_t lock;

unsigned int clk_rate; /* Current clock rate * *

unsigned int pclk_rate;

U32 PWR;

U32 Saved_irq0mask; /* MMCIMASK0 Reg Value * *

struct Mmc_platform_data *plat;

struct Timer_list timer;

unsigned int oldstat;

struct Msmsdcc_dma_data DMA;

struct Msmsdcc_pio_data Pio;

int cmdpoll;

struct Msmsdcc_stats stats;

#ifdef CONFIG_MMC_MSM7X00A_RESUME_IN_WQ

struct Work_struct resume_task;

#endif

/* Command Parameters * *

unsigned int cmd_timeout;

unsigned int cmd_pio_irqmask;

unsigned int cmd_datactrl;

struct Mmc_command *cmd_cmd;

U32 Cmd_c;

};

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.