[MMC Subsystem] MMC core (chapter II)--Description of data structure and macro definitions

Source: Internet
Author: User
Tags bool mutex

MMC subsystem series (in continuous update):
[MMC subsystem] concepts and frameworks
[MMC Subsystem] MMC core (chapter I)--Overview
[MMC Subsystem] MMC core (chapter II)--Description of data structure and macro definitions
[MMC Subsystem] MMC core (chapter III)--bus module description
[MMC Subsystem] MMC core (fourth chapter)--host module description
[MMC Subsystem] MMC core (fifth chapter)--card related modules (MMC type card)
[MMC Subsystem] MMC core (sixth chapter)--MMC Core Master Module

It is recommended that you refer to the [MMC subsystem] concepts and frameworks and [MMC Subsystem] MMC core (chapter I)-Overview for an understanding of the whole.

========================================================================================================= One, Host related 1, struct mmc_host

struct Mmc_host is a struct that is abstracted by the host controller by the MMC core and is used to represent an MMC host controller.
* Data structure is as follows:

struct Mmc_host {struct device *parent;   Device struct device Class_dev for the corresponding host controller;   MMC_HOST device structure, will hang under Class/mmc_host int index; The index number of the host is const struct MMC_HOST_OPS *ops;   The set of operations of the host, which is setup by the host controller, is followed by the unsigned int f_min;   The host supports a minimum frequency of unsigned int f_max;   The host supports a maximum frequency of unsigned int f_init;   The initialization frequency used by the host is U32 Ocr_avail; The available OCR values for the host (voltage-dependent) u32 Ocr_avail_sdio;   /* sdio-specific OCR */u32 OCR_AVAIL_SD;  /* sd-specific OCR */u32 OCR_AVAIL_MMC;
    /* mmc-specific OCR */struct notifier_block pm_notify;   U32 max_current_330;   Maximum current at 3.3V u32 max_current_300;   Maximum current at 3.0V u32 max_current_180;       Maximum current at 1.8V u32 caps;      /* Host capabilities *///host property u32 CAPS2;    /* More Host capabilities *///Host Property 2 mmc_pm_flag_t pm_caps; /* Supported PM Features////Power Management Properties///////////////////////////////////////////////////////The following are member int associated with clock   clk_requests;  /* Internal Reference counter */unsigned int clk_delay;  /* Number of MCI CLK hold cycles */bool clk_gated; /* Clock gated */struct delayed_work clk_gate_work;    /* Delayed Clock Gate */unsigned int clk_old;   /* Old Clock value cache */spinlock_t clk_lock; /* Lock for CLK fields */struct mutex Clk_gate_mutex;
    /* Mutex for clock gating */struct Device_attribute clkgate_delay_attr;

