fsl_specification.h 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _FSL_SPECIFICATION_H_
  31. #define _FSL_SPECIFICATION_H_
  32. #include <stdint.h>
  33. /*******************************************************************************
  34. * Definitions
  35. ******************************************************************************/
  36. /*! @brief SD/MMC card initialization clock frequency */
  37. #define SDMMC_CLOCK_400KHZ (400000U)
  38. /*! @brief SD card bus frequency 1 in high-speed mode */
  39. #define SD_CLOCK_25MHZ (25000000U)
  40. /*! @brief SD card bus frequency 2 in high-speed mode */
  41. #define SD_CLOCK_50MHZ (50000000U)
  42. /*! @brief SD card bus frequency in SDR50 mode */
  43. #define SD_CLOCK_100MHZ (100000000U)
  44. /*! @brief SD card bus frequency in SDR104 mode */
  45. #define SD_CLOCK_208MHZ (208000000U)
  46. /*! @brief MMC card bus frequency 1 in high-speed mode */
  47. #define MMC_CLOCK_26MHZ (26000000U)
  48. /*! @brief MMC card bus frequency 2 in high-speed mode */
  49. #define MMC_CLOCK_52MHZ (52000000U)
  50. /*! @brief MMC card bus frequency in high-speed DDR52 mode */
  51. #define MMC_CLOCK_DDR52 (104000000U)
  52. /*! @brief MMC card bus frequency in high-speed HS200 mode */
  53. #define MMC_CLOCK_HS200 (200000000U)
  54. /*! @brief MMC card bus frequency in high-speed HS400 mode */
  55. #define MMC_CLOCK_HS400 (400000000U)
  56. /*! @brief Card status bit in R1 */
  57. enum _sdmmc_r1_card_status_flag
  58. {
  59. kSDMMC_R1OutOfRangeFlag = (1U << 31U), /*!< Out of range status bit */
  60. kSDMMC_R1AddressErrorFlag = (1U << 30U), /*!< Address error status bit */
  61. kSDMMC_R1BlockLengthErrorFlag = (1U << 29U), /*!< Block length error status bit */
  62. kSDMMC_R1EraseSequenceErrorFlag = (1U << 28U), /*!< Erase sequence error status bit */
  63. kSDMMC_R1EraseParameterErrorFlag = (1U << 27U), /*!< Erase parameter error status bit */
  64. kSDMMC_R1WriteProtectViolationFlag = (1U << 26U), /*!< Write protection violation status bit */
  65. kSDMMC_R1CardIsLockedFlag = (1U << 25U), /*!< Card locked status bit */
  66. kSDMMC_R1LockUnlockFailedFlag = (1U << 24U), /*!< lock/unlock error status bit */
  67. kSDMMC_R1CommandCrcErrorFlag = (1U << 23U), /*!< CRC error status bit */
  68. kSDMMC_R1IllegalCommandFlag = (1U << 22U), /*!< Illegal command status bit */
  69. kSDMMC_R1CardEccFailedFlag = (1U << 21U), /*!< Card ecc error status bit */
  70. kSDMMC_R1CardControllerErrorFlag = (1U << 20U), /*!< Internal card controller error status bit */
  71. kSDMMC_R1ErrorFlag = (1U << 19U), /*!< A general or an unknown error status bit */
  72. kSDMMC_R1CidCsdOverwriteFlag = (1U << 16U), /*!< Cid/csd overwrite status bit */
  73. kSDMMC_R1WriteProtectEraseSkipFlag = (1U << 15U), /*!< Write protection erase skip status bit */
  74. kSDMMC_R1CardEccDisabledFlag = (1U << 14U), /*!< Card ecc disabled status bit */
  75. kSDMMC_R1EraseResetFlag = (1U << 13U), /*!< Erase reset status bit */
  76. kSDMMC_R1ReadyForDataFlag = (1U << 8U), /*!< Ready for data status bit */
  77. kSDMMC_R1SwitchErrorFlag = (1U << 7U), /*!< Switch error status bit */
  78. kSDMMC_R1ApplicationCommandFlag = (1U << 5U), /*!< Application command enabled status bit */
  79. kSDMMC_R1AuthenticationSequenceErrorFlag = (1U << 3U), /*!< error in the sequence of authentication process */
  80. kSDMMC_R1ErrorAllFlag =
  81. (kSDMMC_R1OutOfRangeFlag | kSDMMC_R1AddressErrorFlag | kSDMMC_R1BlockLengthErrorFlag |
  82. kSDMMC_R1EraseSequenceErrorFlag | kSDMMC_R1EraseParameterErrorFlag | kSDMMC_R1WriteProtectViolationFlag |
  83. kSDMMC_R1CardIsLockedFlag | kSDMMC_R1LockUnlockFailedFlag | kSDMMC_R1CommandCrcErrorFlag |
  84. kSDMMC_R1IllegalCommandFlag | kSDMMC_R1CardEccFailedFlag | kSDMMC_R1CardControllerErrorFlag |
  85. kSDMMC_R1ErrorFlag | kSDMMC_R1CidCsdOverwriteFlag |
  86. kSDMMC_R1AuthenticationSequenceErrorFlag), /*!< Card error status */
  87. };
  88. /*! @brief R1: current state */
  89. #define SDMMC_R1_CURRENT_STATE(x) (((x)&0x00001E00U) >> 9U)
  90. /*! @brief CURRENT_STATE filed in R1 */
  91. typedef enum _sdmmc_r1_current_state
  92. {
  93. kSDMMC_R1StateIdle = 0U, /*!< R1: current state: idle */
  94. kSDMMC_R1StateReady = 1U, /*!< R1: current state: ready */
  95. kSDMMC_R1StateIdentify = 2U, /*!< R1: current state: identification */
  96. kSDMMC_R1StateStandby = 3U, /*!< R1: current state: standby */
  97. kSDMMC_R1StateTransfer = 4U, /*!< R1: current state: transfer */
  98. kSDMMC_R1StateSendData = 5U, /*!< R1: current state: sending data */
  99. kSDMMC_R1StateReceiveData = 6U, /*!< R1: current state: receiving data */
  100. kSDMMC_R1StateProgram = 7U, /*!< R1: current state: programming */
  101. kSDMMC_R1StateDisconnect = 8U, /*!< R1: current state: disconnect */
  102. } sdmmc_r1_current_state_t;
  103. /*! @brief Error bit in SPI mode R1 */
  104. enum _sdspi_r1_error_status_flag
  105. {
  106. kSDSPI_R1InIdleStateFlag = (1U << 0U), /*!< In idle state */
  107. kSDSPI_R1EraseResetFlag = (1U << 1U), /*!< Erase reset */
  108. kSDSPI_R1IllegalCommandFlag = (1U << 2U), /*!< Illegal command */
  109. kSDSPI_R1CommandCrcErrorFlag = (1U << 3U), /*!< Com crc error */
  110. kSDSPI_R1EraseSequenceErrorFlag = (1U << 4U), /*!< Erase sequence error */
  111. kSDSPI_R1AddressErrorFlag = (1U << 5U), /*!< Address error */
  112. kSDSPI_R1ParameterErrorFlag = (1U << 6U), /*!< Parameter error */
  113. };
  114. /*! @brief Error bit in SPI mode R2 */
  115. enum _sdspi_r2_error_status_flag
  116. {
  117. kSDSPI_R2CardLockedFlag = (1U << 0U), /*!< Card is locked */
  118. kSDSPI_R2WriteProtectEraseSkip = (1U << 1U), /*!< Write protect erase skip */
  119. kSDSPI_R2LockUnlockFailed = (1U << 1U), /*!< Lock/unlock command failed */
  120. kSDSPI_R2ErrorFlag = (1U << 2U), /*!< Unknown error */
  121. kSDSPI_R2CardControllerErrorFlag = (1U << 3U), /*!< Card controller error */
  122. kSDSPI_R2CardEccFailedFlag = (1U << 4U), /*!< Card ecc failed */
  123. kSDSPI_R2WriteProtectViolationFlag = (1U << 5U), /*!< Write protect violation */
  124. kSDSPI_R2EraseParameterErrorFlag = (1U << 6U), /*!< Erase parameter error */
  125. kSDSPI_R2OutOfRangeFlag = (1U << 7U), /*!< Out of range */
  126. kSDSPI_R2CsdOverwriteFlag = (1U << 7U), /*!< CSD overwrite */
  127. };
  128. /*! @brief The bit mask for COMMAND VERSION field in R7 */
  129. #define SDSPI_R7_VERSION_SHIFT (28U)
  130. /*! @brief The bit mask for COMMAND VERSION field in R7 */
  131. #define SDSPI_R7_VERSION_MASK (0xFU)
  132. /*! @brief The bit shift for VOLTAGE ACCEPTED field in R7 */
  133. #define SDSPI_R7_VOLTAGE_SHIFT (8U)
  134. /*! @brief The bit mask for VOLTAGE ACCEPTED field in R7 */
  135. #define SDSPI_R7_VOLTAGE_MASK (0xFU)
  136. /*! @brief The bit mask for VOLTAGE 2.7V to 3.6V field in R7 */
  137. #define SDSPI_R7_VOLTAGE_27_36_MASK (0x1U << SDSPI_R7_VOLTAGE_SHIFT)
  138. /*! @brief The bit shift for ECHO field in R7 */
  139. #define SDSPI_R7_ECHO_SHIFT (0U)
  140. /*! @brief The bit mask for ECHO field in R7 */
  141. #define SDSPI_R7_ECHO_MASK (0xFFU)
  142. /*! @brief Data error token mask */
  143. #define SDSPI_DATA_ERROR_TOKEN_MASK (0xFU)
  144. /*! @brief Data Error Token mask bit */
  145. enum _sdspi_data_error_token
  146. {
  147. kSDSPI_DataErrorTokenError = (1U << 0U), /*!< Data error */
  148. kSDSPI_DataErrorTokenCardControllerError = (1U << 1U), /*!< Card controller error */
  149. kSDSPI_DataErrorTokenCardEccFailed = (1U << 2U), /*!< Card ecc error */
  150. kSDSPI_DataErrorTokenOutOfRange = (1U << 3U), /*!< Out of range */
  151. };
  152. /*! @brief Data Token */
  153. typedef enum _sdspi_data_token
  154. {
  155. kSDSPI_DataTokenBlockRead = 0xFEU, /*!< Single block read, multiple block read */
  156. kSDSPI_DataTokenSingleBlockWrite = 0xFEU, /*!< Single block write */
  157. kSDSPI_DataTokenMultipleBlockWrite = 0xFCU, /*!< Multiple block write */
  158. kSDSPI_DataTokenStopTransfer = 0xFDU, /*!< Stop transmission */
  159. } sdspi_data_token_t;
  160. /* Data Response Token mask */
  161. #define SDSPI_DATA_RESPONSE_TOKEN_MASK (0x1FU) /*!< Mask for data response bits */
  162. /*! @brief Data Response Token */
  163. typedef enum _sdspi_data_response_token
  164. {
  165. kSDSPI_DataResponseTokenAccepted = 0x05U, /*!< Data accepted */
  166. kSDSPI_DataResponseTokenCrcError = 0x0BU, /*!< Data rejected due to CRC error */
  167. kSDSPI_DataResponseTokenWriteError = 0x0DU, /*!< Data rejected due to write error */
  168. } sdspi_data_response_token_t;
  169. /*! @brief SD card individual commands */
  170. typedef enum _sd_command
  171. {
  172. kSD_SendRelativeAddress = 3U, /*!< Send Relative Address */
  173. kSD_Switch = 6U, /*!< Switch Function */
  174. kSD_SendInterfaceCondition = 8U, /*!< Send Interface Condition */
  175. kSD_VoltageSwitch = 11U, /*!< Voltage Switch */
  176. kSD_SpeedClassControl = 20U, /*!< Speed Class control */
  177. kSD_EraseWriteBlockStart = 32U, /*!< Write Block Start */
  178. kSD_EraseWriteBlockEnd = 33U, /*!< Write Block End */
  179. kSD_SendTuningBlock = 19U, /*!< Send Tuning Block */
  180. } sd_command_t;
  181. /*! @brief SD card individual application commands */
  182. typedef enum _sd_application_command
  183. {
  184. kSD_ApplicationSetBusWdith = 6U, /*!< Set Bus Width */
  185. kSD_ApplicationStatus = 13U, /*!< Send SD status */
  186. kSD_ApplicationSendNumberWriteBlocks = 22U, /*!< Send Number Of Written Blocks */
  187. kSD_ApplicationSetWriteBlockEraseCount = 23U, /*!< Set Write Block Erase Count */
  188. kSD_ApplicationSendOperationCondition = 41U, /*!< Send Operation Condition */
  189. kSD_ApplicationSetClearCardDetect = 42U, /*!< Set Connnect/Disconnect pull up on detect pin */
  190. kSD_ApplicationSendScr = 51U, /*!< Send Scr */
  191. } sd_application_command_t;
  192. /*! @brief SD card command class */
  193. enum _sdmmc_command_class
  194. {
  195. kSDMMC_CommandClassBasic = (1U << 0U), /*!< Card command class 0 */
  196. kSDMMC_CommandClassBlockRead = (1U << 2U), /*!< Card command class 2 */
  197. kSDMMC_CommandClassBlockWrite = (1U << 4U), /*!< Card command class 4 */
  198. kSDMMC_CommandClassErase = (1U << 5U), /*!< Card command class 5 */
  199. kSDMMC_CommandClassWriteProtect = (1U << 6U), /*!< Card command class 6 */
  200. kSDMMC_CommandClassLockCard = (1U << 7U), /*!< Card command class 7 */
  201. kSDMMC_CommandClassApplicationSpecific = (1U << 8U), /*!< Card command class 8 */
  202. kSDMMC_CommandClassInputOutputMode = (1U << 9U), /*!< Card command class 9 */
  203. kSDMMC_CommandClassSwitch = (1U << 10U), /*!< Card command class 10 */
  204. };
  205. /*! @brief OCR register in SD card */
  206. enum _sd_ocr_flag
  207. {
  208. kSD_OcrPowerUpBusyFlag = (1U << 31U), /*!< Power up busy status */
  209. kSD_OcrHostCapacitySupportFlag = (1U << 30U), /*!< Card capacity status */
  210. kSD_OcrCardCapacitySupportFlag = kSD_OcrHostCapacitySupportFlag, /*!< Card capacity status */
  211. kSD_OcrSwitch18RequestFlag = (1U << 24U), /*!< Switch to 1.8V request */
  212. kSD_OcrSwitch18AcceptFlag = kSD_OcrSwitch18RequestFlag, /*!< Switch to 1.8V accepted */
  213. kSD_OcrVdd27_28Flag = (1U << 15U), /*!< VDD 2.7-2.8 */
  214. kSD_OcrVdd28_29Flag = (1U << 16U), /*!< VDD 2.8-2.9 */
  215. kSD_OcrVdd29_30Flag = (1U << 17U), /*!< VDD 2.9-3.0 */
  216. kSD_OcrVdd30_31Flag = (1U << 18U), /*!< VDD 2.9-3.0 */
  217. kSD_OcrVdd31_32Flag = (1U << 19U), /*!< VDD 3.0-3.1 */
  218. kSD_OcrVdd32_33Flag = (1U << 20U), /*!< VDD 3.1-3.2 */
  219. kSD_OcrVdd33_34Flag = (1U << 21U), /*!< VDD 3.2-3.3 */
  220. kSD_OcrVdd34_35Flag = (1U << 22U), /*!< VDD 3.3-3.4 */
  221. kSD_OcrVdd35_36Flag = (1U << 23U), /*!< VDD 3.4-3.5 */
  222. };
  223. /*! @brief SD card specification version number */
  224. enum _sd_specification_version
  225. {
  226. kSD_SpecificationVersion1_0 = (1U << 0U), /*!< SD card version 1.0-1.01 */
  227. kSD_SpecificationVersion1_1 = (1U << 1U), /*!< SD card version 1.10 */
  228. kSD_SpecificationVersion2_0 = (1U << 2U), /*!< SD card version 2.00 */
  229. kSD_SpecificationVersion3_0 = (1U << 3U), /*!< SD card version 3.0 */
  230. };
  231. /*! @brief SD card bus width */
  232. typedef enum _sd_data_bus_width
  233. {
  234. kSD_DataBusWidth1Bit = 0U, /*!< SD data bus width 1-bit mode */
  235. kSD_DataBusWidth4Bit = 1U, /*!< SD data bus width 4-bit mode */
  236. } sd_data_bus_width_t;
  237. /*! @brief SD card switch mode */
  238. typedef enum _sd_switch_mode
  239. {
  240. kSD_SwitchCheck = 0U, /*!< SD switch mode 0: check function */
  241. kSD_SwitchSet = 1U, /*!< SD switch mode 1: set function */
  242. } sd_switch_mode_t;
  243. /*! @brief SD card CSD register flags */
  244. enum _sd_csd_flag
  245. {
  246. kSD_CsdReadBlockPartialFlag = (1U << 0U), /*!< Partial blocks for read allowed [79:79] */
  247. kSD_CsdWriteBlockMisalignFlag = (1U << 1U), /*!< Write block misalignment [78:78] */
  248. kSD_CsdReadBlockMisalignFlag = (1U << 2U), /*!< Read block misalignment [77:77] */
  249. kSD_CsdDsrImplementedFlag = (1U << 3U), /*!< DSR implemented [76:76] */
  250. kSD_CsdEraseBlockEnabledFlag = (1U << 4U), /*!< Erase single block enabled [46:46] */
  251. kSD_CsdWriteProtectGroupEnabledFlag = (1U << 5U), /*!< Write protect group enabled [31:31] */
  252. kSD_CsdWriteBlockPartialFlag = (1U << 6U), /*!< Partial blocks for write allowed [21:21] */
  253. kSD_CsdFileFormatGroupFlag = (1U << 7U), /*!< File format group [15:15] */
  254. kSD_CsdCopyFlag = (1U << 8U), /*!< Copy flag [14:14] */
  255. kSD_CsdPermanentWriteProtectFlag = (1U << 9U), /*!< Permanent write protection [13:13] */
  256. kSD_CsdTemporaryWriteProtectFlag = (1U << 10U), /*!< Temporary write protection [12:12] */
  257. };
  258. /*! @brief SD card SCR register flags */
  259. enum _sd_scr_flag
  260. {
  261. kSD_ScrDataStatusAfterErase = (1U << 0U), /*!< Data status after erases [55:55] */
  262. kSD_ScrSdSpecification3 = (1U << 1U), /*!< Specification version 3.00 or higher [47:47]*/
  263. };
  264. /*! @brief SD timing function number */
  265. enum _sd_timing_function
  266. {
  267. kSD_FunctionSDR12Deafult = 0U, /*!< SDR12 mode & default*/
  268. kSD_FunctionSDR25HighSpeed = 1U, /*!< SDR25 & high speed*/
  269. kSD_FunctionSDR50 = 2U, /*!< SDR50 mode*/
  270. kSD_FunctionSDR104 = 3U, /*!< SDR104 mode*/
  271. kSD_FunctionDDR50 = 4U, /*!< DDR50 mode*/
  272. };
  273. /*! @brief SD group number */
  274. enum _sd_group_num
  275. {
  276. kSD_GroupTimingMode = 0U, /*!< acess mode group*/
  277. kSD_GroupCommandSystem = 1U, /*!< command system group*/
  278. kSD_GroupDriverStrength = 2U, /*!< driver strength group*/
  279. kSD_GroupCurrentLimit = 3U, /*!< current limit group*/
  280. };
  281. /*! @brief SD card timing mode flags */
  282. typedef enum _sd_timing_mode
  283. {
  284. kSD_TimingSDR12DefaultMode = 0U, /*!< Identification mode & SDR12 */
  285. kSD_TimingSDR25HighSpeedMode = 1U, /*!< High speed mode & SDR25 */
  286. kSD_TimingSDR50Mode = 2U, /*!< SDR50 mode*/
  287. kSD_TimingSDR104Mode = 3U, /*!< SDR104 mode */
  288. kSD_TimingDDR50Mode = 4U, /*!< DDR50 mode */
  289. } sd_timing_mode_t;
  290. /*! @brief SD card driver strength */
  291. typedef enum _sd_driver_strength
  292. {
  293. kSD_DriverStrengthTypeB = 0U, /*!< default driver strength*/
  294. kSD_DriverStrengthTypeA = 1U, /*!< driver strength TYPE A */
  295. kSD_DriverStrengthTypeC = 2U, /*!< driver strength TYPE C */
  296. kSD_DriverStrengthTypeD = 3U, /*!< driver strength TYPE D */
  297. } sd_driver_strength_t;
  298. /*! @brief SD card current limit */
  299. typedef enum _sd_max_current
  300. {
  301. kSD_CurrentLimit200MA = 0U, /*!< default current limit */
  302. kSD_CurrentLimit400MA = 1U, /*!< current limit to 400MA */
  303. kSD_CurrentLimit600MA = 2U, /*!< current limit to 600MA */
  304. kSD_CurrentLimit800MA = 3U, /*!< current limit to 800MA */
  305. } sd_max_current_t;
  306. /*! @brief SD/MMC card common commands */
  307. typedef enum _sdmmc_command
  308. {
  309. kSDMMC_GoIdleState = 0U, /*!< Go Idle State */
  310. kSDMMC_AllSendCid = 2U, /*!< All Send CID */
  311. kSDMMC_SetDsr = 4U, /*!< Set DSR */
  312. kSDMMC_SelectCard = 7U, /*!< Select Card */
  313. kSDMMC_SendCsd = 9U, /*!< Send CSD */
  314. kSDMMC_SendCid = 10U, /*!< Send CID */
  315. kSDMMC_StopTransmission = 12U, /*!< Stop Transmission */
  316. kSDMMC_SendStatus = 13U, /*!< Send Status */
  317. kSDMMC_GoInactiveState = 15U, /*!< Go Inactive State */
  318. kSDMMC_SetBlockLength = 16U, /*!< Set Block Length */
  319. kSDMMC_ReadSingleBlock = 17U, /*!< Read Single Block */
  320. kSDMMC_ReadMultipleBlock = 18U, /*!< Read Multiple Block */
  321. kSDMMC_SetBlockCount = 23U, /*!< Set Block Count */
  322. kSDMMC_WriteSingleBlock = 24U, /*!< Write Single Block */
  323. kSDMMC_WriteMultipleBlock = 25U, /*!< Write Multiple Block */
  324. kSDMMC_ProgramCsd = 27U, /*!< Program CSD */
  325. kSDMMC_SetWriteProtect = 28U, /*!< Set Write Protect */
  326. kSDMMC_ClearWriteProtect = 29U, /*!< Clear Write Protect */
  327. kSDMMC_SendWriteProtect = 30U, /*!< Send Write Protect */
  328. kSDMMC_Erase = 38U, /*!< Erase */
  329. kSDMMC_LockUnlock = 42U, /*!< Lock Unlock */
  330. kSDMMC_ApplicationCommand = 55U, /*!< Send Application Command */
  331. kSDMMC_GeneralCommand = 56U, /*!< General Purpose Command */
  332. kSDMMC_ReadOcr = 58U, /*!< Read OCR */
  333. } sdmmc_command_t;
  334. /*! @brief sdio card cccr register addr */
  335. enum _sdio_cccr_reg
  336. {
  337. kSDIO_RegCCCRSdioVer = 0x00U, /*!< CCCR & SDIO version*/
  338. kSDIO_RegSDVersion = 0x01U, /*!< SD version */
  339. kSDIO_RegIOEnable = 0x02U, /*!< io enable register */
  340. kSDIO_RegIOReady = 0x03U, /*!< io ready register */
  341. kSDIO_RegIOIntEnable = 0x04U, /*!< io interrupt enable register */
  342. kSDIO_RegIOIntPending = 0x05U, /*!< io interrupt pending register */
  343. kSDIO_RegIOAbort = 0x06U, /*!< io abort register */
  344. kSDIO_RegBusInterface = 0x07U, /*!< bus interface register */
  345. kSDIO_RegCardCapability = 0x08U, /*!< card capability register */
  346. kSDIO_RegCommonCISPointer = 0x09U, /*!< common CIS pointer register */
  347. kSDIO_RegBusSuspend = 0x0C, /*!< bus suspend register */
  348. kSDIO_RegFunctionSelect = 0x0DU, /*!< function select register */
  349. kSDIO_RegExecutionFlag = 0x0EU, /*!< execution flag register */
  350. kSDIO_RegReadyFlag = 0x0FU, /*!< ready flag register */
  351. kSDIO_RegFN0BlockSizeLow = 0x10U, /*!< FN0 block size register */
  352. kSDIO_RegFN0BlockSizeHigh = 0x11U, /*!< FN0 block size register */
  353. kSDIO_RegPowerControl = 0x12U, /*!< power control register */
  354. kSDIO_RegHighSpeed = 0x13U, /*!< high speed register */
  355. };
  356. /*! @brief sdio card individual commands */
  357. typedef enum _sdio_command
  358. {
  359. kSDIO_SendRelativeAddress = 3U, /*!< send relative address */
  360. kSDIO_SendOperationCondition = 5U, /*!< send operation condition */
  361. kSDIO_SendInterfaceCondition = 8U, /*!< send interface condition */
  362. kSDIO_RWIODirect = 52U, /*!< read/write IO direct command */
  363. kSDIO_RWIOExtended = 53U, /*!< read/write IO extended command */
  364. } sdio_command_t;
  365. /*! @brief sdio card individual commands */
  366. typedef enum _sdio_func_num
  367. {
  368. kSDIO_FunctionNum0, /*!< sdio function0*/
  369. kSDIO_FunctionNum1, /*!< sdio function1*/
  370. kSDIO_FunctionNum2, /*!< sdio function2*/
  371. kSDIO_FunctionNum3, /*!< sdio function3*/
  372. kSDIO_FunctionNum4, /*!< sdio function4*/
  373. kSDIO_FunctionNum5, /*!< sdio function5*/
  374. kSDIO_FunctionNum6, /*!< sdio function6*/
  375. kSDIO_FunctionNum7, /*!< sdio function7*/
  376. kSDIO_FunctionMemory, /*!< for combo card*/
  377. } sdio_func_num_t;
  378. #define SDIO_CMD_ARGUMENT_RW_POS (31U) /*!< read/write flag position */
  379. #define SDIO_CMD_ARGUMENT_FUNC_NUM_POS (28U) /*!< function number position */
  380. #define SDIO_DIRECT_CMD_ARGUMENT_RAW_POS (27U) /*!< direct raw flag position */
  381. #define SDIO_CMD_ARGUMENT_REG_ADDR_POS (9U) /*!< direct reg addr position */
  382. #define SDIO_CMD_ARGUMENT_REG_ADDR_MASK (0x1FFFFU) /*!< direct reg addr mask */
  383. #define SDIO_DIRECT_CMD_DATA_MASK (0xFFU) /*!< data mask */
  384. #define SDIO_EXTEND_CMD_ARGUMENT_BLOCK_MODE_POS (27U) /*!< extended command argument block mode bit position */
  385. #define SDIO_EXTEND_CMD_ARGUMENT_OP_CODE_POS (26U) /*!< extended command argument OP Code bit position */
  386. #define SDIO_EXTEND_CMD_BLOCK_MODE_MASK (0x08000000U) /*!< block mode mask */
  387. #define SDIO_EXTEND_CMD_OP_CODE_MASK (0x04000000U) /*!< op code mask */
  388. #define SDIO_EXTEND_CMD_COUNT_MASK (0x1FFU) /*!< byte/block count mask */
  389. #define SDIO_MAX_BLOCK_SIZE (2048U) /*!< max block size */
  390. #define SDIO_FBR_BASE(x) (x * 0x100U) /*!< function basic register */
  391. #define SDIO_TPL_CODE_END (0xFFU) /*!< tuple end */
  392. #define SDIO_TPL_CODE_MANIFID (0x20U) /*!< manufacturer ID */
  393. #define SDIO_TPL_CODE_FUNCID (0x21U) /*!< function ID */
  394. #define SDIO_TPL_CODE_FUNCE (0x22U) /*!< function extension tuple*/
  395. /*! @brief sdio command response flag */
  396. enum _sdio_status_flag
  397. {
  398. kSDIO_StatusCmdCRCError = 0x8000U, /*!< the CRC check of the previous cmd fail*/
  399. kSDIO_StatusIllegalCmd = 0x4000U, /*!< cmd illegal for the card state */
  400. kSDIO_StatusR6Error = 0x2000U, /*!< special for R6 error status */
  401. kSDIO_StatusError = 0x0800U, /*!< A general or an unknown error occurred */
  402. kSDIO_StatusFunctionNumError = 0x0200U, /*!< invail function error */
  403. kSDIO_StatusOutofRange = 0x0100U, /*!< cmd argument was out of the allowed range*/
  404. };
  405. /*! @brief sdio operation condition flag */
  406. enum _sdio_ocr_flag
  407. {
  408. kSDIO_OcrPowerUpBusyFlag = (1U << 31U), /*!< Power up busy status */
  409. kSDIO_OcrIONumber = (7U << 28U), /*!< number of IO function */
  410. kSDIO_OcrMemPresent = (1U << 27U), /*!< memory present flag */
  411. kSDIO_OcrVdd20_21Flag = (1U << 8U), /*!< VDD 2.0-2.1 */
  412. kSDIO_OcrVdd21_22Flag = (1U << 9U), /*!< VDD 2.1-2.2 */
  413. kSDIO_OcrVdd22_23Flag = (1U << 10U), /*!< VDD 2.2-2.3 */
  414. kSDIO_OcrVdd23_24Flag = (1U << 11U), /*!< VDD 2.3-2.4 */
  415. kSDIO_OcrVdd24_25Flag = (1U << 12U), /*!< VDD 2.4-2.5 */
  416. kSDIO_OcrVdd25_26Flag = (1U << 13U), /*!< VDD 2.5-2.6 */
  417. kSDIO_OcrVdd26_27Flag = (1U << 14U), /*!< VDD 2.6-2.7 */
  418. kSDIO_OcrVdd27_28Flag = (1U << 15U), /*!< VDD 2.7-2.8 */
  419. kSDIO_OcrVdd28_29Flag = (1U << 16U), /*!< VDD 2.8-2.9 */
  420. kSDIO_OcrVdd29_30Flag = (1U << 17U), /*!< VDD 2.9-3.0 */
  421. kSDIO_OcrVdd30_31Flag = (1U << 18U), /*!< VDD 2.9-3.0 */
  422. kSDIO_OcrVdd31_32Flag = (1U << 19U), /*!< VDD 3.0-3.1 */
  423. kSDIO_OcrVdd32_33Flag = (1U << 20U), /*!< VDD 3.1-3.2 */
  424. kSDIO_OcrVdd33_34Flag = (1U << 21U), /*!< VDD 3.2-3.3 */
  425. kSDIO_OcrVdd34_35Flag = (1U << 22U), /*!< VDD 3.3-3.4 */
  426. kSDIO_OcrVdd35_36Flag = (1U << 23U), /*!< VDD 3.4-3.5 */
  427. };
  428. /*! @brief sdio capability flag */
  429. enum _sdio_capability_flag
  430. {
  431. kSDIO_CCCRSupportDirectCmdDuringDataTrans = (1U << 0U), /*!< support direct cmd during data transfer */
  432. kSDIO_CCCRSupportMultiBlock = (1U << 1U), /*!< support multi block mode */
  433. kSDIO_CCCRSupportReadWait = (1U << 2U), /*!< support read wait */
  434. kSDIO_CCCRSupportSuspendResume = (1U << 3U), /*!< support suspend resume */
  435. kSDIO_CCCRSupportIntDuring4BitDataTrans = (1U << 4U), /*!< support interrupt during 4-bit data transfer */
  436. kSDIO_CCCRSupportLowSpeed1Bit = (1U << 6U), /*!< support low speed 1bit mode */
  437. kSDIO_CCCRSupportLowSpeed4Bit = (1U << 7U), /*!< support low speed 4bit mode */
  438. kSDIO_CCCRSupportMasterPowerControl = (1U << 8U), /*!< support master power control */
  439. kSDIO_CCCRSupportHighSpeed = (1U << 9U), /*!< support high speed */
  440. kSDIO_CCCRSupportContinuousSPIInt = (1U << 10U), /*!< support continuous SPI interrupt */
  441. kSDIO_FBRSupportCSA = (1U << 11U), /*!< function support CSA */
  442. kSDIO_FBRSupportPowerSelection = (1U << 12U), /*!< function support power selection */
  443. };
  444. /*! @brief sdio bus width */
  445. typedef enum _sdio_bus_width
  446. {
  447. kSDIO_DataBus1Bit = 0x00U, /*!< 1bit bus mode */
  448. kSDIO_DataBus4Bit = 0X02U, /*!< 4 bit bus mode*/
  449. } sdio_bus_width_t;
  450. /*! @brief MMC card individual commands */
  451. typedef enum _mmc_command
  452. {
  453. kMMC_SendOperationCondition = 1U, /*!< Send Operation Condition */
  454. kMMC_SetRelativeAddress = 3U, /*!< Set Relative Address */
  455. kMMC_SleepAwake = 5U, /*!< Sleep Awake */
  456. kMMC_Switch = 6U, /*!< Switch */
  457. kMMC_SendExtendedCsd = 8U, /*!< Send EXT_CSD */
  458. kMMC_ReadDataUntilStop = 11U, /*!< Read Data Until Stop */
  459. kMMC_BusTestRead = 14U, /*!< Test Read */
  460. kMMC_SendingBusTest = 19U, /*!< test bus width cmd*/
  461. kMMC_WriteDataUntilStop = 20U, /*!< Write Data Until Stop */
  462. kMMC_SendTuningBlock = 21U, /*!< MMC sending tuning block */
  463. kMMC_ProgramCid = 26U, /*!< Program CID */
  464. kMMC_EraseGroupStart = 35U, /*!< Erase Group Start */
  465. kMMC_EraseGroupEnd = 36U, /*!< Erase Group End */
  466. kMMC_FastInputOutput = 39U, /*!< Fast IO */
  467. kMMC_GoInterruptState = 40U, /*!< Go interrupt State */
  468. } mmc_command_t;
  469. /*! @brief MMC card classified as voltage range */
  470. typedef enum _mmc_classified_voltage
  471. {
  472. kMMC_ClassifiedVoltageHigh = 0U, /*!< High-voltage MMC card */
  473. kMMC_ClassifiedVoltageDual = 1U, /*!< Dual-voltage MMC card */
  474. } mmc_classified_voltage_t;
  475. /*! @brief MMC card classified as density level */
  476. typedef enum _mmc_classified_density
  477. {
  478. kMMC_ClassifiedDensityWithin2GB = 0U, /*!< Density byte is less than or equal 2GB */
  479. kMMC_ClassifiedDensityHigher2GB = 1U, /* Density byte is higher than 2GB */
  480. } mmc_classified_density_t;
  481. /*! @brief The bit mask for VOLTAGE WINDOW 1.70V to 1.95V field in OCR */
  482. #define MMC_OCR_V170TO195_SHIFT (7U)
  483. /*! @brief The bit mask for VOLTAGE WINDOW 1.70V to 1.95V field in OCR */
  484. #define MMC_OCR_V170TO195_MASK (0x00000080U)
  485. /*! @brief The bit shift for VOLTAGE WINDOW 2.00V to 2.60V field in OCR */
  486. #define MMC_OCR_V200TO260_SHIFT (8U)
  487. /*! @brief The bit mask for VOLTAGE WINDOW 2.00V to 2.60V field in OCR */
  488. #define MMC_OCR_V200TO260_MASK (0x00007F00U)
  489. /*! @brief The bit shift for VOLTAGE WINDOW 2.70V to 3.60V field in OCR */
  490. #define MMC_OCR_V270TO360_SHIFT (15U)
  491. /*! @brief The bit mask for VOLTAGE WINDOW 2.70V to 3.60V field in OCR */
  492. #define MMC_OCR_V270TO360_MASK (0x00FF8000U)
  493. /*! @brief The bit shift for ACCESS MODE field in OCR */
  494. #define MMC_OCR_ACCESS_MODE_SHIFT (29U)
  495. /*! @brief The bit mask for ACCESS MODE field in OCR */
  496. #define MMC_OCR_ACCESS_MODE_MASK (0x60000000U)
  497. /*! @brief The bit shift for BUSY field in OCR */
  498. #define MMC_OCR_BUSY_SHIFT (31U)
  499. /*! @brief The bit mask for BUSY field in OCR */
  500. #define MMC_OCR_BUSY_MASK (1U << MMC_OCR_BUSY_SHIFT)
  501. /*! @brief MMC card access mode(Access mode in OCR). */
  502. typedef enum _mmc_access_mode
  503. {
  504. kMMC_AccessModeByte = 0U, /*!< The card should be accessed as byte */
  505. kMMC_AccessModeSector = 2U, /*!< The card should be accessed as sector */
  506. } mmc_access_mode_t;
  507. /*! @brief MMC card voltage window(VDD voltage window in OCR). */
  508. typedef enum _mmc_voltage_window
  509. {
  510. kMMC_VoltageWindowNone = 0U, /*!< voltage window is not define by user*/
  511. kMMC_VoltageWindow120 = 0x01U, /*!< Voltage window is 1.20V */
  512. kMMC_VoltageWindow170to195 = 0x02U, /*!< Voltage window is 1.70V to 1.95V */
  513. kMMC_VoltageWindows270to360 = 0x1FFU, /*!< Voltage window is 2.70V to 3.60V */
  514. } mmc_voltage_window_t;
  515. /*! @brief CSD structure version(CSD_STRUCTURE in CSD). */
  516. typedef enum _mmc_csd_structure_version
  517. {
  518. kMMC_CsdStrucureVersion10 = 0U, /*!< CSD version No. 1.0 */
  519. kMMC_CsdStrucureVersion11 = 1U, /*!< CSD version No. 1.1 */
  520. kMMC_CsdStrucureVersion12 = 2U, /*!< CSD version No. 1.2 */
  521. kMMC_CsdStrucureVersionInExtcsd = 3U, /*!< Version coded in Extended CSD */
  522. } mmc_csd_structure_version_t;
  523. /*! @brief MMC card specification version(SPEC_VERS in CSD). */
  524. typedef enum _mmc_specification_version
  525. {
  526. kMMC_SpecificationVersion0 = 0U, /*!< Allocated by MMCA */
  527. kMMC_SpecificationVersion1 = 1U, /*!< Allocated by MMCA */
  528. kMMC_SpecificationVersion2 = 2U, /*!< Allocated by MMCA */
  529. kMMC_SpecificationVersion3 = 3U, /*!< Allocated by MMCA */
  530. kMMC_SpecificationVersion4 = 4U, /*!< Version 4.1/4.2/4.3/4.41-4.5-4.51-5.0 */
  531. } mmc_specification_version_t;
  532. /*! @brief The bit shift for FREQUENCY UNIT field in TRANSFER SPEED(TRAN-SPEED in Extended CSD) */
  533. #define MMC_TRANSFER_SPEED_FREQUENCY_UNIT_SHIFT (0U)
  534. /*! @brief The bit mask for FRQEUENCY UNIT in TRANSFER SPEED */
  535. #define MMC_TRANSFER_SPEED_FREQUENCY_UNIT_MASK (0x07U)
  536. /*! @brief The bit shift for MULTIPLIER field in TRANSFER SPEED */
  537. #define MMC_TRANSFER_SPEED_MULTIPLIER_SHIFT (3U)
  538. /*! @brief The bit mask for MULTIPLIER field in TRANSFER SPEED */
  539. #define MMC_TRANSFER_SPEED_MULTIPLIER_MASK (0x78U)
  540. /*! @brief Read the value of FREQUENCY UNIT in TRANSFER SPEED. */
  541. #define READ_MMC_TRANSFER_SPEED_FREQUENCY_UNIT(CSD) \
  542. (((CSD.transferSpeed) & MMC_TRANSFER_SPEED_FREQUENCY_UNIT_MASK) >> MMC_TRANSFER_SPEED_FREQUENCY_UNIT_SHIFT)
  543. /*! @brief Read the value of MULTIPLER filed in TRANSFER SPEED. */
  544. #define READ_MMC_TRANSFER_SPEED_MULTIPLIER(CSD) \
  545. (((CSD.transferSpeed) & MMC_TRANSFER_SPEED_MULTIPLIER_MASK) >> MMC_TRANSFER_SPEED_MULTIPLIER_SHIFT)
  546. /*! @brief MMC card Extended CSD fix version(EXT_CSD_REV in Extended CSD) */
  547. typedef enum _mmc_extended_csd_revision
  548. {
  549. kMMC_ExtendedCsdRevision10 = 0U, /*!< Revision 1.0 */
  550. kMMC_ExtendedCsdRevision11 = 1U, /*!< Revision 1.1 */
  551. kMMC_ExtendedCsdRevision12 = 2U, /*!< Revision 1.2 */
  552. kMMC_ExtendedCsdRevision13 = 3U, /*!< Revision 1.3 MMC4.3*/
  553. kMMC_ExtendedCsdRevision14 = 4U, /*!< Revision 1.4 obsolete*/
  554. kMMC_ExtendedCsdRevision15 = 5U, /*!< Revision 1.5 MMC4.41*/
  555. kMMC_ExtendedCsdRevision16 = 6U, /*!< Revision 1.6 MMC4.5*/
  556. kMMC_ExtendedCsdRevision17 = 7U, /*!< Revision 1.7 MMC5.0 */
  557. } mmc_extended_csd_revision_t;
  558. /*! @brief MMC card command set(COMMAND_SET in Extended CSD) */
  559. typedef enum _mmc_command_set
  560. {
  561. kMMC_CommandSetStandard = 0U, /*!< Standard MMC */
  562. kMMC_CommandSet1 = 1U, /*!< Command set 1 */
  563. kMMC_CommandSet2 = 2U, /*!< Command set 2 */
  564. kMMC_CommandSet3 = 3U, /*!< Command set 3 */
  565. kMMC_CommandSet4 = 4U, /*!< Command set 4 */
  566. } mmc_command_set_t;
  567. /*! @brief boot support(BOOT_INFO in Extended CSD) */
  568. enum _mmc_support_boot_mode
  569. {
  570. kMMC_SupportAlternateBoot = 1U, /*!< support alternative boot mode*/
  571. kMMC_SupportDDRBoot = 2U, /*!< support DDR boot mode*/
  572. kMMC_SupportHighSpeedBoot = 4U, /*!< support high speed boot mode*/
  573. };
  574. /*! @brief The power class value bit mask when bus in 4 bit mode */
  575. #define MMC_POWER_CLASS_4BIT_MASK (0x0FU)
  576. /*! @brief The power class current value bit mask when bus in 8 bit mode */
  577. #define MMC_POWER_CLASS_8BIT_MASK (0xF0U)
  578. /*! @brief MMC card high-speed timing(HS_TIMING in Extended CSD) */
  579. typedef enum _mmc_high_speed_timing
  580. {
  581. kMMC_HighSpeedTimingNone = 0U, /*!< MMC card using none high-speed timing */
  582. kMMC_HighSpeedTiming = 1U, /*!< MMC card using high-speed timing */
  583. kMMC_HighSpeed200Timing = 2U, /*!< MMC card high speed 200 timing*/
  584. kMMC_HighSpeed400Timing = 3U, /*!< MMC card high speed 400 timing*/
  585. kMMC_HighSpeed26MHZTiming = 4U, /*!< MMC high speed 26MHZ timing */
  586. kMMC_HighSpeed52MHZTiming = 5U, /*!< MMC high speed 52MHZ timing */
  587. kMMC_HighSpeedDDR52180V300VTiming = 6U, /*!< MMC high speed timing DDR52 1.8V */
  588. kMMC_HighSpeedDDR52120VTiming = 7U, /*!< MMC high speed timing DDR52 1.2V */
  589. } mmc_high_speed_timing_t;
  590. /*! @brief The number of data bus width type */
  591. #define MMC_DATA_BUS_WIDTH_TYPE_NUMBER (3U)
  592. /*! @brief MMC card data bus width(BUS_WIDTH in Extended CSD) */
  593. typedef enum _mmc_data_bus_width
  594. {
  595. kMMC_DataBusWidth1bit = 0U, /*!< MMC data bus width is 1 bit */
  596. kMMC_DataBusWidth4bit = 1U, /*!< MMC data bus width is 4 bits */
  597. kMMC_DataBusWidth8bit = 2U, /*!< MMC data bus width is 8 bits */
  598. kMMC_DataBusWidth4bitDDR = 5U, /*!< MMC data bus width is 4 bits ddr */
  599. kMMC_DataBusWidth8bitDDR = 6U, /*!< MMC data bus width is 8 bits ddr */
  600. } mmc_data_bus_width_t;
  601. /*! @brief MMC card boot partition enabled(BOOT_PARTITION_ENABLE in Extended CSD) */
  602. typedef enum _mmc_boot_partition_enable
  603. {
  604. kMMC_BootPartitionEnableNot = 0U, /*!< Device not boot enabled (default) */
  605. kMMC_BootPartitionEnablePartition1 = 1U, /*!< Boot partition 1 enabled for boot */
  606. kMMC_BootPartitionEnablePartition2 = 2U, /*!< Boot partition 2 enabled for boot */
  607. kMMC_BootPartitionEnableUserAera = 7U, /*!< User area enabled for boot */
  608. } mmc_boot_partition_enable_t;
  609. /*! @brief MMC card partition to be accessed(BOOT_PARTITION_ACCESS in Extended CSD) */
  610. typedef enum _mmc_access_partition
  611. {
  612. kMMC_AccessPartitionUserAera = 0U, /*!< No access to boot partition (default), normal partition */
  613. kMMC_AccessPartitionBoot1 = 1U, /*!< Read/Write boot partition 1 */
  614. kMMC_AccessPartitionBoot2 = 2U, /*!< Read/Write boot partition 2*/
  615. kMMC_AccessRPMB = 3U, /*!< Replay protected mem block */
  616. kMMC_AccessGeneralPurposePartition1 = 4U, /*!< access to general purpose partition 1 */
  617. kMMC_AccessGeneralPurposePartition2 = 5U, /*!< access to general purpose partition 2 */
  618. kMMC_AccessGeneralPurposePartition3 = 6U, /*!< access to general purpose partition 3 */
  619. kMMC_AccessGeneralPurposePartition4 = 7U, /*!< access to general purpose partition 4 */
  620. } mmc_access_partition_t;
  621. /*! @brief The bit shift for PARTITION ACCESS filed in BOOT CONFIG (BOOT_CONFIG in Extend CSD) */
  622. #define MMC_BOOT_CONFIG_PARTITION_ACCESS_SHIFT (0U)
  623. /*! @brief The bit mask for PARTITION ACCESS field in BOOT CONFIG */
  624. #define MMC_BOOT_CONFIG_PARTITION_ACCESS_MASK (0x00000007U)
  625. /*! @brief The bit shift for PARTITION ENABLE field in BOOT CONFIG */
  626. #define MMC_BOOT_CONFIG_PARTITION_ENABLE_SHIFT (3U)
  627. /*! @brief The bit mask for PARTITION ENABLE field in BOOT CONFIG */
  628. #define MMC_BOOT_CONFIG_PARTITION_ENABLE_MASK (0x00000038U)
  629. /*! @brief The bit shift for ACK field in BOOT CONFIG */
  630. #define MMC_BOOT_CONFIG_ACK_SHIFT (6U)
  631. /*! @brief The bit mask for ACK field in BOOT CONFIG */
  632. #define MMC_BOOT_CONFIG_ACK_MASK (0x00000040U)
  633. /*! @brief The bit shift for BOOT BUS WIDTH field in BOOT CONFIG */
  634. #define MMC_BOOT_BUS_WIDTH_WIDTH_SHIFT (8U)
  635. /*! @brief The bit mask for BOOT BUS WIDTH field in BOOT CONFIG */
  636. #define MMC_BOOT_BUS_WIDTH_WIDTH_MASK (0x00000300U)
  637. /*! @brief The bit shift for BOOT BUS WIDTH RESET field in BOOT CONFIG */
  638. #define MMC_BOOT_BUS_WIDTH_RESET_SHIFT (10U)
  639. /*! @brief The bit mask for BOOT BUS WIDTH RESET field in BOOT CONFIG */
  640. #define MMC_BOOT_BUS_WIDTH_RESET_MASK (0x00000400U)
  641. /*! @brief MMC card CSD register flags */
  642. enum _mmc_csd_flag
  643. {
  644. kMMC_CsdReadBlockPartialFlag = (1U << 0U), /*!< Partial blocks for read allowed */
  645. kMMC_CsdWriteBlockMisalignFlag = (1U << 1U), /*!< Write block misalignment */
  646. kMMC_CsdReadBlockMisalignFlag = (1U << 2U), /*!< Read block misalignment */
  647. kMMC_CsdDsrImplementedFlag = (1U << 3U), /*!< DSR implemented */
  648. kMMC_CsdWriteProtectGroupEnabledFlag = (1U << 4U), /*!< Write protect group enabled */
  649. kMMC_CsdWriteBlockPartialFlag = (1U << 5U), /*!< Partial blocks for write allowed */
  650. kMMC_ContentProtectApplicationFlag = (1U << 6U), /*!< Content protect application */
  651. kMMC_CsdFileFormatGroupFlag = (1U << 7U), /*!< File format group */
  652. kMMC_CsdCopyFlag = (1U << 8U), /*!< Copy flag */
  653. kMMC_CsdPermanentWriteProtectFlag = (1U << 9U), /*!< Permanent write protection */
  654. kMMC_CsdTemporaryWriteProtectFlag = (1U << 10U), /*!< Temporary write protection */
  655. };
  656. /*! @brief Extended CSD register access mode(Access mode in CMD6). */
  657. typedef enum _mmc_extended_csd_access_mode
  658. {
  659. kMMC_ExtendedCsdAccessModeCommandSet = 0U, /*!< Command set related setting */
  660. kMMC_ExtendedCsdAccessModeSetBits = 1U, /*!< Set bits in specific byte in Extended CSD */
  661. kMMC_ExtendedCsdAccessModeClearBits = 2U, /*!< Clear bits in specific byte in Extended CSD */
  662. kMMC_ExtendedCsdAccessModeWriteBits = 3U, /*!< Write a value to specific byte in Extended CSD */
  663. } mmc_extended_csd_access_mode_t;
  664. /*! @brief EXT CSD byte index */
  665. typedef enum _mmc_extended_csd_index
  666. {
  667. kMMC_ExtendedCsdIndexEraseGroupDefinition = 175U, /*!< Erase Group Def */
  668. kMMC_ExtendedCsdIndexBootBusWidth = 177U, /*!< Boot Bus Width */
  669. kMMC_ExtendedCsdIndexBootConfig = 179U, /*!< Boot Config */
  670. kMMC_ExtendedCsdIndexBusWidth = 183U, /*!< Bus Width */
  671. kMMC_ExtendedCsdIndexHighSpeedTiming = 185U, /*!< High-speed Timing */
  672. kMMC_ExtendedCsdIndexPowerClass = 187U, /*!< Power Class */
  673. kMMC_ExtendedCsdIndexCommandSet = 191U, /*!< Command Set */
  674. } mmc_extended_csd_index_t;
  675. /*! @brief mmc driver strength */
  676. enum _mmc_driver_strength
  677. {
  678. kMMC_DriverStrength0 = 0U, /*!< Driver type0 ,nominal impedance 50ohm */
  679. kMMC_DriverStrength1 = 1U, /*!< Driver type1 ,nominal impedance 33ohm */
  680. kMMC_DriverStrength2 = 2U, /*!< Driver type2 ,nominal impedance 66ohm */
  681. kMMC_DriverStrength3 = 3U, /*!< Driver type3 ,nominal impedance 100ohm */
  682. kMMC_DriverStrength4 = 4U, /*!< Driver type4 ,nominal impedance 40ohm */
  683. };
  684. /*! @brief mmc extended csd flags*/
  685. typedef enum _mmc_extended_csd_flags
  686. {
  687. kMMC_ExtCsdExtPartitionSupport = (1 << 0U), /*!< partitioning support[160] */
  688. kMMC_ExtCsdEnhancePartitionSupport = (1 << 1U), /*!< partitioning support[160] */
  689. kMMC_ExtCsdPartitioningSupport = (1 << 2U), /*!< partitioning support[160] */
  690. kMMC_ExtCsdPrgCIDCSDInDDRModeSupport = (1 << 3U), /*!< CMD26 and CMD27 are support dual data rate [130]*/
  691. kMMC_ExtCsdBKOpsSupport = (1 << 4U), /*!< background operation feature support [502]*/
  692. kMMC_ExtCsdDataTagSupport = (1 << 5U), /*!< data tag support[499]*/
  693. kMMC_ExtCsdModeOperationCodeSupport = (1 << 6U), /*!< mode operation code support[493]*/
  694. } mmc_extended_csd_flags_t;
  695. /*! @brief The length of Extended CSD register, unit as bytes. */
  696. #define MMC_EXTENDED_CSD_BYTES (512U)
  697. /*! @brief MMC card default relative address */
  698. #define MMC_DEFAULT_RELATIVE_ADDRESS (2U)
  699. /*! @brief SD card product name length united as bytes. */
  700. #define SD_PRODUCT_NAME_BYTES (5U)
  701. /*! @brief sdio card FBR register */
  702. typedef struct _sdio_fbr
  703. {
  704. uint8_t flags; /*!< current io flags */
  705. uint8_t ioStdFunctionCode; /*!< current io standard function code */
  706. uint8_t ioExtFunctionCode; /*!< current io extended function code*/
  707. uint32_t ioPointerToCIS; /*!< current io pointer to CIS */
  708. uint32_t ioPointerToCSA; /*!< current io pointer to CSA*/
  709. uint16_t ioBlockSize; /*!< current io block size */
  710. } sdio_fbr_t;
  711. /*! @brief sdio card common CIS */
  712. typedef struct _sdio_common_cis
  713. {
  714. /* manufacturer identification string tuple */
  715. uint16_t mID; /*!< manufacturer code */
  716. uint16_t mInfo; /*!< manufacturer information */
  717. /*function identification tuple */
  718. uint8_t funcID; /*!< function ID */
  719. /* function extension tuple */
  720. uint16_t fn0MaxBlkSize; /*!< function 0 max block size */
  721. uint8_t maxTransSpeed; /*!< max data transfer speed for all function */
  722. } sdio_common_cis_t;
  723. /*! @brief sdio card function CIS */
  724. typedef struct _sdio_func_cis
  725. {
  726. /*function identification tuple */
  727. uint8_t funcID; /*!< function ID */
  728. /* function extension tuple */
  729. uint8_t funcInfo; /*!< function info */
  730. uint8_t ioVersion; /*!< level of application specification this io support */
  731. uint32_t cardPSN; /*!< product serial number */
  732. uint32_t ioCSASize; /*!< avaliable CSA size for io */
  733. uint8_t ioCSAProperty; /*!< CSA property */
  734. uint16_t ioMaxBlockSize; /*!< io max transfer data size */
  735. uint32_t ioOCR; /*!< io ioeration condition */
  736. uint8_t ioOPMinPwr; /*!< min current in operation mode */
  737. uint8_t ioOPAvgPwr; /*!< average current in operation mode */
  738. uint8_t ioOPMaxPwr; /*!< max current in operation mode */
  739. uint8_t ioSBMinPwr; /*!< min current in standby mode */
  740. uint8_t ioSBAvgPwr; /*!< average current in standby mode */
  741. uint8_t ioSBMaxPwr; /*!< max current in standby mode */
  742. uint16_t ioMinBandWidth; /*!< io min transfer bandwidth */
  743. uint16_t ioOptimumBandWidth; /*!< io optimum transfer bandwidth */
  744. uint16_t ioReadyTimeout; /*!< timeout value from enalbe to ready */
  745. uint16_t ioHighCurrentAvgCurrent; /*!< the average peak current (mA)
  746. when IO operating in high current mode */
  747. uint16_t ioHighCurrentMaxCurrent; /*!< the max peak current (mA)
  748. when IO operating in high current mode */
  749. uint16_t ioLowCurrentAvgCurrent; /*!< the average peak current (mA)
  750. when IO operating in lower current mode */
  751. uint16_t ioLowCurrentMaxCurrent; /*!< the max peak current (mA)
  752. when IO operating in lower current mode */
  753. } sdio_func_cis_t;
  754. /*! @brief SD card CID register */
  755. typedef struct _sd_cid
  756. {
  757. uint8_t manufacturerID; /*!< Manufacturer ID [127:120] */
  758. uint16_t applicationID; /*!< OEM/Application ID [119:104] */
  759. uint8_t productName[SD_PRODUCT_NAME_BYTES]; /*!< Product name [103:64] */
  760. uint8_t productVersion; /*!< Product revision [63:56] */
  761. uint32_t productSerialNumber; /*!< Product serial number [55:24] */
  762. uint16_t manufacturerData; /*!< Manufacturing date [19:8] */
  763. } sd_cid_t;
  764. /*! @brief SD card CSD register */
  765. typedef struct _sd_csd
  766. {
  767. uint8_t csdStructure; /*!< CSD structure [127:126] */
  768. uint8_t dataReadAccessTime1; /*!< Data read access-time-1 [119:112] */
  769. uint8_t dataReadAccessTime2; /*!< Data read access-time-2 in clock cycles (NSAC*100) [111:104] */
  770. uint8_t transferSpeed; /*!< Maximum data transfer rate [103:96] */
  771. uint16_t cardCommandClass; /*!< Card command classes [95:84] */
  772. uint8_t readBlockLength; /*!< Maximum read data block length [83:80] */
  773. uint16_t flags; /*!< Flags in _sd_csd_flag */
  774. uint32_t deviceSize; /*!< Device size [73:62] */
  775. /* Following fields from 'readCurrentVddMin' to 'deviceSizeMultiplier' exist in CSD version 1 */
  776. uint8_t readCurrentVddMin; /*!< Maximum read current at VDD min [61:59] */
  777. uint8_t readCurrentVddMax; /*!< Maximum read current at VDD max [58:56] */
  778. uint8_t writeCurrentVddMin; /*!< Maximum write current at VDD min [55:53] */
  779. uint8_t writeCurrentVddMax; /*!< Maximum write current at VDD max [52:50] */
  780. uint8_t deviceSizeMultiplier; /*!< Device size multiplier [49:47] */
  781. uint8_t eraseSectorSize; /*!< Erase sector size [45:39] */
  782. uint8_t writeProtectGroupSize; /*!< Write protect group size [38:32] */
  783. uint8_t writeSpeedFactor; /*!< Write speed factor [28:26] */
  784. uint8_t writeBlockLength; /*!< Maximum write data block length [25:22] */
  785. uint8_t fileFormat; /*!< File format [11:10] */
  786. } sd_csd_t;
  787. /*! @brief The bit shift for RATE UNIT field in TRANSFER SPEED */
  788. #define SD_TRANSFER_SPEED_RATE_UNIT_SHIFT (0U)
  789. /*! @brief The bit mask for RATE UNIT field in TRANSFER SPEED */
  790. #define SD_TRANSFER_SPEED_RATE_UNIT_MASK (0x07U)
  791. /*! @brief The bit shift for TIME VALUE field in TRANSFER SPEED */
  792. #define SD_TRANSFER_SPEED_TIME_VALUE_SHIFT (2U)
  793. /*! @brief The bit mask for TIME VALUE field in TRANSFER SPEED */
  794. #define SD_TRANSFER_SPEED_TIME_VALUE_MASK (0x78U)
  795. /*! @brief Read the value of FREQUENCY UNIT in TRANSFER SPEED field */
  796. #define SD_RD_TRANSFER_SPEED_RATE_UNIT(x) \
  797. (((x.transferSpeed) & SD_TRANSFER_SPEED_RATE_UNIT_MASK) >> SD_TRANSFER_SPEED_RATE_UNIT_SHIFT)
  798. /*! @brief Read the value of TIME VALUE in TRANSFER SPEED field */
  799. #define SD_RD_TRANSFER_SPEED_TIME_VALUE(x) \
  800. (((x.transferSpeed) & SD_TRANSFER_SPEED_TIME_VALUE_MASK) >> SD_TRANSFER_SPEED_TIME_VALUE_SHIFT)
  801. /*! @brief SD card SCR register */
  802. typedef struct _sd_scr
  803. {
  804. uint8_t scrStructure; /*!< SCR Structure [63:60] */
  805. uint8_t sdSpecification; /*!< SD memory card specification version [59:56] */
  806. uint16_t flags; /*!< SCR flags in _sd_scr_flag */
  807. uint8_t sdSecurity; /*!< Security specification supported [54:52] */
  808. uint8_t sdBusWidths; /*!< Data bus widths supported [51:48] */
  809. uint8_t extendedSecurity; /*!< Extended security support [46:43] */
  810. uint8_t commandSupport; /*!< Command support bits [33:32] 33-support CMD23, 32-support cmd20*/
  811. uint32_t reservedForManufacturer; /*!< reserved for manufacturer usage [31:0] */
  812. } sd_scr_t;
  813. /*! @brief MMC card product name length united as bytes. */
  814. #define MMC_PRODUCT_NAME_BYTES (6U)
  815. /*! @brief MMC card CID register. */
  816. typedef struct _mmc_cid
  817. {
  818. uint8_t manufacturerID; /*!< Manufacturer ID */
  819. uint16_t applicationID; /*!< OEM/Application ID */
  820. uint8_t productName[MMC_PRODUCT_NAME_BYTES]; /*!< Product name */
  821. uint8_t productVersion; /*!< Product revision */
  822. uint32_t productSerialNumber; /*!< Product serial number */
  823. uint8_t manufacturerData; /*!< Manufacturing date */
  824. } mmc_cid_t;
  825. /*! @brief MMC card CSD register. */
  826. typedef struct _mmc_csd
  827. {
  828. uint8_t csdStructureVersion; /*!< CSD structure [127:126] */
  829. uint8_t systemSpecificationVersion; /*!< System specification version [125:122] */
  830. uint8_t dataReadAccessTime1; /*!< Data read access-time 1 [119:112] */
  831. uint8_t dataReadAccessTime2; /*!< Data read access-time 2 in CLOCK cycles (NSAC*100) [111:104] */
  832. uint8_t transferSpeed; /*!< Max. bus clock frequency [103:96] */
  833. uint16_t cardCommandClass; /*!< card command classes [95:84] */
  834. uint8_t readBlockLength; /*!< Max. read data block length [83:80] */
  835. uint16_t flags; /*!< Contain flags in _mmc_csd_flag */
  836. uint16_t deviceSize; /*!< Device size [73:62] */
  837. uint8_t readCurrentVddMin; /*!< Max. read current @ VDD min [61:59] */
  838. uint8_t readCurrentVddMax; /*!< Max. read current @ VDD max [58:56] */
  839. uint8_t writeCurrentVddMin; /*!< Max. write current @ VDD min [55:53] */
  840. uint8_t writeCurrentVddMax; /*!< Max. write current @ VDD max [52:50] */
  841. uint8_t deviceSizeMultiplier; /*!< Device size multiplier [49:47] */
  842. uint8_t eraseGroupSize; /*!< Erase group size [46:42] */
  843. uint8_t eraseGroupSizeMultiplier; /*!< Erase group size multiplier [41:37] */
  844. uint8_t writeProtectGroupSize; /*!< Write protect group size [36:32] */
  845. uint8_t defaultEcc; /*!< Manufacturer default ECC [30:29] */
  846. uint8_t writeSpeedFactor; /*!< Write speed factor [28:26] */
  847. uint8_t maxWriteBlockLength; /*!< Max. write data block length [25:22] */
  848. uint8_t fileFormat; /*!< File format [11:10] */
  849. uint8_t eccCode; /*!< ECC code [9:8] */
  850. } mmc_csd_t;
  851. /*! @brief MMC card Extended CSD register (unit: byte). */
  852. typedef struct _mmc_extended_csd
  853. {
  854. uint32_t flags;
  855. uint8_t SecureRemoveType; /*!< secure removal type[16]*/
  856. uint8_t enProductStateAware; /*!< product state awareness enablement[17]*/
  857. uint32_t maxPreLoadDataSize; /*!< max preload data size[21-18]*/
  858. uint32_t preLoadDataSize; /*!< pre-load data size[25-22]*/
  859. uint8_t ffuStatus; /*!< FFU status [26]*/
  860. uint8_t modeOperationCode; /*!< mode operation code[29]*/
  861. uint8_t modeConfig; /*!< mode config [30]*/
  862. uint8_t cacheCtrl; /*!< control to turn on/off cache[33]*/
  863. uint8_t pwroffNotify; /*!< power off notification[34]*/
  864. uint8_t packedCmdFailIndex; /*!< packed cmd fail index [35]*/
  865. uint8_t packedCmdStatus; /*!< packed cmd status[36]*/
  866. uint32_t contextConfig[4U]; /*!< context configuration[51-37]*/
  867. uint16_t extPartitionAttr; /*!< extended partitions attribut[53-52]*/
  868. uint16_t exceptEventStatus; /*!< exception events status[55-54]*/
  869. uint16_t exceptEventControl; /*!< exception events control[57-56]*/
  870. uint8_t toReleaseAddressedGroup; /*!< number of group to be released[58]*/
  871. uint8_t class6CmdCtrl; /*!< class 6 command control[59]*/
  872. uint8_t intTimeoutEmu; /*!< 1st initiallization after disabling sector size emu[60]*/
  873. uint8_t sectorSize; /*!< sector size[61] */
  874. uint8_t sectorSizeEmu; /*!< sector size emulation[62]*/
  875. uint8_t nativeSectorSize; /*!< native sector size[63]*/
  876. uint8_t periodWakeup; /*!< period wakeup [131]*/
  877. uint8_t tCASESupport; /*!< package case temperature is controlled[132]*/
  878. uint8_t productionStateAware; /*!< production state awareness[133]*/
  879. uint32_t enhanceUsrDataStartAddr; /*!< enhanced user data start addr [139-136]*/
  880. uint32_t enhanceUsrDataSize; /*!< enhanced user data area size[142-140]*/
  881. uint32_t generalPartitionSize[3]; /*!< general purpose partition size[154-143]*/
  882. uint8_t partitionAttribute; /*!< partition attribute [156]*/
  883. uint32_t maxEnhanceAreaSize; /*!< max enhance area size [159-157]*/
  884. uint8_t hpiManagementEn; /*!< HPI management [161]*/
  885. uint8_t writeReliabilityParameter; /*!< write reliability parameter register[166] */
  886. uint8_t writeReliabilitySet; /*!< write reliability setting register[167] */
  887. uint8_t rpmbSizeMult; /*!< RPMB size multi [168]*/
  888. uint8_t fwConfig; /*!< FW configuration[169]*/
  889. uint8_t userWPRegister; /*!< user write protect register[171] */
  890. uint8_t bootWPRegister; /*!< boot write protect register[173]*/
  891. uint8_t bootWPStatusRegister; /*!< boot write protect status register[174]*/
  892. uint8_t highDensityEraseGroupDefinition; /*!< High-density erase group definition [175] */
  893. uint8_t bootDataBusWidth; /*!< Boot bus width [177] */
  894. uint8_t bootConfigProtect; /*!< Boot config protection [178]*/
  895. uint8_t partitionConfig; /*!< Boot configuration [179] */
  896. uint8_t eraseMemoryContent; /*!< Erased memory content [181] */
  897. uint8_t dataBusWidth; /*!< Data bus width mode [183] */
  898. uint8_t highSpeedTiming; /*!< High-speed interface timing [185] */
  899. uint8_t powerClass; /*!< Power class [187] */
  900. uint8_t commandSetRevision; /*!< Command set revision [189] */
  901. uint8_t commandSet; /*!< Command set [191] */
  902. uint8_t extendecCsdVersion; /*!< Extended CSD revision [192] */
  903. uint8_t csdStructureVersion; /*!< CSD structure version [194] */
  904. uint8_t cardType; /*!< Card Type [196] */
  905. uint8_t ioDriverStrength; /*!< IO driver strength [197] */
  906. uint8_t OutofInterruptBusyTiming; /*!< out of interrupt busy timing [198] */
  907. uint8_t partitionSwitchTiming; /*!< partition switch timing [199] */
  908. uint8_t powerClass52MHz195V; /*!< Power Class for 52MHz @ 1.95V [200] */
  909. uint8_t powerClass26MHz195V; /*!< Power Class for 26MHz @ 1.95V [201] */
  910. uint8_t powerClass52MHz360V; /*!< Power Class for 52MHz @ 3.6V [202] */
  911. uint8_t powerClass26MHz360V; /*!< Power Class for 26MHz @ 3.6V [203] */
  912. uint8_t minimumReadPerformance4Bit26MHz; /*!< Minimum Read Performance for 4bit at 26MHz [205] */
  913. uint8_t minimumWritePerformance4Bit26MHz; /*!< Minimum Write Performance for 4bit at 26MHz [206] */
  914. uint8_t minimumReadPerformance8Bit26MHz4Bit52MHz;
  915. /*!< Minimum read Performance for 8bit at 26MHz/4bit @52MHz [207] */
  916. uint8_t minimumWritePerformance8Bit26MHz4Bit52MHz;
  917. /*!< Minimum Write Performance for 8bit at 26MHz/4bit @52MHz [208] */
  918. uint8_t minimumReadPerformance8Bit52MHz; /*!< Minimum Read Performance for 8bit at 52MHz [209] */
  919. uint8_t minimumWritePerformance8Bit52MHz; /*!< Minimum Write Performance for 8bit at 52MHz [210] */
  920. uint32_t sectorCount; /*!< Sector Count [215:212] */
  921. uint8_t sleepNotificationTimeout; /*!< sleep notification timeout [216]*/
  922. uint8_t sleepAwakeTimeout; /*!< Sleep/awake timeout [217] */
  923. uint8_t productionStateAwareTimeout; /*!< Production state awareness timeout [218]*/
  924. uint8_t sleepCurrentVCCQ; /*!< Sleep current (VCCQ) [219] */
  925. uint8_t sleepCurrentVCC; /*!< Sleep current (VCC) [220] */
  926. uint8_t highCapacityWriteProtectGroupSize; /*!< High-capacity write protect group size [221] */
  927. uint8_t reliableWriteSectorCount; /*!< Reliable write sector count [222] */
  928. uint8_t highCapacityEraseTimeout; /*!< High-capacity erase timeout [223] */
  929. uint8_t highCapacityEraseUnitSize; /*!< High-capacity erase unit size [224] */
  930. uint8_t accessSize; /*!< Access size [225] */
  931. uint8_t bootSizeMultiplier; /*!< Boot partition size [226] */
  932. uint8_t bootInformation; /*!< Boot information [228] */
  933. uint8_t secureTrimMultiplier; /*!< secure trim multiplier[229]*/
  934. uint8_t secureEraseMultiplier; /*!< secure erase multiplier[230]*/
  935. uint8_t secureFeatureSupport; /*!< secure feature support[231]*/
  936. uint32_t trimMultiplier; /*!< trim multiplier[232]*/
  937. uint8_t minReadPerformance8bitAt52MHZDDR; /*!< Minimum read performance for 8bit at DDR 52MHZ[234]*/
  938. uint8_t minWritePerformance8bitAt52MHZDDR; /*!< Minimum write performance for 8bit at DDR 52MHZ[235]*/
  939. uint8_t powerClass200MHZVCCQ130VVCC360V; /*!< power class for 200MHZ, at VCCQ= 1.3V,VCC=3.6V[236]*/
  940. uint8_t powerClass200MHZVCCQ195VVCC360V; /*!< power class for 200MHZ, at VCCQ= 1.95V,VCC=3.6V[237]*/
  941. uint8_t powerClass52MHZDDR195V; /*!< power class for 52MHZ,DDR at Vcc 1.95V[238]*/
  942. uint8_t powerClass52MHZDDR360V; /*!< power class for 52MHZ,DDR at Vcc 3.6V[239]*/
  943. uint8_t iniTimeoutAP; /*!< 1st initialization time after partitioning[241]*/
  944. uint32_t correctPrgSectorNum; /*!< correct prg sectors number[245-242]*/
  945. uint8_t bkOpsStatus; /*!< background operations status[246]*/
  946. uint8_t powerOffNotifyTimeout; /*!< power off notification timeout[247]*/
  947. uint8_t genericCMD6Timeout; /*!< generic CMD6 timeout[248]*/
  948. uint32_t cacheSize; /*!< cache size[252-249]*/
  949. uint8_t powerClass200MHZDDR360V; /*!< power class for 200MHZ, DDR at VCC=2.6V[253]*/
  950. uint32_t fwVer[2U]; /*!< fw VERSION [261-254]*/
  951. uint16_t deviveVer; /*!< device version[263-262]*/
  952. uint8_t optimalTrimSize; /*!< optimal trim size[264]*/
  953. uint8_t optimalWriteSize; /*!< optimal write size[265]*/
  954. uint8_t optimalReadSize; /*!< optimal read size[266]*/
  955. uint8_t preEolInfo; /*!< pre EOL information[267]*/
  956. uint8_t deviceLifeTimeEstimationA; /*!< device life time estimation typeA[268]*/
  957. uint8_t deviceLifeTimeEstimationB; /*!< device life time estimation typeB[269]*/
  958. uint32_t correctPrgFWSectorNum; /*!< number of FW sectors correctly programmed[305-302]*/
  959. uint32_t ffuArg; /*!< FFU argument[490-487]*/
  960. uint8_t operationCodeTimeout; /*!< operation code timeout[491]*/
  961. uint8_t supportMode; /*!< support mode [493]*/
  962. uint8_t extPartitionSupport; /*!< extended partition attribute support[494]*/
  963. uint8_t largeUnitSize; /*!< large unit size[495]*/
  964. uint8_t contextManageCap; /*!< context management capability[496]*/
  965. uint8_t tagResourceSize; /*!< tag resource size[497]*/
  966. uint8_t tagUnitSize; /*!< tag unit size[498]*/
  967. uint8_t maxPackedWriteCmd; /*!< max packed write cmd[500]*/
  968. uint8_t maxPackedReadCmd; /*!< max packed read cmd[501]*/
  969. uint8_t hpiFeature; /*!< HPI feature[503]*/
  970. uint8_t supportedCommandSet; /*!< Supported Command Sets [504] */
  971. uint8_t extSecurityCmdError; /*!< extended security commands error[505]*/
  972. } mmc_extended_csd_t;
  973. /*! @brief The bit shift for COMMAND SET field in SWITCH command. */
  974. #define MMC_SWITCH_COMMAND_SET_SHIFT (0U)
  975. /*! @brief The bit mask for COMMAND set field in SWITCH command. */
  976. #define MMC_SWITCH_COMMAND_SET_MASK (0x00000007U)
  977. /*! @brief The bit shift for VALUE field in SWITCH command */
  978. #define MMC_SWITCH_VALUE_SHIFT (8U)
  979. /*! @brief The bit mask for VALUE field in SWITCH command */
  980. #define MMC_SWITCH_VALUE_MASK (0x0000FF00U)
  981. /*! @brief The bit shift for BYTE INDEX field in SWITCH command */
  982. #define MMC_SWITCH_BYTE_INDEX_SHIFT (16U)
  983. /*! @brief The bit mask for BYTE INDEX field in SWITCH command */
  984. #define MMC_SWITCH_BYTE_INDEX_MASK (0x00FF0000U)
  985. /*! @brief The bit shift for ACCESS MODE field in SWITCH command */
  986. #define MMC_SWITCH_ACCESS_MODE_SHIFT (24U)
  987. /*! @brief The bit mask for ACCESS MODE field in SWITCH command */
  988. #define MMC_SWTICH_ACCESS_MODE_MASK (0x03000000U)
  989. /*! @brief MMC Extended CSD configuration. */
  990. typedef struct _mmc_extended_csd_config
  991. {
  992. mmc_command_set_t commandSet; /*!< Command set */
  993. uint8_t ByteValue; /*!< The value to set */
  994. uint8_t ByteIndex; /*!< The byte index in Extended CSD(mmc_extended_csd_index_t) */
  995. mmc_extended_csd_access_mode_t accessMode; /*!< Access mode */
  996. } mmc_extended_csd_config_t;
  997. #endif /* _FSL_SPECIFICATION_H_ */