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