fsl_romapi.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. /*
  2. * Copyright 2017-2020 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef _FSL_ROMAPI_H_
  8. #define _FSL_ROMAPI_H_
  9. #include "fsl_common.h"
  10. /*!
  11. * @addtogroup romapi
  12. * @{
  13. */
  14. /*! @brief ROMAPI version 1.1.0. */
  15. #define FSL_ROM_ROMAPI_VERSION (MAKE_VERSION(1U, 1U, 0U))
  16. /*! @brief ROM FLEXSPI NOR driver version 1.4.0. */
  17. #define FSL_ROM_FLEXSPINOR_DRIVER_VERSION (MAKE_VERSION(1U, 4U, 0U))
  18. /*!
  19. * @name Common ROMAPI fearures info defines
  20. * @{
  21. */
  22. /* @brief ROM has FLEXSPI NOR API. */
  23. #define FSL_ROM_HAS_FLEXSPINOR_API (1)
  24. /* @brief ROM has run bootloader API. */
  25. #define FSL_ROM_HAS_RUNBOOTLOADER_API (0)
  26. /* @brief ROM has FLEXSPI NOR get config API. */
  27. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_GET_CONFIG (0)
  28. /* @brief ROM has flash init API. */
  29. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_FLASH_INIT (1)
  30. /* @brief ROM has erase API. */
  31. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE (1)
  32. /* @brief ROM has erase sector API. */
  33. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_SECTOR (1)
  34. /* @brief ROM has erase block API. */
  35. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_BLOCK (1)
  36. /* @brief ROM has erase all API. */
  37. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_ALL (0)
  38. /* @brief ROM has page program API. */
  39. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_PAGE_PROGRAM (1)
  40. /* @brief ROM has update lut API. */
  41. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_UPDATE_LUT (1)
  42. /* @brief ROM has FLEXSPI command API. */
  43. #define FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_CMD_XFER (1)
  44. /*@}*/
  45. #define kROM_StatusGroup_FLEXSPI 60U /*!< ROM FLEXSPI status group number.*/
  46. #define kROM_StatusGroup_FLEXSPINOR 200U /*!< ROM FLEXSPI NOR status group number.*/
  47. #define FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
  48. (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
  49. FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
  50. /*! @brief Generate bit mask */
  51. #define FSL_ROM_FLEXSPI_BITMASK(bit_offset) (1U << (bit_offset))
  52. /*! @brief FLEXSPI memory config block related defintions */
  53. #define FLEXSPI_CFG_BLK_TAG (0x42464346UL) /*!< ascii "FCFB" Big Endian */
  54. #define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) /*!< V1.4.0 */
  55. #define CMD_SDR 0x01U
  56. #define CMD_DDR 0x21U
  57. #define RADDR_SDR 0x02U
  58. #define RADDR_DDR 0x22U
  59. #define CADDR_SDR 0x03U
  60. #define CADDR_DDR 0x23U
  61. #define MODE1_SDR 0x04U
  62. #define MODE1_DDR 0x24U
  63. #define MODE2_SDR 0x05U
  64. #define MODE2_DDR 0x25U
  65. #define MODE4_SDR 0x06U
  66. #define MODE4_DDR 0x26U
  67. #define MODE8_SDR 0x07U
  68. #define MODE8_DDR 0x27U
  69. #define WRITE_SDR 0x08U
  70. #define WRITE_DDR 0x28U
  71. #define READ_SDR 0x09U
  72. #define READ_DDR 0x29U
  73. #define LEARN_SDR 0x0AU
  74. #define LEARN_DDR 0x2AU
  75. #define DATSZ_SDR 0x0BU
  76. #define DATSZ_DDR 0x2BU
  77. #define DUMMY_SDR 0x0CU
  78. #define DUMMY_DDR 0x2CU
  79. #define DUMMY_RWDS_SDR 0x0DU
  80. #define DUMMY_RWDS_DDR 0x2DU
  81. #define JMP_ON_CS 0x1FU
  82. #define STOP 0U
  83. #define FLEXSPI_1PAD 0U
  84. #define FLEXSPI_2PAD 1U
  85. #define FLEXSPI_4PAD 2U
  86. #define FLEXSPI_8PAD 3U
  87. /*!
  88. * NOR LUT sequence index used for default LUT assignment
  89. * NOTE:
  90. * The will take effect if the lut sequences are not customized.
  91. */
  92. #define NOR_CMD_LUT_SEQ_IDX_READ 0U /*!< READ LUT sequence id in lookupTable stored in config block */
  93. #define NOR_CMD_LUT_SEQ_IDX_READSTATUS 1U /*!< Read Status LUT sequence id in lookupTable stored in config block */
  94. #define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
  95. 2U /*!< Read status DPI/QPI/OPI sequence id in lookupTable stored in config block */
  96. #define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE 3U /*!< Write Enable sequence id in lookupTable stored in config block */
  97. #define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
  98. 4U /*!< Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block */
  99. #define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5U /*!< Erase Sector sequence id in lookupTable stored in config block */
  100. #define NOR_CMD_LUT_SEQ_IDX_READID 7U
  101. #define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8U /*!< Erase Block sequence id in lookupTable stored in config block */
  102. #define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM 9U /*!< Program sequence id in lookupTable stored in config block */
  103. #define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11U /*!< Chip Erase sequence in lookupTable id stored in config block */
  104. #define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13U /*!< Read SFDP sequence in lookupTable id stored in config block */
  105. #define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
  106. 14U /*!< Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block */
  107. #define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
  108. 15U /*!< Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk */
  109. /*!
  110. * @name Support for init FLEXSPI NOR configuration
  111. * @{
  112. */
  113. /*! @brief Flash Pad Definitions */
  114. enum
  115. {
  116. kSerialFlash_1Pad = 1U,
  117. kSerialFlash_2Pads = 2U,
  118. kSerialFlash_4Pads = 4U,
  119. kSerialFlash_8Pads = 8U,
  120. };
  121. /*! @brief FLEXSPI clock configuration type */
  122. enum
  123. {
  124. kFLEXSPIClk_SDR, /*!< Clock configure for SDR mode */
  125. kFLEXSPIClk_DDR, /*!< Clock configurat for DDR mode */
  126. };
  127. /*! @brief FLEXSPI Read Sample Clock Source definition */
  128. typedef enum _flexspi_read_sample_clk
  129. {
  130. kFLEXSPIReadSampleClk_LoopbackInternally = 0U,
  131. kFLEXSPIReadSampleClk_LoopbackFromDqsPad = 1U,
  132. kFLEXSPIReadSampleClk_LoopbackFromSckPad = 2U,
  133. kFLEXSPIReadSampleClk_ExternalInputFromDqsPad = 3U,
  134. } flexspi_read_sample_clk_t;
  135. /*! @brief Flash Type Definition */
  136. enum
  137. {
  138. kFLEXSPIDeviceType_SerialNOR = 1U, /*!< Flash device is Serial NOR */
  139. };
  140. /*! @brief Flash Configuration Command Type */
  141. enum
  142. {
  143. kDeviceConfigCmdType_Generic, /*!< Generic command, for example: configure dummy cycles, drive strength, etc */
  144. kDeviceConfigCmdType_QuadEnable, /*!< Quad Enable command */
  145. kDeviceConfigCmdType_Spi2Xpi, /*!< Switch from SPI to DPI/QPI/OPI mode */
  146. kDeviceConfigCmdType_Xpi2Spi, /*!< Switch from DPI/QPI/OPI to SPI mode */
  147. kDeviceConfigCmdType_Spi2NoCmd, /*!< Switch to 0-4-4/0-8-8 mode */
  148. kDeviceConfigCmdType_Reset, /*!< Reset device command */
  149. };
  150. /*! @brief Defintions for FLEXSPI Serial Clock Frequency */
  151. typedef enum _flexspi_serial_clk_freq
  152. {
  153. kFLEXSPISerialClk_NoChange = 0U,
  154. kFLEXSPISerialClk_30MHz = 1U,
  155. kFLEXSPISerialClk_50MHz = 2U,
  156. kFLEXSPISerialClk_60MHz = 3U,
  157. kFLEXSPISerialClk_75MHz = 4U,
  158. kFLEXSPISerialClk_80MHz = 5U,
  159. kFLEXSPISerialClk_100MHz = 6U,
  160. kFLEXSPISerialClk_133MHz = 7U,
  161. kFLEXSPISerialClk_166MHz = 8U,
  162. kFLEXSPISerialClk_200MHz = 9U,
  163. } flexspi_serial_clk_freq_t;
  164. /*! @brief Misc feature bit definitions */
  165. enum
  166. {
  167. kFLEXSPIMiscOffset_DiffClkEnable = 0U, /*!< Bit for Differential clock enable */
  168. kFLEXSPIMiscOffset_Ck2Enable = 1U, /*!< Bit for CK2 enable */
  169. kFLEXSPIMiscOffset_ParallelEnable = 2U, /*!< Bit for Parallel mode enable */
  170. kFLEXSPIMiscOffset_WordAddressableEnable = 3U, /*!< Bit for Word Addressable enable */
  171. kFLEXSPIMiscOffset_SafeConfigFreqEnable = 4U, /*!< Bit for Safe Configuration Frequency enable */
  172. kFLEXSPIMiscOffset_PadSettingOverrideEnable = 5U, /*!< Bit for Pad setting override enable */
  173. kFLEXSPIMiscOffset_DdrModeEnable = 6U, /*!< Bit for DDR clock confiuration indication. */
  174. kFLEXSPIMiscOffset_UseValidTimeForAllFreq = 7U, /*!< Bit for DLLCR settings under all modes */
  175. };
  176. /*@}*/
  177. /*!
  178. * @name FLEXSPI NOR Configuration
  179. * @{
  180. */
  181. /*! @brief FLEXSPI LUT Sequence structure */
  182. typedef struct _flexspi_lut_seq
  183. {
  184. uint8_t seqNum; /*!< Sequence Number, valid number: 1-16 */
  185. uint8_t seqId; /*!< Sequence Index, valid number: 0-15 */
  186. uint16_t reserved;
  187. } flexspi_lut_seq_t;
  188. typedef struct
  189. {
  190. uint8_t time_100ps; /*!< Data valid time, in terms of 100ps */
  191. uint8_t delay_cells; /*!< Data valid time, in terms of delay cells */
  192. } flexspi_dll_time_t;
  193. /*! @brief FLEXSPI Memory Configuration Block */
  194. typedef struct _flexspi_mem_config
  195. {
  196. uint32_t tag; /*!< [0x000-0x003] Tag, fixed value 0x42464346UL */
  197. uint32_t version; /*!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix */
  198. uint32_t reserved0; /*!< [0x008-0x00b] Reserved for future use */
  199. uint8_t readSampleClkSrc; /*!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3 */
  200. uint8_t csHoldTime; /*!< [0x00d-0x00d] Data hold time, default value: 3 */
  201. uint8_t csSetupTime; /*!< [0x00e-0x00e] Date setup time, default value: 3 */
  202. uint8_t columnAddressWidth; /*!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
  203. Serial NAND, need to refer to datasheet */
  204. uint8_t deviceModeCfgEnable; /*!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable */
  205. uint8_t deviceModeType; /*!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
  206. Generic configuration, etc. */
  207. uint16_t waitTimeCfgCommands; /*!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
  208. DPI/QPI/OPI switch or reset command */
  209. flexspi_lut_seq_t deviceModeSeq; /*!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
  210. sequence number, [31:16] Reserved */
  211. uint32_t deviceModeArg; /*!< [0x018-0x01b] Argument/Parameter for device configuration */
  212. uint8_t configCmdEnable; /*!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable */
  213. uint8_t configModeType[3]; /*!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe */
  214. flexspi_lut_seq_t
  215. configCmdSeqs[3]; /*!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq */
  216. uint32_t reserved1; /*!< [0x02c-0x02f] Reserved for future use */
  217. uint32_t configCmdArgs[3]; /*!< [0x030-0x03b] Arguments/Parameters for device Configuration commands */
  218. uint32_t reserved2; /*!< [0x03c-0x03f] Reserved for future use */
  219. uint32_t controllerMiscOption; /*!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
  220. details */
  221. uint8_t deviceType; /*!< [0x044-0x044] Device Type: See Flash Type Definition for more details */
  222. uint8_t sflashPadType; /*!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal */
  223. uint8_t serialClkFreq; /*!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
  224. Chapter for more details */
  225. uint8_t
  226. lutCustomSeqEnable; /*!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
  227. be done using 1 LUT sequence, currently, only applicable to HyperFLASH */
  228. uint32_t reserved3[2]; /*!< [0x048-0x04f] Reserved for future use */
  229. uint32_t sflashA1Size; /*!< [0x050-0x053] Size of Flash connected to A1 */
  230. uint32_t sflashA2Size; /*!< [0x054-0x057] Size of Flash connected to A2 */
  231. uint32_t sflashB1Size; /*!< [0x058-0x05b] Size of Flash connected to B1 */
  232. uint32_t sflashB2Size; /*!< [0x05c-0x05f] Size of Flash connected to B2 */
  233. uint32_t csPadSettingOverride; /*!< [0x060-0x063] CS pad setting override value */
  234. uint32_t sclkPadSettingOverride; /*!< [0x064-0x067] SCK pad setting override value */
  235. uint32_t dataPadSettingOverride; /*!< [0x068-0x06b] data pad setting override value */
  236. uint32_t dqsPadSettingOverride; /*!< [0x06c-0x06f] DQS pad setting override value */
  237. uint32_t timeoutInMs; /*!< [0x070-0x073] Timeout threshold for read status command */
  238. uint32_t commandInterval; /*!< [0x074-0x077] CS deselect interval between two commands */
  239. flexspi_dll_time_t dataValidTime[2]; /*!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B */
  240. uint16_t busyOffset; /*!< [0x07c-0x07d] Busy offset, valid value: 0-31 */
  241. uint16_t busyBitPolarity; /*!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
  242. busy flag is 0 when flash device is busy */
  243. uint32_t lookupTable[64]; /*!< [0x080-0x17f] Lookup table holds Flash command sequences */
  244. flexspi_lut_seq_t lutCustomSeq[12]; /*!< [0x180-0x1af] Customizable LUT Sequences */
  245. uint32_t reserved4[4]; /*!< [0x1b0-0x1bf] Reserved for future use */
  246. } flexspi_mem_config_t;
  247. /*! @brief Serial NOR configuration block */
  248. typedef struct _flexspi_nor_config
  249. {
  250. flexspi_mem_config_t memConfig; /*!< Common memory configuration info via FLEXSPI */
  251. uint32_t pageSize; /*!< Page size of Serial NOR */
  252. uint32_t sectorSize; /*!< Sector size of Serial NOR */
  253. uint8_t ipcmdSerialClkFreq; /*!< Clock frequency for IP command */
  254. uint8_t isUniformBlockSize; /*!< Sector/Block size is the same */
  255. uint8_t isDataOrderSwapped; /*!< Data order (D0, D1, D2, D3) is swapped (D1,D0, D3, D2) */
  256. uint8_t reserved0[1]; /*!< Reserved for future use */
  257. uint8_t serialNorType; /*!< Serial NOR Flash type: 0/1/2/3 */
  258. uint8_t needExitNoCmdMode; /*!< Need to exit NoCmd mode before other IP command */
  259. uint8_t halfClkForNonReadCmd; /*!< Half the Serial Clock for non-read command: true/false */
  260. uint8_t needRestoreNoCmdMode; /*!< Need to Restore NoCmd mode after IP commmand execution */
  261. uint32_t blockSize; /*!< Block size */
  262. uint32_t reserve2[11]; /*!< Reserved for future use */
  263. } flexspi_nor_config_t;
  264. /*@}*/
  265. /*! @brief Manufacturer ID */
  266. enum
  267. {
  268. kSerialFlash_ISSI_ManufacturerID = 0x9DU, /*!< Manufacturer ID of the ISSI serial flash */
  269. kSerialFlash_Adesto_ManufacturerID = 0x1F, /*!< Manufacturer ID of the Adesto Technologies serial flash*/
  270. kSerialFlash_Winbond_ManufacturerID = 0xEFU, /*!< Manufacturer ID of the Winbond serial flash */
  271. kSerialFlash_Cypress_ManufacturerID = 0x01U, /*!< Manufacturer ID for Cypress */
  272. };
  273. /*! @brief ROM FLEXSPI NOR flash status */
  274. enum _flexspi_nor_status
  275. {
  276. kStatus_ROM_FLEXSPI_SequenceExecutionTimeout =
  277. MAKE_STATUS(kROM_StatusGroup_FLEXSPI, 0), /*!< Status for Sequence Execution timeout */
  278. kStatus_ROM_FLEXSPI_InvalidSequence = MAKE_STATUS(kROM_StatusGroup_FLEXSPI, 1), /*!< Status for Invalid Sequence */
  279. kStatus_ROM_FLEXSPI_DeviceTimeout = MAKE_STATUS(kROM_StatusGroup_FLEXSPI, 2), /*!< Status for Device timeout */
  280. kStatus_FLEXSPINOR_DTRRead_DummyProbeFailed =
  281. MAKE_STATUS(kROM_StatusGroup_FLEXSPINOR, 10), /*!< Status for DDR Read dummy probe failure */
  282. kStatus_ROM_FLEXSPINOR_SFDP_NotFound =
  283. MAKE_STATUS(kROM_StatusGroup_FLEXSPINOR, 7), /*!< Status for SFDP read failure */
  284. kStatus_ROM_FLEXSPINOR_Flash_NotFound =
  285. MAKE_STATUS(kROM_StatusGroup_FLEXSPINOR, 9), /*!< Status for Flash detection failure */
  286. };
  287. typedef enum _flexspi_operation
  288. {
  289. kFLEXSPIOperation_Command, /*!< FLEXSPI operation: Only command, both TX and RX buffer are ignored. */
  290. kFLEXSPIOperation_Config, /*!< FLEXSPI operation: Configure device mode, the TX FIFO size is fixed in LUT. */
  291. kFLEXSPIOperation_Write, /*!< FLEXSPI operation: Write, only TX buffer is effective */
  292. kFLEXSPIOperation_Read, /*!< FLEXSPI operation: Read, only Rx Buffer is effective. */
  293. kFLEXSPIOperation_End = kFLEXSPIOperation_Read,
  294. } flexspi_operation_t;
  295. /*! @brief FLEXSPI Transfer Context */
  296. typedef struct _flexspi_xfer
  297. {
  298. flexspi_operation_t operation; /*!< FLEXSPI operation */
  299. uint32_t baseAddress; /*!< FLEXSPI operation base address */
  300. uint32_t seqId; /*!< Sequence Id */
  301. uint32_t seqNum; /*!< Sequence Number */
  302. bool isParallelModeEnable; /*!< Is a parallel transfer */
  303. uint32_t *txBuffer; /*!< Tx buffer */
  304. uint32_t txSize; /*!< Tx size in bytes */
  305. uint32_t *rxBuffer; /*!< Rx buffer */
  306. uint32_t rxSize; /*!< Rx size in bytes */
  307. } flexspi_xfer_t;
  308. #ifdef __cplusplus
  309. extern "C" {
  310. #endif
  311. #if defined(FSL_FEATURE_BOOT_ROM_HAS_ROMAPI) && FSL_FEATURE_BOOT_ROM_HAS_ROMAPI
  312. /*!
  313. * @name Initialization
  314. * @{
  315. */
  316. /*!
  317. * @brief Initialize Serial NOR devices via FLEXSPI
  318. *
  319. * This function checks and initializes the FLEXSPI module for the other FLEXSPI APIs.
  320. *
  321. * @param instance storage the instance of FLEXSPI.
  322. * @param config A pointer to the storage for the driver runtime state.
  323. *
  324. * @retval kStatus_Success Api was executed succesfuly.
  325. * @retval kStatus_InvalidArgument A invalid argument is provided.
  326. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  327. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  328. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout
  329. */
  330. status_t ROM_FLEXSPI_NorFlash_Init(uint32_t instance, flexspi_nor_config_t *config);
  331. /*@}*/
  332. /*!
  333. * @name Programming
  334. * @{
  335. */
  336. /*!
  337. * @brief Program data to Serial NOR via FLEXSPI.
  338. *
  339. * This function programs the NOR flash memory with the dest address for a given
  340. * flash area as determined by the dst address and the length.
  341. *
  342. * @param instance storage the instance of FLEXSPI.
  343. * @param config A pointer to the storage for the driver runtime state.
  344. * @param dstAddr A pointer to the desired flash memory to be programmed.
  345. * NOTE:
  346. * It is recommended that use page aligned access;
  347. * If the dstAddr is not aligned to page,the driver automatically
  348. * aligns address down with the page address.
  349. * @param src A pointer to the source buffer of data that is to be programmed
  350. * into the NOR flash.
  351. *
  352. * @retval kStatus_Success Api was executed succesfuly.
  353. * @retval kStatus_InvalidArgument A invalid argument is provided.
  354. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  355. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  356. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout
  357. */
  358. status_t ROM_FLEXSPI_NorFlash_ProgramPage(uint32_t instance,
  359. flexspi_nor_config_t *config,
  360. uint32_t dstAddr,
  361. const uint32_t *src);
  362. /*@}*/
  363. /*!
  364. * @name Erasing
  365. * @{
  366. */
  367. #if defined(FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_SECTOR) && FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_SECTOR
  368. /*!
  369. * @brief Erase one sector specified by address
  370. *
  371. * This function erases one of NOR flash sectors based on the desired address.
  372. *
  373. * @param instance storage the index of FLEXSPI.
  374. * @param config A pointer to the storage for the driver runtime state.
  375. * @param address The start address of the desired NOR flash memory to be erased.
  376. * NOTE:
  377. * It is recommended that use sector-aligned access nor device;
  378. * If dstAddr is not aligned with the sector,The driver automatically
  379. * aligns address down with the sector address.
  380. *
  381. * @retval kStatus_Success Api was executed succesfuly.
  382. * @retval kStatus_InvalidArgument A invalid argument is provided.
  383. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  384. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  385. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout
  386. */
  387. status_t ROM_FLEXSPI_NorFlash_EraseSector(uint32_t instance, flexspi_nor_config_t *config, uint32_t address);
  388. #endif /* FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_SECTOR */
  389. #if defined(FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_BLOCK) && FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_BLOCK
  390. /*!
  391. * @brief Erase one block specified by address
  392. *
  393. * This function erases one block of NOR flash based on the desired address.
  394. *
  395. * @param instance storage the index of FLEXSPI.
  396. * @param config A pointer to the storage for the driver runtime state.
  397. * @param start The start address of the desired NOR flash memory to be erased.
  398. * NOTE:
  399. * It is recommended that use block-aligned access nor device;
  400. * If dstAddr is not aligned with the block,The driver automatically
  401. * aligns address down with the block address.
  402. *
  403. * @retval kStatus_Success Api was executed succesfuly.
  404. * @retval kStatus_InvalidArgument A invalid argument is provided.
  405. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  406. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  407. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout
  408. */
  409. status_t ROM_FLEXSPI_NorFlash_EraseBlock(uint32_t instance, flexspi_nor_config_t *config, uint32_t start);
  410. #endif /* FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_ERASE_BLOCK */
  411. /*!
  412. * @brief Erase Flash Region specified by address and length
  413. *
  414. * This function erases the appropriate number of flash sectors based on the
  415. * desired start address and length.
  416. *
  417. * @param instance storage the index of FLEXSPI.
  418. * @param config A pointer to the storage for the driver runtime state.
  419. * @param start The start address of the desired NOR flash memory to be erased.
  420. * NOTE:
  421. * It is recommended that use sector-aligned access nor device;
  422. * If dstAddr is not aligned with the sector,the driver automatically
  423. * aligns address down with the sector address.
  424. * @param length The length, given in bytes to be erased.
  425. * NOTE:
  426. * It is recommended that use sector-aligned access nor device;
  427. * If length is not aligned with the sector,the driver automatically
  428. * aligns up with the sector.
  429. * @retval kStatus_Success Api was executed succesfuly.
  430. * @retval kStatus_InvalidArgument A invalid argument is provided.
  431. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  432. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  433. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout
  434. */
  435. status_t ROM_FLEXSPI_NorFlash_Erase(uint32_t instance, flexspi_nor_config_t *config, uint32_t start, uint32_t length);
  436. /*@}*/
  437. /*!
  438. * @name Command
  439. * @{
  440. */
  441. #if defined(FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_CMD_XFER) && FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_CMD_XFER
  442. /*!
  443. * @brief FLEXSPI command
  444. *
  445. * This function is used to perform the command write sequence to the NOR device.
  446. *
  447. * @param instance storage the index of FLEXSPI.
  448. * @param xfer A pointer to the storage FLEXSPI Transfer Context.
  449. *
  450. * @retval kStatus_Success Api was executed succesfuly.
  451. * @retval kStatus_InvalidArgument A invalid argument is provided.
  452. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  453. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  454. */
  455. status_t ROM_FLEXSPI_NorFlash_CommandXfer(uint32_t instance, flexspi_xfer_t *xfer);
  456. #endif /* FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_CMD_XFER */
  457. /*@}*/
  458. /*!
  459. * @name UpdateLut
  460. * @{
  461. */
  462. #if defined(FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_UPDATE_LUT) && FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_UPDATE_LUT
  463. /*!
  464. * @brief Configure FLEXSPI Lookup table
  465. *
  466. * @param instance storage the index of FLEXSPI.
  467. * @param seqIndex storage the sequence Id.
  468. * @param lutBase A pointer to the look-up-table for command sequences.
  469. * @param seqNumber storage sequence number.
  470. *
  471. * @retval kStatus_Success Api was executed succesfuly.
  472. * @retval kStatus_InvalidArgument A invalid argument is provided.
  473. * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided.
  474. * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout.
  475. */
  476. status_t ROM_FLEXSPI_NorFlash_UpdateLut(uint32_t instance,
  477. uint32_t seqIndex,
  478. const uint32_t *lutBase,
  479. uint32_t seqNumber);
  480. #endif /* FSL_ROM_FLEXSPINOR_API_HAS_FEATURE_UPDATE_LUT */
  481. /*@}*/
  482. /*!
  483. * @name ClearCache
  484. * @{
  485. */
  486. /*!
  487. * @brief Software reset for the FLEXSPI logic.
  488. *
  489. * This function sets the software reset flags for both AHB and buffer domain and
  490. * resets both AHB buffer and also IP FIFOs.
  491. *
  492. * @param instance storage the index of FLEXSPI.
  493. */
  494. void ROM_FLEXSPI_NorFlash_ClearCache(uint32_t instance);
  495. /*@}*/
  496. #endif /* FSL_FEATURE_BOOT_ROM_HAS_ROMAPI */
  497. #ifdef __cplusplus
  498. }
  499. #endif
  500. /*! @}*/
  501. #endif /* _FSL_ROMAPI_H_ */