fsl_ftfx_adapter.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /*
  2. * The Clear BSD License
  3. * Copyright 2017-2018 NXP
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted (subject to the limitations in the
  8. * disclaimer below) provided that the following conditions are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * * Neither the name of the copyright holder nor the names of its
  18. * contributors may be used to endorse or promote products derived from
  19. * this software without specific prior written permission.
  20. *
  21. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  22. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  23. * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  24. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  25. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  30. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  32. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  33. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. */
  36. #ifndef _FSL_FTFX_ADAPTER_H_
  37. #define _FSL_FTFX_ADAPTER_H_
  38. /*******************************************************************************
  39. * Definitions
  40. ******************************************************************************/
  41. #define INVALID_REG_MASK (0)
  42. #define INVALID_REG_SHIFT (0)
  43. #define INVALID_REG_ADDRESS (0x00U)
  44. #define INVALID_REG_VALUE (0x00U)
  45. /* @brief Flash register access type defines */
  46. #define FTFx_REG8_ACCESS_TYPE volatile uint8_t *
  47. #define FTFx_REG32_ACCESS_TYPE volatile uint32_t *
  48. /*!
  49. * @name Common flash register info defines
  50. * @{
  51. */
  52. #if defined(FTFA)
  53. #define FTFx FTFA
  54. #define FTFx_BASE FTFA_BASE
  55. #define FTFx_FSTAT_CCIF_MASK FTFA_FSTAT_CCIF_MASK
  56. #define FTFx_FSTAT_RDCOLERR_MASK FTFA_FSTAT_RDCOLERR_MASK
  57. #define FTFx_FSTAT_ACCERR_MASK FTFA_FSTAT_ACCERR_MASK
  58. #define FTFx_FSTAT_FPVIOL_MASK FTFA_FSTAT_FPVIOL_MASK
  59. #define FTFx_FSTAT_MGSTAT0_MASK FTFA_FSTAT_MGSTAT0_MASK
  60. #define FTFx_FSEC_SEC_MASK FTFA_FSEC_SEC_MASK
  61. #define FTFx_FSEC_KEYEN_MASK FTFA_FSEC_KEYEN_MASK
  62. #if defined(FSL_FEATURE_FLASH_HAS_FLEX_RAM) && FSL_FEATURE_FLASH_HAS_FLEX_RAM
  63. #define FTFx_FCNFG_RAMRDY_MASK FTFA_FCNFG_RAMRDY_MASK
  64. #endif /* FSL_FEATURE_FLASH_HAS_FLEX_RAM */
  65. #if defined(FSL_FEATURE_FLASH_HAS_FLEX_NVM) && FSL_FEATURE_FLASH_HAS_FLEX_NVM
  66. #define FTFx_FCNFG_EEERDY_MASK FTFA_FCNFG_EEERDY_MASK
  67. #endif /* FSL_FEATURE_FLASH_HAS_FLEX_NVM */
  68. #elif defined(FTFE)
  69. #define FTFx FTFE
  70. #define FTFx_BASE FTFE_BASE
  71. #define FTFx_FSTAT_CCIF_MASK FTFE_FSTAT_CCIF_MASK
  72. #define FTFx_FSTAT_RDCOLERR_MASK FTFE_FSTAT_RDCOLERR_MASK
  73. #define FTFx_FSTAT_ACCERR_MASK FTFE_FSTAT_ACCERR_MASK
  74. #define FTFx_FSTAT_FPVIOL_MASK FTFE_FSTAT_FPVIOL_MASK
  75. #define FTFx_FSTAT_MGSTAT0_MASK FTFE_FSTAT_MGSTAT0_MASK
  76. #define FTFx_FSEC_SEC_MASK FTFE_FSEC_SEC_MASK
  77. #define FTFx_FSEC_KEYEN_MASK FTFE_FSEC_KEYEN_MASK
  78. #if defined(FSL_FEATURE_FLASH_HAS_FLEX_RAM) && FSL_FEATURE_FLASH_HAS_FLEX_RAM
  79. #define FTFx_FCNFG_RAMRDY_MASK FTFE_FCNFG_RAMRDY_MASK
  80. #endif /* FSL_FEATURE_FLASH_HAS_FLEX_RAM */
  81. #if defined(FSL_FEATURE_FLASH_HAS_FLEX_NVM) && FSL_FEATURE_FLASH_HAS_FLEX_NVM
  82. #define FTFx_FCNFG_EEERDY_MASK FTFE_FCNFG_EEERDY_MASK
  83. #endif /* FSL_FEATURE_FLASH_HAS_FLEX_NVM */
  84. #elif defined(FTFL)
  85. #define FTFx FTFL
  86. #define FTFx_BASE FTFL_BASE
  87. #define FTFx_FSTAT_CCIF_MASK FTFL_FSTAT_CCIF_MASK
  88. #define FTFx_FSTAT_RDCOLERR_MASK FTFL_FSTAT_RDCOLERR_MASK
  89. #define FTFx_FSTAT_ACCERR_MASK FTFL_FSTAT_ACCERR_MASK
  90. #define FTFx_FSTAT_FPVIOL_MASK FTFL_FSTAT_FPVIOL_MASK
  91. #define FTFx_FSTAT_MGSTAT0_MASK FTFL_FSTAT_MGSTAT0_MASK
  92. #define FTFx_FSEC_SEC_MASK FTFL_FSEC_SEC_MASK
  93. #define FTFx_FSEC_KEYEN_MASK FTFL_FSEC_KEYEN_MASK
  94. #if defined(FSL_FEATURE_FLASH_HAS_FLEX_RAM) && FSL_FEATURE_FLASH_HAS_FLEX_RAM
  95. #define FTFx_FCNFG_RAMRDY_MASK FTFL_FCNFG_RAMRDY_MASK
  96. #endif /* FSL_FEATURE_FLASH_HAS_FLEX_RAM */
  97. #if defined(FSL_FEATURE_FLASH_HAS_FLEX_NVM) && FSL_FEATURE_FLASH_HAS_FLEX_NVM
  98. #define FTFx_FCNFG_EEERDY_MASK FTFL_FCNFG_EEERDY_MASK
  99. #endif /* FSL_FEATURE_FLASH_HAS_FLEX_NVM */
  100. #else
  101. #error "Unknown flash controller"
  102. #endif
  103. /*@}*/
  104. /*!
  105. * @name Common flash register access info defines
  106. * @{
  107. */
  108. #define FTFx_FCCOB3_REG (FTFx->FCCOB3)
  109. #define FTFx_FCCOB5_REG (FTFx->FCCOB5)
  110. #define FTFx_FCCOB6_REG (FTFx->FCCOB6)
  111. #define FTFx_FCCOB7_REG (FTFx->FCCOB7)
  112. #if defined(FTFA_FPROTSL_PROTS_MASK) || defined(FTFE_FPROTSL_PROTS_MASK) || defined(FTFL_FPROTSL_PROTS_MASK)
  113. #define FTFx_FLASH1_HAS_INT_PROT_REG (1)
  114. #define FTFx_FPROTSH_REG (FTFx->FPROTSH)
  115. #define FTFx_FPROTSL_REG (FTFx->FPROTSL)
  116. #else
  117. #define FTFx_FLASH1_HAS_INT_PROT_REG (0)
  118. #define FTFx_FPROTSH_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  119. #define FTFx_FPROTSL_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  120. #endif
  121. #if defined(FTFA_FPROTH0_PROT_MASK) || defined(FTFE_FPROTH0_PROT_MASK) || defined(FTFL_FPROTH0_PROT_MASK)
  122. #define FTFx_FPROT_HIGH_REG (FTFx->FPROTH3)
  123. #define FTFx_FPROTH3_REG (FTFx->FPROTH3)
  124. #define FTFx_FPROTH2_REG (FTFx->FPROTH2)
  125. #define FTFx_FPROTH1_REG (FTFx->FPROTH1)
  126. #define FTFx_FPROTH0_REG (FTFx->FPROTH0)
  127. #else
  128. #define FTFx_FPROT_HIGH_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  129. #define FTFx_FPROTH3_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  130. #define FTFx_FPROTH2_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  131. #define FTFx_FPROTH1_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  132. #define FTFx_FPROTH0_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  133. #endif
  134. #if defined(FTFA_FPROTL0_PROT_MASK) || defined(FTFE_FPROTL0_PROT_MASK) || defined(FTFL_FPROTL0_PROT_MASK)
  135. #define FTFx_FPROT_LOW_REG (FTFx->FPROTL3)
  136. #define FTFx_FPROTL3_REG (FTFx->FPROTL3)
  137. #define FTFx_FPROTL2_REG (FTFx->FPROTL2)
  138. #define FTFx_FPROTL1_REG (FTFx->FPROTL1)
  139. #define FTFx_FPROTL0_REG (FTFx->FPROTL0)
  140. #elif defined(FTFA_FPROT0_PROT_MASK) || defined(FTFE_FPROT0_PROT_MASK) || defined(FTFL_FPROT0_PROT_MASK)
  141. #define FTFx_FPROT_LOW_REG (FTFx->FPROT3)
  142. #define FTFx_FPROTL3_REG (FTFx->FPROT3)
  143. #define FTFx_FPROTL2_REG (FTFx->FPROT2)
  144. #define FTFx_FPROTL1_REG (FTFx->FPROT1)
  145. #define FTFx_FPROTL0_REG (FTFx->FPROT0)
  146. #else
  147. #define FTFx_FPROT_LOW_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  148. #define FTFx_FPROTL3_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  149. #define FTFx_FPROTL2_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  150. #define FTFx_FPROTL1_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  151. #define FTFx_FPROTL0_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  152. #endif
  153. #if defined(FTFA_FACSSS_SGSIZE_S_MASK) || defined(FTFE_FACSSS_SGSIZE_S_MASK) || defined(FTFL_FACSSS_SGSIZE_S_MASK)
  154. #define FTFx_FLASH1_HAS_INT_XACC_REG (1)
  155. #define FTFx_XACCSH_REG (FTFx->XACCSH)
  156. #define FTFx_XACCSL_REG (FTFx->XACCSL)
  157. #define FTFx_FACSSS_REG (FTFx->FACSSS)
  158. #define FTFx_FACSNS_REG (FTFx->FACSNS)
  159. #else
  160. #define FTFx_FLASH1_HAS_INT_XACC_REG (0)
  161. #define FTFx_XACCSH_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  162. #define FTFx_XACCSL_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  163. #define FTFx_FACSSS_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  164. #define FTFx_FACSNS_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  165. #endif
  166. #if (defined(FTFA_FACSS_SGSIZE_MASK) || defined(FTFE_FACSS_SGSIZE_MASK) || defined(FTFL_FACSS_SGSIZE_MASK) || \
  167. defined(FTFA_FACSS_SGSIZE_S_MASK) || defined(FTFE_FACSS_SGSIZE_S_MASK) || defined(FTFL_FACSS_SGSIZE_S_MASK))
  168. //#define FTFx_FLASH0_HAS_INT_XACC_REG (FTFx_FLASH1_HAS_INT_XACC_REG)
  169. #define FTFx_XACCH3_REG (FTFx->XACCH3)
  170. #define FTFx_XACCL3_REG (FTFx->XACCL3)
  171. #define FTFx_FACSS_REG (FTFx->FACSS)
  172. #define FTFx_FACSN_REG (FTFx->FACSN)
  173. #else
  174. #define FTFx_FLASH0_HAS_INT_XACC_REG (0)
  175. #define FTFx_XACCH3_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  176. #define FTFx_XACCL3_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  177. #define FTFx_FACSS_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  178. #define FTFx_FACSN_REG (*(uint8_t *)INVALID_REG_ADDRESS)
  179. #endif
  180. /*@}*/
  181. /*!
  182. * @brief MCM cache register access info defines.
  183. */
  184. #if defined(MCM_PLACR_CFCC_MASK)
  185. #define MCM_CACHE_CLEAR_MASK MCM_PLACR_CFCC_MASK
  186. #define MCM_CACHE_CLEAR_SHIFT MCM_PLACR_CFCC_SHIFT
  187. #if defined(MCM0)
  188. #define MCM0_CACHE_REG MCM0->PLACR
  189. #elif defined(MCM) && (!defined(MCM1))
  190. #define MCM0_CACHE_REG MCM->PLACR
  191. #endif
  192. #if defined(MCM1)
  193. #define MCM1_CACHE_REG MCM1->PLACR
  194. #elif defined(MCM) && (!defined(MCM0))
  195. #define MCM1_CACHE_REG MCM->PLACR
  196. #endif
  197. #else
  198. #define MCM_CACHE_CLEAR_MASK INVALID_REG_MASK
  199. #define MCM_CACHE_CLEAR_SHIFT INVALID_REG_SHIFT
  200. #define MCM0_CACHE_REG (*(uint32_t *)INVALID_REG_ADDRESS)
  201. #define MCM1_CACHE_REG (*(uint32_t *)INVALID_REG_ADDRESS)
  202. #endif
  203. /*!
  204. * @brief FMC cache register access info defines.
  205. */
  206. #if defined(FMC_PFB01CR_S_INV_MASK)
  207. #define FMC_SPECULATION_INVALIDATE_MASK FMC_PFB01CR_S_INV_MASK
  208. #define FMC_SPECULATION_INVALIDATE_SHIFT FMC_PFB01CR_S_INV_SHIFT
  209. #define FMC_SPECULATION_INVALIDATE_REG FMC->PFB01CR
  210. #elif defined(FMC_PFB01CR_S_B_INV_MASK)
  211. #define FMC_SPECULATION_INVALIDATE_MASK FMC_PFB01CR_S_B_INV_MASK
  212. #define FMC_SPECULATION_INVALIDATE_SHIFT FMC_PFB01CR_S_B_INV_SHIFT
  213. #define FMC_SPECULATION_INVALIDATE_REG FMC->PFB01CR
  214. #elif defined(FMC_PFB0CR_S_INV_MASK)
  215. #define FMC_SPECULATION_INVALIDATE_MASK FMC_PFB0CR_S_INV_MASK
  216. #define FMC_SPECULATION_INVALIDATE_SHIFT FMC_PFB0CR_S_INV_SHIFT
  217. #define FMC_SPECULATION_INVALIDATE_REG FMC->PFB0CR
  218. #elif defined(FMC_PFB0CR_S_B_INV_MASK)
  219. #define FMC_SPECULATION_INVALIDATE_MASK FMC_PFB0CR_S_B_INV_MASK
  220. #define FMC_SPECULATION_INVALIDATE_SHIFT FMC_PFB0CR_S_B_INV_SHIFT
  221. #define FMC_SPECULATION_INVALIDATE_REG FMC->PFB0CR
  222. #else
  223. #define FMC_SPECULATION_INVALIDATE_MASK INVALID_REG_MASK
  224. #define FMC_SPECULATION_INVALIDATE_SHIFT INVALID_REG_SHIFT
  225. #define FMC_SPECULATION_INVALIDATE(x) (((uint32_t)(((uint32_t)(x)) << INVALID_REG_SHIFT)) & INVALID_REG_MASK)
  226. #define FMC_SPECULATION_INVALIDATE_REG (*(uint32_t *)INVALID_REG_ADDRESS)
  227. #endif
  228. #if defined(FMC_PFB01CR_CINV_WAY_MASK)
  229. #define FMC_CACHE_CLEAR_MASK FMC_PFB01CR_CINV_WAY_MASK
  230. #define FMC_CACHE_CLEAR_SHIFT FMC_PFB01CR_CINV_WAY_SHIFT
  231. #define FMC_CACHE_CLEAR(x) FMC_PFB01CR_CINV_WAY(x)
  232. #elif defined(FMC_PFB0CR_CINV_WAY_MASK)
  233. #define FMC_CACHE_CLEAR_MASK FMC_PFB0CR_CINV_WAY_MASK
  234. #define FMC_CACHE_CLEAR_SHIFT FMC_PFB0CR_CINV_WAY_SHIFT
  235. #define FMC_CACHE_CLEAR(x) FMC_PFB0CR_CINV_WAY(x)
  236. #else
  237. #define FMC_CACHE_CLEAR_MASK INVALID_REG_MASK
  238. #define FMC_CACHE_CLEAR_SHIFT INVALID_REG_SHIFT
  239. #define FMC_CACHE_CLEAR(x) (((uint32_t)(((uint32_t)(x)) << INVALID_REG_SHIFT)) & INVALID_REG_MASK)
  240. #endif
  241. #if defined(FMC_PFB01CR_B0DPE_MASK)
  242. #define FMC_CACHE_B0DPE_MASK FMC_PFB01CR_B0DPE_MASK
  243. #define FMC_CACHE_B0IPE_MASK FMC_PFB01CR_B0IPE_MASK
  244. #define FMC_CACHE_REG FMC->PFB01CR
  245. #elif defined(FMC_PFB0CR_B0DPE_MASK)
  246. #define FMC_CACHE_B0DPE_MASK FMC_PFB0CR_B0DPE_MASK
  247. #define FMC_CACHE_B0IPE_MASK FMC_PFB0CR_B0IPE_MASK
  248. #define FMC_CACHE_REG FMC->PFB0CR
  249. #else
  250. #define FMC_CACHE_B0DPE_MASK INVALID_REG_MASK
  251. #define FMC_CACHE_B0IPE_MASK INVALID_REG_MASK
  252. #define FMC_CACHE_REG (*(uint32_t *)INVALID_REG_ADDRESS)
  253. #endif
  254. /*!
  255. * @brief MSCM cache register access info defines.
  256. */
  257. #if defined(MSCM_OCMDR_OCM1_MASK)
  258. #define MSCM_SPECULATION_SET_MASK MSCM_OCMDR_OCM1_MASK
  259. #define MSCM_SPECULATION_SET_SHIFT MSCM_OCMDR_OCM1_SHIFT
  260. #define MSCM_SPECULATION_SET(x) MSCM_OCMDR_OCM1(x)
  261. #elif defined(MSCM_OCMDR0_OCM1_MASK) || defined(MSCM_OCMDR1_OCM1_MASK)
  262. #define MSCM_SPECULATION_SET_MASK MSCM_OCMDR0_OCM1_MASK
  263. #define MSCM_SPECULATION_SET_SHIFT MSCM_OCMDR0_OCM1_SHIFT
  264. #define MSCM_SPECULATION_SET(x) MSCM_OCMDR0_OCM1(x)
  265. #elif defined(MSCM_OCMDR_OCMC1_MASK)
  266. #define MSCM_SPECULATION_SET_MASK MSCM_OCMDR_OCMC1_MASK
  267. #define MSCM_SPECULATION_SET_SHIFT MSCM_OCMDR_OCMC1_SHIFT
  268. #define MSCM_SPECULATION_SET(x) MSCM_OCMDR_OCMC1(x)
  269. #else
  270. #define MSCM_SPECULATION_SET_MASK INVALID_REG_MASK
  271. #define MSCM_SPECULATION_SET_SHIFT INVALID_REG_SHIFT
  272. #define MSCM_SPECULATION_SET(x) (((uint32_t)(((uint32_t)(x)) << INVALID_REG_SHIFT)) & INVALID_REG_MASK)
  273. #endif
  274. #if defined(MSCM_OCMDR_OCM2_MASK)
  275. #define MSCM_CACHE_CLEAR_MASK MSCM_OCMDR_OCM2_MASK
  276. #define MSCM_CACHE_CLEAR_SHIFT MSCM_OCMDR_OCM2_SHIFT
  277. #define MSCM_CACHE_CLEAR(x) MSCM_OCMDR_OCM2(x)
  278. #else
  279. #define MSCM_CACHE_CLEAR_MASK INVALID_REG_MASK
  280. #define MSCM_CACHE_CLEAR_SHIFT INVALID_REG_SHIFT
  281. #define MSCM_CACHE_CLEAR(x) (((uint32_t)(((uint32_t)(x)) << INVALID_REG_SHIFT)) & INVALID_REG_MASK)
  282. #endif
  283. #if defined(MSCM_OCMDR_OCM1_MASK) || defined(MSCM_OCMDR_OCMC1_MASK)
  284. #define MSCM_OCMDR0_REG MSCM->OCMDR[0]
  285. #define MSCM_OCMDR1_REG MSCM->OCMDR[1]
  286. #elif defined(MSCM_OCMDR0_OCM1_MASK) || defined(MSCM_OCMDR1_OCM1_MASK)
  287. #define MSCM_OCMDR0_REG MSCM->OCMDR0
  288. #define MSCM_OCMDR1_REG MSCM->OCMDR1
  289. #else
  290. #define MSCM_OCMDR0_REG (*(uint32_t *)INVALID_REG_ADDRESS)
  291. #define MSCM_OCMDR1_REG (*(uint32_t *)INVALID_REG_ADDRESS)
  292. #endif
  293. /*!
  294. * @brief MSCM prefetch speculation defines.
  295. */
  296. #define MSCM_OCMDR_OCMC1_DFDS_MASK (0x10U)
  297. #define MSCM_OCMDR_OCMC1_DFCS_MASK (0x20U)
  298. #define MSCM_OCMDR_OCMC1_DFDS_SHIFT (4U)
  299. #define MSCM_OCMDR_OCMC1_DFCS_SHIFT (5U)
  300. /*!
  301. * @brief SIM PFSIZE register access info defines.
  302. */
  303. #if defined(SIM_FCFG1_CORE0_PFSIZE_MASK)
  304. #define SIM_FLASH0_PFSIZE_MASK SIM_FCFG1_CORE0_PFSIZE_MASK
  305. #define SIM_FLASH0_PFSIZE_SHIFT SIM_FCFG1_CORE0_PFSIZE_SHIFT
  306. #define SIM_FCFG1_REG SIM->FCFG1
  307. #elif defined(SIM_FCFG1_PFSIZE_MASK)
  308. #define SIM_FLASH0_PFSIZE_MASK SIM_FCFG1_PFSIZE_MASK
  309. #define SIM_FLASH0_PFSIZE_SHIFT SIM_FCFG1_PFSIZE_SHIFT
  310. #define SIM_FCFG1_REG SIM->FCFG1
  311. #else
  312. #define SIM_FLASH0_PFSIZE_MASK INVALID_REG_MASK
  313. #define SIM_FLASH0_PFSIZE_SHIFT INVALID_REG_SHIFT
  314. #define SIM_FCFG1_REG INVALID_REG_VALUE
  315. #endif
  316. #if defined(SIM_FCFG1_CORE1_PFSIZE_MASK)
  317. #define SIM_FLASH1_PFSIZE_MASK SIM_FCFG1_CORE1_PFSIZE_MASK
  318. #define SIM_FLASH1_PFSIZE_SHIFT SIM_FCFG1_CORE1_PFSIZE_SHIFT
  319. #else
  320. #define SIM_FLASH1_PFSIZE_MASK INVALID_REG_MASK
  321. #define SIM_FLASH1_PFSIZE_SHIFT INVALID_REG_SHIFT
  322. #endif
  323. /*!
  324. * @name Dual core/flash configuration
  325. * @{
  326. */
  327. /*! @brief Redefines some flash features. */
  328. #if defined(FSL_FEATURE_FLASH_CURRENT_CORE_ID)
  329. #if (FSL_FEATURE_FLASH_CURRENT_CORE_ID == 0u)
  330. #define FLASH0_FEATURE_PFLASH_START_ADDRESS FSL_FEATURE_FLASH_PFLASH_START_ADDRESS
  331. #define FLASH0_FEATURE_PFLASH_BLOCK_COUNT FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT
  332. #define FLASH0_FEATURE_PFLASH_BLOCK_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE
  333. #define FLASH0_FEATURE_PFLASH_BLOCK_SECTOR_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE
  334. #define FLASH0_FEATURE_PFLASH_BLOCK_WRITE_UNIT_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_WRITE_UNIT_SIZE
  335. #define FLASH0_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT
  336. #define FLASH0_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT
  337. #define FLASH0_FEATURE_PFLASH_PROTECTION_REGION_COUNT FSL_FEATURE_FLASH_PFLASH_PROTECTION_REGION_COUNT
  338. #define FLASH1_FEATURE_PFLASH_START_ADDRESS FSL_FEATURE_FLASH_PFLASH_1_START_ADDRESS
  339. #define FLASH1_FEATURE_PFLASH_BLOCK_COUNT FSL_FEATURE_FLASH_PFLASH_1_BLOCK_COUNT
  340. #define FLASH1_FEATURE_PFLASH_BLOCK_SIZE FSL_FEATURE_FLASH_PFLASH_1_BLOCK_SIZE
  341. #define FLASH1_FEATURE_PFLASH_BLOCK_SECTOR_SIZE FSL_FEATURE_FLASH_PFLASH_1_BLOCK_SECTOR_SIZE
  342. #define FLASH1_FEATURE_PFLASH_BLOCK_WRITE_UNIT_SIZE FSL_FEATURE_FLASH_PFLASH_1_BLOCK_WRITE_UNIT_SIZE
  343. #if defined(FSL_FEATURE_FLASH_PFLASH_1_SECTOR_CMD_ADDRESS_ALIGMENT) && defined(FSL_FEATURE_FLASH_PFLASH_1_SECTION_CMD_ADDRESS_ALIGMENT)
  344. #define FLASH1_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_1_SECTOR_CMD_ADDRESS_ALIGMENT
  345. #define FLASH1_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_1_SECTION_CMD_ADDRESS_ALIGMENT
  346. #else
  347. #define FLASH1_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT
  348. #define FLASH1_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT
  349. #endif
  350. #define FLASH1_FEATURE_PFLASH_PROTECTION_REGION_COUNT FSL_FEATURE_FLASH_PFLASH_1_PROTECTION_REGION_COUNT
  351. #elif (FSL_FEATURE_FLASH_CURRENT_CORE_ID == 1u)
  352. #define FLASH0_FEATURE_PFLASH_START_ADDRESS FSL_FEATURE_FLASH_PFLASH_1_START_ADDRESS
  353. #define FLASH0_FEATURE_PFLASH_BLOCK_COUNT FSL_FEATURE_FLASH_PFLASH_1_BLOCK_COUNT
  354. #define FLASH0_FEATURE_PFLASH_BLOCK_SIZE FSL_FEATURE_FLASH_PFLASH_1_BLOCK_SIZE
  355. #define FLASH0_FEATURE_PFLASH_BLOCK_SECTOR_SIZE FSL_FEATURE_FLASH_PFLASH_1_BLOCK_SECTOR_SIZE
  356. #define FLASH0_FEATURE_PFLASH_BLOCK_WRITE_UNIT_SIZE FSL_FEATURE_FLASH_PFLASH_1_BLOCK_WRITE_UNIT_SIZE
  357. #if defined(FSL_FEATURE_FLASH_PFLASH_1_SECTOR_CMD_ADDRESS_ALIGMENT) && defined(FSL_FEATURE_FLASH_PFLASH_1_SECTION_CMD_ADDRESS_ALIGMENT)
  358. #define FLASH0_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_1_SECTOR_CMD_ADDRESS_ALIGMENT
  359. #define FLASH0_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_1_SECTION_CMD_ADDRESS_ALIGMENT
  360. #else
  361. #define FLASH0_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT
  362. #define FLASH0_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT
  363. #endif
  364. #define FLASH0_FEATURE_PFLASH_PROTECTION_REGION_COUNT FSL_FEATURE_FLASH_PFLASH_1_PROTECTION_REGION_COUNT
  365. #define FLASH1_FEATURE_PFLASH_START_ADDRESS FSL_FEATURE_FLASH_PFLASH_START_ADDRESS
  366. #define FLASH1_FEATURE_PFLASH_BLOCK_COUNT FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT
  367. #define FLASH1_FEATURE_PFLASH_BLOCK_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE
  368. #define FLASH1_FEATURE_PFLASH_BLOCK_SECTOR_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE
  369. #define FLASH1_FEATURE_PFLASH_BLOCK_WRITE_UNIT_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_WRITE_UNIT_SIZE
  370. #define FLASH1_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT
  371. #define FLASH1_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT
  372. #define FLASH1_FEATURE_PFLASH_PROTECTION_REGION_COUNT FSL_FEATURE_FLASH_PFLASH_PROTECTION_REGION_COUNT
  373. #endif
  374. #else
  375. #define FLASH0_FEATURE_PFLASH_START_ADDRESS FSL_FEATURE_FLASH_PFLASH_START_ADDRESS
  376. #define FLASH0_FEATURE_PFLASH_BLOCK_COUNT FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT
  377. #define FLASH0_FEATURE_PFLASH_BLOCK_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE
  378. #define FLASH0_FEATURE_PFLASH_BLOCK_SECTOR_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE
  379. #define FLASH0_FEATURE_PFLASH_BLOCK_WRITE_UNIT_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_WRITE_UNIT_SIZE
  380. #define FLASH0_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT
  381. #define FLASH0_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT
  382. #define FLASH0_FEATURE_PFLASH_PROTECTION_REGION_COUNT FSL_FEATURE_FLASH_PFLASH_PROTECTION_REGION_COUNT
  383. #define FLASH1_FEATURE_PFLASH_START_ADDRESS 0
  384. #define FLASH1_FEATURE_PFLASH_BLOCK_COUNT 0
  385. #define FLASH1_FEATURE_PFLASH_BLOCK_SIZE 0
  386. #define FLASH1_FEATURE_PFLASH_BLOCK_SECTOR_SIZE 0
  387. #define FLASH1_FEATURE_PFLASH_BLOCK_WRITE_UNIT_SIZE 0
  388. #define FLASH1_FEATURE_PFLASH_SECTOR_CMD_ADDRESS_ALIGMENT 0
  389. #define FLASH1_FEATURE_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT 0
  390. #define FLASH1_FEATURE_PFLASH_PROTECTION_REGION_COUNT 0
  391. #endif
  392. #if FLASH0_FEATURE_PFLASH_PROTECTION_REGION_COUNT > FLASH1_FEATURE_PFLASH_PROTECTION_REGION_COUNT
  393. #define MAX_FLASH_PROT_REGION_COUNT FLASH0_FEATURE_PFLASH_PROTECTION_REGION_COUNT
  394. #else
  395. #define MAX_FLASH_PROT_REGION_COUNT FLASH1_FEATURE_PFLASH_PROTECTION_REGION_COUNT
  396. #endif
  397. /*@}*/
  398. #endif /* _FSL_FTFX_ADAPTER_H_ */