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