onfi.h 4.4 KB

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