3 Interface definition for EFI_SD_HOST_IO_PROTOCOL.
5 Copyright (c) 2013-2015 Intel Corporation.
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #define EFI_SD_HOST_IO_PROTOCOL_GUID \
26 0xb63f8ec7, 0xa9c9, 0x4472, {0xa4, 0xc0, 0x4d, 0x8b, 0xf3, 0x65, 0xcc, 0x51} \
30 /// Forward reference for pure ANSI compatability
32 typedef struct _EFI_SD_HOST_IO_PROTOCOL EFI_SD_HOST_IO_PROTOCOL
;
63 #define PCI_SUBCLASS_SD_HOST_CONTROLLER 0x05
64 #define PCI_IF_STANDARD_HOST_NO_DMA 0x00
65 #define PCI_IF_STANDARD_HOST_SUPPORT_DMA 0x01
67 #define SDHCI_SPEC_100 0
68 #define SDHCI_SPEC_200 1
69 #define SDHCI_SPEC_300 2
72 //MMIO Registers definition for MMC/SDIO controller
74 #define MMIO_DMAADR 0x00
75 #define MMIO_BLKSZ 0x04
76 #define MMIO_BLKCNT 0x06
77 #define MMIO_CMDARG 0x08
78 #define MMIO_XFRMODE 0x0C
79 #define MMIO_SDCMD 0x0E
80 #define MMIO_RESP 0x10
81 #define MMIO_BUFDATA 0x20
82 #define MMIO_PSTATE 0x24
83 #define MMIO_HOSTCTL 0x28
84 #define MMIO_PWRCTL 0x29
85 #define MMIO_BLKGAPCTL 0x2A
86 #define MMIO_WAKECTL 0x2B
87 #define MMIO_CLKCTL 0x2C
88 #define V_MMIO_CLKCTL_MAX_8BIT_FREQ_SEL 0x80
89 #define V_MMIO_CLKCTL_MAX_10BIT_FREQ_SEL 0x3FF
90 #define B_MMIO_CLKCTL_UPR_SDCLK_FREQ_SEL_MASK 0xC0
92 #define MMIO_TOCTL 0x2E
93 #define MMIO_SWRST 0x2F
94 #define MMIO_NINTSTS 0x30
95 #define MMIO_ERINTSTS 0x32
96 #define MMIO_NINTEN 0x34
97 #define MMIO_ERINTEN 0x36
98 #define MMIO_NINTSIGEN 0x38
99 #define MMIO_ERINTSIGEN 0x3A
100 #define MMIO_AC12ERRSTS 0x3C
101 #define MMIO_HOSTCTL2 0x3E
102 #define MMIO_CAP 0x40
103 #define MMIO_MCCAP 0x48
104 #define MMIO_SLTINTSTS 0xFC
105 #define MMIO_CTRLRVER 0xFE
106 #define MMIO_SRST 0x1FC
109 // Protocol definitions
113 The main function used to send the command to the card inserted into the SD host slot.
114 It will assemble the arguments to set the command register and wait for the command
115 and transfer completed until timeout. Then it will read the response register to fill
118 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
119 @param CommandIndex The command index to set the command index field of command register.
120 @param Argument Command argument to set the argument field of command register.
121 @param DataType TRANSFER_TYPE, indicates no data, data in or data out.
122 @param Buffer Contains the data read from / write to the device.
123 @param BufferSize The size of the buffer.
124 @param ResponseType RESPONSE_TYPE.
125 @param TimeOut Time out value in 1 ms unit.
126 @param ResponseData Depending on the ResponseType, such as CSD or card status.
129 @retval EFI_INVALID_PARAMETER
130 @retval EFI_OUT_OF_RESOURCES
132 @retval EFI_DEVICE_ERROR
138 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND
) (
139 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
140 IN UINT16 CommandIndex
,
142 IN TRANSFER_TYPE DataType
,
143 IN UINT8
*Buffer
, OPTIONAL
144 IN UINT32 BufferSize
,
145 IN RESPONSE_TYPE ResponseType
,
147 OUT UINT32
*ResponseData OPTIONAL
151 Set max clock frequency of the host, the actual frequency may not be the same as MaxFrequency.
152 It depends on the max frequency the host can support, divider, and host speed mode.
154 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
155 @param MaxFrequency Max frequency in HZ.
164 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY
) (
165 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
166 IN UINT32 MaxFrequency
171 Set bus width of the host controller
173 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
174 @param BusWidth Bus width in 1, 4, 8 bits.
177 @retval EFI_INVALID_PARAMETER
183 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH
) (
184 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
189 Set voltage which could supported by the host controller.
190 Support 0(Power off the host), 1.8V, 3.0V, 3.3V
192 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
193 @param Voltage Units in 0.1 V.
196 @retval EFI_INVALID_PARAMETER
202 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE
) (
203 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
208 Reset the host controller.
210 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
211 @param ResetAll TRUE to reset all.
220 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST
) (
221 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
222 IN RESET_TYPE ResetType
226 Enable auto stop on the host controller.
228 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
229 @param Enable TRUE to enable, FALSE to disable.
238 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD
) (
239 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
244 Find whether these is a card inserted into the slot. If so init the host.
245 If not, return EFI_NOT_FOUND.
247 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
250 @retval EFI_NOT_FOUND
256 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST
) (
257 IN EFI_SD_HOST_IO_PROTOCOL
*This
261 Set the Block length on the host controller.
263 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
264 @param BlockLength card supportes block length.
273 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH
) (
274 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
275 IN UINT32 BlockLength
279 Enable/Disable High Speed transfer mode
281 @param This A pointer to the EFI_SD_HOST_IO_PROTOCOL instance.
282 @param Enable TRUE to Enable, FALSE to Disable
288 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE
) (
289 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
295 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE
) (
296 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
302 #define EFI_SD_HOST_IO_PROTOCOL_REVISION_01 0x02
306 UINT32 HighSpeedSupport
: 1; //High speed supported
307 UINT32 V18Support
: 1; //1.8V supported
308 UINT32 V30Support
: 1; //3.0V supported
309 UINT32 V33Support
: 1; //3.3V supported
311 UINT32 HostVersion
: 8;
312 UINT32 BusWidth4
: 1; // 4 bit width
313 UINT32 BusWidth8
: 1; // 8 bit width
314 UINT32 Reserved1
: 14;
320 // Interface structure for the SD HOST I/O Protocol
322 struct _EFI_SD_HOST_IO_PROTOCOL
{
324 HOST_CAPABILITY HostCapability
;
325 EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND SendCommand
;
326 EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY SetClockFrequency
;
327 EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH SetBusWidth
;
328 EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE SetHostVoltage
;
329 EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST ResetSDHost
;
330 EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD EnableAutoStopCmd
;
331 EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST DetectCardAndInitHost
;
332 EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH SetBlockLength
;
333 EFI_SD_HOST_IO_PROTOCOL_HIGH_SPEED_MODE SetHighSpeedMode
;
334 EFI_SD_HOST_IO_PROTOCOL_DUAL_DATARATE_MODE SetDDRMode
;
337 extern EFI_GUID gEfiSDHostIoProtocolGuid
;