设为首页 加入收藏

TOP

Linux下sdio设备扫描过程(一)
2018-08-16 09:31:24 】 浏览:484
Tags:Linux sdio 设备 扫描 过程

本文基于Linux version 3.10.52版本代码分析sdio设备的扫描过程,同时选择sdio wifi设备作为分析对象,在分析过程中,附带上sdio的协议内容,帮助初学人员学习sdio协议基本内容及sdio的扫描过程。


本节介绍SDIO设备的硬件接口及内部寄存器等。


SDIO设备的硬件操作接口有3种方式:
A、 SPI mode;
B、 SD 1-bit mode;
C、 SD 4-bit mode;
这3种方式的硬件接口及管脚定义如下面图、表:
这里写图片描述
图1 SDIO硬件接口(连接了2组sdio设备)
这里写图片描述
表1 SDIO各种模式管脚对应关系
本文不对SPI mode的相关内容介绍,有关SPI mode的内容不做过多说明。


下图为SDIO设备内部操作空间的映射表。
这里写图片描述
图2 sdio internal map
CIA: Common I/O Area
CCCR:Card Common Control Registers
FBR :Function Basic Registers
CIS:Card Information Structure
RFU: Reserved for Future Use
图中两个蓝色框表示的是一个东西,只是一个图更详细描述内部各个地址段的用途。CIS区域除了保存CIS信息外,sdio设备商也把设备使用的寄存器定义在这个区域,或作为RAM存储运行固件(fw)等。CSA区域的读写,需要借助FBR中的寄存器0xn0Ch—0xn0Eh、0xn0Fh(n等1~7)。
其中function number的个数随着不同设备而不同,并不一定都需要7个function,如后面介绍的扫描设备就只有function1、function2两个function。
CCCR、FBR、CIS区域的寄存器或数据存储格式如下面各个表,各个寄存器bit的意义在后面介绍扫描过程时再结合实际说明:
这里写图片描述
表2 Card Common Control Registers (CCCR)
这里写图片描述
表3 Function Basic Information Registers (这里为function1的FBR)
在FBR寄存器中,0Ch—0Eh、0Fh用于读写CSA区域,操作方式如下面描述:
In order for the host to access a function’s CSA, it first shall determine if that function supports a CSA. The host reads the FBR register at address 00n00h where n is the function number (1 to 7). If bit 6=1, then the function supports a CSA and the host enables access by writing bit 7=1. The next step is for the host to load the 24 bit address to start reading or writing. This is accomplished by writing the 24 bits (A23-0) to registers
00n0Ch to 00n0Eh where n is the function number (1 to 7). Once the start address is written, data can be read or written by accessing register 00n0Fh, the CSA data window register. If more than 1 byte needs to be read or written, an extended I/O command (byte or block) can be performed with an OP code of 0 (fixed address). The address pointer shall be automatically incremented with each access to the window register, so the access will be to sequential addresses within the CSA. Once the operation is complete, the address of the NEXT operation shall be held in the 24 bit address register for the host to read.


CIS区域从0x001000h~0x017FFFh,其中CIS信息采用一种结构化的信息存储,每一条信息作为一个tuple结构体,该结构体中第一个字节为tuple code,用于表示该tuple存储的信息类型,第二个字节表示该tuple的长度n,同时也指明下一个tuple的开始位置,跟在长度后面就是n bytes的tuple内容,如下表所示。整个CIS信息最后是以一个0xFF字节作为结束符。
这里写图片描述
表4 Basic Tuple Format
SDIO支持的tuple code如下表:
这里写图片描述
表5 Tuples Supported by SDIO Cards
这里写图片描述
表6 CISTPL_MANFID: Manufacturer Identification Tuple
如上表,sdio设备的id就存储在tuple code(0x20)的tuple中,就是后续扫描中说到的vendor id与device id。
这里写图片描述
表7 CISTPL_FUNCID Tuple


在tuple code为0x22的CISTPL_FUNCE中,有3中不同类型的tuple,所在在tuple结构体中增加了一个TYPE字节,但又为了与其它tuple的兼容,把TYPE字段放在了tuple的第3个字节,同时这个字节是包含在长度n内的。如下表:
这里写图片描述
表8 CISTPL_FUNCE Tuple General Structure
这里写图片描述
表9 TPLFID_FUNCTION Tuple for Function 0 (Common:type 0x00)
这里写图片描述
表10 TPLFID_FUNCTION Tuple for Function 1-7
(High Power Tuple:type 0x01)
这里写图片描述
表11 TPLFID_FUNCTION Tuple for Function 1-7
(Power State Tuple:type 0x02)
这里写图片描述
表12 CISTPL_SDIO_STD: Tuple Reserved for SDIO Cards
这里写图片描述
表13 CISTPL_SDIO_EXT: Tuple Reserved for SDIO Cards


本节介绍SDIO总线状态,各个命令及命令的应答。


SDIO总线有各种状态,在不同的状态下,响应的命令也不相同。若在一种状态下,接收到了一个该状态下不响应的命令,就不会回应该命令,也不进行任何处理。如在“Initialization State”接收到CMD52,就不会回应,也不会执行任何动作。
这里写图片描述
图3 总线状态图及可接收的命令


? SDIO的命令、数据收发几种方式(如下图):
A、 单命令没有回应;
B、 命令加回应;
C、 命令+回应+数据(1个block,指定发送1个block);
D、 命令+回应+数据(多个block,指定发送n个block);
E、 命令+回应+数据+命令+回应(后一个命令+回应用于结束数据传输,发送n个block,直到发送停止传输命令为止);
这里写图片描述
图5 (Multiple) Block Read Operation
这里写图片描述
图6 (Multiple) Block Write Operation


? 命令、应答、data之间的时间关系
这里写图片描述
这里写图片描述
图7 timing value


? 个别命令、应答格式
CMD3(SEND_RELATIVE

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇深入理解Java内存与垃圾回收调优 下一篇Linux wait返回及timer_create问..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目