sfud_flash_def.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * This file is part of the Serial Flash Universal Driver Library.
  3. *
  4. * Copyright (c) 2016-2017, Armink, <armink.ztl@gmail.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * 'Software'), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  21. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. * Function: It is the flash types and specification macro definition head file for this library.
  26. * Created on: 2016-06-09
  27. */
  28. #ifndef _SFUD_FLASH_DEF_H_
  29. #define _SFUD_FLASH_DEF_H_
  30. #include <stdint.h>
  31. #include <sfud_cfg.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. * flash program(write) data mode
  37. */
  38. enum sfud_write_mode {
  39. SFUD_WM_PAGE_256B = 1 << 0, /**< write 1 to 256 bytes per page */
  40. SFUD_WM_BYTE = 1 << 1, /**< byte write */
  41. SFUD_WM_AAI = 1 << 2, /**< auto address increment */
  42. SFUD_WM_DUAL_BUFFER = 1 << 3, /**< dual-buffer write, like AT45DB series */
  43. };
  44. /* manufacturer information */
  45. typedef struct {
  46. char *name;
  47. uint8_t id;
  48. } sfud_mf;
  49. /* flash chip information */
  50. typedef struct {
  51. char *name; /**< flash chip name */
  52. uint8_t mf_id; /**< manufacturer ID */
  53. uint8_t type_id; /**< memory type ID */
  54. uint8_t capacity_id; /**< capacity ID */
  55. uint32_t capacity; /**< flash capacity (bytes) */
  56. uint16_t write_mode; /**< write mode @see sfud_write_mode */
  57. uint32_t erase_gran; /**< erase granularity (bytes) */
  58. uint8_t erase_gran_cmd; /**< erase granularity size block command */
  59. } sfud_flash_chip;
  60. /* SFUD support manufacturer JEDEC ID */
  61. #define SFUD_MF_ID_CYPRESS 0x01
  62. #define SFUD_MF_ID_FUJITSU 0x04
  63. #define SFUD_MF_ID_EON 0x1C
  64. #define SFUD_MF_ID_ATMEL 0x1F
  65. #define SFUD_MF_ID_MICRON 0x20
  66. #define SFUD_MF_ID_AMIC 0x37
  67. #define SFUD_MF_ID_SANYO 0x62
  68. #define SFUD_MF_ID_INTEL 0x89
  69. #define SFUD_MF_ID_ESMT 0x8C
  70. #define SFUD_MF_ID_FUDAN 0xA1
  71. #define SFUD_MF_ID_HYUNDAI 0xAD
  72. #define SFUD_MF_ID_SST 0xBF
  73. #define SFUD_MF_ID_GIGADEVICE 0xC8
  74. #define SFUD_MF_ID_ISSI 0xD5
  75. #define SFUD_MF_ID_WINBOND 0xEF
  76. /* SFUD supported manufacturer information table */
  77. #define SFUD_MF_TABLE \
  78. { \
  79. {"Cypress", SFUD_MF_ID_CYPRESS}, \
  80. {"Fujitsu", SFUD_MF_ID_FUJITSU}, \
  81. {"EON", SFUD_MF_ID_EON}, \
  82. {"Atmel", SFUD_MF_ID_ATMEL}, \
  83. {"Micron", SFUD_MF_ID_MICRON}, \
  84. {"AMIC", SFUD_MF_ID_AMIC}, \
  85. {"Sanyo", SFUD_MF_ID_SANYO}, \
  86. {"Intel", SFUD_MF_ID_INTEL}, \
  87. {"ESMT", SFUD_MF_ID_ESMT}, \
  88. {"Fudan", SFUD_MF_ID_FUDAN}, \
  89. {"Hyundai", SFUD_MF_ID_HYUNDAI}, \
  90. {"SST", SFUD_MF_ID_SST}, \
  91. {"GigaDevice", SFUD_MF_ID_GIGADEVICE}, \
  92. {"ISSI", SFUD_MF_ID_ISSI}, \
  93. {"Winbond", SFUD_MF_ID_WINBOND}, \
  94. }
  95. #ifdef SFUD_USING_FLASH_INFO_TABLE
  96. /* SFUD supported flash chip information table. If the flash not support JEDEC JESD216 standard,
  97. * then the SFUD will find the flash chip information by this table. You can add other flash to here then
  98. * notice me for update it. The configuration information name and index reference the sfud_flash_chip structure.
  99. * | name | mf_id | type_id | capacity_id | capacity | write_mode | erase_gran | erase_gran_cmd |
  100. */
  101. #define SFUD_FLASH_CHIP_TABLE \
  102. { \
  103. {"AT45DB161E", SFUD_MF_ID_ATMEL, 0x26, 0x00, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_DUAL_BUFFER, 512, 0x81}, \
  104. {"W25Q40BV", SFUD_MF_ID_WINBOND, 0x40, 0x13, 512L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  105. {"W25Q16BV", SFUD_MF_ID_WINBOND, 0x40, 0x15, 2L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  106. {"SST25VF016B", SFUD_MF_ID_SST, 0x25, 0x41, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
  107. {"M25P32", SFUD_MF_ID_MICRON, 0x20, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 64L*1024L, 0xD8}, \
  108. {"M25P80", SFUD_MF_ID_MICRON, 0x20, 0x14, 1L*1024L*1024L, SFUD_WM_PAGE_256B, 64L*1024L, 0xD8}, \
  109. {"M25P40", SFUD_MF_ID_MICRON, 0x20, 0x13, 512L*1024L, SFUD_WM_PAGE_256B, 64L*1024L, 0xD8}, \
  110. {"EN25Q32B", SFUD_MF_ID_EON, 0x30, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  111. {"GD25Q64B", SFUD_MF_ID_GIGADEVICE, 0x40, 0x17, 8L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  112. {"GD25Q16B", SFUD_MF_ID_GIGADEVICE, 0x40, 0x15, 2L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  113. {"S25FL216K", SFUD_MF_ID_CYPRESS, 0x40, 0x15, 2L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  114. {"S25FL032P", SFUD_MF_ID_CYPRESS, 0x02, 0x15, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  115. {"A25L080", SFUD_MF_ID_AMIC, 0x30, 0x14, 1L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
  116. {"F25L004", SFUD_MF_ID_ESMT, 0x20, 0x13, 512L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
  117. {"PCT25VF016B", SFUD_MF_ID_SST, 0x25, 0x41, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
  118. }
  119. #endif /* SFUD_USING_FLASH_INFO_TABLE */
  120. #ifdef __cplusplus
  121. }
  122. #endif
  123. #endif /* _SFUD_FLASH_DEF_H_ */