5 #ifndef __COMMONLIB_SD_MMC_CTRLR_H__
6 #define __COMMONLIB_SD_MMC_CTRLR_H__
11 #define CARD_UNUSABLE_ERR -17
12 #define CARD_COMM_ERR -18
13 #define CARD_TIMEOUT -19
14 #define CARD_IN_PROGRESS -20
28 #define MMC_CMD_GO_IDLE_STATE 0
29 #define MMC_CMD_SEND_OP_COND 1
30 #define MMC_CMD_ALL_SEND_CID 2
31 #define MMC_CMD_SET_DSR 4
32 #define MMC_CMD_SELECT_CARD 7
33 #define MMC_CMD_SEND_CSD 9
34 #define MMC_CMD_SEND_CID 10
35 #define MMC_CMD_STOP_TRANSMISSION 12
36 #define MMC_CMD_SEND_STATUS 13
37 #define MMC_CMD_SET_BLOCKLEN 16
38 #define MMC_CMD_READ_SINGLE_BLOCK 17
39 #define MMC_CMD_READ_MULTIPLE_BLOCK 18
40 #define MMC_CMD_WRITE_SINGLE_BLOCK 24
41 #define MMC_CMD_WRITE_MULTIPLE_BLOCK 25
42 #define MMC_CMD_APP_CMD 55
45 #define MMC_CMD_SET_RELATIVE_ADDR 3
46 #define MMC_CMD_SWITCH 6
47 #define MMC_CMD_SEND_EXT_CSD 8
48 #define MMC_CMD_AUTO_TUNING_SEQUENCE 21
49 #define MMC_CMD_ERASE_GROUP_START 35
50 #define MMC_CMD_ERASE_GROUP_END 36
51 #define MMC_CMD_ERASE 38
52 #define MMC_CMD_SPI_READ_OCR 58
53 #define MMC_CMD_SPI_CRC_ON_OFF 59
56 #define SD_CMD_SEND_RELATIVE_ADDR 3
57 #define SD_CMD_SWITCH_FUNC 6
58 #define SD_CMD_SEND_IF_COND 8
59 #define SD_CMD_ERASE_WR_BLK_START 32
60 #define SD_CMD_ERASE_WR_BLK_END 33
63 #define SD_CMD_APP_SET_BUS_WIDTH 6
64 #define SD_CMD_APP_SEND_OP_COND 41
65 #define SD_CMD_APP_SEND_SCR 51
69 #define CARD_RSP_PRESENT (1 << 0)
70 #define CARD_RSP_136 (1 << 1)
71 #define CARD_RSP_CRC (1 << 2)
72 #define CARD_RSP_BUSY (1 << 3)
73 #define CARD_RSP_OPCODE (1 << 4)
75 #define CARD_RSP_NONE (0)
76 #define CARD_RSP_R1 (CARD_RSP_PRESENT|CARD_RSP_CRC|CARD_RSP_OPCODE)
77 #define CARD_RSP_R1b (CARD_RSP_PRESENT|CARD_RSP_CRC|CARD_RSP_OPCODE| \
79 #define CARD_RSP_R2 (CARD_RSP_PRESENT|CARD_RSP_136|CARD_RSP_CRC)
80 #define CARD_RSP_R3 (CARD_RSP_PRESENT)
81 #define CARD_RSP_R4 (CARD_RSP_PRESENT)
82 #define CARD_RSP_R5 (CARD_RSP_PRESENT|CARD_RSP_CRC|CARD_RSP_OPCODE)
83 #define CARD_RSP_R6 (CARD_RSP_PRESENT|CARD_RSP_CRC|CARD_RSP_OPCODE)
84 #define CARD_RSP_R7 (CARD_RSP_PRESENT|CARD_RSP_CRC|CARD_RSP_OPCODE)
88 #define MMC_TRIM_ARG 0x1
89 #define MMC_SECURE_ERASE_ARG 0x80000000
94 #define CMD_FLAG_IGNORE_INHIBIT 1
97 #define SD_SWITCH_CHECK 0
98 #define SD_SWITCH_SWITCH 1
100 #define SD_DATA_4BIT 0x00040000
103 #define SD_HIGHSPEED_BUSY 0x00020000
104 #define SD_HIGHSPEED_SUPPORTED 0x00020000
113 #define DATA_FLAG_READ 1
114 #define DATA_FLAG_WRITE 2
131 #define MMC_VDD_165_195 0x00000080
132 #define MMC_VDD_20_21 0x00000100
133 #define MMC_VDD_21_22 0x00000200
134 #define MMC_VDD_22_23 0x00000400
135 #define MMC_VDD_23_24 0x00000800
136 #define MMC_VDD_24_25 0x00001000
137 #define MMC_VDD_25_26 0x00002000
138 #define MMC_VDD_26_27 0x00004000
139 #define MMC_VDD_27_28 0x00008000
140 #define MMC_VDD_28_29 0x00010000
141 #define MMC_VDD_29_30 0x00020000
142 #define MMC_VDD_30_31 0x00040000
143 #define MMC_VDD_31_32 0x00080000
144 #define MMC_VDD_32_33 0x00100000
145 #define MMC_VDD_33_34 0x00200000
146 #define MMC_VDD_34_35 0x00400000
147 #define MMC_VDD_35_36 0x00800000
149 #define MMC_VDD_165_195_SHIFT 7
157 #define CLOCK_KHZ 1000
158 #define CLOCK_MHZ (1000 * CLOCK_KHZ)
159 #define CLOCK_20MHZ (20 * CLOCK_MHZ)
160 #define CLOCK_25MHZ (25 * CLOCK_MHZ)
161 #define CLOCK_26MHZ (26 * CLOCK_MHZ)
162 #define CLOCK_50MHZ (50 * CLOCK_MHZ)
163 #define CLOCK_52MHZ (52 * CLOCK_MHZ)
164 #define CLOCK_200MHZ (200 * CLOCK_MHZ)
172 #define DRVR_CAP_4BIT 0x00000001
173 #define DRVR_CAP_8BIT 0x00000002
174 #define DRVR_CAP_AUTO_CMD12 0x00000004
175 #define DRVR_CAP_HC 0x00000008
176 #define DRVR_CAP_HS 0x00000010
177 #define DRVR_CAP_HS52 0x00000020
178 #define DRVR_CAP_HS200 0x00000040
179 #define DRVR_CAP_HS400 0x00000080
180 #define DRVR_CAP_ENHANCED_STROBE 0x00000100
181 #define DRVR_CAP_REMOVABLE 0x00000200
182 #define DRVR_CAP_DMA_64BIT 0x00000400
183 #define DRVR_CAP_HS200_TUNING 0x00000800
188 #define BUS_TIMING_LEGACY 0
189 #define BUS_TIMING_MMC_HS 1
190 #define BUS_TIMING_SD_HS 2
191 #define BUS_TIMING_UHS_SDR12 3
192 #define BUS_TIMING_UHS_SDR25 4
193 #define BUS_TIMING_UHS_SDR50 5
194 #define BUS_TIMING_UHS_SDR104 6
195 #define BUS_TIMING_UHS_DDR50 7
196 #define BUS_TIMING_MMC_DDR52 8
197 #define BUS_TIMING_MMC_HS200 9
198 #define BUS_TIMING_MMC_HS400 10
199 #define BUS_TIMING_MMC_HS400ES 11
void sdhc_log_command(struct mmc_command *cmd)
void sdhc_log_command_issued(void)
@ MMC_STATUS_CMD1_IN_PROGRESS
@ MMC_STATUS_CMD1_READY_OR_IN_PROGRESS
void soc_sd_mmc_controller_quirks(struct sd_mmc_ctrlr *ctrlr)
void sdhc_log_response(uint32_t entries, uint32_t *response)
void sdhc_log_ret(int ret)
void(* tuning_start)(struct sd_mmc_ctrlr *ctrlr, int retune)
uint32_t udelay_wait_after_cmd
uint32_t mdelay_before_cmd0
int(* send_cmd)(struct sd_mmc_ctrlr *ctrlr, struct mmc_command *cmd, struct mmc_data *data)
uint32_t mdelay_after_cmd0
int(* is_tuning_complete)(struct sd_mmc_ctrlr *ctrlr, int *successful)
void(* set_ios)(struct sd_mmc_ctrlr *ctrlr)
typedef void(X86APIP X86EMU_intrFuncs)(int num)