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