    unsigned long clkgate_delay;        /* Host specific block data *///////////////////////////////////////////////////////and block-related member unsigned int   Max_seg_size;   /* See Blk_queue_max_segment_size */unsigned short max_segs;
    /* See blk_queue_max_segments */unsigned short unused;   unsigned int max_req_size; /* Maximum number of bytesIn one req */unsigned int max_blk_size;  /* Maximum size of one MMC block */unsigned int max_blk_count; /* Maximum number of blocks in one req */unsigned int max_discard_to; /* max.       Discard Timeout in MS */* Private data */spinlock_t lock;        /* Lock for claim and bus OPS *///Host bus used lock struct Mmc_ios iOS;        /* Current IO Bus settings *///IO setting, follow-up instructions u32 OCR;        /* The current OCR setting *////The value of the currently used OCR/* Group bitfields together to minimize padding */unsigned int
    Use_spi_crc:1;  unsigned int claimed:1; /* Host exclusively claimed *//host is already occupied unsigned int bus_dead:1; /* Bus has been released *///Host bus is active int rescan_disable; /* Disable Card Detection * *//Forbidden rescan identification, prohibit the search card int rescan_entered;     /* Used with nonremovable devices *///////is the identity of the rescan, corresponding to the non-removable device can only rescan once the struct Mmc_card*card;
    /* Device attached to this host///and the host is bound together with the card wait_queue_head_t Wq;   struct Task_struct *claimer;
    /* Task that has host claimed */////The host's possessor process struct task_struct *suspend_task;  int claim_cnt;   /* "claim" nesting count///occupier process occupies count of the host struct delayed_work detect;   The working struct Wake_lock detect_wake_lock that detects the change of card slot;   Detection of card slot changes work using the lock const char *wlock_name;  Lock name int detect_change;   /* Card Detect flag *//identification struct Mmc_slot slot that needs to detect slot changes;  The structural body of the card slot is const struct MMC_BUS_OPS *bus_ops;   /* The operation set of the MMC bus for the current bus driver *//host, followed by the unsigned int bus_refs;   /* Reference counter *//Host MMC bus usage count unsigned int bus_resume_flags;   The resume identifier of the host's MMC bus is mmc_pm_flag_t pm_flags; /* Requested PM features */#ifdef config_regulator bool regulator_enabled; /* Regulator State *///For status of Regulator (LDO) #endif struct MMC_supply Supply;   struct Dentry *debugfs_root;      The corresponding debug directory struct struct mmc_async_req *areq;   /* Active Async req/////asynchronous request struct Mmc_context_info context_info currently being processed;   /* Async Synchronization Info *///asynchronous request information unsigned int actual_clock; /* Actual HC Clock rate *///actual clock frequency};
The voltage meaning of each bit of the OCR value is as follows:
#define MMC_VDD_165_195 0x00000080/* VDD voltage 1.65-1.95 */#define MMC_VDD_20_21 0x00000100/* Vdd Volta   GE 2.0 ~ 2.1 */#define MMC_VDD_21_22 0x00000200 */VDD Voltage 2.1 ~ 2.2 */#define MMC_VDD_22_23 0x00000400       /* VDD Voltage 2.2 ~ 2.3 */#define MMC_VDD_23_24 0x00000800 * VDD Voltage 2.3 ~ 2.4 */#define MMC_VDD_24_25 0x00001000/* VDD voltage 2.4 ~ 2.5 */#define MMC_VDD_25_26 0x00002000 * VDD Voltage 2.5 ~ 2.6 */#define MM  c_vdd_26_27 0x00004000/* VDD Voltage 2.6 ~ 2.7 * #define MMC_VDD_27_28 0x00008000/* VDD voltage 2.7 ~ 2.8 */#define MMC_VDD_28_29 0x00010000/* VDD voltage 2.8 ~ 2.9 */#define MMC_VDD_29_30 0x00020000/* VDD Vol Tage 2.9 ~ 3.0 * * #define MMC_VDD_30_31 0x00040000 * VDD Voltage 3.0 ~ 3.1 */#define MMC_VDD_31_32 0x000800       XX/* VDD voltage 3.1 ~ 3.2 */#define MMC_VDD_32_33 0x00100000 * VDD Voltage 3.2 ~ 3.3 */#define MMC_VDD_33_34 0x00200000/* VDD Voltage 3.3 ~ 3.4 * * #define MMC_VDD_34_35 0x00400000 * VDD Voltage 3.4 ~ 3.5 */#define MMC_VDD_35_36 0x00 800000/* VDD Voltage 3.5 ~ 3.6 */
The properties supported by the Host property (Mmc_host->caps) are as follows
#define MMC_CAP_4_BIT_DATA (1 << 0)/* Can the host do 4 BIT transfers */#define MMC_CAP_MMC_HIGHSPEED (1 &lt ;< 1)/* * Can do MMC high-speed timing */#define MMC_CAP_SD_HIGHSPEED (1 << 2)/* Can do SD high-speed t IMing */#define MMC_CAP_SDIO_IRQ (1 << 3)/* Can signal pending SDIO IRQs */#define MMC_CAP_SPI (1 <& Lt
4)/* Talks only SPI protocols */#define MMC_CAP_NEEDS_POLL (1 << 5)/* NEEDS Polling for Card-detection */ #define MMC_CAP_8_BIT_DATA (1 << 6)/* Can the host do 8 BIT transfers */#define MMC_CAP_NONREMOVABLE (1 &lt
;< 8)/* nonremovable e.g. EMMC */#define MMC_CAP_WAIT_WHILE_BUSY (1 << 9)/* Waits while card is BUSY */   #define MMC_CAP_ERASE (1 <<)/* Allow Erase/trim commands */#define MMC_CAP_1_8V_DDR (1 << 11) /* can support */* DDR mode at 1.8V */#define MMC_CAP_1_2V_DDR (1 <<)/* can Su
           Pport * *             /* DDR mode at 1.2V */#define MMC_CAP_HSDDR (mmc_cap_1_8v_ddr | MMC_CAP_1_2V_DDR) #define Mmc_cap_power_off_card (1 <<)/* Can POWER OFF after boot */#define Mmc_cap_bus_wid Th_test (1 <<)/* CMD14/CMD19 bus width OK */#define MMC_CAP_UHS_SDR12 (1 <<)/* Host supports U HS SDR12 mode */#define MMC_CAP_UHS_SDR25 (1 <<)/* Host supports UHS SDR25 mode */#define MMC_CAP_UHS_SDR5 0 (1 <<)/* Host supports UHS SDR50 mode */#define MMC_CAP_UHS_SDR104 (1 <<)/* Host supports UH S SDR104 mode */#define MMC_CAP_UHS_DDR50 (1 << +)/* Host supports UHS DDR50 mode */#define mmc_cap_driver_t Ype_a (1 <<)/* Host supports Driver Type A */#define MMC_CAP_DRIVER_TYPE_C (1 <<)/* Host Supp Orts Driver Type C */#define MMC_CAP_DRIVER_TYPE_D (1 <<)/* Host supports Driver Type D */#define MMC_CAP_ CMD23 (1 <<)/* CMD23 supported. */#define MMc_cap_hw_reset (1 <<)/* Hardware RESET */ 
