emif.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * EMIF programming
  3. *
  4. * (C) Copyright 2010
  5. * Texas Instruments, <www.ti.com>
  6. *
  7. * Aneesh V <aneesh@ti.com>
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <asm/emif.h>
  13. #include <asm/arch/sys_proto.h>
  14. #include <asm/utils.h>
  15. #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
  16. u32 *const T_num = (u32 *)OMAP_SRAM_SCRATCH_EMIF_T_NUM;
  17. u32 *const T_den = (u32 *)OMAP_SRAM_SCRATCH_EMIF_T_DEN;
  18. #endif
  19. #ifdef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  20. /* Base AC Timing values specified by JESD209-2 for 400MHz operation */
  21. static const struct lpddr2_ac_timings timings_jedec_400_mhz = {
  22. .max_freq = 400000000,
  23. .RL = 6,
  24. .tRPab = 21,
  25. .tRCD = 18,
  26. .tWR = 15,
  27. .tRASmin = 42,
  28. .tRRD = 10,
  29. .tWTRx2 = 15,
  30. .tXSR = 140,
  31. .tXPx2 = 15,
  32. .tRFCab = 130,
  33. .tRTPx2 = 15,
  34. .tCKE = 3,
  35. .tCKESR = 15,
  36. .tZQCS = 90,
  37. .tZQCL = 360,
  38. .tZQINIT = 1000,
  39. .tDQSCKMAXx2 = 11,
  40. .tRASmax = 70,
  41. .tFAW = 50
  42. };
  43. /* Base AC Timing values specified by JESD209-2 for 200 MHz operation */
  44. static const struct lpddr2_ac_timings timings_jedec_200_mhz = {
  45. .max_freq = 200000000,
  46. .RL = 3,
  47. .tRPab = 21,
  48. .tRCD = 18,
  49. .tWR = 15,
  50. .tRASmin = 42,
  51. .tRRD = 10,
  52. .tWTRx2 = 20,
  53. .tXSR = 140,
  54. .tXPx2 = 15,
  55. .tRFCab = 130,
  56. .tRTPx2 = 15,
  57. .tCKE = 3,
  58. .tCKESR = 15,
  59. .tZQCS = 90,
  60. .tZQCL = 360,
  61. .tZQINIT = 1000,
  62. .tDQSCKMAXx2 = 11,
  63. .tRASmax = 70,
  64. .tFAW = 50
  65. };
  66. /*
  67. * Min tCK values specified by JESD209-2
  68. * Min tCK specifies the minimum duration of some AC timing parameters in terms
  69. * of the number of cycles. If the calculated number of cycles based on the
  70. * absolute time value is less than the min tCK value, min tCK value should
  71. * be used instead. This typically happens at low frequencies.
  72. */
  73. static const struct lpddr2_min_tck min_tck_jedec = {
  74. .tRL = 3,
  75. .tRP_AB = 3,
  76. .tRCD = 3,
  77. .tWR = 3,
  78. .tRAS_MIN = 3,
  79. .tRRD = 2,
  80. .tWTR = 2,
  81. .tXP = 2,
  82. .tRTP = 2,
  83. .tCKE = 3,
  84. .tCKESR = 3,
  85. .tFAW = 8
  86. };
  87. static const struct lpddr2_ac_timings const*
  88. jedec_ac_timings[MAX_NUM_SPEEDBINS] = {
  89. &timings_jedec_200_mhz,
  90. &timings_jedec_400_mhz
  91. };
  92. const struct lpddr2_device_timings jedec_default_timings = {
  93. .ac_timings = jedec_ac_timings,
  94. .min_tck = &min_tck_jedec
  95. };
  96. void emif_get_device_timings(u32 emif_nr,
  97. const struct lpddr2_device_timings **cs0_device_timings,
  98. const struct lpddr2_device_timings **cs1_device_timings)
  99. {
  100. /* Assume Identical devices on EMIF1 & EMIF2 */
  101. *cs0_device_timings = &jedec_default_timings;
  102. *cs1_device_timings = &jedec_default_timings;
  103. }
  104. #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */