Driver_NAND.h 23 KB

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