Linux mmc Driver Framework
Summary
data structure |
describe |
struct mmc_host |
Used to represent an mmc host controller |
struct mmc_card |
Used to represent an mmc device (card) |
struct mmc_ios |
IO bus related settings |
struct mmc_driver |
Used to represent mmc card drive |
struct mmc_bus_ops |
Bus operation function set, including mmc, sd and sdio |
struct mmc_host_ops |
The Host controller operation function set is used to describe the card controller operation interface function, register the operation function from the Host controller layer to the core layer, so as to isolate the core layer from the specific Host controller |
struct mmc_command |
Represents an mmc command |
struct mmc_data |
Represents an mmc data |
struct mmc_request |
Represents an mmc request |
struct sdio_func |
A sdio card can support many Functions. A Function corresponds to the struct sdio ﹣ func structure of the software. The final reaction to the driver model is a device |
mmc_host
struct mmc_host {
int index;
const struct mmc_host_ops *ops;
u32 ocr_avail;
u32 ocr_avail_sdio;
u32 ocr_avail_sd;
u32 ocr_avail_mmc;
u32 caps;
u32 caps2;
struct mmc_ios ios;
int rescan_disable;
int rescan_entered;
struct mmc_card *card;
struct delayed_work detect;
int detect_change;
struct mmc_slot slot;
const struct mmc_bus_ops *bus_ops;
struct mmc_supply supply;
unsigned int slotno;
int dsr_req;
u32 dsr;
unsigned long private[0] ____cacheline_aligned;
}
mmc_card
struct mmc_card {
struct mmc_host *host;
struct device dev;
u32 ocr;
unsigned int rca;
unsigned int type;
unsigned int state;
unsigned int quirks;
struct mmc_cid cid;
struct mmc_csd csd;
struct mmc_ext_csd ext_csd;
struct sd_scr scr;
struct sd_ssr ssr;
struct sd_switch_caps sw_caps;
unsigned int sdio_funcs;
struct sdio_cccr cccr;
struct sdio_cis cis;
struct sdio_func *sdio_func[7];
unsigned int sd_bus_speed;
unsigned int mmc_avail_type;
unsigned int drive_strength;
};
mmc_ios
struct mmc_ios {
unsigned int clock;
unsigned short vdd;
unsigned char bus_mode;
unsigned char chip_select;
unsigned char power_mode;
unsigned char bus_width;
unsigned char timing;
unsigned char signal_voltage;
unsigned char drv_type;
bool enhanced_strobe;
}
mmc_dirver
struct mmc_driver {
struct device_driver drv;
int (*probe)(struct mmc_card *card);
void (*remove)(struct mmc_card *card);
void (*shutdown)(struct mmc_card *card);
};
mmc_bus_ops
struct mmc_bus_ops {
void (*remove)(struct mmc_host *);
void (*detect)(struct mmc_host *);
int (*pre_suspend)(struct mmc_host *);
int (*suspend)(struct mmc_host *);
int (*resume)(struct mmc_host *);
int (*runtime_suspend)(struct mmc_host *);
int (*runtime_resume)(struct mmc_host *);
int (*power_save)(struct mmc_host *);
int (*power_restore)(struct mmc_host *);
int (*alive)(struct mmc_host *);
int (*shutdown)(struct mmc_host *);
int (*reset)(struct mmc_host *);
};
mmc_host_ops
struct mmc_host_ops {
void (*post_req)(struct mmc_host *, struct mmc_request *, int err);
void (*pre_req)(struct mmc_host *, struct mmc_request *, bool is_first_req);
void (*request)(struct mmc_host *host, struct mmc_request *req);
void (*set_ios)(struct mmc_host *, struct mmc_ios *);
int (*get_ro)(struct mmc_host *);
int (*get_cd)(struct mmc_host *);
void (*enable_sdio_irq)(struct mmc_host *, int enable);
void (*init_card)(struct mmc_host *, struct mmc_card *card);
int (*start_signal_voltage_switch)(struct mmc_host *, struct mmc_ios *);
int (*card_busy)(struct mmc_host *);
int (*execute_tuning)(struct mmc_host *, u32 opcode);
int (*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios);
void (*hs400_enhanced_strobe)(struct mmc_host *, struct mmc_ios *);
int (*select_drive_strength)(struct mmc_card *card,
unsigned int max_dtr, int host_drv, int card_drv, int *drv_type);
void (*hw_reset)(struct mmc_host *);
void (*card_event)(struct mmc_host *);
int (*multi_io_quirk)(struct mmc_card *, unsigned int direction, int blk_size);
};
mmc_command
struct mmc_command {
u32 opcode;
u32 arg;
u32 resp[4];
unsigned int flags;
unsigned int retries;
int error;
unsigned int busy_timeout;
bool sanitize_busy;
struct mmc_data *data;
struct mmc_request *mrq;
}
mmc_data
struct mmc_data {
unsigned int timeout_ns;
unsigned int timeout_clks;
unsigned int blksz;
unsigned int blocks;
unsigned int blk_addr;
int error;
unsigned int flags;
#define MMC_DATA_WRITE BIT(8)
#define MMC_DATA_READ BIT(9)
#define MMC_DATA_QBR BIT(10)
#define MMC_DATA_PRIO BIT(11)
#define MMC_DATA_REL_WR BIT(12)
#define MMC_DATA_DAT_TAG BIT(13)
#define MMC_DATA_FORCED_PRG BIT(14)
unsigned int bytes_xfered;
struct mmc_command *stop;
struct mmc_request *mrq;
unsigned int sg_len;
int sg_count;
struct scatterlist *sg;
s32 host_cookie;
}
mmc_request
struct mmc_request {
struct mmc_command *cmd;
struct mmc_data *data;
struct mmc_command *stop;
void *done_data;
void (*done)(struct mmc_request *);
};
sdio_func
struct sdio_func {
struct mmc_card *card;
struct device dev;
sdio_irq_handler_t *irq_handler;
unsigned int num;
unsigned char class;
unsigned short vendor;
unsigned short device;
unsigned max_blksize;
unsigned cur_blksize;
unsigned enable_timeout;
unsigned int state;
#define SDIO_STATE_PRESENT (1<<0)
u8 *tmpbuf;
unsigned num_info;
const char **info;
struct sdio_func_tuple *tuples;
}