--- /dev/null
+/** @file\r
+\r
+Interface definition for EFI_SD_HOST_IO_PROTOCOL.\r
+\r
+Copyright (c) 2013-2015 Intel Corporation.\r
+\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_HOST_IO_H\r
+#define _SD_HOST_IO_H\r
+\r
+#include "SDCard.h"\r
+#include "CEATA.h"\r
+\r
+\r
+#define EFI_SD_HOST_IO_PROTOCOL_GUID \\r
+ { \\r
+ 0xb63f8ec7, 0xa9c9, 0x4472, {0xa4, 0xc0, 0x4d, 0x8b, 0xf3, 0x65, 0xcc, 0x51} \\r
+ }\r
+\r
+///\r
+/// Forward reference for pure ANSI compatability\r
+///\r
+typedef struct _EFI_SD_HOST_IO_PROTOCOL EFI_SD_HOST_IO_PROTOCOL;\r
+\r
+\r
+\r
+typedef enum {\r
+ ResponseNo = 0,\r
+ ResponseR1,\r
+ ResponseR1b,\r
+ ResponseR2,\r
+ ResponseR3,\r
+ ResponseR4,\r
+ ResponseR5,\r
+ ResponseR5b,\r
+ ResponseR6,\r
+ ResponseR7\r
+}RESPONSE_TYPE;\r
+\r
+typedef enum {\r
+ NoData = 0,\r
+ InData,\r
+ OutData\r
+}TRANSFER_TYPE;\r
+\r
+typedef enum {\r
+ Reset_Auto = 0,\r
+ Reset_DAT,\r
+ Reset_CMD,\r
+ Reset_DAT_CMD,\r
+ Reset_All\r
+}RESET_TYPE;\r
+\r
+#define PCI_SUBCLASS_SD_HOST_CONTROLLER 0x05\r
+#define PCI_IF_STANDARD_HOST_NO_DMA 0x00\r
+#define PCI_IF_STANDARD_HOST_SUPPORT_DMA 0x01\r
+\r
+#define SDHCI_SPEC_100 0\r
+#define SDHCI_SPEC_200 1\r
+#define SDHCI_SPEC_300 2\r
+\r
+//\r
+//MMIO Registers definition for MMC/SDIO controller\r
+//\r
+#define MMIO_DMAADR 0x00\r
+#define MMIO_BLKSZ 0x04\r
+#define MMIO_BLKCNT 0x06\r
+#define MMIO_CMDARG 0x08\r
+#define MMIO_XFRMODE 0x0C\r
+#define MMIO_SDCMD 0x0E\r
+#define MMIO_RESP 0x10\r
+#define MMIO_BUFDATA 0x20\r
+#define MMIO_PSTATE 0x24\r
+#define MMIO_HOSTCTL 0x28\r
+#define MMIO_PWRCTL 0x29\r
+#define MMIO_BLKGAPCTL 0x2A\r
+#define MMIO_WAKECTL 0x2B\r
+#define MMIO_CLKCTL 0x2C\r
+#define V_MMIO_CLKCTL_MAX_8BIT_FREQ_SEL 0x80\r
+#define V_MMIO_CLKCTL_MAX_10BIT_FREQ_SEL 0x3FF\r
+#define B_MMIO_CLKCTL_UPR_SDCLK_FREQ_SEL_MASK 0xC0\r
+\r
+#define MMIO_TOCTL 0x2E\r
+#define MMIO_SWRST 0x2F\r
+#define MMIO_NINTSTS 0x30\r
+#define MMIO_ERINTSTS 0x32\r
+#define MMIO_NINTEN 0x34\r
+#define MMIO_ERINTEN 0x36\r
+#define MMIO_NINTSIGEN 0x38\r
+#define MMIO_ERINTSIGEN 0x3A\r
+#define MMIO_AC12ERRSTS 0x3C\r
+#define MMIO_HOSTCTL2 0x3E\r
+#define MMIO_CAP 0x40\r
+#define MMIO_MCCAP 0x48\r
+#define MMIO_SLTINTSTS 0xFC\r
+#define MMIO_CTRLRVER 0xFE\r
+#define MMIO_SRST 0x1FC\r
+\r
+//\r
+// Protocol definitions\r
+//\r
+\r
+/**\r
+ The main function used to send the command to the card inserted into the SD host slot.\r
+ It will assemble the arguments to set the command register and wait for the command\r
+ and transfer completed until timeout. Then it will read the response register to fill\r
+ the ResponseData.\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param CommandIndex The command index to set the command index field of command register.\r
+ @param Argument Command argument to set the argument field of command register.\r
+ @param DataType TRANSFER_TYPE, indicates no data, data in or data out.\r
+ @param Buffer Contains the data read from / write to the device.\r
+ @param BufferSize The size of the buffer.\r
+ @param ResponseType RESPONSE_TYPE.\r
+ @param TimeOut Time out value in 1 ms unit.\r
+ @param ResponseData Depending on the ResponseType, such as CSD or card status.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_INVALID_PARAMETER\r
+ @retval EFI_OUT_OF_RESOURCES\r
+ @retval EFI_TIMEOUT\r
+ @retval EFI_DEVICE_ERROR\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN UINT16 CommandIndex,\r
+ IN UINT32 Argument,\r
+ IN TRANSFER_TYPE DataType,\r
+ IN UINT8 *Buffer, OPTIONAL\r
+ IN UINT32 BufferSize,\r
+ IN RESPONSE_TYPE ResponseType,\r
+ IN UINT32 TimeOut,\r
+ OUT UINT32 *ResponseData OPTIONAL\r
+ );\r
+\r
+/**\r
+ Set max clock frequency of the host, the actual frequency may not be the same as MaxFrequency.\r
+ It depends on the max frequency the host can support, divider, and host speed mode.\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param MaxFrequency Max frequency in HZ.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_TIMEOUT\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN UINT32 MaxFrequency\r
+ );\r
+\r
+\r
+/**\r
+ Set bus width of the host controller\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param BusWidth Bus width in 1, 4, 8 bits.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_INVALID_PARAMETER\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN UINT32 BusWidth\r
+ );\r
+\r
+/**\r
+ Set voltage which could supported by the host controller.\r
+ Support 0(Power off the host), 1.8V, 3.0V, 3.3V\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param Voltage Units in 0.1 V.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_INVALID_PARAMETER\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN UINT32 Voltage\r
+ );\r
+\r
+/**\r
+ Reset the host controller.\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param ResetAll TRUE to reset all.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_TIMEOUT\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN RESET_TYPE ResetType\r
+ );\r
+\r
+/**\r
+ Enable auto stop on the host controller.\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param Enable TRUE to enable, FALSE to disable.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_TIMEOUT\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN BOOLEAN Enable\r
+ );\r
+\r
+/**\r
+ Find whether these is a card inserted into the slot. If so init the host.\r
+ If not, return EFI_NOT_FOUND.\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_NOT_FOUND\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This\r
+ );\r
+\r
+/**\r
+ Set the Block length on the host controller.\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param BlockLength card supportes block length.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_TIMEOUT\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN UINT32 BlockLength\r
+ );\r
+\r
+/**\r
+ Enable/Disable High Speed transfer mode\r
+\r
+ @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.\r
+ @param Enable TRUE to Enable, FALSE to Disable\r
+\r
+ @return EFI_SUCCESS\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN BOOLEAN Enable\r
+ );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE) (\r
+ IN EFI_SD_HOST_IO_PROTOCOL *This,\r
+ IN BOOLEAN Enable\r
+ );\r
+\r
+\r
+\r
+#define EFI_SD_HOST_IO_PROTOCOL_REVISION_01 0x02\r
+\r
+\r
+typedef struct {\r
+ UINT32 HighSpeedSupport: 1; //High speed supported\r
+ UINT32 V18Support: 1; //1.8V supported\r
+ UINT32 V30Support: 1; //3.0V supported\r
+ UINT32 V33Support: 1; //3.3V supported\r
+ UINT32 Reserved0: 4;\r
+ UINT32 HostVersion: 8;\r
+ UINT32 BusWidth4: 1; // 4 bit width\r
+ UINT32 BusWidth8: 1; // 8 bit width\r
+ UINT32 Reserved1: 14;\r
+ UINT32 BoundarySize;\r
+}HOST_CAPABILITY;\r
+\r
+\r
+//\r
+// Interface structure for the SD HOST I/O Protocol\r
+//\r
+struct _EFI_SD_HOST_IO_PROTOCOL {\r
+ UINT32 Revision;\r
+ HOST_CAPABILITY HostCapability;\r
+ EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND SendCommand;\r
+ EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY SetClockFrequency;\r
+ EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH SetBusWidth;\r
+ EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE SetHostVoltage;\r
+ EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST ResetSDHost;\r
+ EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD EnableAutoStopCmd;\r
+ EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST DetectCardAndInitHost;\r
+ EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH SetBlockLength;\r
+ EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE SetHighSpeedMode;\r
+ EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE SetDDRMode;\r
+};\r
+\r
+extern EFI_GUID gEfiSDHostIoProtocolGuid;\r
+\r
+#endif\r