evm.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * evm.c
  3. *
  4. * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
  5. * Antoine Tenart, <atenart@adeneo-embedded.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <spl.h>
  11. #include <asm/cache.h>
  12. #include <asm/io.h>
  13. #include <asm/arch/clock.h>
  14. #include <asm/arch/cpu.h>
  15. #include <asm/arch/ddr_defs.h>
  16. #include <asm/arch/hardware.h>
  17. #include <asm/arch/sys_proto.h>
  18. #include <asm/arch/mmc_host_def.h>
  19. #include <asm/arch/mem.h>
  20. #include <asm/arch/mux.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. int board_init(void)
  23. {
  24. gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
  25. return 0;
  26. }
  27. #ifdef CONFIG_SPL_BUILD
  28. static struct module_pin_mux mmc_pin_mux[] = {
  29. { OFFSET(pincntl157), PULLDOWN_EN | PULLUDDIS | MODE(0x0) },
  30. { OFFSET(pincntl158), PULLDOWN_EN | PULLUDEN | MODE(0x0) },
  31. { OFFSET(pincntl159), PULLUP_EN | PULLUDDIS | MODE(0x0) },
  32. { OFFSET(pincntl160), PULLUP_EN | PULLUDDIS | MODE(0x0) },
  33. { OFFSET(pincntl161), PULLUP_EN | PULLUDDIS | MODE(0x0) },
  34. { OFFSET(pincntl162), PULLUP_EN | PULLUDDIS | MODE(0x0) },
  35. { OFFSET(pincntl163), PULLUP_EN | PULLUDDIS | MODE(0x0) },
  36. { -1 },
  37. };
  38. const struct dmm_lisa_map_regs evm_lisa_map_regs = {
  39. .dmm_lisa_map_0 = 0x00000000,
  40. .dmm_lisa_map_1 = 0x00000000,
  41. .dmm_lisa_map_2 = 0x80640300,
  42. .dmm_lisa_map_3 = 0xC0640320,
  43. };
  44. /*
  45. * DDR2 related definitions
  46. */
  47. #ifdef CONFIG_TI816X_EVM_DDR2
  48. static struct ddr_data ddr2_data = {
  49. .datardsratio0 = ((0x40<<10) | (0x40<<0)),
  50. .datawdsratio0 = ((0x4A<<10) | (0x4A<<0)),
  51. .datawiratio0 = ((0x0<<10) | (0x0<<0)),
  52. .datagiratio0 = ((0x0<<10) | (0x0<<0)),
  53. .datafwsratio0 = ((0x13A<<10) | (0x13A<<0)),
  54. .datawrsratio0 = ((0x8A<<10) | (0x8A<<0)),
  55. };
  56. static struct cmd_control ddr2_ctrl = {
  57. .cmd0csratio = 0x80,
  58. .cmd0iclkout = 0x00,
  59. .cmd1csratio = 0x80,
  60. .cmd1iclkout = 0x00,
  61. .cmd2csratio = 0x80,
  62. .cmd2iclkout = 0x00,
  63. };
  64. static struct emif_regs ddr2_emif0_regs = {
  65. .sdram_config = 0x43801A3A,
  66. .ref_ctrl = 0x10000C30,
  67. .sdram_tim1 = 0x0AAB15E2,
  68. .sdram_tim2 = 0x423631D2,
  69. .sdram_tim3 = 0x0080032F,
  70. .emif_ddr_phy_ctlr_1 = 0x0, /* depend on cpu rev, set later */
  71. };
  72. static struct emif_regs ddr2_emif1_regs = {
  73. .sdram_config = 0x43801A3A,
  74. .ref_ctrl = 0x10000C30,
  75. .sdram_tim1 = 0x0AAB15E2,
  76. .sdram_tim2 = 0x423631D2,
  77. .sdram_tim3 = 0x0080032F,
  78. .emif_ddr_phy_ctlr_1 = 0x0, /* depend on cpu rev, set later */
  79. };
  80. #endif
  81. /*
  82. * DDR3 related definitions
  83. */
  84. #if defined(CONFIG_TI816X_DDR_PLL_400)
  85. #define RD_DQS 0x03B
  86. #define WR_DQS 0x0A6
  87. #define RD_DQS_GATE 0x12A
  88. #define EMIF_SDCFG 0x62A41032
  89. #define EMIF_SDREF 0x10000C30
  90. #define EMIF_TIM1 0x0CCCE524
  91. #define EMIF_TIM2 0x30308023
  92. #define EMIF_TIM3 0x009F82CF
  93. #define EMIF_PHYCFG 0x0000010B
  94. #elif defined(CONFIG_TI816X_DDR_PLL_531)
  95. #define RD_DQS 0x039
  96. #define WR_DQS 0x0B4
  97. #define RD_DQS_GATE 0x13D
  98. #define EMIF_SDCFG 0x62A51832
  99. #define EMIF_SDREF 0x1000102E
  100. #define EMIF_TIM1 0x0EF136AC
  101. #define EMIF_TIM2 0x30408063
  102. #define EMIF_TIM3 0x009F83AF
  103. #define EMIF_PHYCFG 0x0000010C
  104. #elif defined(CONFIG_TI816X_DDR_PLL_675)
  105. #define RD_DQS 0x039
  106. #define WR_DQS 0x091
  107. #define RD_DQS_GATE 0x196
  108. #define EMIF_SDCFG 0x62A63032
  109. #define EMIF_SDREF 0x10001491
  110. #define EMIF_TIM1 0x13358875
  111. #define EMIF_TIM2 0x5051806C
  112. #define EMIF_TIM3 0x009F84AF
  113. #define EMIF_PHYCFG 0x0000010F
  114. #elif defined(CONFIG_TI816X_DDR_PLL_796)
  115. #define RD_DQS 0x035
  116. #define WR_DQS 0x093
  117. #define RD_DQS_GATE 0x1B3
  118. #define EMIF_SDCFG 0x62A73832
  119. #define EMIF_SDREF 0x10001841
  120. #define EMIF_TIM1 0x1779C9FE
  121. #define EMIF_TIM2 0x50608074
  122. #define EMIF_TIM3 0x009F857F
  123. #define EMIF_PHYCFG 0x00000110
  124. #endif
  125. static struct ddr_data ddr3_data = {
  126. .datardsratio0 = ((RD_DQS<<10) | (RD_DQS<<0)),
  127. .datawdsratio0 = ((WR_DQS<<10) | (WR_DQS<<0)),
  128. .datawiratio0 = ((0x20<<10) | 0x20<<0),
  129. .datagiratio0 = ((0x20<<10) | 0x20<<0),
  130. .datafwsratio0 = ((RD_DQS_GATE<<10) | (RD_DQS_GATE<<0)),
  131. .datawrsratio0 = (((WR_DQS+0x40)<<10) | ((WR_DQS+0x40)<<0)),
  132. };
  133. static const struct cmd_control ddr3_ctrl = {
  134. .cmd0csratio = 0x100,
  135. .cmd0iclkout = 0x001,
  136. .cmd1csratio = 0x100,
  137. .cmd1iclkout = 0x001,
  138. .cmd2csratio = 0x100,
  139. .cmd2iclkout = 0x001,
  140. };
  141. static const struct emif_regs ddr3_emif0_regs = {
  142. .sdram_config = EMIF_SDCFG,
  143. .ref_ctrl = EMIF_SDREF,
  144. .sdram_tim1 = EMIF_TIM1,
  145. .sdram_tim2 = EMIF_TIM2,
  146. .sdram_tim3 = EMIF_TIM3,
  147. .emif_ddr_phy_ctlr_1 = EMIF_PHYCFG,
  148. };
  149. static const struct emif_regs ddr3_emif1_regs = {
  150. .sdram_config = EMIF_SDCFG,
  151. .ref_ctrl = EMIF_SDREF,
  152. .sdram_tim1 = EMIF_TIM1,
  153. .sdram_tim2 = EMIF_TIM2,
  154. .sdram_tim3 = EMIF_TIM3,
  155. .emif_ddr_phy_ctlr_1 = EMIF_PHYCFG,
  156. };
  157. void set_uart_mux_conf(void) {}
  158. void set_mux_conf_regs(void)
  159. {
  160. configure_module_pin_mux(mmc_pin_mux);
  161. }
  162. void sdram_init(void)
  163. {
  164. config_dmm(&evm_lisa_map_regs);
  165. #ifdef CONFIG_TI816X_EVM_DDR2
  166. if (CONFIG_TI816X_USE_EMIF0) {
  167. ddr2_emif0_regs.emif_ddr_phy_ctlr_1 =
  168. (get_cpu_rev() == 0x1 ? 0x0000010B : 0x0000030B);
  169. config_ddr(0, NULL, &ddr2_data, &ddr2_ctrl, &ddr2_emif0_regs,
  170. 0);
  171. }
  172. if (CONFIG_TI816X_USE_EMIF1) {
  173. ddr2_emif1_regs.emif_ddr_phy_ctlr_1 =
  174. (get_cpu_rev() == 0x1 ? 0x0000010B : 0x0000030B);
  175. config_ddr(1, NULL, &ddr2_data, &ddr2_ctrl, &ddr2_emif1_regs,
  176. 1);
  177. }
  178. #endif
  179. #ifdef CONFIG_TI816X_EVM_DDR3
  180. if (CONFIG_TI816X_USE_EMIF0)
  181. config_ddr(0, NULL, &ddr3_data, &ddr3_ctrl, &ddr3_emif0_regs,
  182. 0);
  183. if (CONFIG_TI816X_USE_EMIF1)
  184. config_ddr(1, NULL, &ddr3_data, &ddr3_ctrl, &ddr3_emif1_regs,
  185. 1);
  186. #endif
  187. }
  188. #endif /* CONFIG_SPL_BUILD */