The properties supported by Host Property 2 (MMC_HOST-&GT;CAPS2) are as follows
#define MMC_CAP2_BOOTPART_NOACC (1 << 0)/* Boot partition No access */#define MMC_CAP2_CACHE_CTRL (1 << 1 )/* Allow cache control */#define MMC_CAP2_POWEROFF_NOTIFY (1 << 2)/* NOTIFY POWEROFF Supported */#define M    Mc_cap2_no_multi_read (1 << 3)/* Multiblock reads don ' t work */#define MMC_CAP2_NO_SLEEP_CMD (1 << 4) /* Don ' t allow sleep command */#define MMC_CAP2_HS200_1_8V_SDR (1 << 5)/* can support */#define Mmc_cap
                 2_HS200_1_2V_SDR (1 << 6)/* can support */#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ MMC_CAP2_HS200_1_2V_SDR) #define MMC_CAP2_BROKEN_VOLTAGE (1 << 7)/* Use the broken VOLTAGE */#define M Mc_cap2_detect_on_err (1 << 8)/* on I/O ERR Check card removal */#define MMC_CAP2_HC_ERASE_SZ (1 << 9 
)/* high-capacity Erase Size */#define MMC_CAP2_CD_ACTIVE_HIGH (1 <<)/* Card-detect signal ACTIVE High */ #define Mmc_cap2_ro_actIve_high (1 << one)/* Write-protect signal active High/#define MMC_CAP2_PACKED_RD (1 <<)/* Allow P acked Read */#define MMC_CAP2_PACKED_WR (1 <<)/* Allow PACKED write */#define MMC_CAP2_PACKED_CMD (MMC_CAP2 _packed_rd |  \ MMC_CAP2_PACKED_WR) #define MMC_CAP2_NO_PRESCAN_POWERUP (1 <<)/* Don ' t power up before scan */#define MMC_CAP2_INIT_BKOPS (1 <<)/* need to set Bkops_en */#define MMC_CAP2_PACKED_WR_CONTROL (1 &lt
;<)/* Allow Write packing control */#define MMC_CAP2_CLK_SCALE (1 <<)/* Allow dynamic CLK scaling */  #define MMC_CAP2_STOP_REQUEST (1 <<)/* Allow STOP ongoing REQUEST */* Use runtime PM framework provided by  MMC Core */#define MMC_CAP2_CORE_RUNTIME_PM (1 <<) #define MMC_CAP2_SANITIZE (1 <<)/* Support Sanitize */* allows asynchronous SDIO IRQ while card was in 4-bit mode */#define MMC_CAP2_ASYNC_SDIO_IRQ_4BIT_MODE (1 & lt;< 21)

