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