emif.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * EMIF programming
  3. *
  4. * (C) Copyright 2010
  5. * Texas Instruments, <www.ti.com>
  6. *
  7. * Aneesh V <aneesh@ti.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <asm/emif.h>
  29. #include <asm/arch/sys_proto.h>
  30. #include <asm/utils.h>
  31. #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
  32. u32 *const T_num = (u32 *)OMAP4_SRAM_SCRATCH_EMIF_T_NUM;
  33. u32 *const T_den = (u32 *)OMAP4_SRAM_SCRATCH_EMIF_T_DEN;
  34. u32 *const emif_sizes = (u32 *)OMAP4_SRAM_SCRATCH_EMIF_SIZE;
  35. #endif
  36. #ifdef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  37. /* Base AC Timing values specified by JESD209-2 for 400MHz operation */
  38. static const struct lpddr2_ac_timings timings_jedec_400_mhz = {
  39. .max_freq = 400000000,
  40. .RL = 6,
  41. .tRPab = 21,
  42. .tRCD = 18,
  43. .tWR = 15,
  44. .tRASmin = 42,
  45. .tRRD = 10,
  46. .tWTRx2 = 15,
  47. .tXSR = 140,
  48. .tXPx2 = 15,
  49. .tRFCab = 130,
  50. .tRTPx2 = 15,
  51. .tCKE = 3,
  52. .tCKESR = 15,
  53. .tZQCS = 90,
  54. .tZQCL = 360,
  55. .tZQINIT = 1000,
  56. .tDQSCKMAXx2 = 11,
  57. .tRASmax = 70,
  58. .tFAW = 50
  59. };
  60. /* Base AC Timing values specified by JESD209-2 for 200 MHz operation */
  61. static const struct lpddr2_ac_timings timings_jedec_200_mhz = {
  62. .max_freq = 200000000,
  63. .RL = 3,
  64. .tRPab = 21,
  65. .tRCD = 18,
  66. .tWR = 15,
  67. .tRASmin = 42,
  68. .tRRD = 10,
  69. .tWTRx2 = 20,
  70. .tXSR = 140,
  71. .tXPx2 = 15,
  72. .tRFCab = 130,
  73. .tRTPx2 = 15,
  74. .tCKE = 3,
  75. .tCKESR = 15,
  76. .tZQCS = 90,
  77. .tZQCL = 360,
  78. .tZQINIT = 1000,
  79. .tDQSCKMAXx2 = 11,
  80. .tRASmax = 70,
  81. .tFAW = 50
  82. };
  83. /*
  84. * Min tCK values specified by JESD209-2
  85. * Min tCK specifies the minimum duration of some AC timing parameters in terms
  86. * of the number of cycles. If the calculated number of cycles based on the
  87. * absolute time value is less than the min tCK value, min tCK value should
  88. * be used instead. This typically happens at low frequencies.
  89. */
  90. static const struct lpddr2_min_tck min_tck_jedec = {
  91. .tRL = 3,
  92. .tRP_AB = 3,
  93. .tRCD = 3,
  94. .tWR = 3,
  95. .tRAS_MIN = 3,
  96. .tRRD = 2,
  97. .tWTR = 2,
  98. .tXP = 2,
  99. .tRTP = 2,
  100. .tCKE = 3,
  101. .tCKESR = 3,
  102. .tFAW = 8
  103. };
  104. static const struct lpddr2_ac_timings const*
  105. jedec_ac_timings[MAX_NUM_SPEEDBINS] = {
  106. &timings_jedec_200_mhz,
  107. &timings_jedec_400_mhz
  108. };
  109. static const struct lpddr2_device_timings jedec_default_timings = {
  110. .ac_timings = jedec_ac_timings,
  111. .min_tck = &min_tck_jedec
  112. };
  113. void emif_get_device_timings(u32 emif_nr,
  114. const struct lpddr2_device_timings **cs0_device_timings,
  115. const struct lpddr2_device_timings **cs1_device_timings)
  116. {
  117. /* Assume Identical devices on EMIF1 & EMIF2 */
  118. *cs0_device_timings = &jedec_default_timings;
  119. *cs1_device_timings = &jedec_default_timings;
  120. }
  121. #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */