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