#define MMC_CAP2_HS400_1_8V (1 <<)/* can support */#define MMC_CAP2_HS400_1_2V (1 << 23)      /* can support */#define MMC_CAP2_CORE_PM (1 <<)/* Use PM Framework */#define MMC_CAP2_HS400 (mmc_cap2_hs400_1_8v | \ mmc_cap2_hs400_1_2v) #define MMC_CAP2_NONHOTPLUG (1 <<)/*don ' t Suppo RT hotplug*/
2, struct mmc_host_ops

MMC core encapsulates some of the action methods that host needs to provide into a struct mmc_host_ops.
Many of the interfaces of the MMC core Master module are based on the operation method in this way, which can be used to manipulate the host hardware to achieve the corresponding purpose.
So struct mmc_host_ops is also the core part of host controller driver that needs to be implemented.

struct Mmc_host_ops {/* * ' enable ' is called if the host is claimed and ' disable ' are called * when the Ho St is released.
     ' Enable ' and ' disable ' are deprecated.   */INT (*enable) (struct mmc_host *host);   Enable host when host is occupied (the first call to Mmc_claim_host) calls Int (*disable) (struct mmc_host *host); Disable host when Host is released (first call to Mmc_release_host)/* * It is optional for the host to implement Pre_req and Post_req I
     n * order to support double buffering of requests (prepare one * request and another request is active).
     * PRE_REQ () must always is followed by a post_req ().
     * To undo a call made to Pre_req (), call Post_req () with * a nonzero err condition. *///Post_req and Pre_req are set for asynchronous request processing//Asynchronous request processing means that when another asynchronous request has not yet been processed, another asynchronous request can be prepared without waiting for//specific reference to the
    MMC core master module void (*post_req) (struct mmc_host *host, struct mmc_request *req, int err); void (*pre_req) (struct mmc_host *host, struct mMc_request *req, bool is_first_req); void (*request) (struct mmc_host *host, struct mmc_request *req);   The host handles the method of the MMC request, which in mmc_start_request calls void (*set_ios) (struct mmc_host *host, struct mmc_ios *ios);   Set the host's bus io setting int (*get_ro) (struct mmc_host *host);   Gets the read-write property of the card on host int (*GET_CD) (struct mmc_host *host); Detects the insert status of card slots in the host/* Optional callback for HC quirks */void (*init_card) (struct mmc_host *host, struct m   Mc_card *card);   Initialize the card method int (*start_signal_voltage_switch) (struct mmc_host *host, struct mmc_ios *ios);   How to switch the signal voltage */* Check If the card is pulling dat[0:3] low */INT (*card_busy) (struct mmc_host *host); Used to detect if the card is in the busy state/* The tuning command opcode value is different for SD and EMMC cards */INT (*execute_tuni   NG) (struct mmc_host *host, u32 opcode); Perform tuning operation, select an appropriate sample point int (*select_drive_strength) for the card (unsigned int max_dtr, int host_drv, int card_drv);   Select the drive strength of the signal Void (*hw_reset) (struct mmc_host *host);   Hardware reset Void (*card_event) (struct mmc_host *host); unsigned long (*get_max_frequency) (struct mmc_host *host);   Method for obtaining the maximum frequency supported by host unsigned long (*get_min_frequency) (struct mmc_host *host);
    Gets the minimum frequency supported by the host method Int (*notify_load) (struct mmc_host *, enum mmc_load);   Int (*stop_request) (struct mmc_host *host);
Stop request processing Method unsigned int (*get_xfer_remain) (struct mmc_host *host); };
second, card-related 1, struct Mmc_card

