Go to the documentation of this file.
24 #ifndef LINUX_MMC_MMC_H
25 #define LINUX_MMC_MMC_H
29 #define MMC_GO_IDLE_STATE 0
30 #define MMC_SEND_OP_COND 1
31 #define MMC_ALL_SEND_CID 2
32 #define MMC_SET_RELATIVE_ADDR 3
34 #define MMC_SLEEP_AWAKE 5
36 #define MMC_SELECT_CARD 7
37 #define MMC_SEND_EXT_CSD 8
38 #define MMC_SEND_CSD 9
39 #define MMC_SEND_CID 10
40 #define MMC_READ_DAT_UNTIL_STOP 11
41 #define MMC_STOP_TRANSMISSION 12
42 #define MMC_SEND_STATUS 13
43 #define MMC_BUS_TEST_R 14
44 #define MMC_GO_INACTIVE_STATE 15
45 #define MMC_BUS_TEST_W 19
46 #define MMC_SPI_READ_OCR 58
47 #define MMC_SPI_CRC_ON_OFF 59
50 #define MMC_SET_BLOCKLEN 16
51 #define MMC_READ_SINGLE_BLOCK 17
52 #define MMC_READ_MULTIPLE_BLOCK 18
53 #define MMC_SEND_TUNING_BLOCK 19
54 #define MMC_SEND_TUNING_BLOCK_HS200 21
57 #define MMC_WRITE_DAT_UNTIL_STOP 20
60 #define MMC_SET_BLOCK_COUNT 23
61 #define MMC_WRITE_BLOCK 24
62 #define MMC_WRITE_MULTIPLE_BLOCK 25
63 #define MMC_PROGRAM_CID 26
64 #define MMC_PROGRAM_CSD 27
67 #define MMC_SET_WRITE_PROT 28
68 #define MMC_CLR_WRITE_PROT 29
69 #define MMC_SEND_WRITE_PROT 30
72 #define MMC_ERASE_GROUP_START 35
73 #define MMC_ERASE_GROUP_END 36
77 #define MMC_FAST_IO 39
78 #define MMC_GO_IRQ_STATE 40
81 #define MMC_LOCK_UNLOCK 42
84 #define MMC_APP_CMD 55
85 #define MMC_GEN_CMD 56
87 static inline bool mmc_op_multi(
u32 opcode)
119 #define R1_OUT_OF_RANGE (1 << 31)
120 #define R1_ADDRESS_ERROR (1 << 30)
121 #define R1_BLOCK_LEN_ERROR (1 << 29)
122 #define R1_ERASE_SEQ_ERROR (1 << 28)
123 #define R1_ERASE_PARAM (1 << 27)
124 #define R1_WP_VIOLATION (1 << 26)
125 #define R1_CARD_IS_LOCKED (1 << 25)
126 #define R1_LOCK_UNLOCK_FAILED (1 << 24)
127 #define R1_COM_CRC_ERROR (1 << 23)
128 #define R1_ILLEGAL_COMMAND (1 << 22)
129 #define R1_CARD_ECC_FAILED (1 << 21)
130 #define R1_CC_ERROR (1 << 20)
131 #define R1_ERROR (1 << 19)
132 #define R1_UNDERRUN (1 << 18)
133 #define R1_OVERRUN (1 << 17)
134 #define R1_CID_CSD_OVERWRITE (1 << 16)
135 #define R1_WP_ERASE_SKIP (1 << 15)
136 #define R1_CARD_ECC_DISABLED (1 << 14)
137 #define R1_ERASE_RESET (1 << 13)
138 #define R1_STATUS(x) (x & 0xFFFFE000)
139 #define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9)
140 #define R1_READY_FOR_DATA (1 << 8)
141 #define R1_SWITCH_ERROR (1 << 7)
142 #define R1_EXCEPTION_EVENT (1 << 6)
143 #define R1_APP_CMD (1 << 5)
145 #define R1_STATE_IDLE 0
146 #define R1_STATE_READY 1
147 #define R1_STATE_IDENT 2
148 #define R1_STATE_STBY 3
149 #define R1_STATE_TRAN 4
150 #define R1_STATE_DATA 5
151 #define R1_STATE_RCV 6
152 #define R1_STATE_PRG 7
153 #define R1_STATE_DIS 8
159 #define R1_SPI_IDLE (1 << 0)
160 #define R1_SPI_ERASE_RESET (1 << 1)
161 #define R1_SPI_ILLEGAL_COMMAND (1 << 2)
162 #define R1_SPI_COM_CRC (1 << 3)
163 #define R1_SPI_ERASE_SEQ (1 << 4)
164 #define R1_SPI_ADDRESS (1 << 5)
165 #define R1_SPI_PARAMETER (1 << 6)
167 #define R2_SPI_CARD_LOCKED (1 << 8)
168 #define R2_SPI_WP_ERASE_SKIP (1 << 9)
169 #define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP
170 #define R2_SPI_ERROR (1 << 10)
171 #define R2_SPI_CC_ERROR (1 << 11)
172 #define R2_SPI_CARD_ECC_ERROR (1 << 12)
173 #define R2_SPI_WP_VIOLATION (1 << 13)
174 #define R2_SPI_ERASE_PARAM (1 << 14)
175 #define R2_SPI_OUT_OF_RANGE (1 << 15)
176 #define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE
225 #define MMC_CARD_BUSY 0x80000000
230 #define CCC_BASIC (1<<0)
233 #define CCC_STREAM_READ (1<<1)
235 #define CCC_BLOCK_READ (1<<2)
237 #define CCC_STREAM_WRITE (1<<3)
239 #define CCC_BLOCK_WRITE (1<<4)
241 #define CCC_ERASE (1<<5)
243 #define CCC_WRITE_PROT (1<<6)
245 #define CCC_LOCK_CARD (1<<7)
247 #define CCC_APP_SPEC (1<<8)
249 #define CCC_IO_MODE (1<<9)
251 #define CCC_SWITCH (1<<10)
260 #define CSD_STRUCT_VER_1_0 0
261 #define CSD_STRUCT_VER_1_1 1
262 #define CSD_STRUCT_VER_1_2 2
263 #define CSD_STRUCT_EXT_CSD 3
265 #define CSD_SPEC_VER_0 0
266 #define CSD_SPEC_VER_1 1
267 #define CSD_SPEC_VER_2 2
268 #define CSD_SPEC_VER_3 3
269 #define CSD_SPEC_VER_4 4
275 #define EXT_CSD_FLUSH_CACHE 32
276 #define EXT_CSD_CACHE_CTRL 33
277 #define EXT_CSD_POWER_OFF_NOTIFICATION 34
278 #define EXT_CSD_EXP_EVENTS_STATUS 54
279 #define EXT_CSD_DATA_SECTOR_SIZE 61
280 #define EXT_CSD_GP_SIZE_MULT 143
281 #define EXT_CSD_PARTITION_ATTRIBUTE 156
282 #define EXT_CSD_PARTITION_SUPPORT 160
283 #define EXT_CSD_HPI_MGMT 161
284 #define EXT_CSD_RST_N_FUNCTION 162
285 #define EXT_CSD_BKOPS_EN 163
286 #define EXT_CSD_BKOPS_START 164
287 #define EXT_CSD_SANITIZE_START 165
288 #define EXT_CSD_WR_REL_PARAM 166
289 #define EXT_CSD_BOOT_WP 173
290 #define EXT_CSD_ERASE_GROUP_DEF 175
291 #define EXT_CSD_PART_CONFIG 179
292 #define EXT_CSD_ERASED_MEM_CONT 181
293 #define EXT_CSD_BUS_WIDTH 183
294 #define EXT_CSD_HS_TIMING 185
295 #define EXT_CSD_POWER_CLASS 187
296 #define EXT_CSD_REV 192
297 #define EXT_CSD_STRUCTURE 194
298 #define EXT_CSD_CARD_TYPE 196
299 #define EXT_CSD_OUT_OF_INTERRUPT_TIME 198
300 #define EXT_CSD_PART_SWITCH_TIME 199
301 #define EXT_CSD_PWR_CL_52_195 200
302 #define EXT_CSD_PWR_CL_26_195 201
303 #define EXT_CSD_PWR_CL_52_360 202
304 #define EXT_CSD_PWR_CL_26_360 203
305 #define EXT_CSD_SEC_CNT 212
306 #define EXT_CSD_S_A_TIMEOUT 217
307 #define EXT_CSD_REL_WR_SEC_C 222
308 #define EXT_CSD_HC_WP_GRP_SIZE 221
309 #define EXT_CSD_ERASE_TIMEOUT_MULT 223
310 #define EXT_CSD_HC_ERASE_GRP_SIZE 224
311 #define EXT_CSD_BOOT_MULT 226
312 #define EXT_CSD_SEC_TRIM_MULT 229
313 #define EXT_CSD_SEC_ERASE_MULT 230
314 #define EXT_CSD_SEC_FEATURE_SUPPORT 231
315 #define EXT_CSD_TRIM_MULT 232
316 #define EXT_CSD_PWR_CL_200_195 236
317 #define EXT_CSD_PWR_CL_200_360 237
318 #define EXT_CSD_PWR_CL_DDR_52_195 238
319 #define EXT_CSD_PWR_CL_DDR_52_360 239
320 #define EXT_CSD_BKOPS_STATUS 246
321 #define EXT_CSD_POWER_OFF_LONG_TIME 247
322 #define EXT_CSD_GENERIC_CMD6_TIME 248
323 #define EXT_CSD_CACHE_SIZE 249
324 #define EXT_CSD_TAG_UNIT_SIZE 498
325 #define EXT_CSD_DATA_TAG_SUPPORT 499
326 #define EXT_CSD_BKOPS_SUPPORT 502
327 #define EXT_CSD_HPI_FEATURES 503
333 #define EXT_CSD_WR_REL_PARAM_EN (1<<2)
335 #define EXT_CSD_BOOT_WP_B_PWR_WP_DIS (0x40)
336 #define EXT_CSD_BOOT_WP_B_PERM_WP_DIS (0x10)
337 #define EXT_CSD_BOOT_WP_B_PERM_WP_EN (0x04)
338 #define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01)
340 #define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)
341 #define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1)
342 #define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4)
344 #define EXT_CSD_PART_SUPPORT_PART_EN (0x1)
346 #define EXT_CSD_CMD_SET_NORMAL (1<<0)
347 #define EXT_CSD_CMD_SET_SECURE (1<<1)
348 #define EXT_CSD_CMD_SET_CPSECURE (1<<2)
350 #define EXT_CSD_CARD_TYPE_26 (1<<0)
351 #define EXT_CSD_CARD_TYPE_52 (1<<1)
352 #define EXT_CSD_CARD_TYPE_MASK 0x3F
353 #define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2)
355 #define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3)
357 #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
358 | EXT_CSD_CARD_TYPE_DDR_1_2V)
359 #define EXT_CSD_CARD_TYPE_SDR_1_8V (1<<4)
360 #define EXT_CSD_CARD_TYPE_SDR_1_2V (1<<5)
363 #define EXT_CSD_BUS_WIDTH_1 0
364 #define EXT_CSD_BUS_WIDTH_4 1
365 #define EXT_CSD_BUS_WIDTH_8 2
366 #define EXT_CSD_DDR_BUS_WIDTH_4 5
367 #define EXT_CSD_DDR_BUS_WIDTH_8 6
369 #define EXT_CSD_SEC_ER_EN BIT(0)
370 #define EXT_CSD_SEC_BD_BLK_EN BIT(2)
371 #define EXT_CSD_SEC_GB_CL_EN BIT(4)
372 #define EXT_CSD_SEC_SANITIZE BIT(6)
374 #define EXT_CSD_RST_N_EN_MASK 0x3
375 #define EXT_CSD_RST_N_ENABLED 1
377 #define EXT_CSD_NO_POWER_NOTIFICATION 0
378 #define EXT_CSD_POWER_ON 1
379 #define EXT_CSD_POWER_OFF_SHORT 2
380 #define EXT_CSD_POWER_OFF_LONG 3
382 #define EXT_CSD_PWR_CL_8BIT_MASK 0xF0
383 #define EXT_CSD_PWR_CL_4BIT_MASK 0x0F
384 #define EXT_CSD_PWR_CL_8BIT_SHIFT 4
385 #define EXT_CSD_PWR_CL_4BIT_SHIFT 0
389 #define EXT_CSD_URGENT_BKOPS BIT(0)
390 #define EXT_CSD_DYNCAP_NEEDED BIT(1)
391 #define EXT_CSD_SYSPOOL_EXHAUSTED BIT(2)
392 #define EXT_CSD_PACKED_FAILURE BIT(3)
397 #define EXT_CSD_BKOPS_LEVEL_2 0x2
403 #define MMC_SWITCH_MODE_CMD_SET 0x00
404 #define MMC_SWITCH_MODE_SET_BITS 0x01
405 #define MMC_SWITCH_MODE_CLEAR_BITS 0x02
406 #define MMC_SWITCH_MODE_WRITE_BYTE 0x03