1 /* 2 * Copyright (c) 2015-2020, Renesas Electronics Corporation. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef EMMC_HAL_H 8 #define EMMC_HAL_H 9 10 /* memory card error/status types */ 11 #define HAL_MEMCARD_OUT_OF_RANGE 0x80000000L 12 #define HAL_MEMCARD_ADDRESS_ERROR 0x40000000L 13 #define HAL_MEMCARD_BLOCK_LEN_ERROR 0x20000000L 14 #define HAL_MEMCARD_ERASE_SEQ_ERROR 0x10000000L 15 #define HAL_MEMCARD_ERASE_PARAM 0x08000000L 16 #define HAL_MEMCARD_WP_VIOLATION 0x04000000L 17 #define HAL_MEMCARD_CARD_IS_LOCKED 0x02000000L 18 #define HAL_MEMCARD_LOCK_UNLOCK_FAILED 0x01000000L 19 #define HAL_MEMCARD_COM_CRC_ERROR 0x00800000L 20 #define HAL_MEMCARD_ILEGAL_COMMAND 0x00400000L 21 #define HAL_MEMCARD_CARD_ECC_FAILED 0x00200000L 22 #define HAL_MEMCARD_CC_ERROR 0x00100000L 23 #define HAL_MEMCARD_ERROR 0x00080000L 24 #define HAL_MEMCARD_UNDERRUN 0x00040000L 25 #define HAL_MEMCARD_OVERRUN 0x00020000L 26 #define HAL_MEMCARD_CIDCSD_OVERWRITE 0x00010000L 27 #define HAL_MEMCARD_WP_ERASE_SKIP 0x00008000L 28 #define HAL_MEMCARD_CARD_ECC_DISABLED 0x00004000L 29 #define HAL_MEMCARD_ERASE_RESET 0x00002000L 30 #define HAL_MEMCARD_CARD_STATE 0x00001E00L 31 #define HAL_MEMCARD_CARD_READY_FOR_DATA 0x00000100L 32 #define HAL_MEMCARD_APP_CMD 0x00000020L 33 #define HAL_MEMCARD_SWITCH_ERROR 0x00000080L 34 #define HAL_MEMCARD_AKE_SEQ_ERROR 0x00000008L 35 #define HAL_MEMCARD_NO_ERRORS 0x00000000L 36 37 /* Memory card response types */ 38 #define HAL_MEMCARD_COMMAND_INDEX_MASK 0x0003f 39 40 /* Type of the return value. */ 41 typedef enum { 42 HAL_MEMCARD_FAIL = 0U, 43 HAL_MEMCARD_OK = 1U, 44 HAL_MEMCARD_DMA_ALLOC_FAIL = 2U, /* DMA channel allocation failed */ 45 HAL_MEMCARD_DMA_TRANSFER_FAIL = 3U, /* DMA transfer failed */ 46 HAL_MEMCARD_CARD_STATUS_ERROR = 4U, /* card status non-masked error */ 47 HAL_MEMCARD_CMD_TIMEOUT = 5U, /* Command timeout occurred */ 48 HAL_MEMCARD_DATA_TIMEOUT = 6U, /* Data timeout occurred */ 49 HAL_MEMCARD_CMD_CRC_ERROR = 7U, /* Command CRC error occurred */ 50 HAL_MEMCARD_DATA_CRC_ERROR = 8U /* Data CRC error occurred */ 51 } HAL_MEMCARD_RETURN; 52 53 /* memory access operation */ 54 typedef enum { 55 HAL_MEMCARD_READ = 0U, /* read */ 56 HAL_MEMCARD_WRITE = 1U /* write */ 57 } HAL_MEMCARD_OPERATION; 58 59 /* Type of data width on memorycard bus */ 60 typedef enum { 61 HAL_MEMCARD_DATA_WIDTH_1_BIT = 0U, 62 HAL_MEMCARD_DATA_WIDTH_4_BIT = 1U, 63 HAL_MEMCARD_DATA_WIDTH_8_BIT = 2U 64 } HAL_MEMCARD_DATA_WIDTH; /* data (bus) width types */ 65 66 /* Presence of the memory card */ 67 typedef enum { 68 HAL_MEMCARD_CARD_IS_IN = 0U, 69 HAL_MEMCARD_CARD_IS_OUT = 1U 70 } HAL_MEMCARD_PRESENCE_STATUS; /* presence status of the memory card */ 71 72 /* mode of data transfer */ 73 typedef enum { 74 HAL_MEMCARD_DMA = 0U, 75 HAL_MEMCARD_NOT_DMA = 1U 76 } HAL_MEMCARD_DATA_TRANSFER_MODE; 77 78 /* Memory card response types. */ 79 typedef enum hal_memcard_response_type { 80 HAL_MEMCARD_RESPONSE_NONE = 0x00000U, 81 HAL_MEMCARD_RESPONSE_R1 = 0x00100U, 82 HAL_MEMCARD_RESPONSE_R1b = 0x00200U, 83 HAL_MEMCARD_RESPONSE_R2 = 0x00300U, 84 HAL_MEMCARD_RESPONSE_R3 = 0x00400U, 85 HAL_MEMCARD_RESPONSE_R4 = 0x00500U, 86 HAL_MEMCARD_RESPONSE_R5 = 0x00600U, 87 HAL_MEMCARD_RESPONSE_R6 = 0x00700U, 88 HAL_MEMCARD_RESPONSE_R7 = 0x00800U, 89 HAL_MEMCARD_RESPONSE_TYPE_MASK = 0x00f00U 90 } HAL_MEMCARD_RESPONSE_TYPE; 91 92 /* Memory card command types. */ 93 typedef enum hal_memcard_command_type { 94 HAL_MEMCARD_COMMAND_TYPE_BC = 0x00000U, 95 HAL_MEMCARD_COMMAND_TYPE_BCR = 0x01000U, 96 HAL_MEMCARD_COMMAND_TYPE_AC = 0x02000U, 97 HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE = 0x03000U, 98 HAL_MEMCARD_COMMAND_TYPE_ADTC_READ = 0x04000U, 99 HAL_MEMCARD_COMMAND_TYPE_MASK = 0x07000U 100 } HAL_MEMCARD_COMMAND_TYPE; 101 102 /* Type of memory card */ 103 typedef enum hal_memcard_command_card_type { 104 HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON = 0x00000U, 105 HAL_MEMCARD_COMMAND_CARD_TYPE_MMC = 0x08000U, 106 HAL_MEMCARD_COMMAND_CARD_TYPE_SD = 0x10000U, 107 HAL_MEMCARD_COMMAND_CARD_TYPE_MASK = 0x18000U 108 } HAL_MEMCARD_COMMAND_CARD_TYPE; 109 110 /* Memory card application command. */ 111 typedef enum hal_memcard_command_app_norm { 112 HAL_MEMCARD_COMMAND_NORMAL = 0x00000U, 113 HAL_MEMCARD_COMMAND_APP = 0x20000U, 114 HAL_MEMCARD_COMMAND_APP_NORM_MASK = 0x20000U 115 } HAL_MEMCARD_COMMAND_APP_NORM; 116 117 /* Memory card command codes. */ 118 typedef enum { 119 /* class 0 and class 1 */ 120 /* CMD0 */ 121 CMD0_GO_IDLE_STATE = 122 0U | (uint32_t)HAL_MEMCARD_RESPONSE_NONE | 123 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BC | 124 (uint32_t) HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 125 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 126 /* CMD1 */ 127 CMD1_SEND_OP_COND = 128 1U | (uint32_t)HAL_MEMCARD_RESPONSE_R3 | 129 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BCR | 130 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 131 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 132 /* CMD2 */ 133 CMD2_ALL_SEND_CID_MMC = 134 2U | (uint32_t)HAL_MEMCARD_RESPONSE_R2 | 135 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BCR | 136 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 137 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 138 CMD2_ALL_SEND_CID_SD = 139 2U | (uint32_t)HAL_MEMCARD_RESPONSE_R2 | 140 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BCR | 141 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 142 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 143 /* CMD3 */ 144 CMD3_SET_RELATIVE_ADDR = 145 3U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 146 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 147 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 148 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 149 CMD3_SEND_RELATIVE_ADDR = 150 3U | (uint32_t)HAL_MEMCARD_RESPONSE_R6 | 151 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 152 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 153 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 154 /* CMD4 */ 155 CMD4_SET_DSR = 156 4U | (uint32_t)HAL_MEMCARD_RESPONSE_NONE | 157 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BC | 158 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 159 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 160 /* CMD5 */ 161 CMD5_SLEEP_AWAKE = 162 5U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 163 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 164 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 165 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 166 /* CMD6 */ 167 CMD6_SWITCH = 168 6U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 169 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 170 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 171 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 172 CMD6_SWITCH_FUNC = 173 6U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 174 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 175 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 176 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 177 ACMD6_SET_BUS_WIDTH = 178 6U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 179 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 180 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 181 (uint32_t)HAL_MEMCARD_COMMAND_APP, 182 /* CMD7 */ 183 CMD7_SELECT_CARD = 184 7U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 185 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 186 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 187 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 188 /* CMD7(from Disconnected State to Programming State) */ 189 CMD7_SELECT_CARD_PROG = 190 7U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 191 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 192 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 193 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 194 CMD7_DESELECT_CARD = 195 7U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 196 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 197 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 198 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 199 /* CMD8 */ 200 CMD8_SEND_EXT_CSD = 201 8U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 202 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 203 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 204 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 205 CMD8_SEND_IF_COND = 206 8U | (uint32_t)HAL_MEMCARD_RESPONSE_R7 | 207 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BCR | 208 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 209 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 210 /* CMD9 */ 211 CMD9_SEND_CSD = 212 9U | (uint32_t)HAL_MEMCARD_RESPONSE_R2 | 213 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 214 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 215 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 216 /* CMD10 */ 217 CMD10_SEND_CID = 218 10U | (uint32_t)HAL_MEMCARD_RESPONSE_R2 | 219 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 220 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 221 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 222 /* CMD11 */ 223 CMD11_READ_DAT_UNTIL_STOP = 224 11U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 225 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 226 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 227 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 228 /* CMD12 */ 229 CMD12_STOP_TRANSMISSION = 230 12U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 231 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 232 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 233 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 234 /* CMD12(R1b : write case) */ 235 CMD12_STOP_TRANSMISSION_WRITE = 236 12U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 237 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 238 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 239 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 240 /* CMD13 */ 241 CMD13_SEND_STATUS = 242 13U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 243 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 244 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 245 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 246 ACMD13_SD_STATUS = 247 13U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 248 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 249 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 250 (uint32_t)HAL_MEMCARD_COMMAND_APP, 251 /* CMD14 */ 252 CMD14_BUSTEST_R = 253 14U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 254 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 255 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 256 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 257 /* CMD15 */ 258 CMD15_GO_INACTIVE_STATE = 259 15U | (uint32_t)HAL_MEMCARD_RESPONSE_NONE | 260 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 261 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 262 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 263 264 /* class 2 */ 265 /* CMD16 */ 266 CMD16_SET_BLOCKLEN = 267 16U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 268 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 269 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 270 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 271 /* CMD17 */ 272 CMD17_READ_SINGLE_BLOCK = 273 17U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 274 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 275 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 276 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 277 /* CMD18 */ 278 CMD18_READ_MULTIPLE_BLOCK = 279 18U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 280 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 281 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 282 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 283 /* CMD19 */ 284 CMD19_BUS_TEST_W = 285 19U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 286 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 287 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 288 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 289 290 /* class 3 */ 291 /* CMD20 */ 292 CMD20_WRITE_DAT_UNTIL_STOP = 293 20U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 294 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 295 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 296 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 297 /* CMD21 */ 298 CMD21 = 21U, 299 /* CMD22 */ 300 CMD22 = 22U, 301 ACMD22_SEND_NUM_WR_BLOCKS = 302 22U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 303 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 304 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 305 (uint32_t)HAL_MEMCARD_COMMAND_APP, 306 307 /* class 4 */ 308 /* CMD23 */ 309 CMD23_SET_BLOCK_COUNT = 310 23U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 311 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 312 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 313 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 314 ACMD23_SET_WR_BLK_ERASE_COUNT = 315 23U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 316 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 317 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 318 (uint32_t)HAL_MEMCARD_COMMAND_APP, 319 /* CMD24 */ 320 CMD24_WRITE_BLOCK = 321 24U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 322 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 323 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 324 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 325 /* CMD25 */ 326 CMD25_WRITE_MULTIPLE_BLOCK = 327 25U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 328 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 329 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 330 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 331 /* CMD26 */ 332 CMD26_PROGRAM_CID = 333 26U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 334 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 335 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 336 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 337 /* CMD27 */ 338 CMD27_PROGRAM_CSD = 339 27U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 340 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 341 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 342 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 343 344 /* class 6 */ 345 /* CMD28 */ 346 CMD28_SET_WRITE_PROT = 347 28U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 348 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 349 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 350 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 351 /* CMD29 */ 352 CMD29_CLR_WRITE_PROT = 353 29U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 354 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 355 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 356 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 357 /* CMD30 */ 358 CMD30_SEND_WRITE_PROT = 359 30U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 360 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 361 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 362 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 363 /* CMD31 */ 364 CMD30_SEND_WRITE_PROT_TYPE = 365 31U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 366 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 367 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 368 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 369 370 /* class 5 */ 371 /* CMD32 */ 372 CMD32_ERASE_WR_BLK_START = 373 32U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 374 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 375 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 376 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 377 /* CMD33 */ 378 CMD33_ERASE_WR_BLK_END = 379 33U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 380 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 381 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 382 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 383 /* CMD34 */ 384 CMD34 = 34U, 385 /* CMD35 */ 386 CMD35_ERASE_GROUP_START = 387 35U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 388 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 389 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 390 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 391 /* CMD36 */ 392 CMD36_ERASE_GROUP_END = 393 36U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 394 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 395 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 396 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 397 /* CMD37 */ 398 CMD37 = 37U, 399 /* CMD38 */ 400 CMD38_ERASE = 401 38U | (uint32_t)HAL_MEMCARD_RESPONSE_R1b | 402 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 403 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 404 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 405 406 /* class 9 */ 407 /* CMD39 */ 408 CMD39_FASTIO = 409 39U | (uint32_t)HAL_MEMCARD_RESPONSE_R4 | 410 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 411 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 412 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 413 /* CMD40 */ 414 CMD40_GO_IRQSTATE = 415 40U | (uint32_t)HAL_MEMCARD_RESPONSE_R5 | 416 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BCR | 417 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | 418 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 419 /* CMD41 */ 420 CMD41 = 41, 421 ACMD41_SD_SEND_OP_COND = 422 41U | (uint32_t)HAL_MEMCARD_RESPONSE_R3 | 423 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_BCR | 424 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 425 (uint32_t)HAL_MEMCARD_COMMAND_APP, 426 427 /* class 7 */ 428 /* CMD42 */ 429 CMD42_LOCK_UNLOCK = 430 42U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 431 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 432 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 433 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 434 ACMD42_SET_CLR_CARD_DETECT = 435 42U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 436 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 437 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 438 (uint32_t)HAL_MEMCARD_COMMAND_APP, 439 CMD43 = 43U, /* CMD43 */ 440 CMD44 = 44U, /* CMD44 */ 441 CMD45 = 45U, /* CMD45 */ 442 CMD46 = 46U, /* CMD46 */ 443 CMD47 = 47U, /* CMD47 */ 444 CMD48 = 48U, /* CMD48 */ 445 CMD49 = 49U, /* CMD49 */ 446 CMD50 = 50U, /* CMD50 */ 447 CMD51 = 51U, /* CMD51 */ 448 ACMD51_SEND_SCR = 449 51U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 450 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 451 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_SD | 452 (uint32_t)HAL_MEMCARD_COMMAND_APP, 453 CMD52 = 52U, /* CMD52 */ 454 CMD53 = 53U, /* CMD53 */ 455 CMD54 = 54U, /* CMD54 */ 456 457 /* class 8 */ 458 /* CMD55 */ 459 CMD55_APP_CMD = 460 55U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 461 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_AC | 462 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 463 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 464 /* CMD56 */ 465 CMD56_GEN_CMD = 466 56U | (uint32_t)HAL_MEMCARD_RESPONSE_R1 | 467 (uint32_t)HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | 468 (uint32_t)HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | 469 (uint32_t)HAL_MEMCARD_COMMAND_NORMAL, 470 CMD57 = 57U, /* CMD57 */ 471 CMD58 = 58U, /* CMD58 */ 472 CMD59 = 59U, /* CMD59 */ 473 CMD60 = 60U, /* CMD60 */ 474 CMD61 = 61U, /* CMD61 */ 475 CMD62 = 62U, /* CMD62 */ 476 CMD63 = 63U /* CMD63 */ 477 } HAL_MEMCARD_COMMAND; 478 479 /* 480 * Configuration structure from HAL layer. 481 * 482 * If some field is not available it should be filled with 0xFF. 483 * The API version is 32-bit unsigned integer telling the version of the API. 484 * The integer is divided to four sections which each can be treated as a 8-bit 485 * unsigned number: 486 * Bits 31-24 make the most significant part of the version number. This number 487 * starts from 1 i.e. the second version of the API will be 0x02xxxxxx. This 488 * number changes only, if the API itself changes so much that it is not 489 * compatible anymore with older releases. 490 * Bits 23-16 API minor version number. For example API version 2.1 would be 491 * 0x0201xxxx. 492 * Bits 15-8 are the number of the year when release is done. The 0 is year 493 * 2000, 1 is year 2001 and so on 494 * Bits 7- are the week number when release is done. First full week of the 495 * year is 1 496 * 497 * Example: let's assume that release 2.1 is done on week 10 year 2008 498 * the version will get the value 0x0201080A 499 */ 500 typedef struct { 501 /* 502 * Version of the chipset API implementation 503 * 504 * bits [31:24] API specification major version number.<br> 505 * bits [23:16] API specification minor version number.<br> 506 * bits [15:8] API implementation year. (2000 = 0, 2001 = 1, ...) 507 * bits [7:0] API implementation week. 508 * Example: API spec version 4.0, implementation w46 2008 => 0x0400082E 509 */ 510 uint32_t api_version; 511 512 /* maximum block count which can be transferred at once */ 513 uint32_t max_block_count; 514 515 /* maximum clock frequence in Hz supported by HW */ 516 uint32_t max_clock_freq; 517 518 /* maximum data bus width supported by HW */ 519 uint16_t max_data_width; 520 521 /* Is high-speed mode supported by HW (yes=1, no=0) */ 522 uint8_t hs_mode_supported; 523 524 /* Is memory card removable (yes=1, no=0) */ 525 uint8_t card_removable; 526 527 } HAL_MEMCARD_HW_CONF; 528 529 /* Configuration structure to HAL layer. */ 530 typedef struct { 531 /* how many times to try after fail, for instance sending command */ 532 uint32_t retries_after_fail; 533 } HAL_MEMCARD_INIT_CONF; 534 535 #endif /* EMMC_HAL_H */ 536