jedec_ddr.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Definitions for DDR memories based on JEDEC specs
  3. *
  4. * Copyright (C) 2012 Texas Instruments, Inc.
  5. *
  6. * Aneesh V <aneesh@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __LINUX_JEDEC_DDR_H
  13. #define __LINUX_JEDEC_DDR_H
  14. #include <linux/types.h>
  15. /* DDR Densities */
  16. #define DDR_DENSITY_64Mb 1
  17. #define DDR_DENSITY_128Mb 2
  18. #define DDR_DENSITY_256Mb 3
  19. #define DDR_DENSITY_512Mb 4
  20. #define DDR_DENSITY_1Gb 5
  21. #define DDR_DENSITY_2Gb 6
  22. #define DDR_DENSITY_4Gb 7
  23. #define DDR_DENSITY_8Gb 8
  24. #define DDR_DENSITY_16Gb 9
  25. #define DDR_DENSITY_32Gb 10
  26. /* DDR type */
  27. #define DDR_TYPE_DDR2 1
  28. #define DDR_TYPE_DDR3 2
  29. #define DDR_TYPE_LPDDR2_S4 3
  30. #define DDR_TYPE_LPDDR2_S2 4
  31. #define DDR_TYPE_LPDDR2_NVM 5
  32. /* DDR IO width */
  33. #define DDR_IO_WIDTH_4 1
  34. #define DDR_IO_WIDTH_8 2
  35. #define DDR_IO_WIDTH_16 3
  36. #define DDR_IO_WIDTH_32 4
  37. /* Number of Row bits */
  38. #define R9 9
  39. #define R10 10
  40. #define R11 11
  41. #define R12 12
  42. #define R13 13
  43. #define R14 14
  44. #define R15 15
  45. #define R16 16
  46. /* Number of Column bits */
  47. #define C7 7
  48. #define C8 8
  49. #define C9 9
  50. #define C10 10
  51. #define C11 11
  52. #define C12 12
  53. /* Number of Banks */
  54. #define B1 0
  55. #define B2 1
  56. #define B4 2
  57. #define B8 3
  58. /* Refresh rate in nano-seconds */
  59. #define T_REFI_15_6 15600
  60. #define T_REFI_7_8 7800
  61. #define T_REFI_3_9 3900
  62. /* tRFC values */
  63. #define T_RFC_90 90000
  64. #define T_RFC_110 110000
  65. #define T_RFC_130 130000
  66. #define T_RFC_160 160000
  67. #define T_RFC_210 210000
  68. #define T_RFC_300 300000
  69. #define T_RFC_350 350000
  70. /* Mode register numbers */
  71. #define DDR_MR0 0
  72. #define DDR_MR1 1
  73. #define DDR_MR2 2
  74. #define DDR_MR3 3
  75. #define DDR_MR4 4
  76. #define DDR_MR5 5
  77. #define DDR_MR6 6
  78. #define DDR_MR7 7
  79. #define DDR_MR8 8
  80. #define DDR_MR9 9
  81. #define DDR_MR10 10
  82. #define DDR_MR11 11
  83. #define DDR_MR16 16
  84. #define DDR_MR17 17
  85. #define DDR_MR18 18
  86. /*
  87. * LPDDR2 related defines
  88. */
  89. /* MR4 register fields */
  90. #define MR4_SDRAM_REF_RATE_SHIFT 0
  91. #define MR4_SDRAM_REF_RATE_MASK 7
  92. #define MR4_TUF_SHIFT 7
  93. #define MR4_TUF_MASK (1 << 7)
  94. /* MR4 SDRAM Refresh Rate field values */
  95. #define SDRAM_TEMP_NOMINAL 0x3
  96. #define SDRAM_TEMP_RESERVED_4 0x4
  97. #define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5
  98. #define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6
  99. #define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7
  100. #define NUM_DDR_ADDR_TABLE_ENTRIES 11
  101. #define NUM_DDR_TIMING_TABLE_ENTRIES 4
  102. /* Structure for DDR addressing info from the JEDEC spec */
  103. struct lpddr2_addressing {
  104. u32 num_banks;
  105. u32 tREFI_ns;
  106. u32 tRFCab_ps;
  107. };
  108. /*
  109. * Structure for timings from the LPDDR2 datasheet
  110. * All parameters are in pico seconds(ps) unless explicitly indicated
  111. * with a suffix like tRAS_max_ns below
  112. */
  113. struct lpddr2_timings {
  114. u32 max_freq;
  115. u32 min_freq;
  116. u32 tRPab;
  117. u32 tRCD;
  118. u32 tWR;
  119. u32 tRAS_min;
  120. u32 tRRD;
  121. u32 tWTR;
  122. u32 tXP;
  123. u32 tRTP;
  124. u32 tCKESR;
  125. u32 tDQSCK_max;
  126. u32 tDQSCK_max_derated;
  127. u32 tFAW;
  128. u32 tZQCS;
  129. u32 tZQCL;
  130. u32 tZQinit;
  131. u32 tRAS_max_ns;
  132. };
  133. /*
  134. * Min value for some parameters in terms of number of tCK cycles(nCK)
  135. * Please set to zero parameters that are not valid for a given memory
  136. * type
  137. */
  138. struct lpddr2_min_tck {
  139. u32 tRPab;
  140. u32 tRCD;
  141. u32 tWR;
  142. u32 tRASmin;
  143. u32 tRRD;
  144. u32 tWTR;
  145. u32 tXP;
  146. u32 tRTP;
  147. u32 tCKE;
  148. u32 tCKESR;
  149. u32 tFAW;
  150. };
  151. extern const struct lpddr2_addressing
  152. lpddr2_jedec_addressing_table[NUM_DDR_ADDR_TABLE_ENTRIES];
  153. extern const struct lpddr2_timings
  154. lpddr2_jedec_timings[NUM_DDR_TIMING_TABLE_ENTRIES];
  155. extern const struct lpddr2_min_tck lpddr2_jedec_min_tck;
  156. #endif /* __LINUX_JEDEC_DDR_H */