3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 Interface definition for EFI_SD_HOST_IO_PROTOCOL
32 // Global ID for the EFI_SD_HOST_IO_PROTOCOL
33 // {B63F8EC7-A9C9-4472-A4C0-4D8BF365CC51}
35 #define EFI_SD_HOST_IO_PROTOCOL_GUID \
36 { 0xb63f8ec7, 0xa9c9, 0x4472, { 0xa4, 0xc0, 0x4d, 0x8b, 0xf3, 0x65, 0xcc, 0x51 } }
38 typedef struct _EFI_SD_HOST_IO_PROTOCOL EFI_SD_HOST_IO_PROTOCOL
;
41 // TODO: Move to Pci22.h
43 #define PCI_SUBCLASS_SD_HOST_CONTROLLER 0x05
44 #define PCI_IF_STANDARD_HOST_NO_DMA 0x00
45 #define PCI_IF_STANDARD_HOST_SUPPORT_DMA 0x01
50 #define EFI_SD_HOST_IO_PROTOCOL_REVISION_01 0x01
53 // TODO: Do these belong in an Industry Standard include file?
55 // MMIO Registers definition for MMC/SDIO controller
57 #define MMIO_DMAADR 0x00
58 #define MMIO_BLKSZ 0x04
59 #define MMIO_BLKCNT 0x06
60 #define MMIO_CMDARG 0x08
61 #define MMIO_XFRMODE 0x0C
62 #define MMIO_SDCMD 0x0E
63 #define MMIO_RESP 0x10
64 #define MMIO_BUFDATA 0x20
65 #define MMIO_PSTATE 0x24
66 #define MMIO_HOSTCTL 0x28
67 #define MMIO_PWRCTL 0x29
68 #define MMIO_BLKGAPCTL 0x2A
69 #define MMIO_WAKECTL 0x2B
70 #define MMIO_CLKCTL 0x2C
71 #define MMIO_TOCTL 0x2E
72 #define MMIO_SWRST 0x2F
73 #define MMIO_NINTSTS 0x30
74 #define MMIO_ERINTSTS 0x32
75 #define MMIO_NINTEN 0x34
76 #define MMIO_ERINTEN 0x36
77 #define MMIO_NINTSIGEN 0x38
78 #define MMIO_ERINTSIGEN 0x3A
79 #define MMIO_AC12ERRSTS 0x3C
80 #define MMIO_HOST_CTL2 0x3E //hphang <- New in VLV2
82 #define MMIO_CAP2 0x44 //hphang <- New in VLV2
83 #define MMIO_MCCAP 0x48
84 #define MMIO_FORCEEVENTCMD12ERRSTAT 0x50 //hphang <- New in VLV2
85 #define MMIO_FORCEEVENTERRINTSTAT 0x52 //hphang <- New in VLV2
86 #define MMIO_ADMAERRSTAT 0x54 //hphang <- New in VLV2
87 #define MMIO_ADMASYSADDR 0x58 //hphang <- New in VLV2
88 #define MMIO_PRESETVALUE0 0x60 //hphang <- New in VLV2
89 #define MMIO_PRESETVALUE1 0x64 //hphang <- New in VLV2
90 #define MMIO_PRESETVALUE2 0x68 //hphang <- New in VLV2
91 #define MMIO_PRESETVALUE3 0x6C //hphang <- New in VLV2
92 #define MMIO_BOOTTIMEOUTCTRL 0x70 //hphang <- New in VLV2
93 #define MMIO_DEBUGSEL 0x74 //hphang <- New in VLV2
94 #define MMIO_SHAREDBUS 0xE0 //hphang <- New in VLV2
95 #define MMIO_SPIINTSUP 0xF0 //hphang <- New in VLV2
96 #define MMIO_SLTINTSTS 0xFC
97 #define MMIO_CTRLRVER 0xFE
135 UINT32 HighSpeedSupport
: 1; //High speed supported
136 UINT32 V18Support
: 1; //1.8V supported
137 UINT32 V30Support
: 1; //3.0V supported
138 UINT32 V33Support
: 1; //3.3V supported
139 UINT32 SDR50Support
: 1;
140 UINT32 SDR104Support
: 1;
141 UINT32 DDR50Support
: 1;
143 UINT32 BusWidth4
: 1; // 4 bit width
144 UINT32 BusWidth8
: 1; // 8 bit width
146 UINT32 SDMASupport
: 1;
147 UINT32 ADMA2Support
: 1;
149 UINT32 ReTuneTimer
: 4;
150 UINT32 ReTuneMode
: 2;
158 The main function used to send the command to the card inserted into the SD host
160 It will assemble the arguments to set the command register and wait for the command
161 and transfer completed until timeout. Then it will read the response register to fill
165 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
166 CommandIndex - The command index to set the command index field of command register
167 Argument - Command argument to set the argument field of command register
168 DataType - TRANSFER_TYPE, indicates no data, data in or data out
169 Buffer - Contains the data read from / write to the device
170 BufferSize - The size of the buffer
171 ResponseType - RESPONSE_TYPE
172 TimeOut - Time out value in 1 ms unit
173 ResponseData - Depending on the ResponseType, such as CSD or card status
177 EFI_INVALID_PARAMETER
185 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND
) (
186 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
187 IN UINT16 CommandIndex
,
189 IN TRANSFER_TYPE DataType
,
190 IN UINT8
*Buffer
, OPTIONAL
191 IN UINT32 BufferSize
,
192 IN RESPONSE_TYPE ResponseType
,
194 OUT UINT32
*ResponseData OPTIONAL
200 Set max clock frequency of the host, the actual frequency
201 may not be the same as MaxFrequency. It depends on
202 the max frequency the host can support, divider, and host
206 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
207 MaxFrequency - Max frequency in HZ
215 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY
) (
216 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
217 IN UINT32 MaxFrequency
223 Set bus width of the host
226 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
227 BusWidth - Bus width in 1, 4, 8 bits
231 EFI_INVALID_PARAMETER
236 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH
) (
237 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
244 Set voltage which could supported by the host.
245 Support 0(Power off the host), 1.8V, 3.0V, 3.3V
247 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
248 Voltage - Units in 0.1 V
252 EFI_INVALID_PARAMETER
257 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE
) (
258 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
267 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
268 HighSpeed - True for High Speed Mode set, false for normal mode
272 EFI_INVALID_PARAMETER
277 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_HOST_SPEED_MODE
) (
278 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
287 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
288 SetHostDdrMode - True for DDR Mode set, false for normal mode
292 EFI_INVALID_PARAMETER
297 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_HOST_DDR_MODE
) (
298 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
309 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
310 ResetAll - TRUE to reset all
319 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST
) (
320 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
321 IN RESET_TYPE ResetType
330 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
331 Enable - TRUE to enable, FALSE to disable
340 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD
) (
341 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
348 Find whether these is a card inserted into the slot. If so
349 init the host. If not, return EFI_NOT_FOUND.
352 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
361 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST
) (
362 IN EFI_SD_HOST_IO_PROTOCOL
*This
371 This - Pointer to EFI_SD_HOST_IO_PROTOCOL
372 BlockLength - card supportes block length
381 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH
) (
382 IN EFI_SD_HOST_IO_PROTOCOL
*This
,
383 IN UINT32 BlockLength
387 (EFIAPI
*EFI_SD_HOST_IO_PROTOCOL_SETUP_DEVICE
)(
388 IN EFI_SD_HOST_IO_PROTOCOL
*This
394 // Interface structure for the EFI SD Host I/O Protocol
396 struct _EFI_SD_HOST_IO_PROTOCOL
{
398 HOST_CAPABILITY HostCapability
;
399 EFI_SD_HOST_IO_PROTOCOL_SEND_COMMAND SendCommand
;
400 EFI_SD_HOST_IO_PROTOCOL_SET_CLOCK_FREQUENCY SetClockFrequency
;
401 EFI_SD_HOST_IO_PROTOCOL_SET_BUS_WIDTH SetBusWidth
;
402 EFI_SD_HOST_IO_PROTOCOL_SET_HOST_VOLTAGE SetHostVoltage
;
403 EFI_SD_HOST_IO_PROTOCOL_SET_HOST_DDR_MODE SetHostDdrMode
;
404 EFI_SD_HOST_IO_PROTOCOL_RESET_SD_HOST ResetSdHost
;
405 EFI_SD_HOST_IO_PROTOCOL_ENABLE_AUTO_STOP_CMD EnableAutoStopCmd
;
406 EFI_SD_HOST_IO_PROTOCOL_DETECT_CARD_AND_INIT_HOST DetectCardAndInitHost
;
407 EFI_SD_HOST_IO_PROTOCOL_SET_BLOCK_LENGTH SetBlockLength
;
408 EFI_SD_HOST_IO_PROTOCOL_SETUP_DEVICE SetupDevice
;
409 EFI_SD_HOST_IO_PROTOCOL_SET_HOST_SPEED_MODE SetHostSpeedMode
;
412 extern EFI_GUID gEfiSdHostIoProtocolGuid
;