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