[mmc subsystem] mmc core(第二章)——数据结构和宏定义说明

mmc subsystem系列(持续更新中):
[mmc subsystem] 概念与框架
[mmc subsystem] mmc core(第一章)——概述
[mmc subsystem] mmc core(第二章)——数据结构和宏定义说明
[mmc subsystem] mmc core(第三章)——bus模块说明
[mmc subsystem] mmc core(第四章)——host模块说明
[mmc subsystem] mmc core(第五章)——card相关模块(mmc type card)
[mmc subsystem] mmc core(第六章)——mmc core主模块

建议先参考《[mmc subsystem] 概念与框架》和《[mmc subsystem] mmc core(第一章)——概述》对整体有一个了解。

=========================================================================================================

一、host相关

1、struct mmc_host

struct mmc_host是mmc core由host controller抽象出来的结构体,用于代表一个mmc host控制器。
* 数据结构如下:

struct mmc_host {
    struct device       *parent;   // 对应的host controller的device
    struct device       class_dev;   // mmc_host的device结构体,会挂在class/mmc_host下
    int         index;   // 该host的索引号
    const struct mmc_host_ops *ops; // 该host的操作集,由host controller设置,后面说明
    unsigned int        f_min;   // 该host支持的最低频率
    unsigned int        f_max;   // 该host支持的最大频率
    unsigned int        f_init;   // 该host使用的初始化频率
    u32         ocr_avail;   // 该host可用的ocr值(电压相关)
    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;   // 3.3V时的最大电流
    u32         max_current_300;   // 3.0V时的最大电流
    u32         max_current_180;   // 1.8V时的最大电流
    u32         caps;       /* Host capabilities */   // host属性
    u32         caps2;      /* More host capabilities */   // host属性2
    mmc_pm_flag_t       pm_caps;    /* supported pm features */   // 电源管理属性

        /// 以下是和clock相关的成员
    int         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 */   
        // 和块相关的成员
    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 bytes in 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使用的锁
    struct mmc_ios      ios;        /* current io bus settings */   // io setting,后续说明
    u32         ocr;        /* the current OCR setting */   // 当前使用的ocr的值

    /* group bitfields together to minimize padding */
    unsigned int        use_spi_crc:1;
    unsigned int        claimed:1;  /* host exclusively claimed */   // host是否已经被占用
    unsigned int        bus_dead:1; /* bus has been released */   // host的bus是否处于激活状态

    int         rescan_disable; /* disable card detection */   // 禁止rescan的标识,禁止搜索card
    int         rescan_entered; /* used with nonremovable devices */   // 是否已经rescan过的标识,对应不可移除的设备只能rescan一次

    struct mmc_card     *card;      /* device attached to this host */   // 和该host绑定在一起的card

    wait_queue_head_t   wq;
    struct task_struct  *claimer;   /* task that has host claimed */   // 该host的占有者进程
    struct task_struct  *suspend_task;
    int         claim_cnt;  /* "claim" nesting count */   // 占有者进程对该host的占用计数

    struct delayed_work detect;   // 检测卡槽变化的工作
    struct wake_lock    detect_wake_lock;   // 检测卡槽变化的工作使用的锁
    const char      *wlock_name;   // 锁名称
    int         detect_change;  /* card detect flag */ // 需要检测卡槽变化的标识
    struct mmc_slot     slot;   // 卡槽的结构体

    const struct mmc_bus_ops *bus_ops;  /* current bus driver */   // host的mmc总线的操作集,后
  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值