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