1 /* 2 * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /** 8 * @file emmc_hal.h 9 * @brief emmc boot driver is expecting this header file 10 * 11 */ 12 13 #ifndef EMMC_HAL_H 14 #define EMMC_HAL_H 15 /* ************************ HEADER (INCLUDE) SECTION *********************** */ 16 #include <stdint.h> 17 /* ***************** MACROS, CONSTANTS, COMPILATION FLAGS ****************** */ 18 19 /** @brief memory card error/status types 20 */ 21 #define HAL_MEMCARD_OUT_OF_RANGE 0x80000000L 22 #define HAL_MEMCARD_ADDRESS_ERROR 0x40000000L 23 #define HAL_MEMCARD_BLOCK_LEN_ERROR 0x20000000L 24 #define HAL_MEMCARD_ERASE_SEQ_ERROR 0x10000000L 25 #define HAL_MEMCARD_ERASE_PARAM 0x08000000L 26 #define HAL_MEMCARD_WP_VIOLATION 0x04000000L 27 #define HAL_MEMCARD_CARD_IS_LOCKED 0x02000000L 28 #define HAL_MEMCARD_LOCK_UNLOCK_FAILED 0x01000000L 29 #define HAL_MEMCARD_COM_CRC_ERROR 0x00800000L 30 #define HAL_MEMCARD_ILEGAL_COMMAND 0x00400000L 31 #define HAL_MEMCARD_CARD_ECC_FAILED 0x00200000L 32 #define HAL_MEMCARD_CC_ERROR 0x00100000L 33 #define HAL_MEMCARD_ERROR 0x00080000L 34 #define HAL_MEMCARD_UNDERRUN 0x00040000L 35 #define HAL_MEMCARD_OVERRUN 0x00020000L 36 #define HAL_MEMCARD_CIDCSD_OVERWRITE 0x00010000L 37 #define HAL_MEMCARD_WP_ERASE_SKIP 0x00008000L 38 #define HAL_MEMCARD_CARD_ECC_DISABLED 0x00004000L 39 #define HAL_MEMCARD_ERASE_RESET 0x00002000L 40 #define HAL_MEMCARD_CARD_STATE 0x00001E00L 41 #define HAL_MEMCARD_CARD_READY_FOR_DATA 0x00000100L 42 #define HAL_MEMCARD_APP_CMD 0x00000020L 43 #define HAL_MEMCARD_SWITCH_ERROR 0x00000080L 44 #define HAL_MEMCARD_AKE_SEQ_ERROR 0x00000008L 45 #define HAL_MEMCARD_NO_ERRORS 0x00000000L 46 47 /** @brief Memory card response types 48 */ 49 #define HAL_MEMCARD_COMMAND_INDEX_MASK 0x0003f 50 51 /* ********************** STRUCTURES, TYPE DEFINITIONS ********************* */ 52 53 /** @brief Type of the return value. 54 */ 55 typedef enum { 56 HAL_MEMCARD_FAIL = 0U, 57 HAL_MEMCARD_OK = 1U, 58 HAL_MEMCARD_DMA_ALLOC_FAIL = 2U, /**< DMA channel allocation failed */ 59 HAL_MEMCARD_DMA_TRANSFER_FAIL = 3U, /**< DMA transfer failed */ 60 HAL_MEMCARD_CARD_STATUS_ERROR = 4U, /**< A non-masked error bit was set in the card status */ 61 HAL_MEMCARD_CMD_TIMEOUT = 5U, /**< Command timeout occurred */ 62 HAL_MEMCARD_DATA_TIMEOUT = 6U, /**< Data timeout occurred */ 63 HAL_MEMCARD_CMD_CRC_ERROR = 7U, /**< Command CRC error occurred */ 64 HAL_MEMCARD_DATA_CRC_ERROR = 8U /**< Data CRC error occurred */ 65 } HAL_MEMCARD_RETURN; 66 67 /** @brief memory access operation 68 */ 69 typedef enum { 70 HAL_MEMCARD_READ = 0U, /**< read */ 71 HAL_MEMCARD_WRITE = 1U /**< write */ 72 } HAL_MEMCARD_OPERATION; 73 74 /** @brief Type of data width on memorycard bus 75 */ 76 typedef enum { 77 HAL_MEMCARD_DATA_WIDTH_1_BIT = 0U, 78 HAL_MEMCARD_DATA_WIDTH_4_BIT = 1U, 79 HAL_MEMCARD_DATA_WIDTH_8_BIT = 2U 80 } HAL_MEMCARD_DATA_WIDTH; /**< data (bus) width types */ 81 82 /** @brief Presence of the memory card 83 */ 84 typedef enum { 85 HAL_MEMCARD_CARD_IS_IN = 0U, 86 HAL_MEMCARD_CARD_IS_OUT = 1U 87 } HAL_MEMCARD_PRESENCE_STATUS; /* presence status of the memory card */ 88 89 /** @brief mode of data transfer 90 */ 91 typedef enum { 92 HAL_MEMCARD_DMA = 0U, 93 HAL_MEMCARD_NOT_DMA = 1U 94 } HAL_MEMCARD_DATA_TRANSFER_MODE; 95 96 /** @brief Memory card response types. 97 */ 98 typedef enum hal_memcard_response_type { 99 HAL_MEMCARD_RESPONSE_NONE = 0x00000U, 100 HAL_MEMCARD_RESPONSE_R1 = 0x00100U, 101 HAL_MEMCARD_RESPONSE_R1b = 0x00200U, 102 HAL_MEMCARD_RESPONSE_R2 = 0x00300U, 103 HAL_MEMCARD_RESPONSE_R3 = 0x00400U, 104 HAL_MEMCARD_RESPONSE_R4 = 0x00500U, 105 HAL_MEMCARD_RESPONSE_R5 = 0x00600U, 106 HAL_MEMCARD_RESPONSE_R6 = 0x00700U, 107 HAL_MEMCARD_RESPONSE_R7 = 0x00800U, 108 HAL_MEMCARD_RESPONSE_TYPE_MASK = 0x00f00U 109 } HAL_MEMCARD_RESPONSE_TYPE; 110 111 /** @brief Memory card command types. 112 */ 113 typedef enum hal_memcard_command_type { 114 HAL_MEMCARD_COMMAND_TYPE_BC = 0x00000U, 115 HAL_MEMCARD_COMMAND_TYPE_BCR = 0x01000U, 116 HAL_MEMCARD_COMMAND_TYPE_AC = 0x02000U, 117 HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE = 0x03000U, 118 HAL_MEMCARD_COMMAND_TYPE_ADTC_READ = 0x04000U, 119 HAL_MEMCARD_COMMAND_TYPE_MASK = 0x07000U 120 } HAL_MEMCARD_COMMAND_TYPE; 121 122 /** @brief Type of memory card 123 */ 124 typedef enum hal_memcard_command_card_type { 125 HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON = 0x00000U, 126 HAL_MEMCARD_COMMAND_CARD_TYPE_MMC = 0x08000U, 127 HAL_MEMCARD_COMMAND_CARD_TYPE_SD = 0x10000U, 128 HAL_MEMCARD_COMMAND_CARD_TYPE_MASK = 0x18000U 129 } HAL_MEMCARD_COMMAND_CARD_TYPE; 130 131 /** @brief Memory card application command. 132 */ 133 typedef enum hal_memcard_command_app_norm { 134 HAL_MEMCARD_COMMAND_NORMAL = 0x00000U, 135 HAL_MEMCARD_COMMAND_APP = 0x20000U, 136 HAL_MEMCARD_COMMAND_APP_NORM_MASK = 0x20000U 137 } HAL_MEMCARD_COMMAND_APP_NORM; 138 139 /** @brief Memory card command codes. 140 */ 141 typedef enum { 142 /* class 0 and class 1 */ 143 CMD0_GO_IDLE_STATE = 0 | HAL_MEMCARD_RESPONSE_NONE | HAL_MEMCARD_COMMAND_TYPE_BC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD0 */ 144 CMD1_SEND_OP_COND = 1 | HAL_MEMCARD_RESPONSE_R3 | HAL_MEMCARD_COMMAND_TYPE_BCR | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD1 */ 145 CMD2_ALL_SEND_CID_MMC = 2 | HAL_MEMCARD_RESPONSE_R2 | HAL_MEMCARD_COMMAND_TYPE_BCR | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD2 */ 146 CMD2_ALL_SEND_CID_SD = 147 2 | HAL_MEMCARD_RESPONSE_R2 | HAL_MEMCARD_COMMAND_TYPE_BCR | 148 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, 149 CMD3_SET_RELATIVE_ADDR = 3 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD3 */ 150 CMD3_SEND_RELATIVE_ADDR = 151 3 | HAL_MEMCARD_RESPONSE_R6 | HAL_MEMCARD_COMMAND_TYPE_AC | 152 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, 153 CMD4_SET_DSR = 4 | HAL_MEMCARD_RESPONSE_NONE | HAL_MEMCARD_COMMAND_TYPE_BC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD4 */ 154 CMD5_SLEEP_AWAKE = 5 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD5 */ 155 CMD6_SWITCH = 6 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD6 */ 156 CMD6_SWITCH_FUNC = 157 6 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | 158 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, 159 ACMD6_SET_BUS_WIDTH = 160 6 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | 161 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 162 CMD7_SELECT_CARD = 7 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD7 */ 163 CMD7_SELECT_CARD_PROG = 7 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD7(from Disconnected State to Programming State) */ 164 CMD7_DESELECT_CARD = 165 7 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | 166 HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, 167 CMD8_SEND_EXT_CSD = 8 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD8 */ 168 CMD8_SEND_IF_COND = 169 8 | HAL_MEMCARD_RESPONSE_R7 | HAL_MEMCARD_COMMAND_TYPE_BCR | 170 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, 171 CMD9_SEND_CSD = 9 | HAL_MEMCARD_RESPONSE_R2 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD9 */ 172 CMD10_SEND_CID = 10 | HAL_MEMCARD_RESPONSE_R2 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD10 */ 173 CMD11_READ_DAT_UNTIL_STOP = 11 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, /* CMD11 */ 174 CMD12_STOP_TRANSMISSION = 12 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD12 */ 175 CMD12_STOP_TRANSMISSION_WRITE = 12 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD12(R1b : write case) */ 176 CMD13_SEND_STATUS = 13 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD13 */ 177 ACMD13_SD_STATUS = 178 13 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 179 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 180 CMD14_BUSTEST_R = 14 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD14 */ 181 CMD15_GO_INACTIVE_STATE = 15 | HAL_MEMCARD_RESPONSE_NONE | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD15 */ 182 183 /* class 2 */ 184 CMD16_SET_BLOCKLEN = 16 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD16 */ 185 CMD17_READ_SINGLE_BLOCK = 17 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD17 */ 186 CMD18_READ_MULTIPLE_BLOCK = 18 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD18 */ 187 CMD19_BUS_TEST_W = 19 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD19 */ 188 189 /* class 3 */ 190 CMD20_WRITE_DAT_UNTIL_STOP = 20 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD20 */ 191 CMD21 = 21, /* CMD21 */ 192 CMD22 = 22, /* CMD22 */ 193 ACMD22_SEND_NUM_WR_BLOCKS = 194 22 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | 195 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 196 197 /* class 4 */ 198 CMD23_SET_BLOCK_COUNT = 23 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD23 */ 199 ACMD23_SET_WR_BLK_ERASE_COUNT = 200 23 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | 201 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 202 CMD24_WRITE_BLOCK = 24 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD24 */ 203 CMD25_WRITE_MULTIPLE_BLOCK = 25 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD25 */ 204 CMD26_PROGRAM_CID = 26 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD26 */ 205 CMD27_PROGRAM_CSD = 27 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD27 */ 206 207 /* class 6 */ 208 CMD28_SET_WRITE_PROT = 28 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD28 */ 209 CMD29_CLR_WRITE_PROT = 29 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD29 */ 210 CMD30_SEND_WRITE_PROT = 30 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD30 */ 211 CMD30_SEND_WRITE_PROT_TYPE = 31 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD31 */ 212 213 /* class 5 */ 214 CMD32_ERASE_WR_BLK_START = 32 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, /* CMD32 */ 215 CMD33_ERASE_WR_BLK_END = 33 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_NORMAL, /* CMD33 */ 216 CMD34 = 34, /* CMD34 */ 217 CMD35_ERASE_GROUP_START = 35 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD35 */ 218 CMD36_ERASE_GROUP_END = 36 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD36 */ 219 CMD37 = 37, /* CMD37 */ 220 CMD38_ERASE = 38 | HAL_MEMCARD_RESPONSE_R1b | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD38 */ 221 222 /* class 9 */ 223 CMD39_FASTIO = 39 | HAL_MEMCARD_RESPONSE_R4 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD39 */ 224 CMD40_GO_IRQSTATE = 40 | HAL_MEMCARD_RESPONSE_R5 | HAL_MEMCARD_COMMAND_TYPE_BCR | HAL_MEMCARD_COMMAND_CARD_TYPE_MMC | HAL_MEMCARD_COMMAND_NORMAL, /* CMD40 */ 225 CMD41 = 41, /* CMD41 */ 226 ACMD41_SD_SEND_OP_COND = 227 41 | HAL_MEMCARD_RESPONSE_R3 | HAL_MEMCARD_COMMAND_TYPE_BCR | 228 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 229 230 /* class 7 */ 231 CMD42_LOCK_UNLOCK = 42 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD42 */ 232 ACMD42_SET_CLR_CARD_DETECT = 233 42 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | 234 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 235 CMD43 = 43, /* CMD43 */ 236 CMD44 = 44, /* CMD44 */ 237 CMD45 = 45, /* CMD45 */ 238 CMD46 = 46, /* CMD46 */ 239 CMD47 = 47, /* CMD47 */ 240 CMD48 = 48, /* CMD48 */ 241 CMD49 = 49, /* CMD49 */ 242 CMD50 = 50, /* CMD50 */ 243 CMD51 = 51, /* CMD51 */ 244 ACMD51_SEND_SCR = 245 51 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_READ | 246 HAL_MEMCARD_COMMAND_CARD_TYPE_SD | HAL_MEMCARD_COMMAND_APP, 247 CMD52 = 52, /* CMD52 */ 248 CMD53 = 53, /* CMD53 */ 249 CMD54 = 54, /* CMD54 */ 250 251 /* class 8 */ 252 CMD55_APP_CMD = 55 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_AC | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD55 */ 253 CMD56_GEN_CMD = 56 | HAL_MEMCARD_RESPONSE_R1 | HAL_MEMCARD_COMMAND_TYPE_ADTC_WRITE | HAL_MEMCARD_COMMAND_CARD_TYPE_COMMON | HAL_MEMCARD_COMMAND_NORMAL, /* CMD56 */ 254 CMD57 = 57, /* CMD57 */ 255 CMD58 = 58, /* CMD58 */ 256 CMD59 = 59, /* CMD59 */ 257 CMD60 = 60, /* CMD60 */ 258 CMD61 = 61, /* CMD61 */ 259 CMD62 = 62, /* CMD62 */ 260 CMD63 = 63 /* CMD63 */ 261 } HAL_MEMCARD_COMMAND; 262 263 /** @brief Configuration structure from HAL layer. 264 * 265 * If some field is not available it should be filled with 0xFF. 266 * The API version is 32-bit unsigned integer telling the version of the API. The integer is divided to four sections which each can be treated as a 8-bit unsigned number: 267 * Bits 31-24 make the most significant part of the version number. This number starts from 1 i.e. the second version of the API will be 0x02xxxxxx. This number changes only, if the API itself changes so much that it is not compatible anymore with older releases. 268 * Bits 23-16 API minor version number. For example API version 2.1 would be 0x0201xxxx. 269 * Bits 15-8 are the number of the year when release is done. The 0 is year 2000, 1 is year 2001 and so on 270 * Bits 7- are the week number when release is done. First full week of the year is 1 271 * 272 * @note Example: let's assume that release 2.1 is done on week 10 year 2008 the version will get the value 0x0201080A 273 */ 274 typedef struct { 275 /** 276 * Version of the chipset API implementation 277 * 278 * bits [31:24] API specification major version number.<br> 279 * bits [23:16] API specification minor version number.<br> 280 * bits [15:8] API implemention year. (2000 = 0, 2001 = 1, ...)<br> 281 * bits [7:0] API implemention week.<br> 282 * Example: API specification version 4.0, implementation w46 2008 => 0x0400082E 283 */ 284 uint32_t api_version; 285 286 /** maximum block count which can be transferred at once */ 287 uint32_t max_block_count; 288 289 /** maximum clock frequence in Hz supported by HW */ 290 uint32_t max_clock_freq; 291 292 /** maximum data bus width supported by HW */ 293 uint16_t max_data_width; 294 295 /** Is high-speed mode supported by HW (yes=1, no=0) */ 296 uint8_t hs_mode_supported; 297 298 /** Is memory card removable (yes=1, no=0) */ 299 uint8_t card_removable; 300 301 } HAL_MEMCARD_HW_CONF; 302 303 /** @brief Configuration structure to HAL layer. 304 */ 305 typedef struct { 306 /** how many times to try after fail, for instance sending command */ 307 uint32_t retries_after_fail; 308 } HAL_MEMCARD_INIT_CONF; 309 310 /* ********************** DECLARATION OF EXTERNAL DATA ********************* */ 311 312 /* ************************** FUNCTION PROTOTYPES ************************** */ 313 314 /* ********************************* CODE ********************************** */ 315 316 #endif /* EMMC_HAL_H */ 317 318 /* ******************************** END ************************************ */ 319