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