--- /dev/null
+/** @file\r
+\r
+ Provides some data structure definitions used by the SD/MMC host controller driver.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SD_MMC_PCI_HC_DXE_H_\r
+#define _SD_MMC_PCI_HC_DXE_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/Emmc.h>\r
+#include <IndustryStandard/Sd.h>\r
+\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/ComponentName2.h>\r
+#include <Protocol/SdMmcPassThru.h>\r
+\r
+#include "SdMmcPciHci.h"\r
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL gSdMmcPciHcComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gSdMmcPciHcComponentName2;\r
+extern EFI_DRIVER_BINDING_PROTOCOL gSdMmcPciHcDriverBinding;\r
+\r
+#define SD_MMC_HC_PRIVATE_SIGNATURE SIGNATURE_32 ('s', 'd', 't', 'f')\r
+\r
+#define SD_MMC_HC_PRIVATE_FROM_THIS(a) \\r
+ CR(a, SD_MMC_HC_PRIVATE_DATA, PassThru, SD_MMC_HC_PRIVATE_SIGNATURE)\r
+\r
+//\r
+// Generic time out value, 1 microsecond as unit.\r
+//\r
+#define SD_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 1000\r
+\r
+//\r
+// SD/MMC async transfer timer interval, set by experience.\r
+// The unit is 100us, takes 1ms as interval.\r
+//\r
+#define SD_MMC_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS(1)\r
+//\r
+// SD/MMC removable device enumeration timer interval, set by experience.\r
+// The unit is 100us, takes 100ms as interval.\r
+//\r
+#define SD_MMC_HC_ENUM_TIMER EFI_TIMER_PERIOD_MILLISECONDS(100)\r
+\r
+typedef enum {\r
+ UnknownCardType,\r
+ SdCardType,\r
+ SdioCardType,\r
+ MmcCardType,\r
+ EmmcCardType\r
+} SD_MMC_CARD_TYPE;\r
+\r
+typedef enum {\r
+ RemovableSlot,\r
+ EmbeddedSlot,\r
+ SharedBusSlot,\r
+ UnknownSlot\r
+} EFI_SD_MMC_SLOT_TYPE;\r
+\r
+typedef struct {\r
+ BOOLEAN Enable;\r
+ EFI_SD_MMC_SLOT_TYPE SlotType;\r
+ BOOLEAN MediaPresent;\r
+ SD_MMC_CARD_TYPE CardType;\r
+} SD_MMC_HC_SLOT;\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+\r
+ EFI_HANDLE ControllerHandle;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+\r
+ EFI_SD_MMC_PASS_THRU_PROTOCOL PassThru;\r
+\r
+ UINT64 PciAttributes;\r
+ //\r
+ // The field is used to record the previous slot in GetNextSlot().\r
+ //\r
+ UINT8 PreviousSlot;\r
+ //\r
+ // For Non-blocking operation.\r
+ //\r
+ EFI_EVENT TimerEvent;\r
+ //\r
+ // For Sd removable device enumeration.\r
+ //\r
+ EFI_EVENT ConnectEvent;\r
+ LIST_ENTRY Queue;\r
+\r
+ SD_MMC_HC_SLOT Slot[SD_MMC_HC_MAX_SLOT];\r
+ SD_MMC_HC_SLOT_CAP Capability[SD_MMC_HC_MAX_SLOT];\r
+ UINT64 MaxCurrent[SD_MMC_HC_MAX_SLOT];\r
+\r
+ UINT32 ControllerVersion;\r
+} SD_MMC_HC_PRIVATE_DATA;\r
+\r
+#define SD_MMC_HC_TRB_SIG SIGNATURE_32 ('T', 'R', 'B', 'T')\r
+\r
+//\r
+// TRB (Transfer Request Block) contains information for the cmd request.\r
+//\r
+typedef struct {\r
+ UINT32 Signature;\r
+ LIST_ENTRY TrbList;\r
+\r
+ UINT8 Slot;\r
+ UINT16 BlockSize;\r
+\r
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;\r
+ VOID *Data;\r
+ UINT32 DataLen;\r
+ BOOLEAN Read;\r
+ EFI_PHYSICAL_ADDRESS DataPhy;\r
+ VOID *DataMap;\r
+ SD_MMC_HC_TRANSFER_MODE Mode;\r
+\r
+ EFI_EVENT Event;\r
+ BOOLEAN Started;\r
+ UINT64 Timeout;\r
+\r
+ SD_MMC_HC_ADMA_DESC_LINE *AdmaDesc;\r
+ EFI_PHYSICAL_ADDRESS AdmaDescPhy;\r
+ VOID *AdmaMap;\r
+ UINT32 AdmaPages;\r
+\r
+ SD_MMC_HC_PRIVATE_DATA *Private;\r
+} SD_MMC_HC_TRB;\r
+\r
+#define SD_MMC_HC_TRB_FROM_THIS(a) \\r
+ CR(a, SD_MMC_HC_TRB, TrbList, SD_MMC_HC_TRB_SIG)\r
+\r
+//\r
+// Task for Non-blocking mode.\r
+//\r
+typedef struct {\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+\r
+ UINT8 Slot;\r
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;\r
+ BOOLEAN IsStart;\r
+ EFI_EVENT Event;\r
+ UINT64 RetryTimes;\r
+ BOOLEAN InfiniteWait;\r
+ VOID *Map;\r
+ VOID *MapAddress;\r
+} SD_MMC_HC_QUEUE;\r
+\r
+//\r
+// Prototypes\r
+//\r
+/**\r
+ Execute card identification procedure.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Slot The slot number of the SD card to send the command to.\r
+\r
+ @retval EFI_SUCCESS The card is identified correctly.\r
+ @retval Others The card can't be identified.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(*CARD_TYPE_DETECT_ROUTINE) (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN UINT8 Slot\r
+ );\r
+\r
+/**\r
+ Sends SD command to an SD card that is attached to the SD controller.\r
+\r
+ The PassThru() function sends the SD command specified by Packet to the SD card\r
+ specified by Slot.\r
+\r
+ If Packet is successfully sent to the SD card, then EFI_SUCCESS is returned.\r
+\r
+ If a device error occurs while sending the Packet, then EFI_DEVICE_ERROR is returned.\r
+\r
+ If Slot is not in a valid range for the SD controller, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL,\r
+ EFI_INVALID_PARAMETER is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] Slot The slot number of the SD card to send the command to.\r
+ @param[in,out] Packet A pointer to the SD command data structure.\r
+ @param[in] Event If Event is NULL, blocking I/O is performed. If Event is\r
+ not NULL, then nonblocking I/O is performed, and Event\r
+ will be signaled when the Packet completes.\r
+\r
+ @retval EFI_SUCCESS The SD Command Packet was sent by the host.\r
+ @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SD\r
+ command Packet.\r
+ @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the Packet is invalid.\r
+ @retval EFI_INVALID_PARAMETER Packet defines a data command but both InDataBuffer and\r
+ OutDataBuffer are NULL.\r
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.\r
+ @retval EFI_UNSUPPORTED The command described by the SD Command Packet is not\r
+ supported by the host controller.\r
+ @retval EFI_BAD_BUFFER_SIZE The InTransferLength or OutTransferLength exceeds the\r
+ limit supported by SD card ( i.e. if the number of bytes\r
+ exceed the Last LBA).\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPassThruPassThru (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 Slot,\r
+ IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,\r
+ IN EFI_EVENT Event OPTIONAL\r
+ );\r
+\r
+/**\r
+ Used to retrieve next slot numbers supported by the SD controller. The function\r
+ returns information about all available slots (populated or not-populated).\r
+\r
+ The GetNextSlot() function retrieves the next slot number on an SD controller.\r
+ If on input Slot is 0xFF, then the slot number of the first slot on the SD controller\r
+ is returned.\r
+\r
+ If Slot is a slot number that was returned on a previous call to GetNextSlot(), then\r
+ the slot number of the next slot on the SD controller is returned.\r
+\r
+ If Slot is not 0xFF and Slot was not returned on a previous call to GetNextSlot(),\r
+ EFI_INVALID_PARAMETER is returned.\r
+\r
+ If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND\r
+ is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in,out] Slot On input, a pointer to a slot number on the SD controller.\r
+ On output, a pointer to the next slot number on the SD controller.\r
+ An input value of 0xFF retrieves the first slot number on the SD\r
+ controller.\r
+\r
+ @retval EFI_SUCCESS The next slot number on the SD controller was returned in Slot.\r
+ @retval EFI_NOT_FOUND There are no more slots on this SD controller.\r
+ @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not returned on a previous call\r
+ to GetNextSlot().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPassThruGetNextSlot (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN OUT UINT8 *Slot\r
+ );\r
+\r
+/**\r
+ Used to allocate and build a device path node for an SD card on the SD controller.\r
+\r
+ The BuildDevicePath() function allocates and builds a single device node for the SD\r
+ card specified by Slot.\r
+\r
+ If the SD card specified by Slot is not present on the SD controller, then EFI_NOT_FOUND\r
+ is returned.\r
+\r
+ If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r
+\r
+ If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES\r
+ is returned.\r
+\r
+ Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of\r
+ DevicePath are initialized to describe the SD card specified by Slot, and EFI_SUCCESS is\r
+ returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] Slot Specifies the slot number of the SD card for which a device\r
+ path node is to be allocated and built.\r
+ @param[in,out] DevicePath A pointer to a single device path node that describes the SD\r
+ card specified by Slot. This function is responsible for\r
+ allocating the buffer DevicePath with the boot service\r
+ AllocatePool(). It is the caller's responsibility to free\r
+ DevicePath when the caller is finished with DevicePath.\r
+\r
+ @retval EFI_SUCCESS The device path node that describes the SD card specified by\r
+ Slot was allocated and returned in DevicePath.\r
+ @retval EFI_NOT_FOUND The SD card specified by Slot does not exist on the SD controller.\r
+ @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPassThruBuildDevicePath (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 Slot,\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
+ );\r
+\r
+/**\r
+ This function retrieves an SD card slot number based on the input device path.\r
+\r
+ The GetSlotNumber() function retrieves slot number for the SD card specified by\r
+ the DevicePath node. If DevicePath is NULL, EFI_INVALID_PARAMETER is returned.\r
+\r
+ If DevicePath is not a device path node type that the SD Pass Thru driver supports,\r
+ EFI_UNSUPPORTED is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] DevicePath A pointer to the device path node that describes a SD\r
+ card on the SD controller.\r
+ @param[out] Slot On return, points to the slot number of an SD card on\r
+ the SD controller.\r
+\r
+ @retval EFI_SUCCESS SD card slot number is returned in Slot.\r
+ @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.\r
+ @retval EFI_UNSUPPORTED DevicePath is not a device path node type that the SD\r
+ Pass Thru driver supports.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPassThruGetSlotNumber (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ OUT UINT8 *Slot\r
+ );\r
+\r
+/**\r
+ Resets an SD card that is connected to the SD controller.\r
+\r
+ The ResetDevice() function resets the SD card specified by Slot.\r
+\r
+ If this SD controller does not support a device reset operation, EFI_UNSUPPORTED is\r
+ returned.\r
+\r
+ If Slot is not in a valid slot number for this SD controller, EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the device reset operation is completed, EFI_SUCCESS is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] Slot Specifies the slot number of the SD card to be reset.\r
+\r
+ @retval EFI_SUCCESS The SD card specified by Slot was reset.\r
+ @retval EFI_UNSUPPORTED The SD controller does not support a device reset operation.\r
+ @retval EFI_INVALID_PARAMETER Slot number is invalid.\r
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.\r
+ @retval EFI_DEVICE_ERROR The reset command failed due to a device error\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPassThruResetDevice (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 Slot\r
+ );\r
+\r
+//\r
+// Driver model protocol interfaces\r
+//\r
+/**\r
+ Tests to see if this driver supports a given controller. If a child device is provided,\r
+ it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+ This function checks to see if the driver specified by This supports the device specified by\r
+ ControllerHandle. Drivers will typically use the device path attached to\r
+ ControllerHandle and/or the services from the bus I/O abstraction attached to\r
+ ControllerHandle to determine if the driver supports ControllerHandle. This function\r
+ may be called many times during platform initialization. In order to reduce boot times, the tests\r
+ performed by this function must be very small, and take as little time as possible to execute. This\r
+ function must not change the state of any hardware devices, and this function must be aware that the\r
+ device specified by ControllerHandle may already be managed by the same driver or a\r
+ different driver. This function must match its calls to AllocatePages() with FreePages(),\r
+ AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
+ Since ControllerHandle may have been previously started by the same driver, if a protocol is\r
+ already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
+ to guarantee the state of ControllerHandle is not modified by this function.\r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle The handle of the controller to test. This handle\r
+ must support a protocol interface that supplies\r
+ an I/O abstraction to the driver.\r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
+ parameter is ignored by device drivers, and is optional for bus\r
+ drivers. For bus drivers, if this parameter is not NULL, then\r
+ the bus driver must determine if the bus controller specified\r
+ by ControllerHandle and the child controller specified\r
+ by RemainingDevicePath are both supported by this\r
+ bus driver.\r
+\r
+ @retval EFI_SUCCESS The device specified by ControllerHandle and\r
+ RemainingDevicePath is supported by the driver specified by This.\r
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
+ RemainingDevicePath is already being managed by the driver\r
+ specified by This.\r
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
+ RemainingDevicePath is already being managed by a different\r
+ driver or an application that requires exclusive access.\r
+ Currently not implemented.\r
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
+ RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPciHcDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+/**\r
+ Starts a device controller or a bus controller.\r
+\r
+ The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+ As a result, much of the error checking on the parameters to Start() has been moved into this\r
+ common boot service. It is legal to call Start() from other locations,\r
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
+ 1. ControllerHandle must be a valid EFI_HANDLE.\r
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+ EFI_DEVICE_PATH_PROTOCOL.\r
+ 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+ have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle The handle of the controller to start. This handle\r
+ must support a protocol interface that supplies\r
+ an I/O abstraction to the driver.\r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
+ parameter is ignored by device drivers, and is optional for bus\r
+ drivers. For a bus driver, if this parameter is NULL, then handles\r
+ for all the children of Controller are created by this driver.\r
+ If this parameter is not NULL and the first Device Path Node is\r
+ not the End of Device Path Node, then only the handle for the\r
+ child device specified by the first Device Path Node of\r
+ RemainingDevicePath is created by this driver.\r
+ If the first Device Path Node of RemainingDevicePath is\r
+ the End of Device Path Node, no child handle is created by this\r
+ driver.\r
+\r
+ @retval EFI_SUCCESS The device was started.\r
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+ @retval Others The driver failded to start the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPciHcDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+/**\r
+ Stops a device controller or a bus controller.\r
+\r
+ The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
+ As a result, much of the error checking on the parameters to Stop() has been moved\r
+ into this common boot service. It is legal to call Stop() from other locations,\r
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+ same driver's Start() function.\r
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+ EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+ Start() function, and the Start() function must have called OpenProtocol() on\r
+ ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must\r
+ support a bus specific I/O protocol for the driver\r
+ to use to stop the device.\r
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r
+ if NumberOfChildren is 0.\r
+\r
+ @retval EFI_SUCCESS The device was stopped.\r
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPciHcDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+ This function retrieves the user readable name of a driver in the form of a\r
+ Unicode string. If the driver specified by This has a user readable name in\r
+ the language specified by Language, then a pointer to the driver name is\r
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+ by This does not support the language specified by Language,\r
+ then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified\r
+ in RFC 4646 or ISO 639-2 language code format.\r
+\r
+ @param DriverName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ driver specified by This in the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
+ This and the language specified by Language was\r
+ returned in DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPciHcComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by a driver.\r
+\r
+ This function retrieves the user readable name of the controller specified by\r
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+ driver specified by This has a user readable name in the language specified by\r
+ Language, then a pointer to the controller name is returned in ControllerName,\r
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
+ managing the controller specified by ControllerHandle and ChildHandle,\r
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param ControllerHandle[in] The handle of a controller that the driver\r
+ specified by This is managing. This handle\r
+ specifies the controller whose name is to be\r
+ returned.\r
+\r
+ @param ChildHandle[in] The handle of the child controller to retrieve\r
+ the name of. This is an optional parameter that\r
+ may be NULL. It will be NULL for device\r
+ drivers. It will also be NULL for a bus drivers\r
+ that wish to retrieve the name of the bus\r
+ controller. It will not be NULL for a bus\r
+ driver that wishes to retrieve the name of a\r
+ child controller.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified in\r
+ RFC 4646 or ISO 639-2 language code format.\r
+\r
+ @param ControllerName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ controller specified by ControllerHandle and\r
+ ChildHandle in the language specified by\r
+ Language from the point of view of the driver\r
+ specified by This.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the user readable name in\r
+ the language specified by Language for the\r
+ driver specified by This was returned in\r
+ DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+ EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
+ managing the controller specified by\r
+ ControllerHandle and ChildHandle.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SdMmcPciHcComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle, OPTIONAL\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+/**\r
+ Create a new TRB for the SD/MMC cmd request.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Slot The slot number of the SD card to send the command to.\r
+ @param[in] Packet A pointer to the SD command data structure.\r
+ @param[in] Event If Event is NULL, blocking I/O is performed. If Event is\r
+ not NULL, then nonblocking I/O is performed, and Event\r
+ will be signaled when the Packet completes.\r
+\r
+ @return Created Trb or NULL.\r
+\r
+**/\r
+SD_MMC_HC_TRB *\r
+SdMmcCreateTrb (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN UINT8 Slot,\r
+ IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,\r
+ IN EFI_EVENT Event\r
+ );\r
+\r
+/**\r
+ Free the resource used by the TRB.\r
+\r
+ @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r
+\r
+**/\r
+VOID\r
+SdMmcFreeTrb (\r
+ IN SD_MMC_HC_TRB *Trb\r
+ );\r
+\r
+/**\r
+ Check if the env is ready for execute specified TRB.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r
+\r
+ @retval EFI_SUCCESS The env is ready for TRB execution.\r
+ @retval EFI_NOT_READY The env is not ready for TRB execution.\r
+ @retval Others Some erros happen.\r
+\r
+**/\r
+EFI_STATUS\r
+SdMmcCheckTrbEnv (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN SD_MMC_HC_TRB *Trb\r
+ );\r
+\r
+/**\r
+ Wait for the env to be ready for execute specified TRB.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r
+\r
+ @retval EFI_SUCCESS The env is ready for TRB execution.\r
+ @retval EFI_TIMEOUT The env is not ready for TRB execution in time.\r
+ @retval Others Some erros happen.\r
+\r
+**/\r
+EFI_STATUS\r
+SdMmcWaitTrbEnv (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN SD_MMC_HC_TRB *Trb\r
+ );\r
+\r
+/**\r
+ Execute the specified TRB.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r
+\r
+ @retval EFI_SUCCESS The TRB is sent to host controller successfully.\r
+ @retval Others Some erros happen when sending this request to the host controller.\r
+\r
+**/\r
+EFI_STATUS\r
+SdMmcExecTrb (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN SD_MMC_HC_TRB *Trb\r
+ );\r
+\r
+/**\r
+ Check the TRB execution result.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r
+\r
+ @retval EFI_SUCCESS The TRB is executed successfully.\r
+ @retval EFI_NOT_READY The TRB is not completed for execution.\r
+ @retval Others Some erros happen when executing this request.\r
+\r
+**/\r
+EFI_STATUS\r
+SdMmcCheckTrbResult (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN SD_MMC_HC_TRB *Trb\r
+ );\r
+\r
+/**\r
+ Wait for the TRB execution result.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.\r
+\r
+ @retval EFI_SUCCESS The TRB is executed successfully.\r
+ @retval Others Some erros happen when executing this request.\r
+\r
+**/\r
+EFI_STATUS\r
+SdMmcWaitTrbResult (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN SD_MMC_HC_TRB *Trb\r
+ );\r
+\r
+/**\r
+ Execute EMMC device identification procedure.\r
+\r
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Slot The slot number of the SD card to send the command to.\r
+\r
+ @retval EFI_SUCCESS There is a EMMC card.\r
+ @retval Others There is not a EMMC card.\r
+\r
+**/\r
+EFI_STATUS\r
+EmmcIdentification (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN UINT8 Slot\r
+ );\r
+\r
+/**\r
+ Execute EMMC device identification procedure.\r
+\r
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.\r
+\r
+ @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance.\r
+ @param[in] Slot The slot number of the SD card to send the command to.\r
+\r
+ @retval EFI_SUCCESS There is a EMMC card.\r
+ @retval Others There is not a EMMC card.\r
+\r
+**/\r
+EFI_STATUS\r
+SdCardIdentification (\r
+ IN SD_MMC_HC_PRIVATE_DATA *Private,\r
+ IN UINT8 Slot\r
+ );\r
+\r
+#endif\r