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