Linux下sdio设备扫描过程

本文深入剖析了Linux 3.10.52版本中SDIO设备的扫描步骤,包括设备接口、内部结构、命令与应答以及状态。通过对SDIO设备的初始化,如CMD5、CMD3、CMD8等命令的解析,揭示了设备的配置、状态转换和CIS信息的读取。文章特别强调了在不同状态和模式下命令的响应情况,以及数据线问题可能导致的初始化失败。
摘要由CSDN通过智能技术生成

前言

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

1 SDIO设备接口及内部结构

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

1.1 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的内容不做过多说明。

1.2 SDIO设备内部寄存器

下图为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内的。如下表:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值