drv_nand.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-00-30 thread-liu first version
  9. */
  10. #ifndef __DRV_NAND_H__
  11. #define __DRV_NAND_H__
  12. #include "board.h"
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. #define NAND_MAX_PAGE_SIZE 4096
  18. #define NAND_ECC_SECTOR_SIZE 512
  19. #define NAND_TWHR_DELAY 25
  20. #define NAND_TBERS_DELAY 4
  21. #define MT29F8G08ABACAH4 0x64A690D3 /* id */
  22. #define NAND_ADDR ((rt_uint32_t)0x80000000) /* nand base address */
  23. #define NAND_ADDR_AREA (*(__IO rt_uint8_t *)NAND_ADDR)
  24. #define NAND_CMD_AREA (*(__IO rt_uint8_t *)(NAND_ADDR | 1 << 16)) /* command */
  25. #define NAND_DATA_AREA (*(__IO rt_uint8_t *)(NAND_ADDR | 1 << 17)) /* data */
  26. /* nand flash command */
  27. #define NAND_READID 0x90
  28. #define NAND_FEATURE 0xEF
  29. #define NAND_RESET 0xFF
  30. #define NAND_READSTA 0x70
  31. #define NAND_AREA_A 0x00
  32. #define NAND_AREA_TRUE1 0x30
  33. #define NAND_WRITE0 0x80
  34. #define NAND_WRITE_TURE1 0x10
  35. #define NAND_ERASE0 0x60
  36. #define NAND_ERASE1 0xD0
  37. #define NAND_MOVEDATA_CMD0 0x00
  38. #define NAND_MOVEDATA_CMD1 0x35
  39. #define NAND_MOVEDATA_CMD2 0x85
  40. #define NAND_MOVEDATA_CMD3 0x10
  41. /* nand flash status */
  42. #define NAND_READY 0x40 /* read */
  43. #define NAND_ECC1BITERR 0x03 /* ECC 1bit err */
  44. #define NAND_ECC2BITERR 0x04 /* ECC 2bit or more err */
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif