dram_port.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * Copyright (C) 2021 Sartura Ltd.
  3. * Copyright (C) 2021 Globalscale technologies, Inc.
  4. * Copyright (C) 2021 Marvell International Ltd.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. * https://spdx.org/licenses
  8. */
  9. #include <arch_helpers.h>
  10. #include <common/debug.h>
  11. #include <mv_ddr_if.h>
  12. #include <plat_marvell.h>
  13. /*
  14. * This function may modify the default DRAM parameters
  15. * based on information received from SPD or bootloader
  16. * configuration located on non volatile storage
  17. */
  18. void plat_marvell_dram_update_topology(void)
  19. {
  20. }
  21. /*
  22. * This struct provides the DRAM training code with
  23. * the appropriate board DRAM configuration
  24. */
  25. #if DDR_TOPOLOGY == 0
  26. static struct mv_ddr_topology_map board_topology_map_2g = {
  27. /* 1CS 4Gb x4 devices of Samsung K4A4G085WF */
  28. DEBUG_LEVEL_ERROR,
  29. 0x1, /* active interfaces */
  30. /* cs_mask, mirror, dqs_swap, ck_swap X subphys */
  31. { { { {0x1, 0x2, 0, 0},
  32. {0x1, 0x2, 0, 0},
  33. {0x1, 0x2, 0, 0},
  34. {0x1, 0x2, 0, 0},
  35. {0x1, 0x2, 0, 0},
  36. {0x1, 0x2, 0, 0},
  37. {0x1, 0x2, 0, 0},
  38. {0x1, 0x2, 0, 0},
  39. {0x1, 0x2, 0, 0} },
  40. SPEED_BIN_DDR_2400R, /* speed_bin */
  41. MV_DDR_DEV_WIDTH_8BIT, /* sdram device width */
  42. MV_DDR_DIE_CAP_4GBIT, /* die capacity */
  43. MV_DDR_FREQ_SAR, /* frequency */
  44. 0, 0, /* cas_l, cas_wl */
  45. MV_DDR_TEMP_LOW} }, /* temperature */
  46. BUS_MASK_32BIT, /* subphys mask */
  47. MV_DDR_CFG_DEFAULT, /* ddr configuration data source */
  48. NOT_COMBINED, /* ddr twin-die combined*/
  49. { {0} }, /* raw spd data */
  50. {0}, /* timing parameters */
  51. { /* electrical configuration */
  52. { /* memory electrical configuration */
  53. MV_DDR_RTT_NOM_PARK_RZQ_DISABLE, /* rtt_nom */
  54. {
  55. MV_DDR_RTT_NOM_PARK_RZQ_DIV4, /* rtt_park 1cs */
  56. MV_DDR_RTT_NOM_PARK_RZQ_DIV1 /* rtt_park 2cs */
  57. },
  58. {
  59. MV_DDR_RTT_WR_DYN_ODT_OFF, /* rtt_wr 1cs */
  60. MV_DDR_RTT_WR_RZQ_DIV2 /* rtt_wr 2cs */
  61. },
  62. MV_DDR_DIC_RZQ_DIV7 /* dic */
  63. },
  64. { /* phy electrical configuration */
  65. MV_DDR_OHM_30, /* data_drv_p */
  66. MV_DDR_OHM_30, /* data_drv_n */
  67. MV_DDR_OHM_30, /* ctrl_drv_p */
  68. MV_DDR_OHM_30, /* ctrl_drv_n */
  69. {
  70. MV_DDR_OHM_60, /* odt_p 1cs */
  71. MV_DDR_OHM_120 /* odt_p 2cs */
  72. },
  73. {
  74. MV_DDR_OHM_60, /* odt_n 1cs */
  75. MV_DDR_OHM_120 /* odt_n 2cs */
  76. },
  77. },
  78. { /* mac electrical configuration */
  79. MV_DDR_ODT_CFG_NORMAL, /* odtcfg_pattern */
  80. MV_DDR_ODT_CFG_ALWAYS_ON, /* odtcfg_write */
  81. MV_DDR_ODT_CFG_NORMAL, /* odtcfg_read */
  82. },
  83. }
  84. };
  85. #endif
  86. #if DDR_TOPOLOGY == 1
  87. static struct mv_ddr_topology_map board_topology_map_4g = {
  88. /* 1CS 8Gb x4 devices of Samsung K4A8G085WC-BCTD */
  89. DEBUG_LEVEL_ERROR,
  90. 0x1, /* active interfaces */
  91. /* cs_mask, mirror, dqs_swap, ck_swap X subphys */
  92. { { { {0x1, 0x2, 0, 0},
  93. {0x1, 0x2, 0, 0},
  94. {0x1, 0x2, 0, 0},
  95. {0x1, 0x2, 0, 0},
  96. {0x1, 0x2, 0, 0},
  97. {0x1, 0x2, 0, 0},
  98. {0x1, 0x2, 0, 0},
  99. {0x1, 0x2, 0, 0},
  100. {0x1, 0x2, 0, 0} },
  101. SPEED_BIN_DDR_2400R, /* speed_bin */
  102. MV_DDR_DEV_WIDTH_8BIT, /* sdram device width */
  103. MV_DDR_DIE_CAP_8GBIT, /* die capacity */
  104. MV_DDR_FREQ_SAR, /* frequency */
  105. 0, 0, /* cas_l, cas_wl */
  106. MV_DDR_TEMP_LOW} }, /* temperature */
  107. BUS_MASK_32BIT, /* subphys mask */
  108. MV_DDR_CFG_DEFAULT, /* ddr configuration data source */
  109. NOT_COMBINED, /* ddr twin-die combined*/
  110. { {0} }, /* raw spd data */
  111. {0}, /* timing parameters */
  112. { /* electrical configuration */
  113. { /* memory electrical configuration */
  114. MV_DDR_RTT_NOM_PARK_RZQ_DISABLE, /* rtt_nom */
  115. {
  116. MV_DDR_RTT_NOM_PARK_RZQ_DIV4, /* rtt_park 1cs */
  117. MV_DDR_RTT_NOM_PARK_RZQ_DIV1 /* rtt_park 2cs */
  118. },
  119. {
  120. MV_DDR_RTT_WR_DYN_ODT_OFF, /* rtt_wr 1cs */
  121. MV_DDR_RTT_WR_RZQ_DIV2 /* rtt_wr 2cs */
  122. },
  123. MV_DDR_DIC_RZQ_DIV7 /* dic */
  124. },
  125. { /* phy electrical configuration */
  126. MV_DDR_OHM_30, /* data_drv_p */
  127. MV_DDR_OHM_30, /* data_drv_n */
  128. MV_DDR_OHM_30, /* ctrl_drv_p */
  129. MV_DDR_OHM_30, /* ctrl_drv_n */
  130. {
  131. MV_DDR_OHM_60, /* odt_p 1cs */
  132. MV_DDR_OHM_120 /* odt_p 2cs */
  133. },
  134. {
  135. MV_DDR_OHM_60, /* odt_n 1cs */
  136. MV_DDR_OHM_120 /* odt_n 2cs */
  137. },
  138. },
  139. { /* mac electrical configuration */
  140. MV_DDR_ODT_CFG_NORMAL, /* odtcfg_pattern */
  141. MV_DDR_ODT_CFG_ALWAYS_ON, /* odtcfg_write */
  142. MV_DDR_ODT_CFG_NORMAL, /* odtcfg_read */
  143. },
  144. }
  145. };
  146. #endif
  147. #if DDR_TOPOLOGY == 2
  148. static struct mv_ddr_topology_map board_topology_map_8g = {
  149. /* 2CS 8Gb x8 devices of Micron MT40A1G8WE-083E IT */
  150. DEBUG_LEVEL_ERROR,
  151. 0x1, /* active interfaces */
  152. /* cs_mask, mirror, dqs_swap, ck_swap X subphys */
  153. { { { {0x3, 0x2, 0, 0},
  154. {0x3, 0x2, 0, 0},
  155. {0x3, 0x2, 0, 0},
  156. {0x3, 0x2, 0, 0},
  157. {0x3, 0x2, 0, 0},
  158. {0x3, 0x2, 0, 0},
  159. {0x3, 0x2, 0, 0},
  160. {0x3, 0x2, 0, 0},
  161. {0x3, 0x2, 0, 0} },
  162. SPEED_BIN_DDR_2400R, /* speed_bin */
  163. MV_DDR_DEV_WIDTH_8BIT, /* sdram device width */
  164. MV_DDR_DIE_CAP_8GBIT, /* die capacity */
  165. MV_DDR_FREQ_SAR, /* frequency */
  166. 0, 0, /* cas_l, cas_wl */
  167. MV_DDR_TEMP_LOW} }, /* temperature */
  168. BUS_MASK_32BIT, /* subphys mask */
  169. MV_DDR_CFG_DEFAULT, /* ddr configuration data source */
  170. NOT_COMBINED, /* ddr twin-die combined*/
  171. { {0} }, /* raw spd data */
  172. {0}, /* timing parameters */
  173. { /* electrical configuration */
  174. { /* memory electrical configuration */
  175. MV_DDR_RTT_NOM_PARK_RZQ_DISABLE, /* rtt_nom */
  176. {
  177. MV_DDR_RTT_NOM_PARK_RZQ_DIV4, /* rtt_park 1cs */
  178. MV_DDR_RTT_NOM_PARK_RZQ_DIV1 /* rtt_park 2cs */
  179. },
  180. {
  181. MV_DDR_RTT_WR_DYN_ODT_OFF, /* rtt_wr 1cs */
  182. MV_DDR_RTT_WR_RZQ_DIV2 /* rtt_wr 2cs */
  183. },
  184. MV_DDR_DIC_RZQ_DIV7 /* dic */
  185. },
  186. { /* phy electrical configuration */
  187. MV_DDR_OHM_30, /* data_drv_p */
  188. MV_DDR_OHM_30, /* data_drv_n */
  189. MV_DDR_OHM_30, /* ctrl_drv_p */
  190. MV_DDR_OHM_30, /* ctrl_drv_n */
  191. {
  192. MV_DDR_OHM_60, /* odt_p 1cs */
  193. MV_DDR_OHM_120 /* odt_p 2cs */
  194. },
  195. {
  196. MV_DDR_OHM_60, /* odt_n 1cs */
  197. MV_DDR_OHM_120 /* odt_n 2cs */
  198. },
  199. },
  200. { /* mac electrical configuration */
  201. MV_DDR_ODT_CFG_NORMAL, /* odtcfg_pattern */
  202. MV_DDR_ODT_CFG_ALWAYS_ON, /* odtcfg_write */
  203. MV_DDR_ODT_CFG_NORMAL, /* odtcfg_read */
  204. },
  205. }
  206. };
  207. #endif
  208. struct mv_ddr_topology_map *mv_ddr_topology_map_get(void)
  209. {
  210. /* a70x0_mochabin board supports 3 DDR4 models (2G/1CS, 4G/1CS, 8G/2CS) */
  211. #if DDR_TOPOLOGY == 0
  212. return &board_topology_map_2g;
  213. #elif DDR_TOPOLOGY == 1
  214. return &board_topology_map_4g;
  215. #elif DDR_TOPOLOGY == 2
  216. return &board_topology_map_8g;
  217. #else
  218. #error "Unknown DDR topology"
  219. #endif
  220. }