3 Interface definition for EFI_SD_HOST_IO_PROTOCOL.
5 Copyright (c) 2013-2015 Intel Corporation.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
18 #define EFI_SD_HOST_IO_PROTOCOL_GUID \
20 0xb63f8ec7, 0xa9c9, 0x4472, {0xa4, 0xc0, 0x4d, 0x8b, 0xf3, 0x65, 0xcc, 0x51} \
24 /// Forward reference for pure ANSI compatability
26 typedef struct _EFI_SD_HOST_IO_PROTOCOL EFI_SD_HOST_IO_PROTOCOL
;
57 #define PCI_SUBCLASS_SD_HOST_CONTROLLER 0x05
58 #define PCI_IF_STANDARD_HOST_NO_DMA 0x00
59 #define PCI_IF_STANDARD_HOST_SUPPORT_DMA 0x01
61 #define SDHCI_SPEC_100 0
62 #define SDHCI_SPEC_200 1
63 #define SDHCI_SPEC_300 2
66 //MMIO Registers definition for MMC/SDIO controller
68 #define MMIO_DMAADR 0x00
69 #define MMIO_BLKSZ 0x04
70 #define MMIO_BLKCNT 0x06
71 #define MMIO_CMDARG 0x08
72 #define MMIO_XFRMODE 0x0C
73 #define MMIO_SDCMD 0x0E
74 #define MMIO_RESP 0x10
75 #define MMIO_BUFDATA 0x20
76 #define MMIO_PSTATE 0x24
77 #define MMIO_HOSTCTL 0x28
78 #define MMIO_PWRCTL 0x29
79 #define MMIO_BLKGAPCTL 0x2A
80 #define MMIO_WAKECTL 0x2B
81 #define MMIO_CLKCTL 0x2C
82 #define V_MMIO_CLKCTL_MAX_8BIT_FREQ_SEL 0x80
83 #define V_MMIO_CLKCTL_MAX_10BIT_FREQ_SEL 0x3FF
84 #define B_MMIO_CLKCTL_UPR_SDCLK_FREQ_SEL_MASK 0xC0
86 #define MMIO_TOCTL 0x2E
87 #define MMIO_SWRST 0x2F
88 #define MMIO_NINTSTS 0x30
89 #define MMIO_ERINTSTS 0x32
90 #define MMIO_NINTEN 0x34
91 #define MMIO_ERINTEN 0x36
92 #define MMIO_NINTSIGEN 0x38
93 #define MMIO_ERINTSIGEN 0x3A
94 #define MMIO_AC12ERRSTS 0x3C
95 #define MMIO_HOSTCTL2 0x3E
97 #define MMIO_MCCAP 0x48
98 #define MMIO_SLTINTSTS 0xFC
99 #define MMIO_CTRLRVER 0xFE
100 #define MMIO_SRST 0x1FC
103 // Protocol definitions
107 The main function used to send the command to the card inserted into the SD host slot.
108 It will assemble the arguments to set the command register and wait for the command
109 and transfer completed until timeout. Then it will read the response register to fill
112 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
113 @param CommandIndex The command index to set the command index field of command register.
114 @param Argument Command argument to set the argument field of command register.
115 @param DataType TRANSFER_TYPE, indicates no data, data in or data out.
116 @param Buffer Contains the data read from / write to the device.
117 @param BufferSize The size of the buffer.
118 @param ResponseType RESPONSE_TYPE.
119 @param TimeOut Time out value in 1 ms unit.
120 @param ResponseData Depending on the ResponseType, such as CSD or card status.
123 @retval EFI_INVALID_PARAMETER
124 @retval EFI_OUT_OF_RESOURCES
126 @retval EFI_DEVICE_ERROR
132 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND
) (
133 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
134 IN UINT16 CommandIndex
,
136 IN TRANSFER_TYPE DataType
,
137 IN UINT8
*Buffer
, OPTIONAL
138 IN UINT32 BufferSize
,
139 IN RESPONSE_TYPE ResponseType
,
141 OUT UINT32
*ResponseData OPTIONAL
145 Set max clock frequency of the host, the actual frequency may not be the same as MaxFrequency.
146 It depends on the max frequency the host can support, divider, and host speed mode.
148 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
149 @param MaxFrequency Max frequency in HZ.
158 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY
) (
159 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
160 IN UINT32 MaxFrequency
165 Set bus width of the host controller
167 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
168 @param BusWidth Bus width in 1, 4, 8 bits.
171 @retval EFI_INVALID_PARAMETER
177 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH
) (
178 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
183 Set voltage which could supported by the host controller.
184 Support 0(Power off the host), 1.8V, 3.0V, 3.3V
186 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
187 @param Voltage Units in 0.1 V.
190 @retval EFI_INVALID_PARAMETER
196 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE
) (
197 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
202 Reset the host controller.
204 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
205 @param ResetAll TRUE to reset all.
214 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST
) (
215 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
216 IN RESET_TYPE ResetType
220 Enable auto stop on the host controller.
222 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
223 @param Enable TRUE to enable, FALSE to disable.
232 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD
) (
233 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
238 Find whether these is a card inserted into the slot. If so init the host.
239 If not, return EFI_NOT_FOUND.
241 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
244 @retval EFI_NOT_FOUND
250 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST
) (
251 IN EFI_SD_HOST_IO_PROTOCOL
*This
255 Set the Block length on the host controller.
257 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
258 @param BlockLength card supportes block length.
267 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH
) (
268 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
269 IN UINT32 BlockLength
273 Enable/Disable High Speed transfer mode
275 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
276 @param Enable TRUE to Enable, FALSE to Disable
282 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE
) (
283 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
289 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE
) (
290 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
296 #define EFI_SD_HOST_IO_PROTOCOL_REVISION_01 0x02
300 UINT32 HighSpeedSupport
: 1; //High speed supported
301 UINT32 V18Support
: 1; //1.8V supported
302 UINT32 V30Support
: 1; //3.0V supported
303 UINT32 V33Support
: 1; //3.3V supported
305 UINT32 HostVersion
: 8;
306 UINT32 BusWidth4
: 1; // 4 bit width
307 UINT32 BusWidth8
: 1; // 8 bit width
308 UINT32 Reserved1
: 14;
314 // Interface structure for the SD HOST I/O Protocol
316 struct _EFI_SD_HOST_IO_PROTOCOL
{
318 HOST_CAPABILITY HostCapability
;
319 EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND SendCommand
;
320 EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY SetClockFrequency
;
321 EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH SetBusWidth
;
322 EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE SetHostVoltage
;
323 EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST ResetSDHost
;
324 EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD EnableAutoStopCmd
;
325 EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST DetectCardAndInitHost
;
326 EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH SetBlockLength
;
327 EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE SetHighSpeedMode
;
328 EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE SetDDRMode
;
331 extern EFI_GUID gEfiSDHostIoProtocolGuid
;