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