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