ddr_defs.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. /* AM335X EMIF Register values */
  22. #define VTP_CTRL_READY (0x1 << 5)
  23. #define VTP_CTRL_ENABLE (0x1 << 6)
  24. #define VTP_CTRL_START_EN (0x1)
  25. #define CMD_FORCE 0x00
  26. #define CMD_DELAY 0x00
  27. #define PHY_DLL_LOCK_DIFF 0x0
  28. #define DDR2_EMIF_READ_LATENCY 0x05
  29. #define DDR2_EMIF_TIM1 0x0666B3D6
  30. #define DDR2_EMIF_TIM2 0x143731DA
  31. #define DDR2_EMIF_TIM3 0x00000347
  32. #define DDR2_EMIF_SDCFG 0x43805332
  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. * Encapsulates DDR PHY control and corresponding shadow registers.
  47. */
  48. struct ddr_phy_control {
  49. unsigned long reg;
  50. unsigned long reg_sh;
  51. unsigned long reg2;
  52. };
  53. /**
  54. * Encapsulates SDRAM timing and corresponding shadow registers.
  55. */
  56. struct sdram_timing {
  57. unsigned long time1;
  58. unsigned long time1_sh;
  59. unsigned long time2;
  60. unsigned long time2_sh;
  61. unsigned long time3;
  62. unsigned long time3_sh;
  63. };
  64. /**
  65. * Encapsulates SDRAM configuration.
  66. * (Includes refresh control registers) */
  67. struct sdram_config {
  68. unsigned long sdrcr;
  69. unsigned long sdrcr2;
  70. unsigned long refresh;
  71. unsigned long refresh_sh;
  72. };
  73. /**
  74. * Configure SDRAM
  75. */
  76. int config_sdram(struct sdram_config *cfg);
  77. /**
  78. * Set SDRAM timings
  79. */
  80. int set_sdram_timings(struct sdram_timing *val);
  81. /**
  82. * Configure DDR PHY
  83. */
  84. int config_ddr_phy(struct ddr_phy_control *cfg);
  85. /**
  86. * This structure represents the DDR registers on AM33XX devices.
  87. */
  88. struct ddr_regs {
  89. unsigned int resv0[7];
  90. unsigned int cm0csratio; /* offset 0x01C */
  91. unsigned int cm0csforce; /* offset 0x020 */
  92. unsigned int cm0csdelay; /* offset 0x024 */
  93. unsigned int cm0dldiff; /* offset 0x028 */
  94. unsigned int cm0iclkout; /* offset 0x02C */
  95. unsigned int resv1[8];
  96. unsigned int cm1csratio; /* offset 0x050 */
  97. unsigned int cm1csforce; /* offset 0x054 */
  98. unsigned int cm1csdelay; /* offset 0x058 */
  99. unsigned int cm1dldiff; /* offset 0x05C */
  100. unsigned int cm1iclkout; /* offset 0x060 */
  101. unsigned int resv2[8];
  102. unsigned int cm2csratio; /* offset 0x084 */
  103. unsigned int cm2csforce; /* offset 0x088 */
  104. unsigned int cm2csdelay; /* offset 0x08C */
  105. unsigned int cm2dldiff; /* offset 0x090 */
  106. unsigned int cm2iclkout; /* offset 0x094 */
  107. unsigned int resv3[12];
  108. unsigned int dt0rdsratio0; /* offset 0x0C8 */
  109. unsigned int dt0rdsratio1; /* offset 0x0CC */
  110. unsigned int resv4[3];
  111. unsigned int dt0wdsratio0; /* offset 0x0DC */
  112. unsigned int dt0wdsratio1; /* offset 0x0E0 */
  113. unsigned int resv5[3];
  114. unsigned int dt0wiratio0; /* offset 0x0F0 */
  115. unsigned int dt0wiratio1; /* offset 0x0F4 */
  116. unsigned int dt0giratio0; /* offset 0x0FC */
  117. unsigned int dt0giratio1; /* offset 0x100 */
  118. unsigned int resv6[1];
  119. unsigned int dt0fwsratio0; /* offset 0x108 */
  120. unsigned int dt0fwsratio1; /* offset 0x10C */
  121. unsigned int resv7[4];
  122. unsigned int dt0wrsratio0; /* offset 0x120 */
  123. unsigned int dt0wrsratio1; /* offset 0x124 */
  124. unsigned int resv8[3];
  125. unsigned int dt0rdelays0; /* offset 0x134 */
  126. unsigned int dt0dldiff0; /* offset 0x138 */
  127. unsigned int resv9[39];
  128. unsigned int dt1rdelays0; /* offset 0x1D8 */
  129. };
  130. /**
  131. * Encapsulates DDR CMD control registers.
  132. */
  133. struct cmd_control {
  134. unsigned long cmd0csratio;
  135. unsigned long cmd0csforce;
  136. unsigned long cmd0csdelay;
  137. unsigned long cmd0dldiff;
  138. unsigned long cmd0iclkout;
  139. unsigned long cmd1csratio;
  140. unsigned long cmd1csforce;
  141. unsigned long cmd1csdelay;
  142. unsigned long cmd1dldiff;
  143. unsigned long cmd1iclkout;
  144. unsigned long cmd2csratio;
  145. unsigned long cmd2csforce;
  146. unsigned long cmd2csdelay;
  147. unsigned long cmd2dldiff;
  148. unsigned long cmd2iclkout;
  149. };
  150. /**
  151. * Encapsulates DDR DATA registers.
  152. */
  153. struct ddr_data {
  154. unsigned long datardsratio0;
  155. unsigned long datardsratio1;
  156. unsigned long datawdsratio0;
  157. unsigned long datawdsratio1;
  158. unsigned long datawiratio0;
  159. unsigned long datawiratio1;
  160. unsigned long datagiratio0;
  161. unsigned long datagiratio1;
  162. unsigned long datafwsratio0;
  163. unsigned long datafwsratio1;
  164. unsigned long datawrsratio0;
  165. unsigned long datawrsratio1;
  166. unsigned long datadldiff0;
  167. };
  168. /**
  169. * Configure DDR CMD control registers
  170. */
  171. int config_cmd_ctrl(const struct cmd_control *cmd);
  172. /**
  173. * Configure DDR DATA registers
  174. */
  175. int config_ddr_data(int data_macrono, const struct ddr_data *data);
  176. /**
  177. * This structure represents the DDR io control on AM33XX devices.
  178. */
  179. struct ddr_cmdtctrl {
  180. unsigned int resv1[1];
  181. unsigned int cm0ioctl;
  182. unsigned int cm1ioctl;
  183. unsigned int cm2ioctl;
  184. unsigned int resv2[12];
  185. unsigned int dt0ioctl;
  186. unsigned int dt1ioctl;
  187. };
  188. /**
  189. * Encapsulates DDR CMD & DATA io control registers.
  190. */
  191. struct ddr_ioctrl {
  192. unsigned long cmd1ctl;
  193. unsigned long cmd2ctl;
  194. unsigned long cmd3ctl;
  195. unsigned long data1ctl;
  196. unsigned long data2ctl;
  197. };
  198. /**
  199. * Configure DDR io control registers
  200. */
  201. int config_io_ctrl(struct ddr_ioctrl *ioctrl);
  202. struct ddr_ctrl {
  203. unsigned int ddrioctrl;
  204. unsigned int resv1[325];
  205. unsigned int ddrckectrl;
  206. };
  207. void config_ddr(short ddr_type);
  208. #endif /* _DDR_DEFS_H */