blob: 22d5e35bc0fde2156353f502ce48743409eeb938 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001Introduction
2============
3The Char SDIO Device Driver is an interface which exposes an SDIO
4card/function from kernel space as a char device in user space.
5
6The driver doesn't interact with any HW directly. It relies on SDIO
7card/function interface provided as a part of Linux kernel.
8
9Hardware description
10====================
11Each SDIO device/card contains an SDIO client HW block.
12The host interacts with the device by sending byte sequences called
13command (CMD). Some commands can be followed by data blocks. The
14device sends back a byte sequence called response (R) and a data
15block if required. CMD3, CMD5 and CMD7 are used to initialize the
16device. CMD52 and CMD53 are used to access the device. Command
17format and properties are defined by SDIO Specification document
18published by SD Association:
19 http://www.sdcard.org/developers/tech/sdio/.
20
21CMD52 and CMD53 can access up to 8 address spaces called Functions.
22Function 0 contains system information predefined by SD/SDIO
23standard and Functions 1-7 are defined by the SDIO device
24manufacturer.
25
26An SDIO device/card can send an interrupt to SDIO host. This
27interrupt is intercepted and handled by SDIO host.
28
29Software description
30====================
31Linux provides a framework for handling SDIO devices. It implements
32kind of plug-and-play model in which the Linux SDIO Host Driver is
33responsible for initializing an SDIO device upon insertion. It also
34reads device/card identification information and enumerates functions
35provided by the device and then looks up in the list of
36preregistered user SDIO drivers for a suitable one.
37
38During its lifecycle the user SDIO driver interacts with the Linux
39SDIO Host Driver in order to send/receive information to/from SDIO
40device/card. The user SDIO driver doesn't work with CMD52/CMD53
41directly. Instead it uses an abstraction provided by the Linux SDIO
42Host Driver.
43
44The Linux SDIO Host Driver is also in charge of handling SDIO
45interrupts. User SDIO driver can register its own callback in SDIO
46Host Driver and get a notification about interrupt event.
47
48The Char SDIO Device Driver follows the design guidelines mentioned
49above. It provides the following functionality:
50
51 - Register itself in the user SDIO drivers list;
52 - Handle Probe event upon insertion of supported card/device;
53 - Creates and maintains a char device driver for each SDIO Function
54 found in the card/device;
55 - Translates read/write/ioctl calls to appropriate SDIO call
56 sequences;
57
58In order to handle general SDIO configuration functionality and
59Function 0 the Char SDIO Device Driver provides additional
60simplified char device driver.
61
62The Manufacturer and Device IDs of handled SDIO device should be
63provided as parameters for kernel module or as configuration
64parameters in case of statically linked driver.
65
66Design
67======
68The main goal of the Char SDIO Device Driver is to expose an SDIO
69card/device from kernel space to user space as a char device driver.
70The driver should be generic and simple as far as possible.
71
72The biggest design tradeoff is maintaining a balance between the
73system call overhead required to initiate an SDIO transaction from
74user space and overall SDIO communication performance. But luckily,
75because of nature of SDIO protocol, this overhead is negligible
76comparing to time required to execute SDIO transaction itself. So,
77each CMD52 (read or write) consists from single ioctl system call.
78And each CMD53 invokes single ioctl system call followed by read or
79write system call.
80
81The Char SDIO Device Driver registers its own class of the devices
82called 'csdio'. This class will serve as a common roof for all SDIO
83devices served by different instances of the Char SDIO Device Driver.
84Additional benefit from maintaining its own class is the driver
85ability to overwrite default permissions of the dev nodes created by
86the driver.
87
88Power Management
89================
90None
91
92SMP/multi-core
93==============
94The driver does not anticipate any issues related to multi-core
95since it is expected to run on one core only.
96
97Security
98========
99None
100
101Performance
102===========
103None
104
105Interface
106=========
107The Char SDIO Device Driver has two char device interfaces:
108 - Control Interface;
109 - Function Interface.
110
111Char SDIO Device Driver Control Interface consists of:
112 - open() - device node is /dev/csdio0;
113 - close()
114 - ioctl() - the following options are available:
115 - CSDIO_IOC_ENABLE_HIGHSPEED_MODE;
116 - CSDIO_IOC_SET_DATA_TRANSFER_CLOCKS;
117 - CSDIO_IOC_ENABLE_ISR;
118 - CSDIO_IOC_DISABLE_ISR.
119
120Char SDIO Device Driver Function Interface consists of:
121 - open() - device node is /dev/csdiofX, where X is Function Id;
122 - close()
123 - read() - send CMD53 read;
124 - write() - send CMD53 write;
125 - ioctl() - the following options are available:
126 - CSDIO_IOC_SET_OP_CODE - 0 fixed adrress, 1 autoincrement.
127 - CSDIO_IOC_FUNCTION_SET_BLOCK_SIZE;
128 - CSDIO_IOC_SET_BLOCK_MODE - 0 byte mode, 1 block mode;
129 - CSDIO_IOC_CMD52 - execute CMD52, receives the
130 following structure as a parameter:
131 struct csdio_cmd52_ctrl_t {
132 uint32_t m_write; // 0 - read, 1 -write
133 uint32_t m_address;
134 uint32_t m_data; // data to write or read data
135 uint32_t m_ret; // command execution status
136 }__attribute__ ((packed));
137 - CSDIO_IOC_CMD53 - setup CMD53 data transfer, receives the
138 following structure as a parameter:
139 struct csdio_cmd53_ctrl_t {
140 uint32_t m_block_mode;
141 uint32_t m_op_code;
142 uint32_t m_address;
143 }__attribute__ ((packed));
144 - CSDIO_IOC_CONNECT_ISR;
145 - CSDIO_IOC_DISCONNECT_ISR;
146 - CSDIO_IOC_GET_VDD;
147 - CSDIO_IOC_SET_VDD.
148
149Additionally, user space application can use fcntl system call with
150parameters F_SETOWN and F_SETFL in order to set an asynchronous
151callback for SDIO interrupt.
152
153Driver parameters
154=================
155If the driver is compiled as a kernel module, the following
156parameters can be used in order to provide Manufacturer and Device IDs
157upon module download:
158 - csdio_vendor_id;
159 - csdio_device_id.
160If the driver is intended to work with specific SDIO host the
161host_name parameter should be added followed by the name of the MMC
162host platform device.
163
164Config options
165==============
166These are the kernel configuration options:
167 - CONFIG_CSDIO_VENDOR_ID;
168 - CONFIG_CSDIO_DEVICE_ID.
169
170Dependencies
171============
172The Char SDIO Device Driver depends on Linux SDIO Host Driver.
173
174User space utilities
175====================
176None
177
178Other
179=====
180None
181
182Known issues
183============
184None
185
186To do
187=====
188Provide mechanism to support a number of SDIO devices simultaneously
189connected to different SDIO hosts.