]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkSouthCluster/Include/SDHostIo.h
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Include / SDHostIo.h
CommitLineData
9b6bbcdb
MK
1/** @file\r
2\r
3Interface definition for EFI_SD_HOST_IO_PROTOCOL.\r
4\r
5Copyright (c) 2013-2015 Intel Corporation.\r
6\r
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef _SD_HOST_IO_H\r
18#define _SD_HOST_IO_H\r
19\r
20#include "SDCard.h"\r
21#include "CEATA.h"\r
22\r
23\r
24#define EFI_SD_HOST_IO_PROTOCOL_GUID \\r
25 { \\r
26 0xb63f8ec7, 0xa9c9, 0x4472, {0xa4, 0xc0, 0x4d, 0x8b, 0xf3, 0x65, 0xcc, 0x51} \\r
27 }\r
28\r
29///\r
30/// Forward reference for pure ANSI compatability\r
31///\r
32typedef struct _EFI_SD_HOST_IO_PROTOCOL EFI_SD_HOST_IO_PROTOCOL;\r
33\r
34\r
35\r
36typedef enum {\r
37 ResponseNo = 0,\r
38 ResponseR1,\r
39 ResponseR1b,\r
40 ResponseR2,\r
41 ResponseR3,\r
42 ResponseR4,\r
43 ResponseR5,\r
44 ResponseR5b,\r
45 ResponseR6,\r
46 ResponseR7\r
47}RESPONSE_TYPE;\r
48\r
49typedef enum {\r
50 NoData = 0,\r
51 InData,\r
52 OutData\r
53}TRANSFER_TYPE;\r
54\r
55typedef enum {\r
56 Reset_Auto = 0,\r
57 Reset_DAT,\r
58 Reset_CMD,\r
59 Reset_DAT_CMD,\r
60 Reset_All\r
61}RESET_TYPE;\r
62\r
63#define PCI_SUBCLASS_SD_HOST_CONTROLLER 0x05\r
64#define PCI_IF_STANDARD_HOST_NO_DMA 0x00\r
65#define PCI_IF_STANDARD_HOST_SUPPORT_DMA 0x01\r
66\r
67#define SDHCI_SPEC_100 0\r
68#define SDHCI_SPEC_200 1\r
69#define SDHCI_SPEC_300 2\r
70\r
71//\r
72//MMIO Registers definition for MMC/SDIO controller\r
73//\r
74#define MMIO_DMAADR 0x00\r
75#define MMIO_BLKSZ 0x04\r
76#define MMIO_BLKCNT 0x06\r
77#define MMIO_CMDARG 0x08\r
78#define MMIO_XFRMODE 0x0C\r
79#define MMIO_SDCMD 0x0E\r
80#define MMIO_RESP 0x10\r
81#define MMIO_BUFDATA 0x20\r
82#define MMIO_PSTATE 0x24\r
83#define MMIO_HOSTCTL 0x28\r
84#define MMIO_PWRCTL 0x29\r
85#define MMIO_BLKGAPCTL 0x2A\r
86#define MMIO_WAKECTL 0x2B\r
87#define MMIO_CLKCTL 0x2C\r
88#define V_MMIO_CLKCTL_MAX_8BIT_FREQ_SEL 0x80\r
89#define V_MMIO_CLKCTL_MAX_10BIT_FREQ_SEL 0x3FF\r
90#define B_MMIO_CLKCTL_UPR_SDCLK_FREQ_SEL_MASK 0xC0\r
91\r
92#define MMIO_TOCTL 0x2E\r
93#define MMIO_SWRST 0x2F\r
94#define MMIO_NINTSTS 0x30\r
95#define MMIO_ERINTSTS 0x32\r
96#define MMIO_NINTEN 0x34\r
97#define MMIO_ERINTEN 0x36\r
98#define MMIO_NINTSIGEN 0x38\r
99#define MMIO_ERINTSIGEN 0x3A\r
100#define MMIO_AC12ERRSTS 0x3C\r
101#define MMIO_HOSTCTL2 0x3E\r
102#define MMIO_CAP 0x40\r
103#define MMIO_MCCAP 0x48\r
104#define MMIO_SLTINTSTS 0xFC\r
105#define MMIO_CTRLRVER 0xFE\r
106#define MMIO_SRST 0x1FC\r
107\r
108//\r
109// Protocol definitions\r
110//\r
111\r
112/**\r
113 The main function used to send the command to the card inserted into the SD host slot.\r
114 It will assemble the arguments to set the command register and wait for the command\r
115 and transfer completed until timeout. Then it will read the response register to fill\r
116 the ResponseData.\r
117\r
118 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
119 @param CommandIndex The command index to set the command index field of command register.\r
120 @param Argument Command argument to set the argument field of command register.\r
121 @param DataType TRANSFER_TYPE, indicates no data, data in or data out.\r
122 @param Buffer Contains the data read from / write to the device.\r
123 @param BufferSize The size of the buffer.\r
124 @param ResponseType RESPONSE_TYPE.\r
125 @param TimeOut Time out value in 1 ms unit.\r
126 @param ResponseData Depending on the ResponseType, such as CSD or card status.\r
127\r
128 @retval EFI_SUCCESS\r
129 @retval EFI_INVALID_PARAMETER\r
130 @retval EFI_OUT_OF_RESOURCES\r
131 @retval EFI_TIMEOUT\r
132 @retval EFI_DEVICE_ERROR\r
133\r
134**/\r
135\r
136typedef\r
137EFI_STATUS\r
138(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND) (\r
139 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
140 IN UINT16 CommandIndex,\r
141 IN UINT32 Argument,\r
142 IN TRANSFER_TYPE DataType,\r
143 IN UINT8 *Buffer, OPTIONAL\r
144 IN UINT32 BufferSize,\r
145 IN RESPONSE_TYPE ResponseType,\r
146 IN UINT32 TimeOut,\r
147 OUT UINT32 *ResponseData OPTIONAL\r
148 );\r
149\r
150/**\r
151 Set max clock frequency of the host, the actual frequency may not be the same as MaxFrequency.\r
152 It depends on the max frequency the host can support, divider, and host speed mode.\r
153\r
154 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
155 @param MaxFrequency Max frequency in HZ.\r
156\r
157 @retval EFI_SUCCESS\r
158 @retval EFI_TIMEOUT\r
159\r
160**/\r
161\r
162typedef\r
163EFI_STATUS\r
164(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY) (\r
165 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
166 IN UINT32 MaxFrequency\r
167 );\r
168\r
169\r
170/**\r
171 Set bus width of the host controller\r
172\r
173 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
174 @param BusWidth Bus width in 1, 4, 8 bits.\r
175\r
176 @retval EFI_SUCCESS\r
177 @retval EFI_INVALID_PARAMETER\r
178\r
179**/\r
180\r
181typedef\r
182EFI_STATUS\r
183(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH) (\r
184 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
185 IN UINT32 BusWidth\r
186 );\r
187\r
188/**\r
189 Set voltage which could supported by the host controller.\r
190 Support 0(Power off the host), 1.8V, 3.0V, 3.3V\r
191\r
192 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
193 @param Voltage Units in 0.1 V.\r
194\r
195 @retval EFI_SUCCESS\r
196 @retval EFI_INVALID_PARAMETER\r
197\r
198**/\r
199\r
200typedef\r
201EFI_STATUS\r
202(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE) (\r
203 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
204 IN UINT32 Voltage\r
205 );\r
206\r
207/**\r
208 Reset the host controller.\r
209\r
210 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
211 @param ResetAll TRUE to reset all.\r
212\r
213 @retval EFI_SUCCESS\r
214 @retval EFI_TIMEOUT\r
215\r
216**/\r
217\r
218typedef\r
219EFI_STATUS\r
220(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST) (\r
221 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
222 IN RESET_TYPE ResetType\r
223 );\r
224\r
225/**\r
226 Enable auto stop on the host controller.\r
227\r
228 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
229 @param Enable TRUE to enable, FALSE to disable.\r
230\r
231 @retval EFI_SUCCESS\r
232 @retval EFI_TIMEOUT\r
233\r
234**/\r
235\r
236typedef\r
237EFI_STATUS\r
238(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD) (\r
239 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
240 IN BOOLEAN Enable\r
241 );\r
242\r
243/**\r
244 Find whether these is a card inserted into the slot. If so init the host.\r
245 If not, return EFI_NOT_FOUND.\r
246\r
247 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
248\r
249 @retval EFI_SUCCESS\r
250 @retval EFI_NOT_FOUND\r
251\r
252**/\r
253\r
254typedef\r
255EFI_STATUS\r
256(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST) (\r
257 IN EFI_SD_HOST_IO_PROTOCOL *This\r
258 );\r
259\r
260/**\r
261 Set the Block length on the host controller.\r
262\r
263 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
264 @param BlockLength card supportes block length.\r
265\r
266 @retval EFI_SUCCESS\r
267 @retval EFI_TIMEOUT\r
268\r
269**/\r
270\r
271typedef\r
272EFI_STATUS\r
273(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH) (\r
274 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
275 IN UINT32 BlockLength\r
276 );\r
277\r
278/**\r
279 Enable/Disable High Speed transfer mode\r
280\r
281 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
282 @param Enable TRUE to Enable, FALSE to Disable\r
283\r
284 @return EFI_SUCCESS\r
285**/\r
286typedef\r
287EFI_STATUS\r
288(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE) (\r
289 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
290 IN BOOLEAN Enable\r
291 );\r
292\r
293typedef\r
294EFI_STATUS\r
295(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE) (\r
296 IN EFI_SD_HOST_IO_PROTOCOL *This,\r
297 IN BOOLEAN Enable\r
298 );\r
299\r
300\r
301\r
302#define EFI_SD_HOST_IO_PROTOCOL_REVISION_01 0x02\r
303\r
304\r
305typedef struct {\r
306 UINT32 HighSpeedSupport: 1; //High speed supported\r
307 UINT32 V18Support: 1; //1.8V supported\r
308 UINT32 V30Support: 1; //3.0V supported\r
309 UINT32 V33Support: 1; //3.3V supported\r
310 UINT32 Reserved0: 4;\r
311 UINT32 HostVersion: 8;\r
312 UINT32 BusWidth4: 1; // 4 bit width\r
313 UINT32 BusWidth8: 1; // 8 bit width\r
314 UINT32 Reserved1: 14;\r
315 UINT32 BoundarySize;\r
316}HOST_CAPABILITY;\r
317\r
318\r
319//\r
320// Interface structure for the SD HOST I/O Protocol\r
321//\r
322struct _EFI_SD_HOST_IO_PROTOCOL {\r
323 UINT32 Revision;\r
324 HOST_CAPABILITY HostCapability;\r
325 EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND SendCommand;\r
326 EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY SetClockFrequency;\r
327 EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH SetBusWidth;\r
328 EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE SetHostVoltage;\r
329 EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST ResetSDHost;\r
330 EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD EnableAutoStopCmd;\r
331 EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST DetectCardAndInitHost;\r
332 EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH SetBlockLength;\r
333 EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE SetHighSpeedMode;\r
334 EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE SetDDRMode;\r
335};\r
336\r
337extern EFI_GUID gEfiSDHostIoProtocolGuid;\r
338\r
339#endif\r