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