]>
Commit | Line | Data |
---|---|---|
48555339 FT |
1 | /** @file\r |
2 | \r | |
3 | Provides some data structure definitions used by the SD/MMC host controller driver.\r | |
4 | \r | |
b5547b9c | 5 | Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.\r |
48555339 FT |
6 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _SD_MMC_PCI_HC_DXE_H_\r | |
18 | #define _SD_MMC_PCI_HC_DXE_H_\r | |
19 | \r | |
20 | #include <Uefi.h>\r | |
21 | \r | |
22 | #include <IndustryStandard/Pci.h>\r | |
23 | #include <IndustryStandard/Emmc.h>\r | |
24 | #include <IndustryStandard/Sd.h>\r | |
25 | \r | |
26 | #include <Library/UefiDriverEntryPoint.h>\r | |
27 | #include <Library/DebugLib.h>\r | |
28 | #include <Library/UefiBootServicesTableLib.h>\r | |
29 | #include <Library/BaseMemoryLib.h>\r | |
30 | #include <Library/MemoryAllocationLib.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/DevicePathLib.h>\r | |
33 | \r | |
34 | #include <Protocol/DevicePath.h>\r | |
35 | #include <Protocol/PciIo.h>\r | |
36 | #include <Protocol/DriverBinding.h>\r | |
37 | #include <Protocol/ComponentName.h>\r | |
38 | #include <Protocol/ComponentName2.h>\r | |
b23fc39c | 39 | #include <Protocol/SdMmcOverride.h>\r |
48555339 FT |
40 | #include <Protocol/SdMmcPassThru.h>\r |
41 | \r | |
42 | #include "SdMmcPciHci.h"\r | |
43 | \r | |
44 | extern EFI_COMPONENT_NAME_PROTOCOL gSdMmcPciHcComponentName;\r | |
45 | extern EFI_COMPONENT_NAME2_PROTOCOL gSdMmcPciHcComponentName2;\r | |
46 | extern EFI_DRIVER_BINDING_PROTOCOL gSdMmcPciHcDriverBinding;\r | |
47 | \r | |
b23fc39c AB |
48 | extern EDKII_SD_MMC_OVERRIDE *mOverride;\r |
49 | \r | |
48555339 FT |
50 | #define SD_MMC_HC_PRIVATE_SIGNATURE SIGNATURE_32 ('s', 'd', 't', 'f')\r |
51 | \r | |
52 | #define SD_MMC_HC_PRIVATE_FROM_THIS(a) \\r | |
53 | CR(a, SD_MMC_HC_PRIVATE_DATA, PassThru, SD_MMC_HC_PRIVATE_SIGNATURE)\r | |
54 | \r | |
55 | //\r | |
56 | // Generic time out value, 1 microsecond as unit.\r | |
57 | //\r | |
58 | #define SD_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 1000\r | |
59 | \r | |
60 | //\r | |
61 | // SD/MMC async transfer timer interval, set by experience.\r | |
62 | // The unit is 100us, takes 1ms as interval.\r | |
63 | //\r | |
64 | #define SD_MMC_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS(1)\r | |
65 | //\r | |
66 | // SD/MMC removable device enumeration timer interval, set by experience.\r | |
67 | // The unit is 100us, takes 100ms as interval.\r | |
68 | //\r | |
69 | #define SD_MMC_HC_ENUM_TIMER EFI_TIMER_PERIOD_MILLISECONDS(100)\r | |
70 | \r | |
71 | typedef enum {\r | |
72 | UnknownCardType,\r | |
73 | SdCardType,\r | |
74 | SdioCardType,\r | |
75 | MmcCardType,\r | |
76 | EmmcCardType\r | |
77 | } SD_MMC_CARD_TYPE;\r | |
78 | \r | |
79 | typedef enum {\r | |
80 | RemovableSlot,\r | |
81 | EmbeddedSlot,\r | |
82 | SharedBusSlot,\r | |
83 | UnknownSlot\r | |
84 | } EFI_SD_MMC_SLOT_TYPE;\r | |
85 | \r | |
86 | typedef struct {\r | |
87 | BOOLEAN Enable;\r | |
88 | EFI_SD_MMC_SLOT_TYPE SlotType;\r | |
89 | BOOLEAN MediaPresent;\r | |
c25ddd01 | 90 | BOOLEAN Initialized;\r |
48555339 FT |
91 | SD_MMC_CARD_TYPE CardType;\r |
92 | } SD_MMC_HC_SLOT;\r | |
93 | \r | |
94 | typedef struct {\r | |
95 | UINTN Signature;\r | |
96 | \r | |
97 | EFI_HANDLE ControllerHandle;\r | |
98 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
99 | \r | |
100 | EFI_SD_MMC_PASS_THRU_PROTOCOL PassThru;\r | |
101 | \r | |
102 | UINT64 PciAttributes;\r | |
103 | //\r | |
104 | // The field is used to record the previous slot in GetNextSlot().\r | |
105 | //\r | |
106 | UINT8 PreviousSlot;\r | |
107 | //\r | |
108 | // For Non-blocking operation.\r | |
109 | //\r | |
110 | EFI_EVENT TimerEvent;\r | |
111 | //\r | |
112 | // For Sd removable device enumeration.\r | |
113 | //\r | |
114 | EFI_EVENT ConnectEvent;\r | |
115 | LIST_ENTRY Queue;\r | |
116 | \r | |
117 | SD_MMC_HC_SLOT Slot[SD_MMC_HC_MAX_SLOT];\r | |
118 | SD_MMC_HC_SLOT_CAP Capability[SD_MMC_HC_MAX_SLOT];\r | |
119 | UINT64 MaxCurrent[SD_MMC_HC_MAX_SLOT];\r | |
b5547b9c | 120 | UINT16 ControllerVersion[SD_MMC_HC_MAX_SLOT];\r |
7f3b0bad MW |
121 | \r |
122 | //\r | |
123 | // Some controllers may require to override base clock frequency\r | |
124 | // value stored in Capabilities Register 1.\r | |
125 | //\r | |
126 | UINT32 BaseClkFreq[SD_MMC_HC_MAX_SLOT];\r | |
48555339 FT |
127 | } SD_MMC_HC_PRIVATE_DATA;\r |
128 | \r | |
129 | #define SD_MMC_HC_TRB_SIG SIGNATURE_32 ('T', 'R', 'B', 'T')\r | |
130 | \r | |
131 | //\r | |
132 | // TRB (Transfer Request Block) contains information for the cmd request.\r | |
133 | //\r | |
134 | typedef struct {\r | |
135 | UINT32 Signature;\r | |
136 | LIST_ENTRY TrbList;\r | |
137 | \r | |
138 | UINT8 Slot;\r | |
139 | UINT16 BlockSize;\r | |
140 | \r | |
141 | EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;\r | |
142 | VOID *Data;\r | |
143 | UINT32 DataLen;\r | |
144 | BOOLEAN Read;\r | |
145 | EFI_PHYSICAL_ADDRESS DataPhy;\r | |
146 | VOID *DataMap;\r | |
147 | SD_MMC_HC_TRANSFER_MODE Mode;\r | |
148 | \r | |
149 | EFI_EVENT Event;\r | |
150 | BOOLEAN Started;\r | |
151 | UINT64 Timeout;\r | |
152 | \r | |
b5547b9c AS |
153 | SD_MMC_HC_ADMA_32_DESC_LINE *Adma32Desc;\r |
154 | SD_MMC_HC_ADMA_64_DESC_LINE *Adma64Desc;\r | |
48555339 FT |
155 | EFI_PHYSICAL_ADDRESS AdmaDescPhy;\r |
156 | VOID *AdmaMap;\r | |
157 | UINT32 AdmaPages;\r | |
158 | \r | |
159 | SD_MMC_HC_PRIVATE_DATA *Private;\r | |
160 | } SD_MMC_HC_TRB;\r | |
161 | \r | |
162 | #define SD_MMC_HC_TRB_FROM_THIS(a) \\r | |
163 | CR(a, SD_MMC_HC_TRB, TrbList, SD_MMC_HC_TRB_SIG)\r | |
164 | \r | |
165 | //\r | |
166 | // Task for Non-blocking mode.\r | |
167 | //\r | |
168 | typedef struct {\r | |
169 | UINT32 Signature;\r | |
170 | LIST_ENTRY Link;\r | |
171 | \r | |
172 | UINT8 Slot;\r | |
173 | EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;\r | |
174 | BOOLEAN IsStart;\r | |
175 | EFI_EVENT Event;\r | |
176 | UINT64 RetryTimes;\r | |
177 | BOOLEAN InfiniteWait;\r | |
178 | VOID *Map;\r | |
179 | VOID *MapAddress;\r | |
180 | } SD_MMC_HC_QUEUE;\r | |
181 | \r | |
182 | //\r | |
183 | // Prototypes\r | |
184 | //\r | |
185 | /**\r | |
186 | Execute card identification procedure.\r | |
187 | \r | |
188 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
189 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
190 | \r | |
191 | @retval EFI_SUCCESS The card is identified correctly.\r | |
192 | @retval Others The card can't be identified.\r | |
193 | \r | |
194 | **/\r | |
195 | typedef\r | |
196 | EFI_STATUS\r | |
197 | (*CARD_TYPE_DETECT_ROUTINE) (\r | |
198 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
199 | IN UINT8 Slot\r | |
200 | );\r | |
201 | \r | |
202 | /**\r | |
203 | Sends SD command to an SD card that is attached to the SD controller.\r | |
204 | \r | |
205 | The PassThru() function sends the SD command specified by Packet to the SD card\r | |
206 | specified by Slot.\r | |
207 | \r | |
208 | If Packet is successfully sent to the SD card, then EFI_SUCCESS is returned.\r | |
209 | \r | |
210 | If a device error occurs while sending the Packet, then EFI_DEVICE_ERROR is returned.\r | |
211 | \r | |
212 | If Slot is not in a valid range for the SD controller, then EFI_INVALID_PARAMETER\r | |
213 | is returned.\r | |
214 | \r | |
215 | If Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL,\r | |
216 | EFI_INVALID_PARAMETER is returned.\r | |
217 | \r | |
218 | @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r | |
219 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
220 | @param[in,out] Packet A pointer to the SD command data structure.\r | |
221 | @param[in] Event If Event is NULL, blocking I/O is performed. If Event is\r | |
222 | not NULL, then nonblocking I/O is performed, and Event\r | |
223 | will be signaled when the Packet completes.\r | |
224 | \r | |
225 | @retval EFI_SUCCESS The SD Command Packet was sent by the host.\r | |
226 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SD\r | |
227 | command Packet.\r | |
228 | @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the Packet is invalid.\r | |
229 | @retval EFI_INVALID_PARAMETER Packet defines a data command but both InDataBuffer and\r | |
230 | OutDataBuffer are NULL.\r | |
231 | @retval EFI_NO_MEDIA SD Device not present in the Slot.\r | |
232 | @retval EFI_UNSUPPORTED The command described by the SD Command Packet is not\r | |
233 | supported by the host controller.\r | |
234 | @retval EFI_BAD_BUFFER_SIZE The InTransferLength or OutTransferLength exceeds the\r | |
235 | limit supported by SD card ( i.e. if the number of bytes\r | |
236 | exceed the Last LBA).\r | |
237 | \r | |
238 | **/\r | |
239 | EFI_STATUS\r | |
240 | EFIAPI\r | |
241 | SdMmcPassThruPassThru (\r | |
242 | IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r | |
243 | IN UINT8 Slot,\r | |
244 | IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,\r | |
245 | IN EFI_EVENT Event OPTIONAL\r | |
246 | );\r | |
247 | \r | |
248 | /**\r | |
249 | Used to retrieve next slot numbers supported by the SD controller. The function\r | |
250 | returns information about all available slots (populated or not-populated).\r | |
251 | \r | |
252 | The GetNextSlot() function retrieves the next slot number on an SD controller.\r | |
253 | If on input Slot is 0xFF, then the slot number of the first slot on the SD controller\r | |
254 | is returned.\r | |
255 | \r | |
256 | If Slot is a slot number that was returned on a previous call to GetNextSlot(), then\r | |
257 | the slot number of the next slot on the SD controller is returned.\r | |
258 | \r | |
259 | If Slot is not 0xFF and Slot was not returned on a previous call to GetNextSlot(),\r | |
260 | EFI_INVALID_PARAMETER is returned.\r | |
261 | \r | |
262 | If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND\r | |
263 | is returned.\r | |
264 | \r | |
265 | @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r | |
266 | @param[in,out] Slot On input, a pointer to a slot number on the SD controller.\r | |
267 | On output, a pointer to the next slot number on the SD controller.\r | |
268 | An input value of 0xFF retrieves the first slot number on the SD\r | |
269 | controller.\r | |
270 | \r | |
271 | @retval EFI_SUCCESS The next slot number on the SD controller was returned in Slot.\r | |
272 | @retval EFI_NOT_FOUND There are no more slots on this SD controller.\r | |
273 | @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not returned on a previous call\r | |
274 | to GetNextSlot().\r | |
275 | \r | |
276 | **/\r | |
277 | EFI_STATUS\r | |
278 | EFIAPI\r | |
279 | SdMmcPassThruGetNextSlot (\r | |
280 | IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r | |
281 | IN OUT UINT8 *Slot\r | |
282 | );\r | |
283 | \r | |
284 | /**\r | |
285 | Used to allocate and build a device path node for an SD card on the SD controller.\r | |
286 | \r | |
287 | The BuildDevicePath() function allocates and builds a single device node for the SD\r | |
288 | card specified by Slot.\r | |
289 | \r | |
290 | If the SD card specified by Slot is not present on the SD controller, then EFI_NOT_FOUND\r | |
291 | is returned.\r | |
292 | \r | |
293 | If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r | |
294 | \r | |
295 | If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES\r | |
296 | is returned.\r | |
297 | \r | |
298 | Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of\r | |
299 | DevicePath are initialized to describe the SD card specified by Slot, and EFI_SUCCESS is\r | |
300 | returned.\r | |
301 | \r | |
302 | @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r | |
303 | @param[in] Slot Specifies the slot number of the SD card for which a device\r | |
304 | path node is to be allocated and built.\r | |
305 | @param[in,out] DevicePath A pointer to a single device path node that describes the SD\r | |
306 | card specified by Slot. This function is responsible for\r | |
307 | allocating the buffer DevicePath with the boot service\r | |
308 | AllocatePool(). It is the caller's responsibility to free\r | |
309 | DevicePath when the caller is finished with DevicePath.\r | |
310 | \r | |
311 | @retval EFI_SUCCESS The device path node that describes the SD card specified by\r | |
312 | Slot was allocated and returned in DevicePath.\r | |
313 | @retval EFI_NOT_FOUND The SD card specified by Slot does not exist on the SD controller.\r | |
314 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r | |
315 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r | |
316 | \r | |
317 | **/\r | |
318 | EFI_STATUS\r | |
319 | EFIAPI\r | |
320 | SdMmcPassThruBuildDevicePath (\r | |
321 | IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r | |
322 | IN UINT8 Slot,\r | |
323 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r | |
324 | );\r | |
325 | \r | |
326 | /**\r | |
327 | This function retrieves an SD card slot number based on the input device path.\r | |
328 | \r | |
329 | The GetSlotNumber() function retrieves slot number for the SD card specified by\r | |
330 | the DevicePath node. If DevicePath is NULL, EFI_INVALID_PARAMETER is returned.\r | |
331 | \r | |
332 | If DevicePath is not a device path node type that the SD Pass Thru driver supports,\r | |
333 | EFI_UNSUPPORTED is returned.\r | |
334 | \r | |
335 | @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r | |
336 | @param[in] DevicePath A pointer to the device path node that describes a SD\r | |
337 | card on the SD controller.\r | |
338 | @param[out] Slot On return, points to the slot number of an SD card on\r | |
339 | the SD controller.\r | |
340 | \r | |
341 | @retval EFI_SUCCESS SD card slot number is returned in Slot.\r | |
342 | @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.\r | |
343 | @retval EFI_UNSUPPORTED DevicePath is not a device path node type that the SD\r | |
344 | Pass Thru driver supports.\r | |
345 | \r | |
346 | **/\r | |
347 | EFI_STATUS\r | |
348 | EFIAPI\r | |
349 | SdMmcPassThruGetSlotNumber (\r | |
350 | IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r | |
351 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
352 | OUT UINT8 *Slot\r | |
353 | );\r | |
354 | \r | |
355 | /**\r | |
356 | Resets an SD card that is connected to the SD controller.\r | |
357 | \r | |
358 | The ResetDevice() function resets the SD card specified by Slot.\r | |
359 | \r | |
360 | If this SD controller does not support a device reset operation, EFI_UNSUPPORTED is\r | |
361 | returned.\r | |
362 | \r | |
363 | If Slot is not in a valid slot number for this SD controller, EFI_INVALID_PARAMETER\r | |
364 | is returned.\r | |
365 | \r | |
366 | If the device reset operation is completed, EFI_SUCCESS is returned.\r | |
367 | \r | |
368 | @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r | |
369 | @param[in] Slot Specifies the slot number of the SD card to be reset.\r | |
370 | \r | |
371 | @retval EFI_SUCCESS The SD card specified by Slot was reset.\r | |
372 | @retval EFI_UNSUPPORTED The SD controller does not support a device reset operation.\r | |
373 | @retval EFI_INVALID_PARAMETER Slot number is invalid.\r | |
374 | @retval EFI_NO_MEDIA SD Device not present in the Slot.\r | |
375 | @retval EFI_DEVICE_ERROR The reset command failed due to a device error\r | |
376 | \r | |
377 | **/\r | |
378 | EFI_STATUS\r | |
379 | EFIAPI\r | |
380 | SdMmcPassThruResetDevice (\r | |
381 | IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r | |
382 | IN UINT8 Slot\r | |
383 | );\r | |
384 | \r | |
385 | //\r | |
386 | // Driver model protocol interfaces\r | |
387 | //\r | |
388 | /**\r | |
389 | Tests to see if this driver supports a given controller. If a child device is provided,\r | |
390 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
391 | \r | |
392 | This function checks to see if the driver specified by This supports the device specified by\r | |
393 | ControllerHandle. Drivers will typically use the device path attached to\r | |
394 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
395 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
396 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
397 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
398 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
399 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
400 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
401 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
402 | Since ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
403 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
404 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
405 | \r | |
406 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
407 | @param[in] ControllerHandle The handle of the controller to test. This handle\r | |
408 | must support a protocol interface that supplies\r | |
409 | an I/O abstraction to the driver.\r | |
410 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
411 | parameter is ignored by device drivers, and is optional for bus\r | |
412 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
413 | the bus driver must determine if the bus controller specified\r | |
414 | by ControllerHandle and the child controller specified\r | |
415 | by RemainingDevicePath are both supported by this\r | |
416 | bus driver.\r | |
417 | \r | |
418 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
419 | RemainingDevicePath is supported by the driver specified by This.\r | |
420 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
421 | RemainingDevicePath is already being managed by the driver\r | |
422 | specified by This.\r | |
423 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
424 | RemainingDevicePath is already being managed by a different\r | |
425 | driver or an application that requires exclusive access.\r | |
426 | Currently not implemented.\r | |
427 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
428 | RemainingDevicePath is not supported by the driver specified by This.\r | |
429 | **/\r | |
430 | EFI_STATUS\r | |
431 | EFIAPI\r | |
432 | SdMmcPciHcDriverBindingSupported (\r | |
433 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
434 | IN EFI_HANDLE Controller,\r | |
435 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
436 | );\r | |
437 | \r | |
438 | /**\r | |
439 | Starts a device controller or a bus controller.\r | |
440 | \r | |
441 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
442 | As a result, much of the error checking on the parameters to Start() has been moved into this\r | |
443 | common boot service. It is legal to call Start() from other locations,\r | |
444 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
445 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
446 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
447 | EFI_DEVICE_PATH_PROTOCOL.\r | |
448 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
449 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r | |
450 | \r | |
451 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
452 | @param[in] ControllerHandle The handle of the controller to start. This handle\r | |
453 | must support a protocol interface that supplies\r | |
454 | an I/O abstraction to the driver.\r | |
455 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
456 | parameter is ignored by device drivers, and is optional for bus\r | |
457 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
458 | for all the children of Controller are created by this driver.\r | |
459 | If this parameter is not NULL and the first Device Path Node is\r | |
460 | not the End of Device Path Node, then only the handle for the\r | |
461 | child device specified by the first Device Path Node of\r | |
462 | RemainingDevicePath is created by this driver.\r | |
463 | If the first Device Path Node of RemainingDevicePath is\r | |
464 | the End of Device Path Node, no child handle is created by this\r | |
465 | driver.\r | |
466 | \r | |
467 | @retval EFI_SUCCESS The device was started.\r | |
468 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
469 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
470 | @retval Others The driver failded to start the device.\r | |
471 | \r | |
472 | **/\r | |
473 | EFI_STATUS\r | |
474 | EFIAPI\r | |
475 | SdMmcPciHcDriverBindingStart (\r | |
476 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
477 | IN EFI_HANDLE Controller,\r | |
478 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
479 | );\r | |
480 | \r | |
481 | /**\r | |
482 | Stops a device controller or a bus controller.\r | |
483 | \r | |
484 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
485 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
486 | into this common boot service. It is legal to call Stop() from other locations,\r | |
487 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
488 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
489 | same driver's Start() function.\r | |
490 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
491 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
492 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
493 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
494 | \r | |
495 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
496 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r | |
497 | support a bus specific I/O protocol for the driver\r | |
498 | to use to stop the device.\r | |
499 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
500 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r | |
501 | if NumberOfChildren is 0.\r | |
502 | \r | |
503 | @retval EFI_SUCCESS The device was stopped.\r | |
504 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
505 | \r | |
506 | **/\r | |
507 | EFI_STATUS\r | |
508 | EFIAPI\r | |
509 | SdMmcPciHcDriverBindingStop (\r | |
510 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
511 | IN EFI_HANDLE Controller,\r | |
512 | IN UINTN NumberOfChildren,\r | |
513 | IN EFI_HANDLE *ChildHandleBuffer\r | |
514 | );\r | |
515 | \r | |
516 | //\r | |
517 | // EFI Component Name Functions\r | |
518 | //\r | |
519 | /**\r | |
520 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
521 | \r | |
522 | This function retrieves the user readable name of a driver in the form of a\r | |
523 | Unicode string. If the driver specified by This has a user readable name in\r | |
524 | the language specified by Language, then a pointer to the driver name is\r | |
525 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
526 | by This does not support the language specified by Language,\r | |
527 | then EFI_UNSUPPORTED is returned.\r | |
528 | \r | |
529 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
530 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
531 | \r | |
532 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
533 | array indicating the language. This is the\r | |
534 | language of the driver name that the caller is\r | |
535 | requesting, and it must match one of the\r | |
536 | languages specified in SupportedLanguages. The\r | |
537 | number of languages supported by a driver is up\r | |
538 | to the driver writer. Language is specified\r | |
539 | in RFC 4646 or ISO 639-2 language code format.\r | |
540 | \r | |
541 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
542 | This Unicode string is the name of the\r | |
543 | driver specified by This in the language\r | |
544 | specified by Language.\r | |
545 | \r | |
546 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
547 | This and the language specified by Language was\r | |
548 | returned in DriverName.\r | |
549 | \r | |
550 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
551 | \r | |
552 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
553 | \r | |
554 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
555 | the language specified by Language.\r | |
556 | \r | |
557 | **/\r | |
558 | EFI_STATUS\r | |
559 | EFIAPI\r | |
560 | SdMmcPciHcComponentNameGetDriverName (\r | |
561 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
562 | IN CHAR8 *Language,\r | |
563 | OUT CHAR16 **DriverName\r | |
564 | );\r | |
565 | \r | |
566 | /**\r | |
567 | Retrieves a Unicode string that is the user readable name of the controller\r | |
568 | that is being managed by a driver.\r | |
569 | \r | |
570 | This function retrieves the user readable name of the controller specified by\r | |
571 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
572 | driver specified by This has a user readable name in the language specified by\r | |
573 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
574 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
575 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
576 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
577 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
578 | \r | |
579 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
580 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
581 | \r | |
582 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
583 | specified by This is managing. This handle\r | |
584 | specifies the controller whose name is to be\r | |
585 | returned.\r | |
586 | \r | |
587 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
588 | the name of. This is an optional parameter that\r | |
589 | may be NULL. It will be NULL for device\r | |
590 | drivers. It will also be NULL for a bus drivers\r | |
591 | that wish to retrieve the name of the bus\r | |
592 | controller. It will not be NULL for a bus\r | |
593 | driver that wishes to retrieve the name of a\r | |
594 | child controller.\r | |
595 | \r | |
596 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
597 | array indicating the language. This is the\r | |
598 | language of the driver name that the caller is\r | |
599 | requesting, and it must match one of the\r | |
600 | languages specified in SupportedLanguages. The\r | |
601 | number of languages supported by a driver is up\r | |
602 | to the driver writer. Language is specified in\r | |
603 | RFC 4646 or ISO 639-2 language code format.\r | |
604 | \r | |
605 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
606 | This Unicode string is the name of the\r | |
607 | controller specified by ControllerHandle and\r | |
608 | ChildHandle in the language specified by\r | |
609 | Language from the point of view of the driver\r | |
610 | specified by This.\r | |
611 | \r | |
612 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
613 | the language specified by Language for the\r | |
614 | driver specified by This was returned in\r | |
615 | DriverName.\r | |
616 | \r | |
617 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
618 | \r | |
619 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
620 | EFI_HANDLE.\r | |
621 | \r | |
622 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
623 | \r | |
624 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
625 | \r | |
626 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
627 | managing the controller specified by\r | |
628 | ControllerHandle and ChildHandle.\r | |
629 | \r | |
630 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
631 | the language specified by Language.\r | |
632 | \r | |
633 | **/\r | |
634 | EFI_STATUS\r | |
635 | EFIAPI\r | |
636 | SdMmcPciHcComponentNameGetControllerName (\r | |
637 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
638 | IN EFI_HANDLE ControllerHandle,\r | |
639 | IN EFI_HANDLE ChildHandle, OPTIONAL\r | |
640 | IN CHAR8 *Language,\r | |
641 | OUT CHAR16 **ControllerName\r | |
642 | );\r | |
643 | \r | |
644 | /**\r | |
645 | Create a new TRB for the SD/MMC cmd request.\r | |
646 | \r | |
647 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
648 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
649 | @param[in] Packet A pointer to the SD command data structure.\r | |
650 | @param[in] Event If Event is NULL, blocking I/O is performed. If Event is\r | |
651 | not NULL, then nonblocking I/O is performed, and Event\r | |
652 | will be signaled when the Packet completes.\r | |
653 | \r | |
654 | @return Created Trb or NULL.\r | |
655 | \r | |
656 | **/\r | |
657 | SD_MMC_HC_TRB *\r | |
658 | SdMmcCreateTrb (\r | |
659 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
660 | IN UINT8 Slot,\r | |
661 | IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,\r | |
662 | IN EFI_EVENT Event\r | |
663 | );\r | |
664 | \r | |
665 | /**\r | |
666 | Free the resource used by the TRB.\r | |
667 | \r | |
668 | @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r | |
669 | \r | |
670 | **/\r | |
671 | VOID\r | |
672 | SdMmcFreeTrb (\r | |
673 | IN SD_MMC_HC_TRB *Trb\r | |
674 | );\r | |
675 | \r | |
676 | /**\r | |
677 | Check if the env is ready for execute specified TRB.\r | |
678 | \r | |
679 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
680 | @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r | |
681 | \r | |
682 | @retval EFI_SUCCESS The env is ready for TRB execution.\r | |
683 | @retval EFI_NOT_READY The env is not ready for TRB execution.\r | |
684 | @retval Others Some erros happen.\r | |
685 | \r | |
686 | **/\r | |
687 | EFI_STATUS\r | |
688 | SdMmcCheckTrbEnv (\r | |
689 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
690 | IN SD_MMC_HC_TRB *Trb\r | |
691 | );\r | |
692 | \r | |
693 | /**\r | |
694 | Wait for the env to be ready for execute specified TRB.\r | |
695 | \r | |
696 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
697 | @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r | |
698 | \r | |
699 | @retval EFI_SUCCESS The env is ready for TRB execution.\r | |
700 | @retval EFI_TIMEOUT The env is not ready for TRB execution in time.\r | |
701 | @retval Others Some erros happen.\r | |
702 | \r | |
703 | **/\r | |
704 | EFI_STATUS\r | |
705 | SdMmcWaitTrbEnv (\r | |
706 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
707 | IN SD_MMC_HC_TRB *Trb\r | |
708 | );\r | |
709 | \r | |
710 | /**\r | |
711 | Execute the specified TRB.\r | |
712 | \r | |
713 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
714 | @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r | |
715 | \r | |
716 | @retval EFI_SUCCESS The TRB is sent to host controller successfully.\r | |
717 | @retval Others Some erros happen when sending this request to the host controller.\r | |
718 | \r | |
719 | **/\r | |
720 | EFI_STATUS\r | |
721 | SdMmcExecTrb (\r | |
722 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
723 | IN SD_MMC_HC_TRB *Trb\r | |
724 | );\r | |
725 | \r | |
726 | /**\r | |
727 | Check the TRB execution result.\r | |
728 | \r | |
729 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
730 | @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r | |
731 | \r | |
732 | @retval EFI_SUCCESS The TRB is executed successfully.\r | |
733 | @retval EFI_NOT_READY The TRB is not completed for execution.\r | |
734 | @retval Others Some erros happen when executing this request.\r | |
735 | \r | |
736 | **/\r | |
737 | EFI_STATUS\r | |
738 | SdMmcCheckTrbResult (\r | |
739 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
740 | IN SD_MMC_HC_TRB *Trb\r | |
741 | );\r | |
742 | \r | |
743 | /**\r | |
744 | Wait for the TRB execution result.\r | |
745 | \r | |
746 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
747 | @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r | |
748 | \r | |
749 | @retval EFI_SUCCESS The TRB is executed successfully.\r | |
750 | @retval Others Some erros happen when executing this request.\r | |
751 | \r | |
752 | **/\r | |
753 | EFI_STATUS\r | |
754 | SdMmcWaitTrbResult (\r | |
755 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
756 | IN SD_MMC_HC_TRB *Trb\r | |
757 | );\r | |
758 | \r | |
759 | /**\r | |
760 | Execute EMMC device identification procedure.\r | |
761 | \r | |
762 | Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.\r | |
763 | \r | |
764 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
765 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
766 | \r | |
767 | @retval EFI_SUCCESS There is a EMMC card.\r | |
768 | @retval Others There is not a EMMC card.\r | |
769 | \r | |
770 | **/\r | |
771 | EFI_STATUS\r | |
772 | EmmcIdentification (\r | |
773 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
774 | IN UINT8 Slot\r | |
775 | );\r | |
776 | \r | |
777 | /**\r | |
778 | Execute EMMC device identification procedure.\r | |
779 | \r | |
780 | Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.\r | |
781 | \r | |
782 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
783 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
784 | \r | |
785 | @retval EFI_SUCCESS There is a EMMC card.\r | |
786 | @retval Others There is not a EMMC card.\r | |
787 | \r | |
788 | **/\r | |
789 | EFI_STATUS\r | |
790 | SdCardIdentification (\r | |
791 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
792 | IN UINT8 Slot\r | |
793 | );\r | |
794 | \r | |
b23fc39c AB |
795 | /**\r |
796 | Software reset the specified SD/MMC host controller.\r | |
797 | \r | |
798 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
799 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
800 | \r | |
801 | @retval EFI_SUCCESS The software reset executes successfully.\r | |
802 | @retval Others The software reset fails.\r | |
803 | \r | |
804 | **/\r | |
805 | EFI_STATUS\r | |
806 | SdMmcHcReset (\r | |
807 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
808 | IN UINT8 Slot\r | |
809 | );\r | |
810 | \r | |
811 | /**\r | |
812 | Initial SD/MMC host controller with lowest clock frequency, max power and max timeout value\r | |
813 | at initialization.\r | |
814 | \r | |
815 | @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r | |
816 | @param[in] Slot The slot number of the SD card to send the command to.\r | |
817 | \r | |
818 | @retval EFI_SUCCESS The host controller is initialized successfully.\r | |
819 | @retval Others The host controller isn't initialized successfully.\r | |
820 | \r | |
821 | **/\r | |
822 | EFI_STATUS\r | |
823 | SdMmcHcInitHost (\r | |
824 | IN SD_MMC_HC_PRIVATE_DATA *Private,\r | |
825 | IN UINT8 Slot\r | |
826 | );\r | |
827 | \r | |
48555339 | 828 | #endif\r |