MMC:(Multi Media Card)由西门子公司和首推CF的SanDisk于1997年推出的多媒体记忆卡标准。
SD:(Secure Digital Memory Card)由日本松下、东芝及美国SanDisk公司于1999年8月共同开发研制的新一代记忆卡标准,已完全兼容MMC标准。
SDIO:(Secure Digital Input and Output Card)安全数字输入输出卡。SDIO是在SD标准上定义了一种外设接口,通过SD的I/O接脚来连接外围设备,并且通过SD上的
I/O数据接位与这些外围设备进行数据传输。是目前较热门的技术,如下图中的一些设备:GPS、相机、Wi-Fi、调频广播、条形码读卡器、蓝牙等。
命令操作步骤:
a. 写命令参数32位到SDICmdArg寄存器;
b. 设置命令类型并通过设置SDICCON寄存器开始命令传输;
c. 当SDICSTA寄存器的特殊标志被置位,确认命令操作完成;
d. 如果命令类型相应,标志是RspFin,否则标志是CmdSend;
e. 通过对相应位写1,清除SDICmdSta的标志。
数据操作步骤:
a. 写数据超时时间到SDIDTimer寄存器;
b. 写模块大小到SDIBSize寄存器(通常是0x80字节);
c. 确定模块模式、总线线宽、DMA等且通过设置SDIDatCon寄存器开始数据传输;
d. 发送数据->写数据到SDIDAT寄存器,当发送FIFO有效(TFDET置位),或一半(TFHalf置位),或空(TFEmpty置位);
e. 接收数据->从数据寄存器SDIDAT读数据,当接收FIFO有效(RFDET置位),或满(RFFull置位),或一半(RFHalf置位),或准备最后数据(RFLast置位);
f. 当SDIDatSta寄存器的DatFin标志置位,确认数据操作完成;
g. 通过对相应位写1,清除SDIDatSta的标志。
MMC/SD卡驱动程序的重要数据结构,该结果位于Core核心层,主要用于核心层与主机驱动层的数据交换处理。定义在/include/linux/mmc/host.h中: struct mmc_host
{ struct device *parent; struct device class_dev; int index; const
struct mmc_host_ops *ops; unsigned
int f_min; unsigned
int f_max;
u32 ocr_avail;
#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ #define MMC_VDD_20_21 0x00000100 /* VDD voltage 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 MMC_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 voltage 2.9 ~ 3.0 */ #define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */ #define MMC_VDD_31_32 0x00080000 /* 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 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
unsigned
long caps;
/* Host capabilities */
#define MMC_CAP_4_BIT_DATA (1
<< 0)/* Can the host do 4 bit transfers */ #define MMC_CAP_MMC_HIGHSPEED (1
<< 1)/* Can do MMC high-speed timing */ #define MMC_CAP_SD_HIGHSPEED (1
<< 2)/* Can do SD high-speed timing */ #define MMC_CAP_SDIO_IRQ
(1 << 3)/* Can signal pending SDIO IRQs */ #define MMC_CAP_SPI
(1 << 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 */
/* host specific block data */ unsigned
int max_seg_size;/* see blk_queue_max_segment_size */ unsigned
short max_hw_segs;/* see blk_queue_max_hw_segments */ unsigned
short max_phys_segs;/* see blk_queue_max_phys_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 */
/* private data */
spinlock_t lock;/* lock for claim and bus ops */
struct mmc_ios iOS;/*
current io bus settings */
u32 ocr;/* the current OCR setting */
/* group bitfields together to minimize padding */ unsigned
int use_spi_crc:1; unsigned
int claimed:1;/* host exclusively claimed */ unsigned
int bus_dead:1;/* bus has been released */ #ifdef CONFIG_MMC_DEBUG unsigned
int removed:1;/* host is being removed */ #endif
struct mmc_card *card;/* device attached to this host */
wait_queue_head_t wq;
struct delayed_work detect;
const
struct mmc_bus_ops *bus_ops;/* current bus driver */ unsigned
int bus_refs;/* reference counter */
unsigned
int sdio_irqs; struct task_struct *sdio_irq_thread;
atomic_t sdio_irq_thread_abort;
#ifdef CONFIG_LEDS_TRIGGERS struct led_trigger *led;/* activity led */ #endif