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