]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/SdMmcPassThru.h
MdePkg/ProcessorBind: add defines for page allocation granularity
[mirror_edk2.git] / MdePkg / Include / Protocol / SdMmcPassThru.h
CommitLineData
03e17578
FT
1/** @file\r
2 The EFI_SD_MMC_PASS_THRU_PROTOCOL provides the ability to send SD/MMC Commands\r
3 to any SD/MMC device attached to the SD compatible pci host controller.\r
4\r
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __SD_MMC_PASS_THRU_H__\r
17#define __SD_MMC_PASS_THRU_H__\r
18\r
19#define EFI_SD_MMC_PASS_THRU_PROTOCOL_GUID \\r
20 { \\r
21 0x716ef0d9, 0xff83, 0x4f69, {0x81, 0xe9, 0x51, 0x8b, 0xd3, 0x9a, 0x8e, 0x70 } \\r
22 }\r
23\r
24typedef struct _EFI_SD_MMC_PASS_THRU_PROTOCOL EFI_SD_MMC_PASS_THRU_PROTOCOL;\r
25\r
26typedef enum {\r
27 SdMmcCommandTypeBc, // Broadcast commands, no response\r
28 SdMmcCommandTypeBcr, // Broadcast commands with response\r
29 SdMmcCommandTypeAc, // Addressed(point-to-point) commands\r
30 SdMmcCommandTypeAdtc // Addressed(point-to-point) data transfer commands\r
31} EFI_SD_MMC_COMMAND_TYPE;\r
32\r
33typedef enum {\r
34 SdMmcResponseTypeR1,\r
35 SdMmcResponseTypeR1b,\r
36 SdMmcResponseTypeR2,\r
37 SdMmcResponseTypeR3,\r
38 SdMmcResponseTypeR4,\r
39 SdMmcResponseTypeR5,\r
40 SdMmcResponseTypeR5b,\r
41 SdMmcResponseTypeR6,\r
42 SdMmcResponseTypeR7\r
43} EFI_SD_MMC_RESPONSE_TYPE;\r
44\r
45typedef struct _EFI_SD_MMC_COMMAND_BLOCK {\r
46 UINT16 CommandIndex;\r
47 UINT32 CommandArgument;\r
48 UINT32 CommandType; // One of the EFI_SD_MMC_COMMAND_TYPE values\r
49 UINT32 ResponseType; // One of the EFI_SD_MMC_RESPONSE_TYPE values\r
50} EFI_SD_MMC_COMMAND_BLOCK;\r
51\r
52typedef struct _EFI_SD_MMC_STATUS_BLOCK {\r
53 UINT32 Resp0;\r
54 UINT32 Resp1;\r
55 UINT32 Resp2;\r
56 UINT32 Resp3;\r
57} EFI_SD_MMC_STATUS_BLOCK;\r
58\r
59typedef struct _EFI_SD_MMC_PASS_THRU_COMMAND_PACKET {\r
60 UINT64 Timeout;\r
61 EFI_SD_MMC_COMMAND_BLOCK *SdMmcCmdBlk;\r
62 EFI_SD_MMC_STATUS_BLOCK *SdMmcStatusBlk;\r
63 VOID *InDataBuffer;\r
64 VOID *OutDataBuffer;\r
65 UINT32 InTransferLength;\r
66 UINT32 OutTransferLength;\r
67 EFI_STATUS TransactionStatus;\r
68} EFI_SD_MMC_PASS_THRU_COMMAND_PACKET;\r
69\r
70/**\r
71 Sends SD command to an SD card that is attached to the SD controller.\r
72\r
73 The PassThru() function sends the SD command specified by Packet to the SD card\r
74 specified by Slot.\r
75\r
76 If Packet is successfully sent to the SD card, then EFI_SUCCESS is returned.\r
77\r
78 If a device error occurs while sending the Packet, then EFI_DEVICE_ERROR is returned.\r
79\r
80 If Slot is not in a valid range for the SD controller, then EFI_INVALID_PARAMETER\r
81 is returned.\r
82\r
83 If Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL,\r
84 EFI_INVALID_PARAMETER is returned.\r
85\r
86 @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
87 @param[in] Slot The slot number of the SD card to send the command to.\r
88 @param[in,out] Packet A pointer to the SD command data structure.\r
89 @param[in] Event If Event is NULL, blocking I/O is performed. If Event is\r
90 not NULL, then nonblocking I/O is performed, and Event\r
91 will be signaled when the Packet completes.\r
92\r
93 @retval EFI_SUCCESS The SD Command Packet was sent by the host.\r
94 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SD\r
95 command Packet.\r
96 @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the Packet is invalid.\r
97 @retval EFI_INVALID_PARAMETER Packet defines a data command but both InDataBuffer and\r
98 OutDataBuffer are NULL.\r
99 @retval EFI_NO_MEDIA SD Device not present in the Slot.\r
100 @retval EFI_UNSUPPORTED The command described by the SD Command Packet is not\r
101 supported by the host controller.\r
102 @retval EFI_BAD_BUFFER_SIZE The InTransferLength or OutTransferLength exceeds the\r
103 limit supported by SD card ( i.e. if the number of bytes\r
104 exceed the Last LBA).\r
105\r
106**/\r
107typedef\r
108EFI_STATUS\r
109(EFIAPI *EFI_SD_MMC_PASS_THRU_PASSTHRU) (\r
110 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
111 IN UINT8 Slot,\r
112 IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,\r
113 IN EFI_EVENT Event OPTIONAL\r
114);\r
115\r
116/**\r
117 Used to retrieve next slot numbers supported by the SD controller. The function\r
118 returns information about all available slots (populated or not-populated).\r
119\r
120 The GetNextSlot() function retrieves the next slot number on an SD controller.\r
121 If on input Slot is 0xFF, then the slot number of the first slot on the SD controller\r
122 is returned.\r
123\r
124 If Slot is a slot number that was returned on a previous call to GetNextSlot(), then\r
125 the slot number of the next slot on the SD controller is returned.\r
126\r
127 If Slot is not 0xFF and Slot was not returned on a previous call to GetNextSlot(),\r
128 EFI_INVALID_PARAMETER is returned.\r
129\r
130 If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND\r
131 is returned.\r
132\r
133 @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r
134 @param[in,out] Slot On input, a pointer to a slot number on the SD controller.\r
135 On output, a pointer to the next slot number on the SD controller.\r
136 An input value of 0xFF retrieves the first slot number on the SD\r
137 controller.\r
138\r
139 @retval EFI_SUCCESS The next slot number on the SD controller was returned in Slot.\r
140 @retval EFI_NOT_FOUND There are no more slots on this SD controller.\r
141 @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not returned on a previous call\r
142 to GetNextSlot().\r
143\r
144**/\r
145typedef\r
146EFI_STATUS\r
147(EFIAPI *EFI_SD_MMC_PASS_THRU_GET_NEXT_SLOT) (\r
148 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
149 IN OUT UINT8 *Slot\r
150);\r
151\r
152/**\r
153 Used to allocate and build a device path node for an SD card on the SD controller.\r
154\r
155 The BuildDevicePath() function allocates and builds a single device node for the SD\r
156 card specified by Slot.\r
157\r
158 If the SD card specified by Slot is not present on the SD controller, then EFI_NOT_FOUND\r
159 is returned.\r
160\r
161 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r
162\r
163 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES\r
164 is returned.\r
165\r
166 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of\r
167 DevicePath are initialized to describe the SD card specified by Slot, and EFI_SUCCESS is\r
168 returned.\r
169\r
170 @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r
171 @param[in] Slot Specifies the slot number of the SD card for which a device\r
172 path node is to be allocated and built.\r
173 @param[in,out] DevicePath A pointer to a single device path node that describes the SD\r
174 card specified by Slot. This function is responsible for\r
175 allocating the buffer DevicePath with the boot service\r
176 AllocatePool(). It is the caller's responsibility to free\r
177 DevicePath when the caller is finished with DevicePath.\r
178\r
179 @retval EFI_SUCCESS The device path node that describes the SD card specified by\r
180 Slot was allocated and returned in DevicePath.\r
181 @retval EFI_NOT_FOUND The SD card specified by Slot does not exist on the SD controller.\r
182 @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
183 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r
184\r
185**/\r
186typedef\r
187EFI_STATUS\r
188(EFIAPI *EFI_SD_MMC_PASS_THRU_BUILD_DEVICE_PATH) (\r
189 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
190 IN UINT8 Slot,\r
191 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
192);\r
193\r
194/**\r
195 This function retrieves an SD card slot number based on the input device path.\r
196\r
197 The GetSlotNumber() function retrieves slot number for the SD card specified by\r
198 the DevicePath node. If DevicePath is NULL, EFI_INVALID_PARAMETER is returned.\r
199\r
200 If DevicePath is not a device path node type that the SD Pass Thru driver supports,\r
201 EFI_UNSUPPORTED is returned.\r
202\r
203 @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
204 @param[in] DevicePath A pointer to the device path node that describes a SD\r
205 card on the SD controller.\r
206 @param[out] Slot On return, points to the slot number of an SD card on\r
207 the SD controller.\r
208\r
209 @retval EFI_SUCCESS SD card slot number is returned in Slot.\r
210 @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.\r
211 @retval EFI_UNSUPPORTED DevicePath is not a device path node type that the SD\r
212 Pass Thru driver supports.\r
213\r
214**/\r
215typedef\r
216EFI_STATUS\r
217(EFIAPI *EFI_SD_MMC_PASS_THRU_GET_SLOT_NUMBER) (\r
218 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
219 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
220 OUT UINT8 *Slot\r
221);\r
222\r
223/**\r
224 Resets an SD card that is connected to the SD controller.\r
225\r
226 The ResetDevice() function resets the SD card specified by Slot.\r
227\r
228 If this SD controller does not support a device reset operation, EFI_UNSUPPORTED is\r
229 returned.\r
230\r
231 If Slot is not in a valid slot number for this SD controller, EFI_INVALID_PARAMETER\r
232 is returned.\r
233\r
234 If the device reset operation is completed, EFI_SUCCESS is returned.\r
235\r
236 @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
237 @param[in] Slot Specifies the slot number of the SD card to be reset.\r
238\r
239 @retval EFI_SUCCESS The SD card specified by Slot was reset.\r
240 @retval EFI_UNSUPPORTED The SD controller does not support a device reset operation.\r
241 @retval EFI_INVALID_PARAMETER Slot number is invalid.\r
242 @retval EFI_NO_MEDIA SD Device not present in the Slot.\r
243 @retval EFI_DEVICE_ERROR The reset command failed due to a device error\r
244\r
245**/\r
246typedef\r
247EFI_STATUS\r
248(EFIAPI *EFI_SD_MMC_PASS_THRU_RESET_DEVICE) (\r
249 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
250 IN UINT8 Slot\r
251);\r
252\r
253struct _EFI_SD_MMC_PASS_THRU_PROTOCOL {\r
254 UINT32 IoAlign;\r
255 EFI_SD_MMC_PASS_THRU_PASSTHRU PassThru;\r
256 EFI_SD_MMC_PASS_THRU_GET_NEXT_SLOT GetNextSlot;\r
257 EFI_SD_MMC_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;\r
258 EFI_SD_MMC_PASS_THRU_GET_SLOT_NUMBER GetSlotNumber;\r
259 EFI_SD_MMC_PASS_THRU_RESET_DEVICE ResetDevice;\r
260};\r
261\r
262extern EFI_GUID gEfiSdMmcPassThruProtocolGuid;\r
263\r
264#endif\r