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