sfdp.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2005, Intec Automation Inc.
  4. * Copyright (C) 2014, Freescale Semiconductor, Inc.
  5. */
  6. #ifndef __LINUX_MTD_SFDP_H
  7. #define __LINUX_MTD_SFDP_H
  8. /* SFDP revisions */
  9. #define SFDP_JESD216_MAJOR 1
  10. #define SFDP_JESD216_MINOR 0
  11. #define SFDP_JESD216A_MINOR 5
  12. #define SFDP_JESD216B_MINOR 6
  13. /* SFDP DWORDS are indexed from 1 but C arrays are indexed from 0. */
  14. #define SFDP_DWORD(i) ((i) - 1)
  15. #define SFDP_MASK_CHECK(dword, mask) (((dword) & (mask)) == (mask))
  16. /* Basic Flash Parameter Table */
  17. /* JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. */
  18. #define BFPT_DWORD_MAX 20
  19. struct sfdp_bfpt {
  20. u32 dwords[BFPT_DWORD_MAX];
  21. };
  22. /* The first version of JESD216 defined only 9 DWORDs. */
  23. #define BFPT_DWORD_MAX_JESD216 9
  24. #define BFPT_DWORD_MAX_JESD216B 16
  25. /* 1st DWORD. */
  26. #define BFPT_DWORD1_FAST_READ_1_1_2 BIT(16)
  27. #define BFPT_DWORD1_ADDRESS_BYTES_MASK GENMASK(18, 17)
  28. #define BFPT_DWORD1_ADDRESS_BYTES_3_ONLY (0x0UL << 17)
  29. #define BFPT_DWORD1_ADDRESS_BYTES_3_OR_4 (0x1UL << 17)
  30. #define BFPT_DWORD1_ADDRESS_BYTES_4_ONLY (0x2UL << 17)
  31. #define BFPT_DWORD1_DTR BIT(19)
  32. #define BFPT_DWORD1_FAST_READ_1_2_2 BIT(20)
  33. #define BFPT_DWORD1_FAST_READ_1_4_4 BIT(21)
  34. #define BFPT_DWORD1_FAST_READ_1_1_4 BIT(22)
  35. /* 5th DWORD. */
  36. #define BFPT_DWORD5_FAST_READ_2_2_2 BIT(0)
  37. #define BFPT_DWORD5_FAST_READ_4_4_4 BIT(4)
  38. /* 11th DWORD. */
  39. #define BFPT_DWORD11_PAGE_SIZE_SHIFT 4
  40. #define BFPT_DWORD11_PAGE_SIZE_MASK GENMASK(7, 4)
  41. /* 15th DWORD. */
  42. /*
  43. * (from JESD216 rev B)
  44. * Quad Enable Requirements (QER):
  45. * - 000b: Device does not have a QE bit. Device detects 1-1-4 and 1-4-4
  46. * reads based on instruction. DQ3/HOLD# functions are hold during
  47. * instruction phase.
  48. * - 001b: QE is bit 1 of status register 2. It is set via Write Status with
  49. * two data bytes where bit 1 of the second byte is one.
  50. * [...]
  51. * Writing only one byte to the status register has the side-effect of
  52. * clearing status register 2, including the QE bit. The 100b code is
  53. * used if writing one byte to the status register does not modify
  54. * status register 2.
  55. * - 010b: QE is bit 6 of status register 1. It is set via Write Status with
  56. * one data byte where bit 6 is one.
  57. * [...]
  58. * - 011b: QE is bit 7 of status register 2. It is set via Write status
  59. * register 2 instruction 3Eh with one data byte where bit 7 is one.
  60. * [...]
  61. * The status register 2 is read using instruction 3Fh.
  62. * - 100b: QE is bit 1 of status register 2. It is set via Write Status with
  63. * two data bytes where bit 1 of the second byte is one.
  64. * [...]
  65. * In contrast to the 001b code, writing one byte to the status
  66. * register does not modify status register 2.
  67. * - 101b: QE is bit 1 of status register 2. Status register 1 is read using
  68. * Read Status instruction 05h. Status register2 is read using
  69. * instruction 35h. QE is set via Write Status instruction 01h with
  70. * two data bytes where bit 1 of the second byte is one.
  71. * [...]
  72. */
  73. #define BFPT_DWORD15_QER_MASK GENMASK(22, 20)
  74. #define BFPT_DWORD15_QER_NONE (0x0UL << 20) /* Micron */
  75. #define BFPT_DWORD15_QER_SR2_BIT1_BUGGY (0x1UL << 20)
  76. #define BFPT_DWORD15_QER_SR1_BIT6 (0x2UL << 20) /* Macronix */
  77. #define BFPT_DWORD15_QER_SR2_BIT7 (0x3UL << 20)
  78. #define BFPT_DWORD15_QER_SR2_BIT1_NO_RD (0x4UL << 20)
  79. #define BFPT_DWORD15_QER_SR2_BIT1 (0x5UL << 20) /* Spansion */
  80. #define BFPT_DWORD16_EN4B_MASK GENMASK(31, 24)
  81. #define BFPT_DWORD16_EN4B_ALWAYS_4B BIT(30)
  82. #define BFPT_DWORD16_EN4B_4B_OPCODES BIT(29)
  83. #define BFPT_DWORD16_EN4B_16BIT_NV_CR BIT(28)
  84. #define BFPT_DWORD16_EN4B_BRWR BIT(27)
  85. #define BFPT_DWORD16_EN4B_WREAR BIT(26)
  86. #define BFPT_DWORD16_EN4B_WREN_EN4B BIT(25)
  87. #define BFPT_DWORD16_EN4B_EN4B BIT(24)
  88. #define BFPT_DWORD16_EX4B_MASK GENMASK(18, 14)
  89. #define BFPT_DWORD16_EX4B_16BIT_NV_CR BIT(18)
  90. #define BFPT_DWORD16_EX4B_BRWR BIT(17)
  91. #define BFPT_DWORD16_EX4B_WREAR BIT(16)
  92. #define BFPT_DWORD16_EX4B_WREN_EX4B BIT(15)
  93. #define BFPT_DWORD16_EX4B_EX4B BIT(14)
  94. #define BFPT_DWORD16_4B_ADDR_MODE_MASK \
  95. (BFPT_DWORD16_EN4B_MASK | BFPT_DWORD16_EX4B_MASK)
  96. #define BFPT_DWORD16_4B_ADDR_MODE_16BIT_NV_CR \
  97. (BFPT_DWORD16_EN4B_16BIT_NV_CR | BFPT_DWORD16_EX4B_16BIT_NV_CR)
  98. #define BFPT_DWORD16_4B_ADDR_MODE_BRWR \
  99. (BFPT_DWORD16_EN4B_BRWR | BFPT_DWORD16_EX4B_BRWR)
  100. #define BFPT_DWORD16_4B_ADDR_MODE_WREAR \
  101. (BFPT_DWORD16_EN4B_WREAR | BFPT_DWORD16_EX4B_WREAR)
  102. #define BFPT_DWORD16_4B_ADDR_MODE_WREN_EN4B_EX4B \
  103. (BFPT_DWORD16_EN4B_WREN_EN4B | BFPT_DWORD16_EX4B_WREN_EX4B)
  104. #define BFPT_DWORD16_4B_ADDR_MODE_EN4B_EX4B \
  105. (BFPT_DWORD16_EN4B_EN4B | BFPT_DWORD16_EX4B_EX4B)
  106. #define BFPT_DWORD16_SWRST_EN_RST BIT(12)
  107. #define BFPT_DWORD17_RD_1_1_8_CMD GENMASK(31, 24)
  108. #define BFPT_DWORD17_RD_1_1_8_MODE_CLOCKS GENMASK(23, 21)
  109. #define BFPT_DWORD17_RD_1_1_8_WAIT_STATES GENMASK(20, 16)
  110. #define BFPT_DWORD17_RD_1_8_8_CMD GENMASK(15, 8)
  111. #define BFPT_DWORD17_RD_1_8_8_MODE_CLOCKS GENMASK(7, 5)
  112. #define BFPT_DWORD17_RD_1_8_8_WAIT_STATES GENMASK(4, 0)
  113. #define BFPT_DWORD18_CMD_EXT_MASK GENMASK(30, 29)
  114. #define BFPT_DWORD18_CMD_EXT_REP (0x0UL << 29) /* Repeat */
  115. #define BFPT_DWORD18_CMD_EXT_INV (0x1UL << 29) /* Invert */
  116. #define BFPT_DWORD18_CMD_EXT_RES (0x2UL << 29) /* Reserved */
  117. #define BFPT_DWORD18_CMD_EXT_16B (0x3UL << 29) /* 16-bit opcode */
  118. struct sfdp_parameter_header {
  119. u8 id_lsb;
  120. u8 minor;
  121. u8 major;
  122. u8 length; /* in double words */
  123. u8 parameter_table_pointer[3]; /* byte address */
  124. u8 id_msb;
  125. };
  126. #endif /* __LINUX_MTD_SFDP_H */