onfi.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright © 2000-2010 David Woodhouse <[email protected]>
  4. * Steven J. Hill <[email protected]>
  5. * Thomas Gleixner <[email protected]>
  6. *
  7. * Contains all ONFI related definitions
  8. */
  9. #ifndef __LINUX_MTD_ONFI_H
  10. #define __LINUX_MTD_ONFI_H
  11. #include <linux/types.h>
  12. #include <linux/bitfield.h>
  13. /* ONFI version bits */
  14. #define ONFI_VERSION_1_0 BIT(1)
  15. #define ONFI_VERSION_2_0 BIT(2)
  16. #define ONFI_VERSION_2_1 BIT(3)
  17. #define ONFI_VERSION_2_2 BIT(4)
  18. #define ONFI_VERSION_2_3 BIT(5)
  19. #define ONFI_VERSION_3_0 BIT(6)
  20. #define ONFI_VERSION_3_1 BIT(7)
  21. #define ONFI_VERSION_3_2 BIT(8)
  22. #define ONFI_VERSION_4_0 BIT(9)
  23. /* ONFI features */
  24. #define ONFI_FEATURE_16_BIT_BUS BIT(0)
  25. #define ONFI_FEATURE_NV_DDR BIT(5)
  26. #define ONFI_FEATURE_EXT_PARAM_PAGE BIT(7)
  27. /* ONFI timing mode, used in both asynchronous and synchronous mode */
  28. #define ONFI_DATA_INTERFACE_SDR 0
  29. #define ONFI_DATA_INTERFACE_NVDDR BIT(4)
  30. #define ONFI_DATA_INTERFACE_NVDDR2 BIT(5)
  31. #define ONFI_TIMING_MODE_0 BIT(0)
  32. #define ONFI_TIMING_MODE_1 BIT(1)
  33. #define ONFI_TIMING_MODE_2 BIT(2)
  34. #define ONFI_TIMING_MODE_3 BIT(3)
  35. #define ONFI_TIMING_MODE_4 BIT(4)
  36. #define ONFI_TIMING_MODE_5 BIT(5)
  37. #define ONFI_TIMING_MODE_UNKNOWN BIT(6)
  38. #define ONFI_TIMING_MODE_PARAM(x) FIELD_GET(GENMASK(3, 0), (x))
  39. /* ONFI feature number/address */
  40. #define ONFI_FEATURE_NUMBER 256
  41. #define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
  42. /* Vendor-specific feature address (Micron) */
  43. #define ONFI_FEATURE_ADDR_READ_RETRY 0x89
  44. #define ONFI_FEATURE_ON_DIE_ECC 0x90
  45. #define ONFI_FEATURE_ON_DIE_ECC_EN BIT(3)
  46. /* ONFI subfeature parameters length */
  47. #define ONFI_SUBFEATURE_PARAM_LEN 4
  48. /* ONFI optional commands SET/GET FEATURES supported? */
  49. #define ONFI_OPT_CMD_SET_GET_FEATURES BIT(2)
  50. struct nand_onfi_params {
  51. /* rev info and features block */
  52. /* 'O' 'N' 'F' 'I' */
  53. u8 sig[4];
  54. __le16 revision;
  55. __le16 features;
  56. __le16 opt_cmd;
  57. u8 reserved0[2];
  58. __le16 ext_param_page_length; /* since ONFI 2.1 */
  59. u8 num_of_param_pages; /* since ONFI 2.1 */
  60. u8 reserved1[17];
  61. /* manufacturer information block */
  62. char manufacturer[12];
  63. char model[20];
  64. u8 jedec_id;
  65. __le16 date_code;
  66. u8 reserved2[13];
  67. /* memory organization block */
  68. __le32 byte_per_page;
  69. __le16 spare_bytes_per_page;
  70. __le32 data_bytes_per_ppage;
  71. __le16 spare_bytes_per_ppage;
  72. __le32 pages_per_block;
  73. __le32 blocks_per_lun;
  74. u8 lun_count;
  75. u8 addr_cycles;
  76. u8 bits_per_cell;
  77. __le16 bb_per_lun;
  78. __le16 block_endurance;
  79. u8 guaranteed_good_blocks;
  80. __le16 guaranteed_block_endurance;
  81. u8 programs_per_page;
  82. u8 ppage_attr;
  83. u8 ecc_bits;
  84. u8 interleaved_bits;
  85. u8 interleaved_ops;
  86. u8 reserved3[13];
  87. /* electrical parameter block */
  88. u8 io_pin_capacitance_max;
  89. __le16 sdr_timing_modes;
  90. __le16 program_cache_timing_mode;
  91. __le16 t_prog;
  92. __le16 t_bers;
  93. __le16 t_r;
  94. __le16 t_ccs;
  95. u8 nvddr_timing_modes;
  96. u8 nvddr2_timing_modes;
  97. u8 nvddr_nvddr2_features;
  98. __le16 clk_pin_capacitance_typ;
  99. __le16 io_pin_capacitance_typ;
  100. __le16 input_pin_capacitance_typ;
  101. u8 input_pin_capacitance_max;
  102. u8 driver_strength_support;
  103. __le16 t_int_r;
  104. __le16 t_adl;
  105. u8 reserved4[8];
  106. /* vendor */
  107. __le16 vendor_revision;
  108. u8 vendor[88];
  109. __le16 crc;
  110. } __packed;
  111. #define ONFI_CRC_BASE 0x4F4E
  112. /* Extended ECC information Block Definition (since ONFI 2.1) */
  113. struct onfi_ext_ecc_info {
  114. u8 ecc_bits;
  115. u8 codeword_size;
  116. __le16 bb_per_lun;
  117. __le16 block_endurance;
  118. u8 reserved[2];
  119. } __packed;
  120. #define ONFI_SECTION_TYPE_0 0 /* Unused section. */
  121. #define ONFI_SECTION_TYPE_1 1 /* for additional sections. */
  122. #define ONFI_SECTION_TYPE_2 2 /* for ECC information. */
  123. struct onfi_ext_section {
  124. u8 type;
  125. u8 length;
  126. } __packed;
  127. #define ONFI_EXT_SECTION_MAX 8
  128. /* Extended Parameter Page Definition (since ONFI 2.1) */
  129. struct onfi_ext_param_page {
  130. __le16 crc;
  131. u8 sig[4]; /* 'E' 'P' 'P' 'S' */
  132. u8 reserved0[10];
  133. struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];
  134. /*
  135. * The actual size of the Extended Parameter Page is in
  136. * @ext_param_page_length of nand_onfi_params{}.
  137. * The following are the variable length sections.
  138. * So we do not add any fields below. Please see the ONFI spec.
  139. */
  140. } __packed;
  141. /**
  142. * struct onfi_params - ONFI specific parameters that will be reused
  143. * @version: ONFI version (BCD encoded), 0 if ONFI is not supported
  144. * @tPROG: Page program time
  145. * @tBERS: Block erase time
  146. * @tR: Page read time
  147. * @tCCS: Change column setup time
  148. * @fast_tCAD: Command/Address/Data slow or fast delay (NV-DDR only)
  149. * @sdr_timing_modes: Supported asynchronous/SDR timing modes
  150. * @nvddr_timing_modes: Supported source synchronous/NV-DDR timing modes
  151. * @vendor_revision: Vendor specific revision number
  152. * @vendor: Vendor specific data
  153. */
  154. struct onfi_params {
  155. int version;
  156. u16 tPROG;
  157. u16 tBERS;
  158. u16 tR;
  159. u16 tCCS;
  160. bool fast_tCAD;
  161. u16 sdr_timing_modes;
  162. u16 nvddr_timing_modes;
  163. u16 vendor_revision;
  164. u8 vendor[88];
  165. };
  166. #endif /* __LINUX_MTD_ONFI_H */