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