fsl_flash.h 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370
  1. /*
  2. * Copyright (c) 2013-2016, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * o Redistributions of source code must retain the above copyright notice, this list
  10. * of conditions and the following disclaimer.
  11. *
  12. * o Redistributions in binary form must reproduce the above copyright notice, this
  13. * list of conditions and the following disclaimer in the documentation and/or
  14. * other materials provided with the distribution.
  15. *
  16. * o Neither the name of the copyright holder nor the names of its
  17. * contributors may be used to endorse or promote products derived from this
  18. * software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  21. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  24. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  27. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef _FSL_FLASH_H_
  32. #define _FSL_FLASH_H_
  33. #if (defined(BL_TARGET_FLASH) || defined(BL_TARGET_ROM) || defined(BL_TARGET_RAM))
  34. #include <assert.h>
  35. #include <string.h>
  36. #include "fsl_device_registers.h"
  37. #include "bootloader_common.h"
  38. #else
  39. #include "fsl_common.h"
  40. #endif
  41. /*******************************************************************************
  42. * Definitions
  43. ******************************************************************************/
  44. /*!
  45. * @addtogroup flash_driver
  46. * @{
  47. */
  48. /*!
  49. * @name Flash version
  50. * @{
  51. */
  52. /*! @brief Constructs the version number for drivers. */
  53. #if !defined(MAKE_VERSION)
  54. #define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
  55. #endif
  56. /*! @brief Flash driver version for SDK*/
  57. #define FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(2, 4, 1)) /*!< Version 2.4.1. */
  58. /*! @brief Flash driver version for ROM*/
  59. enum _flash_driver_version_constants
  60. {
  61. kFLASH_DriverVersionName = 'F', /*!< Flash driver version name.*/
  62. kFLASH_DriverVersionMajor = 2, /*!< Major flash driver version.*/
  63. kFLASH_DriverVersionMinor = 4, /*!< Minor flash driver version.*/
  64. kFLASH_DriverVersionBugfix = 1 /*!< Bugfix for flash driver version.*/
  65. };
  66. /*@}*/
  67. /*!
  68. * @name Flash configuration
  69. * @{
  70. */
  71. /*! @brief Indicates whether to support FlexNVM in the Flash driver */
  72. #if !defined(FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT)
  73. #define FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT 1 /*!< Enables the FlexNVM support by default. */
  74. #endif
  75. /*! @brief Indicates whether the FlexNVM is enabled in the Flash driver */
  76. #define FLASH_SSD_IS_FLEXNVM_ENABLED (FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT && FSL_FEATURE_FLASH_HAS_FLEX_NVM)
  77. /*! @brief Indicates whether to support Secondary flash in the Flash driver */
  78. #if !defined(FLASH_SSD_CONFIG_ENABLE_SECONDARY_FLASH_SUPPORT)
  79. #define FLASH_SSD_CONFIG_ENABLE_SECONDARY_FLASH_SUPPORT 1 /*!< Enables the secondary flash support by default. */
  80. #endif
  81. /*! @brief Indicates whether the secondary flash is supported in the Flash driver */
  82. #if defined(FSL_FEATURE_FLASH_HAS_MULTIPLE_FLASH) || defined(FSL_FEATURE_FLASH_PFLASH_1_START_ADDRESS)
  83. #define FLASH_SSD_IS_SECONDARY_FLASH_ENABLED (FLASH_SSD_CONFIG_ENABLE_SECONDARY_FLASH_SUPPORT)
  84. #else
  85. #define FLASH_SSD_IS_SECONDARY_FLASH_ENABLED (0)
  86. #endif
  87. /*! @brief Flash driver location. */
  88. #if !defined(FLASH_DRIVER_IS_FLASH_RESIDENT)
  89. #if (!defined(BL_TARGET_ROM) && !defined(BL_TARGET_RAM))
  90. #define FLASH_DRIVER_IS_FLASH_RESIDENT 1 /*!< Used for the flash resident application. */
  91. #else
  92. #define FLASH_DRIVER_IS_FLASH_RESIDENT 0 /*!< Used for the non-flash resident application. */
  93. #endif
  94. #endif
  95. /*! @brief Flash Driver Export option */
  96. #if !defined(FLASH_DRIVER_IS_EXPORTED)
  97. #if (defined(BL_TARGET_ROM) || defined(BL_TARGET_FLASH))
  98. #define FLASH_DRIVER_IS_EXPORTED 1 /*!< Used for the ROM bootloader. */
  99. #else
  100. #define FLASH_DRIVER_IS_EXPORTED 0 /*!< Used for the MCUXpresso SDK application. */
  101. #endif
  102. #endif
  103. /*@}*/
  104. /*!
  105. * @name Flash status
  106. * @{
  107. */
  108. /*! @brief Flash driver status group. */
  109. #if defined(kStatusGroup_FlashDriver)
  110. #define kStatusGroupGeneric kStatusGroup_Generic
  111. #define kStatusGroupFlashDriver kStatusGroup_FlashDriver
  112. #elif defined(kStatusGroup_FLASH)
  113. #define kStatusGroupGeneric kStatusGroup_Generic
  114. #define kStatusGroupFlashDriver kStatusGroup_FLASH
  115. #else
  116. #define kStatusGroupGeneric 0
  117. #define kStatusGroupFlashDriver 1
  118. #endif
  119. /*! @brief Constructs a status code value from a group and a code number. */
  120. #if !defined(MAKE_STATUS)
  121. #define MAKE_STATUS(group, code) ((((group)*100) + (code)))
  122. #endif
  123. /*!
  124. * @brief Flash driver status codes.
  125. */
  126. enum _flash_status
  127. {
  128. kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0), /*!< API is executed successfully*/
  129. kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4), /*!< Invalid argument*/
  130. kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0), /*!< Error size*/
  131. kStatus_FLASH_AlignmentError =
  132. MAKE_STATUS(kStatusGroupFlashDriver, 1), /*!< Parameter is not aligned with the specified baseline*/
  133. kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2), /*!< Address is out of range */
  134. kStatus_FLASH_AccessError =
  135. MAKE_STATUS(kStatusGroupFlashDriver, 3), /*!< Invalid instruction codes and out-of bound addresses */
  136. kStatus_FLASH_ProtectionViolation = MAKE_STATUS(
  137. kStatusGroupFlashDriver, 4), /*!< The program/erase operation is requested to execute on protected areas */
  138. kStatus_FLASH_CommandFailure =
  139. MAKE_STATUS(kStatusGroupFlashDriver, 5), /*!< Run-time error during command execution. */
  140. kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6), /*!< Unknown property.*/
  141. kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7), /*!< API erase key is invalid.*/
  142. kStatus_FLASH_RegionExecuteOnly =
  143. MAKE_STATUS(kStatusGroupFlashDriver, 8), /*!< The current region is execute-only.*/
  144. kStatus_FLASH_ExecuteInRamFunctionNotReady =
  145. MAKE_STATUS(kStatusGroupFlashDriver, 9), /*!< Execute-in-RAM function is not available.*/
  146. kStatus_FLASH_PartitionStatusUpdateFailure =
  147. MAKE_STATUS(kStatusGroupFlashDriver, 10), /*!< Failed to update partition status.*/
  148. kStatus_FLASH_SetFlexramAsEepromError =
  149. MAKE_STATUS(kStatusGroupFlashDriver, 11), /*!< Failed to set FlexRAM as EEPROM.*/
  150. kStatus_FLASH_RecoverFlexramAsRamError =
  151. MAKE_STATUS(kStatusGroupFlashDriver, 12), /*!< Failed to recover FlexRAM as RAM.*/
  152. kStatus_FLASH_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFlashDriver, 13), /*!< Failed to set FlexRAM as RAM.*/
  153. kStatus_FLASH_RecoverFlexramAsEepromError =
  154. MAKE_STATUS(kStatusGroupFlashDriver, 14), /*!< Failed to recover FlexRAM as EEPROM.*/
  155. kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 15), /*!< Flash API is not supported.*/
  156. kStatus_FLASH_SwapSystemNotInUninitialized =
  157. MAKE_STATUS(kStatusGroupFlashDriver, 16), /*!< Swap system is not in an uninitialzed state.*/
  158. kStatus_FLASH_SwapIndicatorAddressError =
  159. MAKE_STATUS(kStatusGroupFlashDriver, 17), /*!< The swap indicator address is invalid.*/
  160. kStatus_FLASH_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFlashDriver, 18), /*!< The flash property is read-only.*/
  161. kStatus_FLASH_InvalidPropertyValue =
  162. MAKE_STATUS(kStatusGroupFlashDriver, 19), /*!< The flash property value is out of range.*/
  163. kStatus_FLASH_InvalidSpeculationOption =
  164. MAKE_STATUS(kStatusGroupFlashDriver, 20), /*!< The option of flash prefetch speculation is invalid.*/
  165. };
  166. /*@}*/
  167. /*!
  168. * @name Flash API key
  169. * @{
  170. */
  171. /*! @brief Constructs the four character code for the Flash driver API key. */
  172. #if !defined(FOUR_CHAR_CODE)
  173. #define FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))
  174. #endif
  175. /*!
  176. * @brief Enumeration for Flash driver API keys.
  177. *
  178. * @note The resulting value is built with a byte order such that the string
  179. * being readable in expected order when viewed in a hex editor, if the value
  180. * is treated as a 32-bit little endian value.
  181. */
  182. enum _flash_driver_api_keys
  183. {
  184. kFLASH_ApiEraseKey = FOUR_CHAR_CODE('k', 'f', 'e', 'k') /*!< Key value used to validate all flash erase APIs.*/
  185. };
  186. /*@}*/
  187. /*!
  188. * @brief Enumeration for supported flash margin levels.
  189. */
  190. typedef enum _flash_margin_value
  191. {
  192. kFLASH_MarginValueNormal, /*!< Use the 'normal' read level for 1s.*/
  193. kFLASH_MarginValueUser, /*!< Apply the 'User' margin to the normal read-1 level.*/
  194. kFLASH_MarginValueFactory, /*!< Apply the 'Factory' margin to the normal read-1 level.*/
  195. kFLASH_MarginValueInvalid /*!< Not real margin level, Used to determine the range of valid margin level. */
  196. } flash_margin_value_t;
  197. /*!
  198. * @brief Enumeration for the three possible flash security states.
  199. */
  200. typedef enum _flash_security_state
  201. {
  202. kFLASH_SecurityStateNotSecure = 0xc33cc33cU, /*!< Flash is not secure.*/
  203. kFLASH_SecurityStateBackdoorEnabled = 0x5aa55aa5U, /*!< Flash backdoor is enabled.*/
  204. kFLASH_SecurityStateBackdoorDisabled = 0x5ac33ca5U /*!< Flash backdoor is disabled.*/
  205. } flash_security_state_t;
  206. /*!
  207. * @brief Enumeration for the three possible flash protection levels.
  208. */
  209. typedef enum _flash_protection_state
  210. {
  211. kFLASH_ProtectionStateUnprotected, /*!< Flash region is not protected.*/
  212. kFLASH_ProtectionStateProtected, /*!< Flash region is protected.*/
  213. kFLASH_ProtectionStateMixed /*!< Flash is mixed with protected and unprotected region.*/
  214. } flash_protection_state_t;
  215. /*!
  216. * @brief Enumeration for the three possible flash execute access levels.
  217. */
  218. typedef enum _flash_execute_only_access_state
  219. {
  220. kFLASH_AccessStateUnLimited, /*!< Flash region is unlimited.*/
  221. kFLASH_AccessStateExecuteOnly, /*!< Flash region is execute only.*/
  222. kFLASH_AccessStateMixed /*!< Flash is mixed with unlimited and execute only region.*/
  223. } flash_execute_only_access_state_t;
  224. /*!
  225. * @brief Enumeration for various flash properties.
  226. */
  227. typedef enum _flash_property_tag
  228. {
  229. kFLASH_PropertyPflashSectorSize = 0x00U, /*!< Pflash sector size property.*/
  230. kFLASH_PropertyPflashTotalSize = 0x01U, /*!< Pflash total size property.*/
  231. kFLASH_PropertyPflashBlockSize = 0x02U, /*!< Pflash block size property.*/
  232. kFLASH_PropertyPflashBlockCount = 0x03U, /*!< Pflash block count property.*/
  233. kFLASH_PropertyPflashBlockBaseAddr = 0x04U, /*!< Pflash block base address property.*/
  234. kFLASH_PropertyPflashFacSupport = 0x05U, /*!< Pflash fac support property.*/
  235. kFLASH_PropertyPflashAccessSegmentSize = 0x06U, /*!< Pflash access segment size property.*/
  236. kFLASH_PropertyPflashAccessSegmentCount = 0x07U, /*!< Pflash access segment count property.*/
  237. kFLASH_PropertyFlexRamBlockBaseAddr = 0x08U, /*!< FlexRam block base address property.*/
  238. kFLASH_PropertyFlexRamTotalSize = 0x09U, /*!< FlexRam total size property.*/
  239. kFLASH_PropertyDflashSectorSize = 0x10U, /*!< Dflash sector size property.*/
  240. kFLASH_PropertyDflashTotalSize = 0x11U, /*!< Dflash total size property.*/
  241. kFLASH_PropertyDflashBlockSize = 0x12U, /*!< Dflash block size property.*/
  242. kFLASH_PropertyDflashBlockCount = 0x13U, /*!< Dflash block count property.*/
  243. kFLASH_PropertyDflashBlockBaseAddr = 0x14U, /*!< Dflash block base address property.*/
  244. kFLASH_PropertyEepromTotalSize = 0x15U, /*!< EEPROM total size property.*/
  245. kFLASH_PropertyFlashMemoryIndex = 0x20U /*!< Flash memory index property.*/
  246. } flash_property_tag_t;
  247. /*!
  248. * @brief Constants for execute-in-RAM flash function.
  249. */
  250. enum _flash_execute_in_ram_function_constants
  251. {
  252. kFLASH_ExecuteInRamFunctionMaxSizeInWords = 16U, /*!< The maximum size of execute-in-RAM function.*/
  253. kFLASH_ExecuteInRamFunctionTotalNum = 2U /*!< Total number of execute-in-RAM functions.*/
  254. };
  255. /*!
  256. * @brief Flash execute-in-RAM function information.
  257. */
  258. typedef struct _flash_execute_in_ram_function_config
  259. {
  260. uint32_t activeFunctionCount; /*!< Number of available execute-in-RAM functions.*/
  261. uint32_t *flashRunCommand; /*!< Execute-in-RAM function: flash_run_command.*/
  262. uint32_t *flashCommonBitOperation; /*!< Execute-in-RAM function: flash_common_bit_operation.*/
  263. } flash_execute_in_ram_function_config_t;
  264. /*!
  265. * @brief Enumeration for the two possible options of flash read resource command.
  266. */
  267. typedef enum _flash_read_resource_option
  268. {
  269. kFLASH_ResourceOptionFlashIfr =
  270. 0x00U, /*!< Select code for Program flash 0 IFR, Program flash swap 0 IFR, Data flash 0 IFR */
  271. kFLASH_ResourceOptionVersionId = 0x01U /*!< Select code for the version ID*/
  272. } flash_read_resource_option_t;
  273. /*!
  274. * @brief Enumeration for the range of special-purpose flash resource
  275. */
  276. enum _flash_read_resource_range
  277. {
  278. #if (FSL_FEATURE_FLASH_IS_FTFE == 1)
  279. kFLASH_ResourceRangePflashIfrSizeInBytes = 1024U, /*!< Pflash IFR size in byte.*/
  280. kFLASH_ResourceRangeVersionIdSizeInBytes = 8U, /*!< Version ID IFR size in byte.*/
  281. kFLASH_ResourceRangeVersionIdStart = 0x08U, /*!< Version ID IFR start address.*/
  282. kFLASH_ResourceRangeVersionIdEnd = 0x0FU, /*!< Version ID IFR end address.*/
  283. kFLASH_ResourceRangePflashSwapIfrStart = 0x40000U, /*!< Pflash swap IFR start address.*/
  284. kFLASH_ResourceRangePflashSwapIfrEnd =
  285. (kFLASH_ResourceRangePflashSwapIfrStart + 0x3FFU), /*!< Pflash swap IFR end address.*/
  286. #else /* FSL_FEATURE_FLASH_IS_FTFL == 1 or FSL_FEATURE_FLASH_IS_FTFA = =1 */
  287. kFLASH_ResourceRangePflashIfrSizeInBytes = 256U, /*!< Pflash IFR size in byte.*/
  288. kFLASH_ResourceRangeVersionIdSizeInBytes = 8U, /*!< Version ID IFR size in byte.*/
  289. kFLASH_ResourceRangeVersionIdStart = 0x00U, /*!< Version ID IFR start address.*/
  290. kFLASH_ResourceRangeVersionIdEnd = 0x07U, /*!< Version ID IFR end address.*/
  291. #if 0x20000U == (FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT * FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE)
  292. kFLASH_ResourceRangePflashSwapIfrStart = 0x8000U, /*!< Pflash swap IFR start address.*/
  293. #elif 0x40000U == (FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT * FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE)
  294. kFLASH_ResourceRangePflashSwapIfrStart = 0x10000U, /*!< Pflash swap IFR start address.*/
  295. #elif 0x80000U == (FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT * FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE)
  296. kFLASH_ResourceRangePflashSwapIfrStart = 0x20000U, /*!< Pflash swap IFR start address.*/
  297. #else
  298. kFLASH_ResourceRangePflashSwapIfrStart = 0,
  299. #endif
  300. kFLASH_ResourceRangePflashSwapIfrEnd =
  301. (kFLASH_ResourceRangePflashSwapIfrStart + 0xFFU), /*!< Pflash swap IFR end address.*/
  302. #endif
  303. kFLASH_ResourceRangeDflashIfrStart = 0x800000U, /*!< Dflash IFR start address.*/
  304. kFLASH_ResourceRangeDflashIfrEnd = 0x8003FFU, /*!< Dflash IFR end address.*/
  305. };
  306. /*!
  307. * @brief Enumeration for the index of read/program once record
  308. */
  309. enum _k3_flash_read_once_index
  310. {
  311. kFLASH_RecordIndexSwapAddr = 0xA1U, /*!< Index of Swap indicator address.*/
  312. kFLASH_RecordIndexSwapEnable = 0xA2U, /*!< Index of Swap system enable.*/
  313. kFLASH_RecordIndexSwapDisable = 0xA3U, /*!< Index of Swap system disable.*/
  314. };
  315. /*!
  316. * @brief Enumeration for the two possilbe options of set FlexRAM function command.
  317. */
  318. typedef enum _flash_flexram_function_option
  319. {
  320. kFLASH_FlexramFunctionOptionAvailableAsRam = 0xFFU, /*!< An option used to make FlexRAM available as RAM */
  321. kFLASH_FlexramFunctionOptionAvailableForEeprom = 0x00U /*!< An option used to make FlexRAM available for EEPROM */
  322. } flash_flexram_function_option_t;
  323. /*!
  324. * @brief Enumeration for acceleration RAM property.
  325. */
  326. enum _flash_acceleration_ram_property
  327. {
  328. kFLASH_AccelerationRamSize = 0x400U
  329. };
  330. /*!
  331. * @brief Enumeration for the possible options of Swap function
  332. */
  333. typedef enum _flash_swap_function_option
  334. {
  335. kFLASH_SwapFunctionOptionEnable = 0x00U, /*!< An option used to enable the Swap function */
  336. kFLASH_SwapFunctionOptionDisable = 0x01U /*!< An option used to disable the Swap function */
  337. } flash_swap_function_option_t;
  338. /*!
  339. * @brief Enumeration for the possible options of Swap control commands
  340. */
  341. typedef enum _flash_swap_control_option
  342. {
  343. kFLASH_SwapControlOptionIntializeSystem = 0x01U, /*!< An option used to initialize the Swap system */
  344. kFLASH_SwapControlOptionSetInUpdateState = 0x02U, /*!< An option used to set the Swap in an update state */
  345. kFLASH_SwapControlOptionSetInCompleteState = 0x04U, /*!< An option used to set the Swap in a complete state */
  346. kFLASH_SwapControlOptionReportStatus = 0x08U, /*!< An option used to report the Swap status */
  347. kFLASH_SwapControlOptionDisableSystem = 0x10U /*!< An option used to disable the Swap status */
  348. } flash_swap_control_option_t;
  349. /*!
  350. * @brief Enumeration for the possible flash Swap status.
  351. */
  352. typedef enum _flash_swap_state
  353. {
  354. kFLASH_SwapStateUninitialized = 0x00U, /*!< Flash Swap system is in an uninitialized state.*/
  355. kFLASH_SwapStateReady = 0x01U, /*!< Flash Swap system is in a ready state.*/
  356. kFLASH_SwapStateUpdate = 0x02U, /*!< Flash Swap system is in an update state.*/
  357. kFLASH_SwapStateUpdateErased = 0x03U, /*!< Flash Swap system is in an updateErased state.*/
  358. kFLASH_SwapStateComplete = 0x04U, /*!< Flash Swap system is in a complete state.*/
  359. kFLASH_SwapStateDisabled = 0x05U /*!< Flash Swap system is in a disabled state.*/
  360. } flash_swap_state_t;
  361. /*!
  362. * @breif Enumeration for the possible flash Swap block status
  363. */
  364. typedef enum _flash_swap_block_status
  365. {
  366. kFLASH_SwapBlockStatusLowerHalfProgramBlocksAtZero =
  367. 0x00U, /*!< Swap block status is that lower half program block at zero.*/
  368. kFLASH_SwapBlockStatusUpperHalfProgramBlocksAtZero =
  369. 0x01U, /*!< Swap block status is that upper half program block at zero.*/
  370. } flash_swap_block_status_t;
  371. /*!
  372. * @brief Flash Swap information
  373. */
  374. typedef struct _flash_swap_state_config
  375. {
  376. flash_swap_state_t flashSwapState; /*!<The current Swap system status.*/
  377. flash_swap_block_status_t currentSwapBlockStatus; /*!< The current Swap block status.*/
  378. flash_swap_block_status_t nextSwapBlockStatus; /*!< The next Swap block status.*/
  379. } flash_swap_state_config_t;
  380. /*!
  381. * @brief Flash Swap IFR fields
  382. */
  383. typedef struct _flash_swap_ifr_field_config
  384. {
  385. uint16_t swapIndicatorAddress; /*!< A Swap indicator address field.*/
  386. uint16_t swapEnableWord; /*!< A Swap enable word field.*/
  387. uint8_t reserved0[4]; /*!< A reserved field.*/
  388. #if (FSL_FEATURE_FLASH_IS_FTFE == 1)
  389. uint8_t reserved1[2]; /*!< A reserved field.*/
  390. uint16_t swapDisableWord; /*!< A Swap disable word field.*/
  391. uint8_t reserved2[4]; /*!< A reserved field.*/
  392. #endif
  393. } flash_swap_ifr_field_config_t;
  394. /*!
  395. * @brief Flash Swap IFR field data
  396. */
  397. typedef union _flash_swap_ifr_field_data
  398. {
  399. uint32_t flashSwapIfrData[2]; /*!< A flash Swap IFR field data .*/
  400. flash_swap_ifr_field_config_t flashSwapIfrField; /*!< A flash Swap IFR field structure.*/
  401. } flash_swap_ifr_field_data_t;
  402. /*!
  403. * @brief PFlash protection status - low 32bit
  404. */
  405. typedef union _pflash_protection_status_low
  406. {
  407. uint32_t protl32b; /*!< PROT[31:0] .*/
  408. struct
  409. {
  410. uint8_t protsl; /*!< PROTS[7:0] .*/
  411. uint8_t protsh; /*!< PROTS[15:8] .*/
  412. uint8_t reserved[2];
  413. } prots16b;
  414. } pflash_protection_status_low_t;
  415. /*!
  416. * @brief PFlash protection status - full
  417. */
  418. typedef struct _pflash_protection_status
  419. {
  420. pflash_protection_status_low_t valueLow32b; /*!< PROT[31:0] or PROTS[15:0].*/
  421. #if ((FSL_FEATURE_FLASH_IS_FTFA == 1) && (defined(FTFA_FPROTH0_PROT_MASK))) || \
  422. ((FSL_FEATURE_FLASH_IS_FTFE == 1) && (defined(FTFE_FPROTH0_PROT_MASK))) || \
  423. ((FSL_FEATURE_FLASH_IS_FTFL == 1) && (defined(FTFL_FPROTH0_PROT_MASK)))
  424. struct
  425. {
  426. uint32_t proth32b;
  427. } valueHigh32b; /*!< PROT[63:32].*/
  428. #endif
  429. } pflash_protection_status_t;
  430. /*!
  431. * @brief Enumeration for the FlexRAM load during reset option.
  432. */
  433. typedef enum _flash_partition_flexram_load_option
  434. {
  435. kFLASH_PartitionFlexramLoadOptionLoadedWithValidEepromData =
  436. 0x00U, /*!< FlexRAM is loaded with valid EEPROM data during reset sequence.*/
  437. kFLASH_PartitionFlexramLoadOptionNotLoaded = 0x01U /*!< FlexRAM is not loaded during reset sequence.*/
  438. } flash_partition_flexram_load_option_t;
  439. /*!
  440. * @brief Enumeration for the flash memory index.
  441. */
  442. typedef enum _flash_memory_index
  443. {
  444. kFLASH_MemoryIndexPrimaryFlash = 0x00U, /*!< Current flash memory is primary flash.*/
  445. kFLASH_MemoryIndexSecondaryFlash = 0x01U, /*!< Current flash memory is secondary flash.*/
  446. } flash_memory_index_t;
  447. /*!
  448. * @brief Enumeration for the flash cache controller index.
  449. */
  450. typedef enum _flash_cache_controller_index
  451. {
  452. kFLASH_CacheControllerIndexForCore0 = 0x00U, /*!< Current flash cache controller is for core 0.*/
  453. kFLASH_CacheControllerIndexForCore1 = 0x01U, /*!< Current flash cache controller is for core 1.*/
  454. } flash_cache_controller_index_t;
  455. /*!
  456. * @brief Enumeration for the two possible options of flash prefetch speculation.
  457. */
  458. typedef enum _flash_prefetch_speculation_option
  459. {
  460. kFLASH_prefetchSpeculationOptionEnable = 0x00U,
  461. kFLASH_prefetchSpeculationOptionDisable = 0x01U
  462. } flash_prefetch_speculation_option_t;
  463. /*!
  464. * @brief Flash prefetch speculation status.
  465. */
  466. typedef struct _flash_prefetch_speculation_status
  467. {
  468. flash_prefetch_speculation_option_t instructionOption; /*!< Instruction speculation.*/
  469. flash_prefetch_speculation_option_t dataOption; /*!< Data speculation.*/
  470. } flash_prefetch_speculation_status_t;
  471. /*!
  472. * @brief Flash cache clear process code.
  473. */
  474. typedef enum _flash_cache_clear_process
  475. {
  476. kFLASH_CacheClearProcessPre = 0x00U, /*!< Pre flash cache clear process.*/
  477. kFLASH_CacheClearProcessPost = 0x01U, /*!< Post flash cache clear process.*/
  478. } flash_cache_clear_process_t;
  479. /*!
  480. * @brief Active flash protection information for the current operation.
  481. */
  482. typedef struct _flash_protection_config
  483. {
  484. uint32_t regionBase; /*!< Base address of flash protection region.*/
  485. uint32_t regionSize; /*!< size of flash protection region.*/
  486. uint32_t regionCount; /*!< flash protection region count.*/
  487. } flash_protection_config_t;
  488. /*!
  489. * @brief Active flash Execute-Only access information for the current operation.
  490. */
  491. typedef struct _flash_access_config
  492. {
  493. uint32_t SegmentBase; /*!< Base address of flash Execute-Only segment.*/
  494. uint32_t SegmentSize; /*!< size of flash Execute-Only segment.*/
  495. uint32_t SegmentCount; /*!< flash Execute-Only segment count.*/
  496. } flash_access_config_t;
  497. /*!
  498. * @brief Active flash information for the current operation.
  499. */
  500. typedef struct _flash_operation_config
  501. {
  502. uint32_t convertedAddress; /*!< A converted address for the current flash type.*/
  503. uint32_t activeSectorSize; /*!< A sector size of the current flash type.*/
  504. uint32_t activeBlockSize; /*!< A block size of the current flash type.*/
  505. uint32_t blockWriteUnitSize; /*!< The write unit size.*/
  506. uint32_t sectorCmdAddressAligment; /*!< An erase sector command address alignment.*/
  507. uint32_t sectionCmdAddressAligment; /*!< A program/verify section command address alignment.*/
  508. uint32_t resourceCmdAddressAligment; /*!< A read resource command address alignment.*/
  509. uint32_t checkCmdAddressAligment; /*!< A program check command address alignment.*/
  510. } flash_operation_config_t;
  511. /*! @brief Flash driver state information.
  512. *
  513. * An instance of this structure is allocated by the user of the flash driver and
  514. * passed into each of the driver APIs.
  515. */
  516. typedef struct _flash_config
  517. {
  518. uint32_t PFlashBlockBase; /*!< A base address of the first PFlash block */
  519. uint32_t PFlashTotalSize; /*!< The size of the combined PFlash block. */
  520. uint8_t PFlashBlockCount; /*!< A number of PFlash blocks. */
  521. uint8_t FlashMemoryIndex; /*!< 0 - primary flash; 1 - secondary flash*/
  522. uint8_t Reserved0[2]; /*!< Reserved field 0 */
  523. uint32_t PFlashSectorSize; /*!< The size in bytes of a sector of PFlash. */
  524. uint32_t Reserved1; /*!< Reserved field 1 */
  525. uint32_t PFlashAccessSegmentSize; /*!< A size in bytes of an access segment of PFlash. */
  526. uint32_t PFlashAccessSegmentCount; /*!< A number of PFlash access segments. */
  527. uint32_t *flashExecuteInRamFunctionInfo; /*!< An information structure of the flash execute-in-RAM function. */
  528. uint32_t FlexRAMBlockBase; /*!< For the FlexNVM device, this is the base address of the FlexRAM */
  529. /*!< For the non-FlexNVM device, this is the base address of the acceleration RAM memory */
  530. uint32_t FlexRAMTotalSize; /*!< For the FlexNVM device, this is the size of the FlexRAM */
  531. /*!< For the non-FlexNVM device, this is the size of the acceleration RAM memory */
  532. uint32_t
  533. DFlashBlockBase; /*!< For the FlexNVM device, this is the base address of the D-Flash memory (FlexNVM memory) */
  534. /*!< For the non-FlexNVM device, this field is unused */
  535. uint32_t DFlashTotalSize; /*!< For the FlexNVM device, this is the total size of the FlexNVM memory; */
  536. /*!< For the non-FlexNVM device, this field is unused */
  537. uint32_t EEpromTotalSize; /*!< For the FlexNVM device, this is the size in bytes of the EEPROM area which was
  538. partitioned from FlexRAM */
  539. /*!< For the non-FlexNVM device, this field is unused */
  540. } flash_config_t;
  541. /*******************************************************************************
  542. * API
  543. ******************************************************************************/
  544. #if defined(__cplusplus)
  545. extern "C" {
  546. #endif
  547. /*!
  548. * @name Initialization
  549. * @{
  550. */
  551. /*!
  552. * @brief Initializes the global flash properties structure members.
  553. *
  554. * This function checks and initializes the Flash module for the other Flash APIs.
  555. *
  556. * @param config Pointer to the storage for the driver runtime state.
  557. *
  558. * @retval #kStatus_FLASH_Success API was executed successfully.
  559. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  560. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  561. * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update the partition status.
  562. */
  563. status_t FLASH_Init(flash_config_t *config);
  564. /*!
  565. * @brief Prepares flash execute-in-RAM functions.
  566. *
  567. * @param config Pointer to the storage for the driver runtime state.
  568. *
  569. * @retval #kStatus_FLASH_Success API was executed successfully.
  570. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  571. */
  572. #if FLASH_DRIVER_IS_FLASH_RESIDENT
  573. status_t FLASH_PrepareExecuteInRamFunctions(flash_config_t *config);
  574. #endif
  575. /*@}*/
  576. /*!
  577. * @name Erasing
  578. * @{
  579. */
  580. /*!
  581. * @brief Erases entire flash
  582. *
  583. * @param config Pointer to the storage for the driver runtime state.
  584. * @param key A value used to validate all flash erase APIs.
  585. *
  586. * @retval #kStatus_FLASH_Success API was executed successfully.
  587. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  588. * @retval #kStatus_FLASH_EraseKeyError API erase key is invalid.
  589. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  590. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  591. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  592. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  593. * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update the partition status.
  594. */
  595. status_t FLASH_EraseAll(flash_config_t *config, uint32_t key);
  596. /*!
  597. * @brief Erases the flash sectors encompassed by parameters passed into function.
  598. *
  599. * This function erases the appropriate number of flash sectors based on the
  600. * desired start address and length.
  601. *
  602. * @param config The pointer to the storage for the driver runtime state.
  603. * @param start The start address of the desired flash memory to be erased.
  604. * The start address does not need to be sector-aligned but must be word-aligned.
  605. * @param lengthInBytes The length, given in bytes (not words or long-words)
  606. * to be erased. Must be word-aligned.
  607. * @param key The value used to validate all flash erase APIs.
  608. *
  609. * @retval #kStatus_FLASH_Success API was executed successfully.
  610. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  611. * @retval #kStatus_FLASH_AlignmentError The parameter is not aligned with the specified baseline.
  612. * @retval #kStatus_FLASH_AddressError The address is out of range.
  613. * @retval #kStatus_FLASH_EraseKeyError The API erase key is invalid.
  614. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  615. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  616. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  617. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  618. */
  619. status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key);
  620. /*!
  621. * @brief Erases the entire flash, including protected sectors.
  622. *
  623. * @param config Pointer to the storage for the driver runtime state.
  624. * @param key A value used to validate all flash erase APIs.
  625. *
  626. * @retval #kStatus_FLASH_Success API was executed successfully.
  627. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  628. * @retval #kStatus_FLASH_EraseKeyError API erase key is invalid.
  629. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  630. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  631. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  632. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  633. * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update the partition status.
  634. */
  635. #if defined(FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD) && FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD
  636. status_t FLASH_EraseAllUnsecure(flash_config_t *config, uint32_t key);
  637. #endif
  638. /*!
  639. * @brief Erases all program flash execute-only segments defined by the FXACC registers.
  640. *
  641. * @param config Pointer to the storage for the driver runtime state.
  642. * @param key A value used to validate all flash erase APIs.
  643. *
  644. * @retval #kStatus_FLASH_Success API was executed successfully.
  645. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  646. * @retval #kStatus_FLASH_EraseKeyError API erase key is invalid.
  647. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  648. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  649. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  650. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  651. */
  652. status_t FLASH_EraseAllExecuteOnlySegments(flash_config_t *config, uint32_t key);
  653. /*@}*/
  654. /*!
  655. * @name Programming
  656. * @{
  657. */
  658. /*!
  659. * @brief Programs flash with data at locations passed in through parameters.
  660. *
  661. * This function programs the flash memory with the desired data for a given
  662. * flash area as determined by the start address and the length.
  663. *
  664. * @param config A pointer to the storage for the driver runtime state.
  665. * @param start The start address of the desired flash memory to be programmed. Must be
  666. * word-aligned.
  667. * @param src A pointer to the source buffer of data that is to be programmed
  668. * into the flash.
  669. * @param lengthInBytes The length, given in bytes (not words or long-words),
  670. * to be programmed. Must be word-aligned.
  671. *
  672. * @retval #kStatus_FLASH_Success API was executed successfully.
  673. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  674. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline.
  675. * @retval #kStatus_FLASH_AddressError Address is out of range.
  676. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  677. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  678. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  679. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  680. */
  681. status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);
  682. /*!
  683. * @brief Programs Program Once Field through parameters.
  684. *
  685. * This function programs the Program Once Field with the desired data for a given
  686. * flash area as determined by the index and length.
  687. *
  688. * @param config A pointer to the storage for the driver runtime state.
  689. * @param index The index indicating which area of the Program Once Field to be programmed.
  690. * @param src A pointer to the source buffer of data that is to be programmed
  691. * into the Program Once Field.
  692. * @param lengthInBytes The length, given in bytes (not words or long-words),
  693. * to be programmed. Must be word-aligned.
  694. *
  695. * @retval #kStatus_FLASH_Success API was executed successfully.
  696. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  697. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  698. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  699. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  700. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  701. */
  702. status_t FLASH_ProgramOnce(flash_config_t *config, uint32_t index, uint32_t *src, uint32_t lengthInBytes);
  703. /*!
  704. * @brief Programs flash with data at locations passed in through parameters via the Program Section command.
  705. *
  706. * This function programs the flash memory with the desired data for a given
  707. * flash area as determined by the start address and length.
  708. *
  709. * @param config A pointer to the storage for the driver runtime state.
  710. * @param start The start address of the desired flash memory to be programmed. Must be
  711. * word-aligned.
  712. * @param src A pointer to the source buffer of data that is to be programmed
  713. * into the flash.
  714. * @param lengthInBytes The length, given in bytes (not words or long-words),
  715. * to be programmed. Must be word-aligned.
  716. *
  717. * @retval #kStatus_FLASH_Success API was executed successfully.
  718. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  719. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
  720. * @retval #kStatus_FLASH_AddressError Address is out of range.
  721. * @retval #kStatus_FLASH_SetFlexramAsRamError Failed to set flexram as RAM.
  722. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  723. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  724. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  725. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  726. * @retval #kStatus_FLASH_RecoverFlexramAsEepromError Failed to recover FlexRAM as EEPROM.
  727. */
  728. #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD
  729. status_t FLASH_ProgramSection(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);
  730. #endif
  731. /*!
  732. * @brief Programs the EEPROM with data at locations passed in through parameters.
  733. *
  734. * This function programs the emulated EEPROM with the desired data for a given
  735. * flash area as determined by the start address and length.
  736. *
  737. * @param config A pointer to the storage for the driver runtime state.
  738. * @param start The start address of the desired flash memory to be programmed. Must be
  739. * word-aligned.
  740. * @param src A pointer to the source buffer of data that is to be programmed
  741. * into the flash.
  742. * @param lengthInBytes The length, given in bytes (not words or long-words),
  743. * to be programmed. Must be word-aligned.
  744. *
  745. * @retval #kStatus_FLASH_Success API was executed successfully.
  746. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  747. * @retval #kStatus_FLASH_AddressError Address is out of range.
  748. * @retval #kStatus_FLASH_SetFlexramAsEepromError Failed to set flexram as eeprom.
  749. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  750. * @retval #kStatus_FLASH_RecoverFlexramAsRamError Failed to recover the FlexRAM as RAM.
  751. */
  752. #if FLASH_SSD_IS_FLEXNVM_ENABLED
  753. status_t FLASH_EepromWrite(flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes);
  754. #endif
  755. /*@}*/
  756. /*!
  757. * @name Reading
  758. * @{
  759. */
  760. /*!
  761. * @brief Reads the resource with data at locations passed in through parameters.
  762. *
  763. * This function reads the flash memory with the desired location for a given
  764. * flash area as determined by the start address and length.
  765. *
  766. * @param config A pointer to the storage for the driver runtime state.
  767. * @param start The start address of the desired flash memory to be programmed. Must be
  768. * word-aligned.
  769. * @param dst A pointer to the destination buffer of data that is used to store
  770. * data to be read.
  771. * @param lengthInBytes The length, given in bytes (not words or long-words),
  772. * to be read. Must be word-aligned.
  773. * @param option The resource option which indicates which area should be read back.
  774. *
  775. * @retval #kStatus_FLASH_Success API was executed successfully.
  776. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  777. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline.
  778. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  779. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  780. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  781. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  782. */
  783. #if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
  784. status_t FLASH_ReadResource(
  785. flash_config_t *config, uint32_t start, uint32_t *dst, uint32_t lengthInBytes, flash_read_resource_option_t option);
  786. #endif
  787. /*!
  788. * @brief Reads the Program Once Field through parameters.
  789. *
  790. * This function reads the read once feild with given index and length.
  791. *
  792. * @param config A pointer to the storage for the driver runtime state.
  793. * @param index The index indicating the area of program once field to be read.
  794. * @param dst A pointer to the destination buffer of data that is used to store
  795. * data to be read.
  796. * @param lengthInBytes The length, given in bytes (not words or long-words),
  797. * to be programmed. Must be word-aligned.
  798. *
  799. * @retval #kStatus_FLASH_Success API was executed successfully.
  800. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  801. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  802. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  803. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  804. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  805. */
  806. status_t FLASH_ReadOnce(flash_config_t *config, uint32_t index, uint32_t *dst, uint32_t lengthInBytes);
  807. /*@}*/
  808. /*!
  809. * @name Security
  810. * @{
  811. */
  812. /*!
  813. * @brief Returns the security state via the pointer passed into the function.
  814. *
  815. * This function retrieves the current flash security status, including the
  816. * security enabling state and the backdoor key enabling state.
  817. *
  818. * @param config A pointer to storage for the driver runtime state.
  819. * @param state A pointer to the value returned for the current security status code:
  820. *
  821. * @retval #kStatus_FLASH_Success API was executed successfully.
  822. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  823. */
  824. status_t FLASH_GetSecurityState(flash_config_t *config, flash_security_state_t *state);
  825. /*!
  826. * @brief Allows users to bypass security with a backdoor key.
  827. *
  828. * If the MCU is in secured state, this function unsecures the MCU by
  829. * comparing the provided backdoor key with ones in the flash configuration
  830. * field.
  831. *
  832. * @param config A pointer to the storage for the driver runtime state.
  833. * @param backdoorKey A pointer to the user buffer containing the backdoor key.
  834. *
  835. * @retval #kStatus_FLASH_Success API was executed successfully.
  836. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  837. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  838. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  839. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  840. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  841. */
  842. status_t FLASH_SecurityBypass(flash_config_t *config, const uint8_t *backdoorKey);
  843. /*@}*/
  844. /*!
  845. * @name Verification
  846. * @{
  847. */
  848. /*!
  849. * @brief Verifies erasure of the entire flash at a specified margin level.
  850. *
  851. * This function checks whether the flash is erased to the
  852. * specified read margin level.
  853. *
  854. * @param config A pointer to the storage for the driver runtime state.
  855. * @param margin Read margin choice.
  856. *
  857. * @retval #kStatus_FLASH_Success API was executed successfully.
  858. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  859. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  860. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  861. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  862. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  863. */
  864. status_t FLASH_VerifyEraseAll(flash_config_t *config, flash_margin_value_t margin);
  865. /*!
  866. * @brief Verifies an erasure of the desired flash area at a specified margin level.
  867. *
  868. * This function checks the appropriate number of flash sectors based on
  869. * the desired start address and length to check whether the flash is erased
  870. * to the specified read margin level.
  871. *
  872. * @param config A pointer to the storage for the driver runtime state.
  873. * @param start The start address of the desired flash memory to be verified.
  874. * The start address does not need to be sector-aligned but must be word-aligned.
  875. * @param lengthInBytes The length, given in bytes (not words or long-words),
  876. * to be verified. Must be word-aligned.
  877. * @param margin Read margin choice.
  878. *
  879. * @retval #kStatus_FLASH_Success API was executed successfully.
  880. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  881. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
  882. * @retval #kStatus_FLASH_AddressError Address is out of range.
  883. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  884. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  885. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  886. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  887. */
  888. status_t FLASH_VerifyErase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_margin_value_t margin);
  889. /*!
  890. * @brief Verifies programming of the desired flash area at a specified margin level.
  891. *
  892. * This function verifies the data programed in the flash memory using the
  893. * Flash Program Check Command and compares it to the expected data for a given
  894. * flash area as determined by the start address and length.
  895. *
  896. * @param config A pointer to the storage for the driver runtime state.
  897. * @param start The start address of the desired flash memory to be verified. Must be word-aligned.
  898. * @param lengthInBytes The length, given in bytes (not words or long-words),
  899. * to be verified. Must be word-aligned.
  900. * @param expectedData A pointer to the expected data that is to be
  901. * verified against.
  902. * @param margin Read margin choice.
  903. * @param failedAddress A pointer to the returned failing address.
  904. * @param failedData A pointer to the returned failing data. Some derivatives do
  905. * not include failed data as part of the FCCOBx registers. In this
  906. * case, zeros are returned upon failure.
  907. *
  908. * @retval #kStatus_FLASH_Success API was executed successfully.
  909. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  910. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
  911. * @retval #kStatus_FLASH_AddressError Address is out of range.
  912. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  913. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  914. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  915. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  916. */
  917. status_t FLASH_VerifyProgram(flash_config_t *config,
  918. uint32_t start,
  919. uint32_t lengthInBytes,
  920. const uint32_t *expectedData,
  921. flash_margin_value_t margin,
  922. uint32_t *failedAddress,
  923. uint32_t *failedData);
  924. /*!
  925. * @brief Verifies whether the program flash execute-only segments have been erased to
  926. * the specified read margin level.
  927. *
  928. * @param config A pointer to the storage for the driver runtime state.
  929. * @param margin Read margin choice.
  930. *
  931. * @retval #kStatus_FLASH_Success API was executed successfully.
  932. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  933. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  934. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  935. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  936. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  937. */
  938. status_t FLASH_VerifyEraseAllExecuteOnlySegments(flash_config_t *config, flash_margin_value_t margin);
  939. /*@}*/
  940. /*!
  941. * @name Protection
  942. * @{
  943. */
  944. /*!
  945. * @brief Returns the protection state of the desired flash area via the pointer passed into the function.
  946. *
  947. * This function retrieves the current flash protect status for a given
  948. * flash area as determined by the start address and length.
  949. *
  950. * @param config A pointer to the storage for the driver runtime state.
  951. * @param start The start address of the desired flash memory to be checked. Must be word-aligned.
  952. * @param lengthInBytes The length, given in bytes (not words or long-words)
  953. * to be checked. Must be word-aligned.
  954. * @param protection_state A pointer to the value returned for the current
  955. * protection status code for the desired flash area.
  956. *
  957. * @retval #kStatus_FLASH_Success API was executed successfully.
  958. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  959. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
  960. * @retval #kStatus_FLASH_AddressError The address is out of range.
  961. */
  962. status_t FLASH_IsProtected(flash_config_t *config,
  963. uint32_t start,
  964. uint32_t lengthInBytes,
  965. flash_protection_state_t *protection_state);
  966. /*!
  967. * @brief Returns the access state of the desired flash area via the pointer passed into the function.
  968. *
  969. * This function retrieves the current flash access status for a given
  970. * flash area as determined by the start address and length.
  971. *
  972. * @param config A pointer to the storage for the driver runtime state.
  973. * @param start The start address of the desired flash memory to be checked. Must be word-aligned.
  974. * @param lengthInBytes The length, given in bytes (not words or long-words),
  975. * to be checked. Must be word-aligned.
  976. * @param access_state A pointer to the value returned for the current
  977. * access status code for the desired flash area.
  978. *
  979. * @retval #kStatus_FLASH_Success API was executed successfully.
  980. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  981. * @retval #kStatus_FLASH_AlignmentError The parameter is not aligned to the specified baseline.
  982. * @retval #kStatus_FLASH_AddressError The address is out of range.
  983. */
  984. status_t FLASH_IsExecuteOnly(flash_config_t *config,
  985. uint32_t start,
  986. uint32_t lengthInBytes,
  987. flash_execute_only_access_state_t *access_state);
  988. /*@}*/
  989. /*!
  990. * @name Properties
  991. * @{
  992. */
  993. /*!
  994. * @brief Returns the desired flash property.
  995. *
  996. * @param config A pointer to the storage for the driver runtime state.
  997. * @param whichProperty The desired property from the list of properties in
  998. * enum flash_property_tag_t
  999. * @param value A pointer to the value returned for the desired flash property.
  1000. *
  1001. * @retval #kStatus_FLASH_Success API was executed successfully.
  1002. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1003. * @retval #kStatus_FLASH_UnknownProperty An unknown property tag.
  1004. */
  1005. status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value);
  1006. /*!
  1007. * @brief Sets the desired flash property.
  1008. *
  1009. * @param config A pointer to the storage for the driver runtime state.
  1010. * @param whichProperty The desired property from the list of properties in
  1011. * enum flash_property_tag_t
  1012. * @param value A to set for the desired flash property.
  1013. *
  1014. * @retval #kStatus_FLASH_Success API was executed successfully.
  1015. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1016. * @retval #kStatus_FLASH_UnknownProperty An unknown property tag.
  1017. * @retval #kStatus_FLASH_InvalidPropertyValue An invalid property value.
  1018. * @retval #kStatus_FLASH_ReadOnlyProperty An read-only property tag.
  1019. */
  1020. status_t FLASH_SetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t value);
  1021. /*@}*/
  1022. /*!
  1023. * @name FlexRAM
  1024. * @{
  1025. */
  1026. /*!
  1027. * @brief Sets the FlexRAM function command.
  1028. *
  1029. * @param config A pointer to the storage for the driver runtime state.
  1030. * @param option The option used to set the work mode of FlexRAM.
  1031. *
  1032. * @retval #kStatus_FLASH_Success API was executed successfully.
  1033. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1034. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  1035. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  1036. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  1037. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  1038. */
  1039. #if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
  1040. status_t FLASH_SetFlexramFunction(flash_config_t *config, flash_flexram_function_option_t option);
  1041. #endif
  1042. /*@}*/
  1043. /*!
  1044. * @name Swap
  1045. * @{
  1046. */
  1047. /*!
  1048. * @brief Configures the Swap function or checks the the swap state of the Flash module.
  1049. *
  1050. * @param config A pointer to the storage for the driver runtime state.
  1051. * @param address Address used to configure the flash Swap function.
  1052. * @param option The possible option used to configure Flash Swap function or check the flash Swap status
  1053. * @param returnInfo A pointer to the data which is used to return the information of flash Swap.
  1054. *
  1055. * @retval #kStatus_FLASH_Success API was executed successfully.
  1056. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1057. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
  1058. * @retval #kStatus_FLASH_SwapIndicatorAddressError Swap indicator address is invalid.
  1059. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  1060. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  1061. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  1062. * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
  1063. */
  1064. #if defined(FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD) && FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
  1065. status_t FLASH_SwapControl(flash_config_t *config,
  1066. uint32_t address,
  1067. flash_swap_control_option_t option,
  1068. flash_swap_state_config_t *returnInfo);
  1069. #endif
  1070. /*!
  1071. * @brief Swaps the lower half flash with the higher half flash.
  1072. *
  1073. * @param config A pointer to the storage for the driver runtime state.
  1074. * @param address Address used to configure the flash swap function
  1075. * @param option The possible option used to configure the Flash Swap function or check the flash Swap status.
  1076. *
  1077. * @retval #kStatus_FLASH_Success API was executed successfully.
  1078. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1079. * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
  1080. * @retval #kStatus_FLASH_SwapIndicatorAddressError Swap indicator address is invalid.
  1081. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  1082. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  1083. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  1084. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  1085. * @retval #kStatus_FLASH_SwapSystemNotInUninitialized Swap system is not in an uninitialzed state.
  1086. */
  1087. #if defined(FSL_FEATURE_FLASH_HAS_PFLASH_BLOCK_SWAP) && FSL_FEATURE_FLASH_HAS_PFLASH_BLOCK_SWAP
  1088. status_t FLASH_Swap(flash_config_t *config, uint32_t address, flash_swap_function_option_t option);
  1089. #endif
  1090. /*!
  1091. * @name FlexNVM
  1092. * @{
  1093. */
  1094. /*!
  1095. * @brief Prepares the FlexNVM block for use as data flash, EEPROM backup, or a combination of both and initializes the
  1096. * FlexRAM.
  1097. *
  1098. * @param config Pointer to storage for the driver runtime state.
  1099. * @param option The option used to set FlexRAM load behavior during reset.
  1100. * @param eepromDataSizeCode Determines the amount of FlexRAM used in each of the available EEPROM subsystems.
  1101. * @param flexnvmPartitionCode Specifies how to split the FlexNVM block between data flash memory and EEPROM backup
  1102. * memory supporting EEPROM functions.
  1103. *
  1104. * @retval #kStatus_FLASH_Success API was executed successfully.
  1105. * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided.
  1106. * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  1107. * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
  1108. * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
  1109. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  1110. */
  1111. #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD
  1112. status_t FLASH_ProgramPartition(flash_config_t *config,
  1113. flash_partition_flexram_load_option_t option,
  1114. uint32_t eepromDataSizeCode,
  1115. uint32_t flexnvmPartitionCode);
  1116. #endif
  1117. /*@}*/
  1118. /*!
  1119. * @name Flash Protection Utilities
  1120. * @{
  1121. */
  1122. /*!
  1123. * @brief Sets the PFlash Protection to the intended protection status.
  1124. *
  1125. * @param config A pointer to storage for the driver runtime state.
  1126. * @param protectStatus The expected protect status to set to the PFlash protection register. Each bit is
  1127. * corresponding to protection of 1/32(64) of the total PFlash. The least significant bit is corresponding to the lowest
  1128. * address area of PFlash. The most significant bit is corresponding to the highest address area of PFlash. There are
  1129. * two possible cases as shown below:
  1130. * 0: this area is protected.
  1131. * 1: this area is unprotected.
  1132. *
  1133. * @retval #kStatus_FLASH_Success API was executed successfully.
  1134. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1135. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  1136. */
  1137. status_t FLASH_PflashSetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus);
  1138. /*!
  1139. * @brief Gets the PFlash protection status.
  1140. *
  1141. * @param config A pointer to the storage for the driver runtime state.
  1142. * @param protectStatus Protect status returned by the PFlash IP. Each bit is corresponding to the protection of
  1143. * 1/32(64)
  1144. * of the
  1145. * total PFlash. The least significant bit corresponds to the lowest address area of the PFlash. The most significant
  1146. * bit corresponds to the highest address area of PFlash. There are two possible cases as shown below:
  1147. * 0: this area is protected.
  1148. * 1: this area is unprotected.
  1149. *
  1150. * @retval #kStatus_FLASH_Success API was executed successfully.
  1151. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1152. */
  1153. status_t FLASH_PflashGetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus);
  1154. /*!
  1155. * @brief Sets the DFlash protection to the intended protection status.
  1156. *
  1157. * @param config A pointer to the storage for the driver runtime state.
  1158. * @param protectStatus The expected protect status to set to the DFlash protection register. Each bit
  1159. * corresponds to the protection of the 1/8 of the total DFlash. The least significant bit corresponds to the lowest
  1160. * address area of the DFlash. The most significant bit corresponds to the highest address area of the DFlash. There
  1161. * are
  1162. * two possible cases as shown below:
  1163. * 0: this area is protected.
  1164. * 1: this area is unprotected.
  1165. *
  1166. * @retval #kStatus_FLASH_Success API was executed successfully.
  1167. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1168. * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
  1169. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  1170. */
  1171. #if FLASH_SSD_IS_FLEXNVM_ENABLED
  1172. status_t FLASH_DflashSetProtection(flash_config_t *config, uint8_t protectStatus);
  1173. #endif
  1174. /*!
  1175. * @brief Gets the DFlash protection status.
  1176. *
  1177. * @param config A pointer to the storage for the driver runtime state.
  1178. * @param protectStatus DFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the
  1179. * 1/8 of
  1180. * the total DFlash. The least significant bit corresponds to the lowest address area of the DFlash. The most
  1181. * significant bit corresponds to the highest address area of the DFlash, and so on. There are two possible cases as
  1182. * below:
  1183. * 0: this area is protected.
  1184. * 1: this area is unprotected.
  1185. *
  1186. * @retval #kStatus_FLASH_Success API was executed successfully.
  1187. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1188. * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
  1189. */
  1190. #if FLASH_SSD_IS_FLEXNVM_ENABLED
  1191. status_t FLASH_DflashGetProtection(flash_config_t *config, uint8_t *protectStatus);
  1192. #endif
  1193. /*!
  1194. * @brief Sets the EEPROM protection to the intended protection status.
  1195. *
  1196. * @param config A pointer to the storage for the driver runtime state.
  1197. * @param protectStatus The expected protect status to set to the EEPROM protection register. Each bit
  1198. * corresponds to the protection of the 1/8 of the total EEPROM. The least significant bit corresponds to the lowest
  1199. * address area of the EEPROM. The most significant bit corresponds to the highest address area of EEPROM, and so on.
  1200. * There are two possible cases as shown below:
  1201. * 0: this area is protected.
  1202. * 1: this area is unprotected.
  1203. *
  1204. * @retval #kStatus_FLASH_Success API was executed successfully.
  1205. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1206. * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
  1207. * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
  1208. */
  1209. #if FLASH_SSD_IS_FLEXNVM_ENABLED
  1210. status_t FLASH_EepromSetProtection(flash_config_t *config, uint8_t protectStatus);
  1211. #endif
  1212. /*!
  1213. * @brief Gets the DFlash protection status.
  1214. *
  1215. * @param config A pointer to the storage for the driver runtime state.
  1216. * @param protectStatus DFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the
  1217. * 1/8 of
  1218. * the total EEPROM. The least significant bit corresponds to the lowest address area of the EEPROM. The most
  1219. * significant bit corresponds to the highest address area of the EEPROM. There are two possible cases as below:
  1220. * 0: this area is protected.
  1221. * 1: this area is unprotected.
  1222. *
  1223. * @retval #kStatus_FLASH_Success API was executed successfully.
  1224. * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
  1225. * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
  1226. */
  1227. #if FLASH_SSD_IS_FLEXNVM_ENABLED
  1228. status_t FLASH_EepromGetProtection(flash_config_t *config, uint8_t *protectStatus);
  1229. #endif
  1230. /*@}*/
  1231. /*@}*/
  1232. /*!
  1233. * @name Flash Speculation Utilities
  1234. * @{
  1235. */
  1236. /*!
  1237. * @brief Sets the PFlash prefetch speculation to the intended speculation status.
  1238. *
  1239. * @param speculationStatus The expected protect status to set to the PFlash protection register. Each bit is
  1240. * @retval #kStatus_FLASH_Success API was executed successfully.
  1241. * @retval #kStatus_FLASH_InvalidSpeculationOption An invalid speculation option argument is provided.
  1242. */
  1243. status_t FLASH_PflashSetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus);
  1244. /*!
  1245. * @brief Gets the PFlash prefetch speculation status.
  1246. *
  1247. * @param speculationStatus Speculation status returned by the PFlash IP.
  1248. * @retval #kStatus_FLASH_Success API was executed successfully.
  1249. */
  1250. status_t FLASH_PflashGetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus);
  1251. /*@}*/
  1252. #if defined(__cplusplus)
  1253. }
  1254. #endif
  1255. /*! @}*/
  1256. #endif /* _FSL_FLASH_H_ */