struct Mmc_card is the structure of an MMC-core card device that is abstracted by an MMC device and is used to represent an MMC device.
* Data structure is as follows:

struct Mmc_card {struct mmc_host *host;        /* The host this device belongs to *///Mmc_card belongs to host struct device dev;        /* the device *//corresponding device unsigned int RCA;       /* Relative card address of device */////The card's RCA addresses unsigned int type;      /* Card type *//card types, followed by unsigned int state;     /* The current status of the card state *//card, followed by unsigned int quirks; /* Card Quirks *///The card has some features unsigned int erase_size;    /* Erase size in sectors */unsigned int erase_shift; /* If erase unit is Power 2 */unsigned int pref_erase;    /* in Sectors */U8 erased_byte; /* Value of erased bytes */u32 raw_cid[4]; /* RAW Card CID *///RAW CID Register value u32 raw_csd[4]; /* RAW Card CSD *///RAW CSD Register value u32 raw_scr[2];        /* RAW Card SCR *///RAW SCR Register value struct MMC_CID cid; /* Card IdentificatIon/////////The information from the value of the CID register struct MMC_CSD CSD;    /* Card specific///////////////////From the value of CSD register MMC_EXT_CSD EXT_CSD        /* MMC v4 extended Card Specific///////////////////From the value of the EXT_CSD register struct SD_SCR        /* Extra SD information *///external sdcard information struct SD_SSR SSR;    /* Yet more SD information *///More information about SD card struct sd_switch_caps sw_caps;   /* SWITCH (CMD6) Caps *///SD Toggle Properties unsigned int sd_bus_speed;    /* Bus speed Mode set for the card */struct dentry *debugfs_root; struct struct Mmc_part part[mmc_num_phy_partition] corresponding to the debug directory;    /* Physical partitions *///physical partition unsigned int nr_parts;    Number of partitions unsigned int part_curr; The current partition struct mmc_wr_pack_stats wr_pack_stats;

    /* Packed commands stats*/struct mmc_bkops_info bkops_info;    struct Device_attribute rpm_attrib; 
    RPM attribute unsigned int idle_timeout;        struct Notifier_blockreboot_notify;
    BOOL Issue_long_pon;
U8 *CACHED_EXT_CSD; };
The MMC card type (Mmc_card->type) is as follows:
#define MMC_TYPE_MMC        0/       * MMC card */
#define MMC_TYPE_SD     1       */SD Card */
#define Mmc_type_sdio       2       /* SDIO card *
/#define MMC_TYPE_SD_COMBO   3       */SD COMBO (IO+MEM) card */
The MMC card status (mmc_card->state) is as follows:
 #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 is in + Speed mode */#       Define MMC_STATE_BLOCKADDR (1<<3)/* Card uses block-addressing */#define MMC_STATE_HIGHSPEED_DDR (1<<4) /* Card is in high speed mode */#define MMC_STATE_ULTRAHIGHSPEED (1<<5)/* Card is in ultra high speed MO De * * #define MMC_CARD_SDXC (1<<6)/* CARD is SDXC */#define MMC_CARD_REMOVED (1<<7)/* CA RD has been removed */#define MMC_STATE_HIGHSPEED_200 (1<<8)/* Card is in HS200 mode */#define Mmc_state_hig hspeed_400 (1<<9)/* Card is in HS400 mode */#define MMC_STATE_DOING_BKOPS (1<<10)/* Card is doin G Bkops */#define MMC_STATE_NEED_BKOPS (1<<11)/* card needs to do bkops */

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.