ddr_defs.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * ddr_defs.h
  3. *
  4. * ddr specific header
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef _DDR_DEFS_H
  19. #define _DDR_DEFS_H
  20. #include <asm/arch/hardware.h>
  21. #include <asm/emif.h>
  22. /* AM335X EMIF Register values */
  23. #define VTP_CTRL_READY (0x1 << 5)
  24. #define VTP_CTRL_ENABLE (0x1 << 6)
  25. #define VTP_CTRL_START_EN (0x1)
  26. #define PHY_DLL_LOCK_DIFF 0x0
  27. #define DDR_CKE_CTRL_NORMAL 0x1
  28. #define DDR2_EMIF_READ_LATENCY 0x100005 /* Enable Dynamic Power Down */
  29. #define DDR2_EMIF_TIM1 0x0666B3C9
  30. #define DDR2_EMIF_TIM2 0x243631CA
  31. #define DDR2_EMIF_TIM3 0x0000033F
  32. #define DDR2_EMIF_SDCFG 0x41805332
  33. #define DDR2_EMIF_SDREF 0x0000081a
  34. #define DDR2_DLL_LOCK_DIFF 0x0
  35. #define DDR2_RATIO 0x80
  36. #define DDR2_INVERT_CLKOUT 0x00
  37. #define DDR2_RD_DQS 0x12
  38. #define DDR2_WR_DQS 0x00
  39. #define DDR2_PHY_WRLVL 0x00
  40. #define DDR2_PHY_GATELVL 0x00
  41. #define DDR2_PHY_WR_DATA 0x40
  42. #define DDR2_PHY_FIFO_WE 0x80
  43. #define DDR2_PHY_RANK0_DELAY 0x1
  44. #define DDR2_IOCTRL_VALUE 0x18B
  45. /**
  46. * Configure SDRAM
  47. */
  48. void config_sdram(const struct emif_regs *regs);
  49. /**
  50. * Set SDRAM timings
  51. */
  52. void set_sdram_timings(const struct emif_regs *regs);
  53. /**
  54. * Configure DDR PHY
  55. */
  56. void config_ddr_phy(const struct emif_regs *regs);
  57. /**
  58. * This structure represents the DDR registers on AM33XX devices.
  59. * We make use of DDR_PHY_BASE_ADDR2 to address the DATA1 registers that
  60. * correspond to DATA1 registers defined here.
  61. */
  62. struct ddr_regs {
  63. unsigned int resv0[7];
  64. unsigned int cm0csratio; /* offset 0x01C */
  65. unsigned int resv1[2];
  66. unsigned int cm0dldiff; /* offset 0x028 */
  67. unsigned int cm0iclkout; /* offset 0x02C */
  68. unsigned int resv2[8];
  69. unsigned int cm1csratio; /* offset 0x050 */
  70. unsigned int resv3[2];
  71. unsigned int cm1dldiff; /* offset 0x05C */
  72. unsigned int cm1iclkout; /* offset 0x060 */
  73. unsigned int resv4[8];
  74. unsigned int cm2csratio; /* offset 0x084 */
  75. unsigned int resv5[2];
  76. unsigned int cm2dldiff; /* offset 0x090 */
  77. unsigned int cm2iclkout; /* offset 0x094 */
  78. unsigned int resv6[12];
  79. unsigned int dt0rdsratio0; /* offset 0x0C8 */
  80. unsigned int resv7[4];
  81. unsigned int dt0wdsratio0; /* offset 0x0DC */
  82. unsigned int resv8[4];
  83. unsigned int dt0wiratio0; /* offset 0x0F0 */
  84. unsigned int resv9;
  85. unsigned int dt0wimode0; /* offset 0x0F8 */
  86. unsigned int dt0giratio0; /* offset 0x0FC */
  87. unsigned int resv10;
  88. unsigned int dt0gimode0; /* offset 0x104 */
  89. unsigned int dt0fwsratio0; /* offset 0x108 */
  90. unsigned int resv11[4];
  91. unsigned int dt0dqoffset; /* offset 0x11C */
  92. unsigned int dt0wrsratio0; /* offset 0x120 */
  93. unsigned int resv12[4];
  94. unsigned int dt0rdelays0; /* offset 0x134 */
  95. unsigned int dt0dldiff0; /* offset 0x138 */
  96. };
  97. /**
  98. * Encapsulates DDR CMD control registers.
  99. */
  100. struct cmd_control {
  101. unsigned long cmd0csratio;
  102. unsigned long cmd0csforce;
  103. unsigned long cmd0csdelay;
  104. unsigned long cmd0dldiff;
  105. unsigned long cmd0iclkout;
  106. unsigned long cmd1csratio;
  107. unsigned long cmd1csforce;
  108. unsigned long cmd1csdelay;
  109. unsigned long cmd1dldiff;
  110. unsigned long cmd1iclkout;
  111. unsigned long cmd2csratio;
  112. unsigned long cmd2csforce;
  113. unsigned long cmd2csdelay;
  114. unsigned long cmd2dldiff;
  115. unsigned long cmd2iclkout;
  116. };
  117. /**
  118. * Encapsulates DDR DATA registers.
  119. */
  120. struct ddr_data {
  121. unsigned long datardsratio0;
  122. unsigned long datawdsratio0;
  123. unsigned long datawiratio0;
  124. unsigned long datagiratio0;
  125. unsigned long datafwsratio0;
  126. unsigned long datawrsratio0;
  127. unsigned long datauserank0delay;
  128. unsigned long datadldiff0;
  129. };
  130. /**
  131. * Configure DDR CMD control registers
  132. */
  133. void config_cmd_ctrl(const struct cmd_control *cmd);
  134. /**
  135. * Configure DDR DATA registers
  136. */
  137. void config_ddr_data(int data_macrono, const struct ddr_data *data);
  138. /**
  139. * This structure represents the DDR io control on AM33XX devices.
  140. */
  141. struct ddr_cmdtctrl {
  142. unsigned int resv1[1];
  143. unsigned int cm0ioctl;
  144. unsigned int cm1ioctl;
  145. unsigned int cm2ioctl;
  146. unsigned int resv2[12];
  147. unsigned int dt0ioctl;
  148. unsigned int dt1ioctl;
  149. };
  150. /**
  151. * Configure DDR io control registers
  152. */
  153. void config_io_ctrl(unsigned long val);
  154. struct ddr_ctrl {
  155. unsigned int ddrioctrl;
  156. unsigned int resv1[325];
  157. unsigned int ddrckectrl;
  158. };
  159. void config_ddr(short ddr_type);
  160. #endif /* _DDR_DEFS_H */