Driver_NAND.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /*
  2. * Copyright (c) 2013-2020 ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * $Date: 31. March 2020
  19. * $Revision: V2.4
  20. *
  21. * Project: NAND Flash Driver definitions
  22. */
  23. /* History:
  24. * Version 2.4
  25. * Removed volatile from ARM_NAND_STATUS
  26. * Version 2.3
  27. * Extended ARM_NAND_ECC_INFO structure
  28. * Version 2.2
  29. * ARM_NAND_STATUS made volatile
  30. * Version 2.1
  31. * Updated ARM_NAND_ECC_INFO structure and ARM_NAND_ECC_xxx definitions
  32. * Version 2.0
  33. * New simplified driver:
  34. * complexity moved to upper layer (command agnostic)
  35. * Added support for:
  36. * NV-DDR & NV-DDR2 Interface (ONFI specification)
  37. * VCC, VCCQ and VPP Power Supply Control
  38. * WP (Write Protect) Control
  39. * Version 1.11
  40. * Changed prefix ARM_DRV -> ARM_DRIVER
  41. * Version 1.10
  42. * Namespace prefix ARM_ added
  43. * Version 1.00
  44. * Initial release
  45. */
  46. #ifndef DRIVER_NAND_H_
  47. #define DRIVER_NAND_H_
  48. #ifdef __cplusplus
  49. extern "C"
  50. {
  51. #endif
  52. #include "Driver_Common.h"
  53. #define ARM_NAND_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2,4) /* API version */
  54. #define _ARM_Driver_NAND_(n) Driver_NAND##n
  55. #define ARM_Driver_NAND_(n) _ARM_Driver_NAND_(n)
  56. /****** NAND Device Power *****/
  57. #define ARM_NAND_POWER_VCC_Pos 0
  58. #define ARM_NAND_POWER_VCC_Msk (0x07UL << ARM_NAND_POWER_VCC_Pos)
  59. #define ARM_NAND_POWER_VCC_OFF (0x01UL << ARM_NAND_POWER_VCC_Pos) ///< VCC Power off
  60. #define ARM_NAND_POWER_VCC_3V3 (0x02UL << ARM_NAND_POWER_VCC_Pos) ///< VCC = 3.3V
  61. #define ARM_NAND_POWER_VCC_1V8 (0x03UL << ARM_NAND_POWER_VCC_Pos) ///< VCC = 1.8V
  62. #define ARM_NAND_POWER_VCCQ_Pos 3
  63. #define ARM_NAND_POWER_VCCQ_Msk (0x07UL << ARM_NAND_POWER_VCCQ_Pos)
  64. #define ARM_NAND_POWER_VCCQ_OFF (0x01UL << ARM_NAND_POWER_VCCQ_Pos) ///< VCCQ I/O Power off
  65. #define ARM_NAND_POWER_VCCQ_3V3 (0x02UL << ARM_NAND_POWER_VCCQ_Pos) ///< VCCQ = 3.3V
  66. #define ARM_NAND_POWER_VCCQ_1V8 (0x03UL << ARM_NAND_POWER_VCCQ_Pos) ///< VCCQ = 1.8V
  67. #define ARM_NAND_POWER_VPP_OFF (1UL << 6) ///< VPP off
  68. #define ARM_NAND_POWER_VPP_ON (1UL << 7) ///< VPP on
  69. /****** NAND Control Codes *****/
  70. #define ARM_NAND_BUS_MODE (0x01UL) ///< Set Bus Mode as specified with arg
  71. #define ARM_NAND_BUS_DATA_WIDTH (0x02UL) ///< Set Bus Data Width as specified with arg
  72. #define ARM_NAND_DRIVER_STRENGTH (0x03UL) ///< Set Driver Strength as specified with arg
  73. #define ARM_NAND_DEVICE_READY_EVENT (0x04UL) ///< Generate \ref ARM_NAND_EVENT_DEVICE_READY; arg: 0=disabled (default), 1=enabled
  74. #define ARM_NAND_DRIVER_READY_EVENT (0x05UL) ///< Generate \ref ARM_NAND_EVENT_DRIVER_READY; arg: 0=disabled (default), 1=enabled
  75. /*----- NAND Bus Mode (ONFI - Open NAND Flash Interface) -----*/
  76. #define ARM_NAND_BUS_INTERFACE_Pos 4
  77. #define ARM_NAND_BUS_INTERFACE_Msk (0x03UL << ARM_NAND_BUS_INTERFACE_Pos)
  78. #define ARM_NAND_BUS_SDR (0x00UL << ARM_NAND_BUS_INTERFACE_Pos) ///< Data Interface: SDR (Single Data Rate) - Traditional interface (default)
  79. #define ARM_NAND_BUS_DDR (0x01UL << ARM_NAND_BUS_INTERFACE_Pos) ///< Data Interface: NV-DDR (Double Data Rate)
  80. #define ARM_NAND_BUS_DDR2 (0x02UL << ARM_NAND_BUS_INTERFACE_Pos) ///< Data Interface: NV-DDR2 (Double Data Rate)
  81. #define ARM_NAND_BUS_TIMING_MODE_Pos 0
  82. #define ARM_NAND_BUS_TIMING_MODE_Msk (0x0FUL << ARM_NAND_BUS_TIMING_MODE_Pos)
  83. #define ARM_NAND_BUS_TIMING_MODE_0 (0x00UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 0 (default)
  84. #define ARM_NAND_BUS_TIMING_MODE_1 (0x01UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 1
  85. #define ARM_NAND_BUS_TIMING_MODE_2 (0x02UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 2
  86. #define ARM_NAND_BUS_TIMING_MODE_3 (0x03UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 3
  87. #define ARM_NAND_BUS_TIMING_MODE_4 (0x04UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 4 (SDR EDO capable)
  88. #define ARM_NAND_BUS_TIMING_MODE_5 (0x05UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 5 (SDR EDO capable)
  89. #define ARM_NAND_BUS_TIMING_MODE_6 (0x06UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 6 (NV-DDR2 only)
  90. #define ARM_NAND_BUS_TIMING_MODE_7 (0x07UL << ARM_NAND_BUS_TIMING_MODE_Pos) ///< Timing Mode 7 (NV-DDR2 only)
  91. #define ARM_NAND_BUS_DDR2_DO_WCYC_Pos 8
  92. #define ARM_NAND_BUS_DDR2_DO_WCYC_Msk (0x0FUL << ARM_NAND_BUS_DDR2_DO_WCYC_Pos)
  93. #define ARM_NAND_BUS_DDR2_DO_WCYC_0 (0x00UL << ARM_NAND_BUS_DDR2_DO_WCYC_Pos) ///< DDR2 Data Output Warm-up cycles: 0 (default)
  94. #define ARM_NAND_BUS_DDR2_DO_WCYC_1 (0x01UL << ARM_NAND_BUS_DDR2_DO_WCYC_Pos) ///< DDR2 Data Output Warm-up cycles: 1
  95. #define ARM_NAND_BUS_DDR2_DO_WCYC_2 (0x02UL << ARM_NAND_BUS_DDR2_DO_WCYC_Pos) ///< DDR2 Data Output Warm-up cycles: 2
  96. #define ARM_NAND_BUS_DDR2_DO_WCYC_4 (0x03UL << ARM_NAND_BUS_DDR2_DO_WCYC_Pos) ///< DDR2 Data Output Warm-up cycles: 4
  97. #define ARM_NAND_BUS_DDR2_DI_WCYC_Pos 12
  98. #define ARM_NAND_BUS_DDR2_DI_WCYC_Msk (0x0FUL << ARM_NAND_BUS_DDR2_DI_WCYC_Pos)
  99. #define ARM_NAND_BUS_DDR2_DI_WCYC_0 (0x00UL << ARM_NAND_BUS_DDR2_DI_WCYC_Pos) ///< DDR2 Data Input Warm-up cycles: 0 (default)
  100. #define ARM_NAND_BUS_DDR2_DI_WCYC_1 (0x01UL << ARM_NAND_BUS_DDR2_DI_WCYC_Pos) ///< DDR2 Data Input Warm-up cycles: 1
  101. #define ARM_NAND_BUS_DDR2_DI_WCYC_2 (0x02UL << ARM_NAND_BUS_DDR2_DI_WCYC_Pos) ///< DDR2 Data Input Warm-up cycles: 2
  102. #define ARM_NAND_BUS_DDR2_DI_WCYC_4 (0x03UL << ARM_NAND_BUS_DDR2_DI_WCYC_Pos) ///< DDR2 Data Input Warm-up cycles: 4
  103. #define ARM_NAND_BUS_DDR2_VEN (1UL << 16) ///< DDR2 Enable external VREFQ as reference
  104. #define ARM_NAND_BUS_DDR2_CMPD (1UL << 17) ///< DDR2 Enable complementary DQS (DQS_c) signal
  105. #define ARM_NAND_BUS_DDR2_CMPR (1UL << 18) ///< DDR2 Enable complementary RE_n (RE_c) signal
  106. /*----- NAND Data Bus Width -----*/
  107. #define ARM_NAND_BUS_DATA_WIDTH_8 (0x00UL) ///< Bus Data Width: 8 bit (default)
  108. #define ARM_NAND_BUS_DATA_WIDTH_16 (0x01UL) ///< Bus Data Width: 16 bit
  109. /*----- NAND Driver Strength (ONFI - Open NAND Flash Interface) -----*/
  110. #define ARM_NAND_DRIVER_STRENGTH_18 (0x00UL) ///< Driver Strength 2.0x = 18 Ohms
  111. #define ARM_NAND_DRIVER_STRENGTH_25 (0x01UL) ///< Driver Strength 1.4x = 25 Ohms
  112. #define ARM_NAND_DRIVER_STRENGTH_35 (0x02UL) ///< Driver Strength 1.0x = 35 Ohms (default)
  113. #define ARM_NAND_DRIVER_STRENGTH_50 (0x03UL) ///< Driver Strength 0.7x = 50 Ohms
  114. /****** NAND ECC for Read/Write Data Mode and Sequence Execution Code *****/
  115. #define ARM_NAND_ECC_INDEX_Pos 0
  116. #define ARM_NAND_ECC_INDEX_Msk (0xFFUL << ARM_NAND_ECC_INDEX_Pos)
  117. #define ARM_NAND_ECC(n) ((n) & ARM_NAND_ECC_INDEX_Msk) ///< Select ECC
  118. #define ARM_NAND_ECC0 (1UL << 8) ///< Use ECC0 of selected ECC
  119. #define ARM_NAND_ECC1 (1UL << 9) ///< Use ECC1 of selected ECC
  120. /****** NAND Flag for Read/Write Data Mode and Sequence Execution Code *****/
  121. #define ARM_NAND_DRIVER_DONE_EVENT (1UL << 16) ///< Generate \ref ARM_NAND_EVENT_DRIVER_DONE
  122. /****** NAND Sequence Execution Code *****/
  123. #define ARM_NAND_CODE_SEND_CMD1 (1UL << 17) ///< Send Command 1
  124. #define ARM_NAND_CODE_SEND_ADDR_COL1 (1UL << 18) ///< Send Column Address 1
  125. #define ARM_NAND_CODE_SEND_ADDR_COL2 (1UL << 19) ///< Send Column Address 2
  126. #define ARM_NAND_CODE_SEND_ADDR_ROW1 (1UL << 20) ///< Send Row Address 1
  127. #define ARM_NAND_CODE_SEND_ADDR_ROW2 (1UL << 21) ///< Send Row Address 2
  128. #define ARM_NAND_CODE_SEND_ADDR_ROW3 (1UL << 22) ///< Send Row Address 3
  129. #define ARM_NAND_CODE_INC_ADDR_ROW (1UL << 23) ///< Auto-increment Row Address
  130. #define ARM_NAND_CODE_WRITE_DATA (1UL << 24) ///< Write Data
  131. #define ARM_NAND_CODE_SEND_CMD2 (1UL << 25) ///< Send Command 2
  132. #define ARM_NAND_CODE_WAIT_BUSY (1UL << 26) ///< Wait while R/Bn busy
  133. #define ARM_NAND_CODE_READ_DATA (1UL << 27) ///< Read Data
  134. #define ARM_NAND_CODE_SEND_CMD3 (1UL << 28) ///< Send Command 3
  135. #define ARM_NAND_CODE_READ_STATUS (1UL << 29) ///< Read Status byte and check FAIL bit (bit 0)
  136. /*----- NAND Sequence Execution Code: Command -----*/
  137. #define ARM_NAND_CODE_CMD1_Pos 0
  138. #define ARM_NAND_CODE_CMD1_Msk (0xFFUL << ARM_NAND_CODE_CMD1_Pos)
  139. #define ARM_NAND_CODE_CMD2_Pos 8
  140. #define ARM_NAND_CODE_CMD2_Msk (0xFFUL << ARM_NAND_CODE_CMD2_Pos)
  141. #define ARM_NAND_CODE_CMD3_Pos 16
  142. #define ARM_NAND_CODE_CMD3_Msk (0xFFUL << ARM_NAND_CODE_CMD3_Pos)
  143. /*----- NAND Sequence Execution Code: Column Address -----*/
  144. #define ARM_NAND_CODE_ADDR_COL1_Pos 0
  145. #define ARM_NAND_CODE_ADDR_COL1_Msk (0xFFUL << ARM_NAND_CODE_ADDR_COL1_Pos)
  146. #define ARM_NAND_CODE_ADDR_COL2_Pos 8
  147. #define ARM_NAND_CODE_ADDR_COL2_Msk (0xFFUL << ARM_NAND_CODE_ADDR_COL2_Pos)
  148. /*----- NAND Sequence Execution Code: Row Address -----*/
  149. #define ARM_NAND_CODE_ADDR_ROW1_Pos 0
  150. #define ARM_NAND_CODE_ADDR_ROW1_Msk (0xFFUL << ARM_NAND_CODE_ADDR_ROW1_Pos)
  151. #define ARM_NAND_CODE_ADDR_ROW2_Pos 8
  152. #define ARM_NAND_CODE_ADDR_ROW2_Msk (0xFFUL << ARM_NAND_CODE_ADDR_ROW2_Pos)
  153. #define ARM_NAND_CODE_ADDR_ROW3_Pos 16
  154. #define ARM_NAND_CODE_ADDR_ROW3_Msk (0xFFUL << ARM_NAND_CODE_ADDR_ROW3_Pos)
  155. /****** NAND specific error codes *****/
  156. #define ARM_NAND_ERROR_ECC (ARM_DRIVER_ERROR_SPECIFIC - 1) ///< ECC generation/correction failed
  157. /**
  158. \brief NAND ECC (Error Correction Code) Information
  159. */
  160. typedef struct _ARM_NAND_ECC_INFO {
  161. uint32_t type : 2; ///< Type: 1=ECC0 over Main, 2=ECC0 over Main+Spare, 3=ECC0 over Main and ECC1 over Spare
  162. uint32_t page_layout : 1; ///< Page layout: 0=|Main0|Spare0|...|MainN-1|SpareN-1|, 1=|Main0|...|MainN-1|Spare0|...|SpareN-1|
  163. uint32_t page_count : 3; ///< Number of virtual pages: N = 2 ^ page_count
  164. uint32_t page_size : 4; ///< Virtual Page size (Main+Spare): 0=512+16, 1=1k+32, 2=2k+64, 3=4k+128, 4=8k+256, 8=512+28, 9=1k+56, 10=2k+112, 11=4k+224, 12=8k+448, 15=Not used (extended description)
  165. uint32_t reserved : 14; ///< Reserved (must be zero)
  166. uint32_t correctable_bits : 8; ///< Number of correctable bits (based on 512 byte codeword size)
  167. uint16_t codeword_size [2]; ///< Number of bytes over which ECC is calculated
  168. uint16_t ecc_size [2]; ///< ECC size in bytes (rounded up)
  169. uint16_t ecc_offset [2]; ///< ECC offset in bytes (where ECC starts in Spare)
  170. /* Extended description */
  171. uint16_t virtual_page_size [2]; ///< Virtual Page size in bytes (Main/Spare)
  172. uint16_t codeword_offset [2]; ///< Codeword offset in bytes (where ECC protected data starts in Main/Spare)
  173. uint16_t codeword_gap [2]; ///< Codeword gap in bytes till next protected data
  174. uint16_t ecc_gap [2]; ///< ECC gap in bytes till next generated ECC
  175. } ARM_NAND_ECC_INFO;
  176. /**
  177. \brief NAND Status
  178. */
  179. typedef struct _ARM_NAND_STATUS {
  180. uint32_t busy : 1; ///< Driver busy flag
  181. uint32_t ecc_error : 1; ///< ECC error detected (cleared on next Read/WriteData or ExecuteSequence)
  182. uint32_t reserved : 30;
  183. } ARM_NAND_STATUS;
  184. /****** NAND Event *****/
  185. #define ARM_NAND_EVENT_DEVICE_READY (1UL << 0) ///< Device Ready: R/Bn rising edge
  186. #define ARM_NAND_EVENT_DRIVER_READY (1UL << 1) ///< Driver Ready
  187. #define ARM_NAND_EVENT_DRIVER_DONE (1UL << 2) ///< Driver operation done
  188. #define ARM_NAND_EVENT_ECC_ERROR (1UL << 3) ///< ECC could not correct data
  189. // Function documentation
  190. /**
  191. \fn ARM_DRIVER_VERSION ARM_NAND_GetVersion (void)
  192. \brief Get driver version.
  193. \return \ref ARM_DRIVER_VERSION
  194. */
  195. /**
  196. \fn ARM_NAND_CAPABILITIES ARM_NAND_GetCapabilities (void)
  197. \brief Get driver capabilities.
  198. \return \ref ARM_NAND_CAPABILITIES
  199. */
  200. /**
  201. \fn int32_t ARM_NAND_Initialize (ARM_NAND_SignalEvent_t cb_event)
  202. \brief Initialize the NAND Interface.
  203. \param[in] cb_event Pointer to \ref ARM_NAND_SignalEvent
  204. \return \ref execution_status
  205. */
  206. /**
  207. \fn int32_t ARM_NAND_Uninitialize (void)
  208. \brief De-initialize the NAND Interface.
  209. \return \ref execution_status
  210. */
  211. /**
  212. \fn int32_t ARM_NAND_PowerControl (ARM_POWER_STATE state)
  213. \brief Control the NAND interface power.
  214. \param[in] state Power state
  215. \return \ref execution_status
  216. */
  217. /**
  218. \fn int32_t ARM_NAND_DevicePower (uint32_t voltage)
  219. \brief Set device power supply voltage.
  220. \param[in] voltage NAND Device supply voltage
  221. \return \ref execution_status
  222. */
  223. /**
  224. \fn int32_t ARM_NAND_WriteProtect (uint32_t dev_num, bool enable)
  225. \brief Control WPn (Write Protect).
  226. \param[in] dev_num Device number
  227. \param[in] enable
  228. - \b false Write Protect off
  229. - \b true Write Protect on
  230. \return \ref execution_status
  231. */
  232. /**
  233. \fn int32_t ARM_NAND_ChipEnable (uint32_t dev_num, bool enable)
  234. \brief Control CEn (Chip Enable).
  235. \param[in] dev_num Device number
  236. \param[in] enable
  237. - \b false Chip Enable off
  238. - \b true Chip Enable on
  239. \return \ref execution_status
  240. */
  241. /**
  242. \fn int32_t ARM_NAND_GetDeviceBusy (uint32_t dev_num)
  243. \brief Get Device Busy pin state.
  244. \param[in] dev_num Device number
  245. \return 1=busy, 0=not busy, or error
  246. */
  247. /**
  248. \fn int32_t ARM_NAND_SendCommand (uint32_t dev_num, uint8_t cmd)
  249. \brief Send command to NAND device.
  250. \param[in] dev_num Device number
  251. \param[in] cmd Command
  252. \return \ref execution_status
  253. */
  254. /**
  255. \fn int32_t ARM_NAND_SendAddress (uint32_t dev_num, uint8_t addr)
  256. \brief Send address to NAND device.
  257. \param[in] dev_num Device number
  258. \param[in] addr Address
  259. \return \ref execution_status
  260. */
  261. /**
  262. \fn int32_t ARM_NAND_ReadData (uint32_t dev_num, void *data, uint32_t cnt, uint32_t mode)
  263. \brief Read data from NAND device.
  264. \param[in] dev_num Device number
  265. \param[out] data Pointer to buffer for data to read from NAND device
  266. \param[in] cnt Number of data items to read
  267. \param[in] mode Operation mode
  268. \return number of data items read or \ref execution_status
  269. */
  270. /**
  271. \fn int32_t ARM_NAND_WriteData (uint32_t dev_num, const void *data, uint32_t cnt, uint32_t mode)
  272. \brief Write data to NAND device.
  273. \param[in] dev_num Device number
  274. \param[out] data Pointer to buffer with data to write to NAND device
  275. \param[in] cnt Number of data items to write
  276. \param[in] mode Operation mode
  277. \return number of data items written or \ref execution_status
  278. */
  279. /**
  280. \fn int32_t ARM_NAND_ExecuteSequence (uint32_t dev_num, uint32_t code, uint32_t cmd,
  281. uint32_t addr_col, uint32_t addr_row,
  282. void *data, uint32_t data_cnt,
  283. uint8_t *status, uint32_t *count)
  284. \brief Execute sequence of operations.
  285. \param[in] dev_num Device number
  286. \param[in] code Sequence code
  287. \param[in] cmd Command(s)
  288. \param[in] addr_col Column address
  289. \param[in] addr_row Row address
  290. \param[in,out] data Pointer to data to be written or read
  291. \param[in] data_cnt Number of data items in one iteration
  292. \param[out] status Pointer to status read
  293. \param[in,out] count Number of iterations
  294. \return \ref execution_status
  295. */
  296. /**
  297. \fn int32_t ARM_NAND_AbortSequence (uint32_t dev_num)
  298. \brief Abort sequence execution.
  299. \param[in] dev_num Device number
  300. \return \ref execution_status
  301. */
  302. /**
  303. \fn int32_t ARM_NAND_Control (uint32_t dev_num, uint32_t control, uint32_t arg)
  304. \brief Control NAND Interface.
  305. \param[in] dev_num Device number
  306. \param[in] control Operation
  307. \param[in] arg Argument of operation
  308. \return \ref execution_status
  309. */
  310. /**
  311. \fn ARM_NAND_STATUS ARM_NAND_GetStatus (uint32_t dev_num)
  312. \brief Get NAND status.
  313. \param[in] dev_num Device number
  314. \return NAND status \ref ARM_NAND_STATUS
  315. */
  316. /**
  317. \fn int32_t ARM_NAND_InquireECC (int32_t index, ARM_NAND_ECC_INFO *info)
  318. \brief Inquire about available ECC.
  319. \param[in] index Inquire ECC index
  320. \param[out] info Pointer to ECC information \ref ARM_NAND_ECC_INFO retrieved
  321. \return \ref execution_status
  322. */
  323. /**
  324. \fn void ARM_NAND_SignalEvent (uint32_t dev_num, uint32_t event)
  325. \brief Signal NAND event.
  326. \param[in] dev_num Device number
  327. \param[in] event Event notification mask
  328. \return none
  329. */
  330. typedef void (*ARM_NAND_SignalEvent_t) (uint32_t dev_num, uint32_t event); ///< Pointer to \ref ARM_NAND_SignalEvent : Signal NAND Event.
  331. /**
  332. \brief NAND Driver Capabilities.
  333. */
  334. typedef struct _ARM_NAND_CAPABILITIES {
  335. uint32_t event_device_ready : 1; ///< Signal Device Ready event (R/Bn rising edge)
  336. uint32_t reentrant_operation : 1; ///< Supports re-entrant operation (SendCommand/Address, Read/WriteData)
  337. uint32_t sequence_operation : 1; ///< Supports Sequence operation (ExecuteSequence, AbortSequence)
  338. uint32_t vcc : 1; ///< Supports VCC Power Supply Control
  339. uint32_t vcc_1v8 : 1; ///< Supports 1.8 VCC Power Supply
  340. uint32_t vccq : 1; ///< Supports VCCQ I/O Power Supply Control
  341. uint32_t vccq_1v8 : 1; ///< Supports 1.8 VCCQ I/O Power Supply
  342. uint32_t vpp : 1; ///< Supports VPP High Voltage Power Supply Control
  343. uint32_t wp : 1; ///< Supports WPn (Write Protect) Control
  344. uint32_t ce_lines : 4; ///< Number of CEn (Chip Enable) lines: ce_lines + 1
  345. uint32_t ce_manual : 1; ///< Supports manual CEn (Chip Enable) Control
  346. uint32_t rb_monitor : 1; ///< Supports R/Bn (Ready/Busy) Monitoring
  347. uint32_t data_width_16 : 1; ///< Supports 16-bit data
  348. uint32_t ddr : 1; ///< Supports NV-DDR Data Interface (ONFI)
  349. uint32_t ddr2 : 1; ///< Supports NV-DDR2 Data Interface (ONFI)
  350. uint32_t sdr_timing_mode : 3; ///< Fastest (highest) SDR Timing Mode supported (ONFI)
  351. uint32_t ddr_timing_mode : 3; ///< Fastest (highest) NV_DDR Timing Mode supported (ONFI)
  352. uint32_t ddr2_timing_mode : 3; ///< Fastest (highest) NV_DDR2 Timing Mode supported (ONFI)
  353. uint32_t driver_strength_18 : 1; ///< Supports Driver Strength 2.0x = 18 Ohms
  354. uint32_t driver_strength_25 : 1; ///< Supports Driver Strength 1.4x = 25 Ohms
  355. uint32_t driver_strength_50 : 1; ///< Supports Driver Strength 0.7x = 50 Ohms
  356. uint32_t reserved : 2; ///< Reserved (must be zero)
  357. } ARM_NAND_CAPABILITIES;
  358. /**
  359. \brief Access structure of the NAND Driver.
  360. */
  361. typedef struct _ARM_DRIVER_NAND {
  362. ARM_DRIVER_VERSION (*GetVersion) (void); ///< Pointer to \ref ARM_NAND_GetVersion : Get driver version.
  363. ARM_NAND_CAPABILITIES (*GetCapabilities)(void); ///< Pointer to \ref ARM_NAND_GetCapabilities : Get driver capabilities.
  364. int32_t (*Initialize) (ARM_NAND_SignalEvent_t cb_event); ///< Pointer to \ref ARM_NAND_Initialize : Initialize NAND Interface.
  365. int32_t (*Uninitialize) (void); ///< Pointer to \ref ARM_NAND_Uninitialize : De-initialize NAND Interface.
  366. int32_t (*PowerControl) (ARM_POWER_STATE state); ///< Pointer to \ref ARM_NAND_PowerControl : Control NAND Interface Power.
  367. int32_t (*DevicePower) (uint32_t voltage); ///< Pointer to \ref ARM_NAND_DevicePower : Set device power supply voltage.
  368. int32_t (*WriteProtect) (uint32_t dev_num, bool enable); ///< Pointer to \ref ARM_NAND_WriteProtect : Control WPn (Write Protect).
  369. int32_t (*ChipEnable) (uint32_t dev_num, bool enable); ///< Pointer to \ref ARM_NAND_ChipEnable : Control CEn (Chip Enable).
  370. int32_t (*GetDeviceBusy) (uint32_t dev_num); ///< Pointer to \ref ARM_NAND_GetDeviceBusy : Get Device Busy pin state.
  371. int32_t (*SendCommand) (uint32_t dev_num, uint8_t cmd); ///< Pointer to \ref ARM_NAND_SendCommand : Send command to NAND device.
  372. int32_t (*SendAddress) (uint32_t dev_num, uint8_t addr); ///< Pointer to \ref ARM_NAND_SendAddress : Send address to NAND device.
  373. int32_t (*ReadData) (uint32_t dev_num, void *data, uint32_t cnt, uint32_t mode); ///< Pointer to \ref ARM_NAND_ReadData : Read data from NAND device.
  374. int32_t (*WriteData) (uint32_t dev_num, const void *data, uint32_t cnt, uint32_t mode); ///< Pointer to \ref ARM_NAND_WriteData : Write data to NAND device.
  375. int32_t (*ExecuteSequence)(uint32_t dev_num, uint32_t code, uint32_t cmd,
  376. uint32_t addr_col, uint32_t addr_row,
  377. void *data, uint32_t data_cnt,
  378. uint8_t *status, uint32_t *count); ///< Pointer to \ref ARM_NAND_ExecuteSequence : Execute sequence of operations.
  379. int32_t (*AbortSequence) (uint32_t dev_num); ///< Pointer to \ref ARM_NAND_AbortSequence : Abort sequence execution.
  380. int32_t (*Control) (uint32_t dev_num, uint32_t control, uint32_t arg); ///< Pointer to \ref ARM_NAND_Control : Control NAND Interface.
  381. ARM_NAND_STATUS (*GetStatus) (uint32_t dev_num); ///< Pointer to \ref ARM_NAND_GetStatus : Get NAND status.
  382. int32_t (*InquireECC) ( int32_t index, ARM_NAND_ECC_INFO *info); ///< Pointer to \ref ARM_NAND_InquireECC : Inquire about available ECC.
  383. } const ARM_DRIVER_NAND;
  384. #ifdef __cplusplus
  385. }
  386. #endif
  387. #endif /* DRIVER_NAND_H_ */