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