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