11#ifndef _SD_MMC_PCI_HCI_H_
12#define _SD_MMC_PCI_HCI_H_
17#define SD_MMC_HC_SLOT_OFFSET 0x40
19#define SD_MMC_HC_MAX_SLOT 6
24#define SD_MMC_HC_SDMA_ADDR 0x00
25#define SD_MMC_HC_ARG2 0x00
26#define SD_MMC_HC_BLK_SIZE 0x04
27#define SD_MMC_HC_BLK_COUNT 0x06
28#define SD_MMC_HC_ARG1 0x08
29#define SD_MMC_HC_TRANS_MOD 0x0C
30#define SD_MMC_HC_COMMAND 0x0E
31#define SD_MMC_HC_RESPONSE 0x10
32#define SD_MMC_HC_BUF_DAT_PORT 0x20
33#define SD_MMC_HC_PRESENT_STATE 0x24
34#define SD_MMC_HC_HOST_CTRL1 0x28
35#define SD_MMC_HC_POWER_CTRL 0x29
36#define SD_MMC_HC_BLK_GAP_CTRL 0x2A
37#define SD_MMC_HC_WAKEUP_CTRL 0x2B
38#define SD_MMC_HC_CLOCK_CTRL 0x2C
39#define SD_MMC_HC_TIMEOUT_CTRL 0x2E
40#define SD_MMC_HC_SW_RST 0x2F
41#define SD_MMC_HC_NOR_INT_STS 0x30
42#define SD_MMC_HC_ERR_INT_STS 0x32
43#define SD_MMC_HC_NOR_INT_STS_EN 0x34
44#define SD_MMC_HC_ERR_INT_STS_EN 0x36
45#define SD_MMC_HC_NOR_INT_SIG_EN 0x38
46#define SD_MMC_HC_ERR_INT_SIG_EN 0x3A
47#define SD_MMC_HC_AUTO_CMD_ERR_STS 0x3C
48#define SD_MMC_HC_HOST_CTRL2 0x3E
49#define SD_MMC_HC_CAP 0x40
50#define SD_MMC_HC_MAX_CURRENT_CAP 0x48
51#define SD_MMC_HC_FORCE_EVT_AUTO_CMD 0x50
52#define SD_MMC_HC_FORCE_EVT_ERR_INT 0x52
53#define SD_MMC_HC_ADMA_ERR_STS 0x54
54#define SD_MMC_HC_ADMA_SYS_ADDR 0x58
55#define SD_MMC_HC_PRESET_VAL 0x60
56#define SD_MMC_HC_SHARED_BUS_CTRL 0xE0
57#define SD_MMC_HC_SLOT_INT_STS 0xFC
58#define SD_MMC_HC_CTRL_VER 0xFE
63#define SD_MMC_HC_CTRL_UHS_MASK 0x0007
64#define SD_MMC_HC_CTRL_UHS_SDR12 0x0000
65#define SD_MMC_HC_CTRL_UHS_SDR25 0x0001
66#define SD_MMC_HC_CTRL_UHS_SDR50 0x0002
67#define SD_MMC_HC_CTRL_UHS_SDR104 0x0003
68#define SD_MMC_HC_CTRL_UHS_DDR50 0x0004
69#define SD_MMC_HC_CTRL_MMC_LEGACY 0x0000
70#define SD_MMC_HC_CTRL_MMC_HS_SDR 0x0001
71#define SD_MMC_HC_CTRL_MMC_HS_DDR 0x0004
72#define SD_MMC_HC_CTRL_MMC_HS200 0x0003
73#define SD_MMC_HC_CTRL_MMC_HS400 0x0005
75#define SD_MMC_HC_CTRL_DRIVER_STRENGTH_MASK 0x0030
87} SD_MMC_HC_TRANSFER_MODE;
95} SD_MMC_HC_ADMA_LENGTH_MODE;
100#define ADMA_MAX_DATA_PER_LINE_16B SIZE_64KB
101#define ADMA_MAX_DATA_PER_LINE_26B SIZE_64MB
112 UINT32 UpperLength : 10;
113 UINT32 LowerLength : 16;
126 UINT32 UpperLength : 10;
127 UINT32 LowerLength : 16;
138 UINT32 UpperLength : 10;
139 UINT32 LowerLength : 16;
145#define SD_MMC_SDMA_BOUNDARY 512 * 1024
146#define SD_MMC_SDMA_ROUND_UP(x, n) (((x) + n) & ~(n - 1))
156 UINT32 TimeoutFreq : 6;
158 UINT32 TimeoutUnit : 1;
159 UINT32 BaseClkFreq : 8;
160 UINT32 MaxBlkLen : 2;
161 UINT32 BusWidth8 : 1;
163 UINT32 Reserved2 : 1;
164 UINT32 HighSpeed : 1;
167 UINT32 Voltage33 : 1;
168 UINT32 Voltage30 : 1;
169 UINT32 Voltage18 : 1;
170 UINT32 SysBus64V4 : 1;
171 UINT32 SysBus64V3 : 1;
177 UINT32 Reserved3 : 1;
178 UINT32 DriverTypeA : 1;
179 UINT32 DriverTypeC : 1;
180 UINT32 DriverTypeD : 1;
181 UINT32 DriverType4 : 1;
182 UINT32 TimerCount : 4;
183 UINT32 Reserved4 : 1;
184 UINT32 TuningSDR50 : 1;
185 UINT32 RetuningMod : 2;
186 UINT32 ClkMultiplier : 8;
187 UINT32 Reserved5 : 7;
194#define SD_MMC_HC_CTRL_VER_100 0x00
195#define SD_MMC_HC_CTRL_VER_200 0x01
196#define SD_MMC_HC_CTRL_VER_300 0x02
197#define SD_MMC_HC_CTRL_VER_400 0x03
198#define SD_MMC_HC_CTRL_VER_410 0x04
199#define SD_MMC_HC_CTRL_VER_420 0x05
204#define SD_MMC_HC_V4_EN BIT12
205#define SD_MMC_HC_64_ADDR_EN BIT13
206#define SD_MMC_HC_26_DATA_LEN_ADMA_EN BIT10
438 OUT UINT64 *MaxCurrent
460 OUT BOOLEAN *MediaPresent
590 IN SD_MMC_BUS_MODE Timing
607 IN SD_DRIVER_STRENGTH_TYPE DriverStrength
EFI_STATUS SdMmcHcInitPowerVoltage(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP Capability)
EFI_STATUS SdMmcHcCardDetect(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT BOOLEAN *MediaPresent)
EFI_STATUS EFIAPI SdMmcHcRwMmio(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN BOOLEAN Read, IN UINT8 Count, IN OUT VOID *Data)
EFI_STATUS SdMmcHcStartSdClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
EFI_STATUS SdMmcHcGetMaxCurrent(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT UINT64 *MaxCurrent)
EFI_STATUS SdMmcSetDriverStrength(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 SlotIndex, IN SD_DRIVER_STRENGTH_TYPE DriverStrength)
EFI_STATUS SdMmcHcUhsSignaling(IN EFI_HANDLE ControllerHandle, IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_BUS_MODE Timing)
EFI_STATUS EFIAPI SdMmcHcGetSlotInfo(IN EFI_PCI_IO_PROTOCOL *PciIo, OUT UINT8 *FirstBar, OUT UINT8 *SlotNum)
EFI_STATUS EFIAPI SdMmcHcAndMmio(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN VOID *AndData)
EFI_STATUS SdMmcHcGetCapability(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT SD_MMC_HC_SLOT_CAP *Capability)
EFI_STATUS SdMmcHcInitTimeoutCtrl(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
EFI_STATUS SdMmcHcStopClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
EFI_STATUS SdMmcHcPowerControl(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT8 PowerCtrl)
EFI_STATUS SdMmcHcGetControllerVersion(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT UINT16 *Version)
EFI_STATUS EFIAPI SdMmcHcWaitMmioSet(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN UINT64 MaskValue, IN UINT64 TestValue, IN UINT64 Timeout)
VOID DumpCapabilityReg(IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP *Capability)
EFI_STATUS SdMmcHcSetBusWidth(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT16 BusWidth)
EFI_STATUS SdMmcHcEnableInterrupt(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
EFI_STATUS EFIAPI SdMmcHcOrMmio(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN VOID *OrData)