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