ql_boot_spi_nand_flash.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /** @file
  2. ql_boot_spi_nand_flash.h
  3. @brief
  4. This file is used to define boot spi nand flash api for different Quectel Project.
  5. */
  6. /*================================================================
  7. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  8. Quectel Wireless Solution Proprietary and Confidential.
  9. =================================================================*/
  10. /*=================================================================
  11. EDIT HISTORY FOR MODULE
  12. This section contains comments describing changes made to the module.
  13. Notice that changes are listed in reverse chronological order.
  14. WHEN WHO WHAT, WHERE, WHY
  15. ------------ ------- -------------------------------------------------------------------------------
  16. =================================================================*/
  17. #ifndef QL_BOOT_SPI_NAND_FLASH_H
  18. #define QL_BOOT_SPI_NAND_FLASH_H
  19. #include "ql_api_common.h"
  20. #include "quec_boot_pin_cfg.h"
  21. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH
  22. #include "quec_boot_spi.h"
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  28. spi nand flash api接口
  29. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  30. /*========================================================================
  31. * Variable Definition
  32. *========================================================================*/
  33. #define QL_BOOT_SPI_NAND_PAGE_SIZE 2048
  34. #define QL_BOOT_SPI_NAND_SPARE_SIZE 64
  35. #define QL_BOOT_SPI_NAND_PAGE_SPARE_SIZE (QL_BOOT_SPI_NAND_PAGE_SIZE+QL_BOOT_SPI_NAND_SPARE_SIZE)
  36. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH
  37. typedef ql_boot_spi_flash_config_s ql_boot_spi_nand_config_s ;
  38. #endif
  39. typedef enum
  40. {
  41. QL_BOOT_NAND_FLASH_STATUS_1 = 0, //Status Register-1
  42. QL_BOOT_NAND_FLASH_STATUS_2, //Status Register-2
  43. QL_BOOT_NAND_FLASH_STATUS_3, //Status Register-3
  44. QL_BOOT_NAND_FLASH_STATUS_4, //Status Register-4
  45. }ql_boot_spi_nand_status_reg_e;
  46. typedef enum
  47. {
  48. QL_BOOT_NAND_FLASH_ID_16BIT = 0, //Manufacturer ID(8bit) + device ID(8bit)
  49. QL_BOOT_NAND_FLASH_ID_24BIT, //Manufacturer ID(8bit) + device ID(16bit)
  50. }ql_boot_spi_nand_id_type_e;
  51. typedef enum
  52. {
  53. QL_BOOT_SPI6_NAND_SUCCESS = 0,
  54. QL_BOOT_SPI6_NAND_ERROR = 1 | (QL_COMPONENT_STORAGE_EXT_NANDFLASH << 16), //其他错误
  55. QL_BOOT_SPI6_NAND_PARAM_TYPE_ERROR, //参数类型错误
  56. QL_BOOT_SPI6_NAND_PARAM_DATA_ERROR, //参数数据错误
  57. QL_BOOT_SPI6_NAND_PARAM_ACQUIRE_ERROR, //参数无法获取
  58. QL_BOOT_SPI6_NAND_PARAM_NULL_ERROR, //参数NULL错误
  59. QL_BOOT_SPI6_NAND_DEV_NOT_ACQUIRE_ERROR, //无法获取SPI总线
  60. QL_BOOT_SPI6_NAND_PARAM_LENGTH_ERROR, //参数长度错误
  61. QL_BOOT_SPI6_NAND_MALLOC_MEM_ERROR, //申请内存错误
  62. QL_BOOT_SPI6_NAND_NOT_SUPPORT_ERROR,
  63. QL_BOOT_SPI6_NAND_ECC_ERROR, //nand flash ecc error
  64. QL_BOOT_SPI6_NAND_PROGRAM_ERROR, //flash program error
  65. QL_BOOT_SPI6_NAND_ERASE_ERROR, //flash erase error
  66. QL_BOOT_SPI6_NAND_SPI6_INIT_ERR,
  67. QL_BOOT_SPI6_NAND_READ_DATA_ERR,
  68. QL_BOOT_SPI6_NAND_WRITE_DATA_ERR,
  69. QL_BOOT_SPI6_NAND_READ_ECC_2BIT_ERR,
  70. QL_BOOT_SPI6_NAND_READ_ECC_1BIT_ERR,
  71. QL_BOOT_SPI6_NAND_WRITE_STATUS_ERR,
  72. QL_BOOT_SPI6_NAND_ERASE_ERR,
  73. QL_BOOT_SPI6_NAND_ERASE_STATUS_ERR,
  74. }ql_boot_errcode_spi6_nand_e;
  75. typedef enum
  76. {
  77. QL_BOOT_NAND_TYPE_STANDARD_SPI = 0, //Standard SPI: SCLK, CS#, SI, SO
  78. QL_BOOT_NAND_TYPE_QUAD_SPI, //Quad SPI: SCLK, CS#, SIO0, SIO1, SIO2, SIO3
  79. QL_BOOT_NAND_TYPE_DUAL_SPI, //Dual SPI: SCLK, CS#, SIO0, SIO1
  80. }ql_boot_nand_spi_type_e;
  81. typedef struct
  82. {
  83. int (*nand_init)(void);
  84. int (*nand_uninit)(void);
  85. int (*nand_read_page)(unsigned int block_num, unsigned short page_num, unsigned short column_addr, unsigned char *pbuffer, int len);
  86. } ql_boot_nand_ops_t;
  87. typedef enum
  88. {
  89. //BOOT_SPI6_NAND_FLASH_CLK_31MHZ = 0x0, //8850上不支持该频率,与8910有差异
  90. //BOOT_SPI6_NAND_FLASH_CLK_41MHZ = 0x0, //8850上不支持该频率,与8910有差异
  91. BOOT_SPI6_NAND_FLASH_CLK_62MHZ = 0x1,
  92. BOOT_SPI6_NAND_FLASH_CLK_71MHZ = 0x3,
  93. BOOT_SPI6_NAND_FLASH_CLK_83MHZ = 0x5,
  94. BOOT_SPI6_NAND_FLASH_CLK_91MHZ = 0x6,
  95. BOOT_SPI6_NAND_FLASH_CLK_100MHZ = 0x7,
  96. BOOT_SPI6_NAND_FLASH_CLK_111MHZ = 0x8,
  97. BOOT_SPI6_NAND_FLASH_CLK_125MHZ = 0x9,
  98. //以下为8850支持,但8910不支持的
  99. BOOT_SPI6_NAND_FLASH_CLK_142MHZ = 0xa,
  100. BOOT_SPI6_NAND_FLASH_CLK_166MHZ = 0xb,
  101. BOOT_SPI6_NAND_FLASH_CLK_200MHZ = 0xc, //8850默认为该频率
  102. //8850内置flash不支持以下时钟频率
  103. //BOOT_SPI6_NAND_FLASH_CLK_250MHZ = 0xd,
  104. //BOOT_SPI6_NAND_FLASH_CLK_333MHZ = 0xe,
  105. BOOT_SPI6_NAND_FLASH_CLK_500MHZ = 0xf,
  106. BOOT_SPI6_NAND_FLASH_CLK_INVALID = 0x10,
  107. }ql_boot_spi6_nand_flash_clk_e;
  108. typedef struct
  109. {
  110. ql_boot_spi_port_e port; //SPI6总线选择
  111. ql_boot_spi6_nand_flash_clk_e clk; //SPI6时钟配置,默认BOOT_SPI6_NAND_FLASH_CLK_200MHZ
  112. uint8_t clk_div; //时钟分频,默认5,freq =200M/5=40M
  113. uint8_t quad_mode; //1--Quad SPII: SCLK, CS#, SIO0, SIO1, SIO2, SIO3 0--Dual SPI: SCLK, CS#, SIO0, SIO1
  114. uint8_t sample_delay; //延时采样,默认3
  115. uint8_t isslow; //是否使用低速率时钟,1--low 0--fast;仅8910有效
  116. } ql_boot_spi6_nand_config_s;
  117. /*========================================================================
  118. * function Definition
  119. *========================================================================*/
  120. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH
  121. /*****************************************************************
  122. * Function: ql_spi_nand_init
  123. *
  124. * Description:
  125. * 初始化NAND FLASH
  126. *
  127. * Parameters:
  128. * port [in] SPI总线选择
  129. * spiclk [in] SPI时钟选择
  130. *
  131. * Return:ql_boot_errcode_spi_e
  132. *
  133. *****************************************************************/
  134. ql_boot_errcode_spi_e ql_boot_spi_nand_init(ql_boot_spi_port_e port, ql_boot_spi_clk_e spiclk);
  135. /*****************************************************************
  136. * Function: ql_spi_nand_init_ext
  137. *
  138. * Description:
  139. * 扩展初始化NAND FLASH,与ql_spi_nand_init有更多的设置选项
  140. *
  141. * Parameters:
  142. * nand_config [in] SPI配置参数
  143. *
  144. * Return:ql_boot_errcode_spi_e
  145. *
  146. *****************************************************************/
  147. ql_boot_errcode_spi_e ql_boot_spi_nand_init_ext(ql_boot_spi_nand_config_s nand_config);
  148. /*****************************************************************
  149. * Function: ql_boot_spi_nand_read_devid_ex
  150. *
  151. * Description:
  152. * read flash devie id
  153. *
  154. * Parameters:
  155. * port [in] SPI bus select
  156. * mid [out] manufacturer id
  157. * mid_type [out] manufacturer id type
  158. *
  159. * Return:ql_boot_errcode_spi_e
  160. *
  161. *****************************************************************/
  162. ql_boot_errcode_spi_e ql_boot_spi_nand_read_devid_ex(ql_boot_spi_port_e port, unsigned char *mid,ql_boot_spi_nand_id_type_e mid_type);
  163. /*****************************************************************
  164. * Function: ql_spi_nand_read_devid
  165. *
  166. * Description:
  167. * read flash devie id
  168. *
  169. * Parameters:
  170. * port [in] SPI bus select
  171. * mid [out] manufacturer id
  172. *
  173. * Return:ql_boot_errcode_spi_e
  174. *
  175. *****************************************************************/
  176. //ql_boot_errcode_spi_e ql_boot_spi_nand_read_devid(ql_boot_spi_port_e port, unsigned char *mid);
  177. #define ql_boot_spi_nand_read_devid(port, mid) ql_boot_spi_nand_read_devid_ex(port, mid, QL_BOOT_NAND_FLASH_ID_24BIT)
  178. /*****************************************************************
  179. * Function: ql_spi_nand_read_page_spare
  180. *
  181. * Description:
  182. * read page(2048 byte)+spare area(64 byte)
  183. *
  184. * Parameters:
  185. * port [in] SPI bus select
  186. * page_addr [in] page address
  187. * column_addr [in] column address
  188. * data [out] data read buffer
  189. * len [out] data read length
  190. *
  191. * Return:ql_boot_errcode_spi_e
  192. *
  193. *****************************************************************/
  194. ql_boot_errcode_spi_e ql_boot_spi_nand_read_page_spare(ql_boot_spi_port_e port, unsigned int page_addr, unsigned short column_addr, unsigned char *data, int len);
  195. /*****************************************************************
  196. * Function: ql_spi_nand_write_page_spare
  197. *
  198. * Description:
  199. * write page(2048 byte)+spare area(64 byte)
  200. *
  201. * Parameters:
  202. * port [in] SPI bus select
  203. * page_addr [in] page address
  204. * column_addr [in] column address
  205. * data [out] data read buffer
  206. * len [out] data read length
  207. *
  208. * Return:ql_boot_errcode_spi_e
  209. *
  210. *****************************************************************/
  211. ql_boot_errcode_spi_e ql_boot_spi_nand_write_page_spare(ql_boot_spi_port_e port, unsigned int page_addr, unsigned short column_addr, unsigned char *data, int len);
  212. /*****************************************************************
  213. * Function: ql_spi_nand_write_spare
  214. *
  215. * Description:
  216. * write spare area(64 byte)
  217. *
  218. * Parameters:
  219. * port [in] SPI bus select
  220. * page_addr [in] page address
  221. * data [out] data read buffer
  222. * len [out] data read length
  223. *
  224. * Return:ql_boot_errcode_spi_e
  225. *
  226. *****************************************************************/
  227. ql_boot_errcode_spi_e ql_boot_spi_nand_write_spare(ql_boot_spi_port_e port, unsigned int page_addr, unsigned char *data, int len);
  228. /*****************************************************************
  229. * Function: ql_spi_nand_read_status
  230. *
  231. * Description:
  232. * read status register value
  233. *
  234. * Parameters:
  235. * port [in] SPI bus select
  236. * reg [in] FLASH status register
  237. * status [out] status register value
  238. *
  239. * Return:ql_boot_errcode_spi_e
  240. *
  241. *****************************************************************/
  242. ql_boot_errcode_spi_e ql_boot_spi_nand_read_status(ql_boot_spi_port_e port, ql_boot_spi_nand_status_reg_e reg, unsigned char *status);
  243. /*****************************************************************
  244. * Function: ql_spi_nand_write_status
  245. *
  246. * Description:
  247. * read status register value
  248. *
  249. * Parameters:
  250. * port [in] SPI bus select
  251. * reg [in] FLASH status register
  252. * status [in] status register value
  253. *
  254. * Return:ql_boot_errcode_spi_e
  255. *
  256. *****************************************************************/
  257. ql_boot_errcode_spi_e ql_boot_spi_nand_write_status(ql_boot_spi_port_e port, ql_boot_spi_nand_status_reg_e reg, unsigned char status);
  258. /*****************************************************************
  259. * Function: ql_spi_nand_erase_block
  260. *
  261. * Description:
  262. * erase block(128k):D8H
  263. *
  264. * Parameters:
  265. * port [in] SPI bus selelct
  266. * page_addr [in] page address
  267. *
  268. * Return:ql_boot_errcode_spi_e
  269. *
  270. *****************************************************************/
  271. ql_boot_errcode_spi_e ql_boot_spi_nand_erase_block(ql_boot_spi_port_e port, unsigned int page_addr);
  272. /*****************************************************************
  273. * Function: ql_spi_nand_reset
  274. *
  275. * Description:
  276. * reset flash device:FFH
  277. *
  278. * Parameters:
  279. * port [in] SPI bus selelct
  280. *
  281. * Return:ql_boot_errcode_spi_e
  282. *
  283. *****************************************************************/
  284. ql_boot_errcode_spi_e ql_boot_spi_nand_reset(ql_boot_spi_port_e port);
  285. #endif
  286. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI6_NAND
  287. /*****************************************************************
  288. * Function: ql_boot_spi6_nand_init
  289. *
  290. * Description:
  291. * 初始化NAND FLASH
  292. *
  293. * Parameters:
  294. * nand_config [in] SPI配置参数
  295. *
  296. * Return:ql_boot_errcode_spi6_nand_e
  297. *
  298. *****************************************************************/
  299. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_init(ql_boot_spi6_nand_config_s nand_config);
  300. /*****************************************************************
  301. * Function: ql_boot_spi6_nand_read_devid_ex
  302. *
  303. * Description:
  304. * read flash devie id
  305. *
  306. * Parameters:
  307. * port [in] SPI6总线选择,此参数预留,目前没有实际意义
  308. * mid [out] manufacturer id
  309. * mid_type [out] manufacturer id type
  310. *
  311. * Return:ql_boot_errcode_spi6_nand_e
  312. *
  313. *****************************************************************/
  314. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_read_devid_ex(ql_boot_spi_port_e port, unsigned char *mid,ql_boot_spi_nand_id_type_e mid_type);
  315. /*****************************************************************
  316. * Function: ql_boot_spi6_nand_read_devid
  317. *
  318. * Description:
  319. * read flash devie id
  320. *
  321. * Parameters:
  322. * port [in] SPI6 bus select,this parameter is reserved
  323. * mid [out] manufacturer id
  324. *
  325. * Return:ql_boot_errcode_spi_e
  326. *
  327. *****************************************************************/
  328. //ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_read_devid(unsigned char *mid);
  329. #define ql_boot_spi6_nand_read_devid(port, mid) ql_boot_spi6_nand_read_devid_ex(port, mid, QL_BOOT_NAND_FLASH_ID_24BIT)
  330. /*****************************************************************
  331. * Function: ql_boot_spi6_nand_read_page_spare
  332. *
  333. * Description:
  334. * read page(2048 byte)+spare area(64 byte)
  335. *
  336. * Parameters:
  337. * port [in] SPI6 bus select,this parameter is reserved
  338. * page_addr [in] page address
  339. * column_addr [in] column address
  340. * data [out] data read buffer
  341. * len [out] data read length
  342. *
  343. * Return:ql_boot_errcode_spi6_nand_e
  344. *
  345. *****************************************************************/
  346. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_read_page_spare(ql_boot_spi_port_e port, unsigned int page_addr, unsigned short column_addr, unsigned char *data, int len);
  347. /*****************************************************************
  348. * Function: ql_boot_spi6_nand_write_page_spare
  349. *
  350. * Description:
  351. * write page(2048 byte)+spare area(64 byte)
  352. *
  353. * Parameters:
  354. * port [in] SPI6 bus select,this parameter is reserved
  355. * page_addr [in] page address
  356. * column_addr [in] column address
  357. * data [out] data read buffer
  358. * len [out] data read length
  359. *
  360. * Return:ql_boot_errcode_spi6_nand_e
  361. *
  362. *****************************************************************/
  363. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_write_page_spare(ql_boot_spi_port_e port, unsigned int page_addr, unsigned short column_addr, unsigned char *data, int len);
  364. /*****************************************************************
  365. * Function: ql_boot_spi6_nand_write_spare
  366. *
  367. * Description:
  368. * write spare area(64 byte)
  369. *
  370. * Parameters:
  371. * port [in] SPI6 bus select,this parameter is reserved
  372. * page_addr [in] page address
  373. * data [out] data read buffer
  374. * len [out] data read length
  375. *
  376. * Return:ql_boot_errcode_spi6_nand_e
  377. *
  378. *****************************************************************/
  379. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_write_spare(ql_boot_spi_port_e port, unsigned int page_addr, unsigned char *data, int len);
  380. /*****************************************************************
  381. * Function: ql_boot_spi6_nand_read_status
  382. *
  383. * Description:
  384. * read status register value
  385. *
  386. * Parameters:
  387. * port [in] SPI6 bus select,this parameter is reserved
  388. * reg [in] FLASH status register
  389. * status [out] status register value
  390. *
  391. * Return:ql_boot_errcode_spi6_nand_e
  392. *
  393. *****************************************************************/
  394. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_read_status(ql_boot_spi_port_e port, ql_boot_spi_nand_status_reg_e reg, unsigned char *status);
  395. /*****************************************************************
  396. * Function: ql_boot_spi6_nand_write_status
  397. *
  398. * Description:
  399. * read status register value
  400. *
  401. * Parameters:
  402. * port [in] SPI6 bus select,this parameter is reserved
  403. * reg [in] FLASH status register
  404. * status [in] status register value
  405. *
  406. * Return:ql_boot_errcode_spi6_nand_e
  407. *
  408. *****************************************************************/
  409. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_write_status(ql_boot_spi_port_e port, ql_boot_spi_nand_status_reg_e reg, unsigned char status);
  410. /*****************************************************************
  411. * Function: ql_boot_spi6_nand_erase_block
  412. *
  413. * Description:
  414. * erase block(128k):D8H
  415. *
  416. * Parameters:
  417. * port [in] SPI6 bus select,this parameter is reserved
  418. * page_addr [in] page address
  419. *
  420. * Return:ql_boot_errcode_spi6_nand_e
  421. *
  422. *****************************************************************/
  423. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_erase_block(ql_boot_spi_port_e port, unsigned int page_addr);
  424. /*****************************************************************
  425. * Function: ql_boot_spi6_nand_reset
  426. *
  427. * Description:
  428. * reset flash device:FFH
  429. *
  430. * Parameters:
  431. * port [in] SPI6 bus select,this parameter is reserved
  432. *
  433. * Return:ql_boot_errcode_spi6_nand_e
  434. *
  435. *****************************************************************/
  436. ql_boot_errcode_spi6_nand_e ql_boot_spi6_nand_reset(ql_boot_spi_port_e port);
  437. #endif
  438. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  439. spi/spi6 nand flash demo 实列
  440. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  441. /*===========================================================================
  442. * Macro Definition
  443. *===========================================================================*/
  444. typedef enum
  445. {
  446. QL_BOOT_ECC_OK,
  447. QL_BOOT_ECC_1BIT,
  448. QL_BOOT_ECC_2BIT
  449. }ql_boot_nand_ecc_status_e;
  450. typedef struct
  451. {
  452. unsigned int data_blocknum;
  453. unsigned int free_blocknum;
  454. unsigned int nand_id;
  455. unsigned int *logical_map_table;
  456. unsigned char *pbuffer;
  457. }ql_boot_nand_config_s;
  458. typedef struct
  459. {
  460. unsigned int acture_block_num;
  461. unsigned short acture_page_num;
  462. unsigned int cache_block_num;
  463. unsigned short cache_page_num;
  464. }ql_boot_nand_cache_page_s;
  465. typedef struct
  466. {
  467. unsigned int page_mainsize;
  468. unsigned int page_sparesize;
  469. unsigned int block_pagenum;
  470. unsigned int plane_blocknum; //not use
  471. unsigned int block_totalnum;
  472. unsigned int cache_blocknum;
  473. unsigned int cache_total_pagenum;
  474. unsigned short page_spare_shift;
  475. unsigned short block_postion_shift;
  476. unsigned short block_type_shift;
  477. unsigned short logic_addr_shift; //offset in page
  478. unsigned short logic_addr_addr; //addr in page,4byte
  479. unsigned short page_used_shift; //offset in page
  480. unsigned short page_used_addr; //addr in page,1byte
  481. unsigned short page_garbage_shift;
  482. unsigned short page_num_shift;
  483. } ql_boot_nand_spec_s;
  484. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH
  485. /*****************************************************************
  486. * Function: ql_nand_init
  487. *
  488. * Description: nand flash init
  489. *
  490. * Parameters:
  491. * NULL
  492. *
  493. * Return:
  494. * QL_BOOT_SPI_SUCCESS success
  495. * other error code
  496. *
  497. *****************************************************************/
  498. ql_boot_errcode_spi_e ql_boot_nand_init();
  499. /*****************************************************************
  500. * Function: ql_nand_uninit
  501. *
  502. * Description: nand flash uninit
  503. *
  504. * Parameters:
  505. * NULL
  506. *
  507. * Return:
  508. * QL_BOOT_SPI_SUCCESS success
  509. * other error code
  510. *
  511. *****************************************************************/
  512. ql_boot_errcode_spi_e ql_boot_nand_uninit();
  513. /*****************************************************************
  514. * Function: ql_nand_read_page
  515. *
  516. * Description: read page
  517. *
  518. * Parameters:
  519. * block_num [in] physical block number
  520. * page_num [in] page number
  521. * column_addr [in] column address
  522. * pbuffer [out] data buffer
  523. * len [in] data len
  524. *
  525. * Return:
  526. * QL_BOOT_SPI_SUCCESS success
  527. * other error code
  528. *
  529. *****************************************************************/
  530. ql_boot_errcode_spi_e ql_boot_nand_read_page(unsigned int block_num, unsigned short page_num, unsigned short column_addr, unsigned char *pbuffer, int len);
  531. #endif
  532. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI6_NAND
  533. /*****************************************************************
  534. * Function: ql_nand_init_spi6
  535. *
  536. * Description: nand flash init
  537. *
  538. * Parameters:
  539. * NULL
  540. *
  541. * Return:
  542. * QL_BOOT_SPI6_NAND_SUCCESS success
  543. * other error code
  544. *
  545. *****************************************************************/
  546. ql_boot_errcode_spi6_nand_e ql_boot_nand_init_spi6();
  547. /*****************************************************************
  548. * Function: ql_nand_uninit_spi6
  549. *
  550. * Description: nand flash uninit
  551. *
  552. * Parameters:
  553. * NULL
  554. *
  555. * Return:
  556. * QL_BOOT_SPI6_NAND_SUCCESS success
  557. * other error code
  558. *
  559. *****************************************************************/
  560. ql_boot_errcode_spi6_nand_e ql_boot_nand_uninit_spi6();
  561. /*****************************************************************
  562. * Function: ql_nand_read_page_spi6
  563. *
  564. * Description: read page
  565. *
  566. * Parameters:
  567. * block_num [in] physical block number
  568. * page_num [in] page number
  569. * column_addr [in] column address
  570. * pbuffer [out] data buffer
  571. * len [in] data len
  572. *
  573. * Return:
  574. * QL_BOOT_SPI6_NAND_SUCCESS success
  575. * other error code
  576. *
  577. *****************************************************************/
  578. ql_boot_errcode_spi6_nand_e ql_boot_nand_read_page_spi6(unsigned int block_num, unsigned short page_num, unsigned short column_addr, unsigned char *pbuffer, int len);
  579. #endif
  580. #ifdef __cplusplus
  581. } /*"C" */
  582. #endif
  583. #endif /* QL_API_SPI_NAND_FLASH_H */