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