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