概述
数据结构
描述
struct mmc_host
用来表示一个mmc host控制器
struct mmc_card
用来表示一个mmc设备(卡)
struct mmc_ios
IO总线相关设置
struct mmc_driver
用来表示 mmc 卡驱动
struct mmc_bus_ops
总线操作函数集, 有mmc、sd、sdio三种
struct mmc_host_ops
Host控制器操作函数集,用来描述卡控制器操作接口函数功能,用于从主机控制器层向 core 层注册操作函数,从而将core 层与具体的主机控制器隔离
struct mmc_command
表示一个mmc命令
struct mmc_data
表示一个mmc数据
struct mmc_request
表示一个mmc请求
struct sdio_func
一张sdio卡可以支持很多Functions,一个Function对应软件上的struct sdio_func结构体,最后反应到驱动模型上就是一个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;
}