0008-nb-gm45-Fix-Angel-s-DDR2-RCOMP-fix-on-DDR3-boards.patch 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. From 27a07626b780182fad0a2fa5fb73e10578e157c8 Mon Sep 17 00:00:00 2001
  2. From: Leah Rowe <info@minifree.org>
  3. Date: Tue, 6 Aug 2024 00:50:24 +0100
  4. Subject: [PATCH 08/18] nb/gm45: Fix Angel's DDR2 RCOMP fix on DDR3 boards
  5. We add this patch:
  6. commit commit_id_here
  7. Author: Angel Pons <th3fanbus@gmail.com>
  8. Date: Mon May 10 22:40:59 2021 +0200
  9. nb/intel/gm45: Make DDR2 raminit work
  10. This patch was original applied, in lbmk, only on coreboot/dell,
  11. separately from coreboot/default, which was wasteful because it
  12. meant having an entire coreboot tree just for a single board. We
  13. did this, because the DDR2 RCOMP fix happened to break DDR3 init
  14. on other boards.
  15. What *this* new patch does on top of Angel's patch, is make sure
  16. that their changes only apply to DDR2, while DDR3 behaviour remains
  17. unchanged. This means that the Dell Latitude E6400 can be supported
  18. in the main coreboot tree, within lbmk.
  19. Essentially, this patch restores the old behaviour, prior to applying
  20. Angel's patch, only when DDR3 memory is used.
  21. Signed-off-by: Leah Rowe <info@minifree.org>
  22. ---
  23. src/northbridge/intel/gm45/raminit.c | 161 +++++++++---------
  24. .../intel/gm45/raminit_rcomp_calibration.c | 9 +-
  25. 2 files changed, 88 insertions(+), 82 deletions(-)
  26. diff --git a/src/northbridge/intel/gm45/raminit.c b/src/northbridge/intel/gm45/raminit.c
  27. index df8f46fbbc..433db3a68c 100644
  28. --- a/src/northbridge/intel/gm45/raminit.c
  29. +++ b/src/northbridge/intel/gm45/raminit.c
  30. @@ -1117,7 +1117,10 @@ static void dram_program_timings(const int spd_type, const timings_t *const timi
  31. reg = (reg & ~(0xf << 10)) | (2 << 10);
  32. else
  33. reg = (reg & ~(0xf << 10)) | (3 << 10);
  34. - reg = (reg & ~(0x7 << 5)) | (2 << 5);
  35. + if (spd_type == DDR2)
  36. + reg = (reg & ~(0x7 << 5)) | (2 << 5);
  37. + else
  38. + reg = (reg & ~(0x7 << 5)) | (3 << 5);
  39. } else if (timings->mem_clock != MEM_CLOCK_1067MT) {
  40. reg = (reg & ~(0x7 << 15)) | ((9 - timings->CAS) << 15);
  41. reg = (reg & ~(0xf << 10)) | ((timings->CAS - 3) << 10);
  42. @@ -2209,83 +2212,85 @@ void raminit(sysinfo_t *const sysinfo, const int s3resume)
  43. raminit_write_training(timings->mem_clock, dimms, s3resume);
  44. }
  45. - /*
  46. - * Program hardcoded DDR2-800 RCOMP SRAM codes. This must be done
  47. - * after receiver enable calibration, otherwise raminit sometimes
  48. - * completes with non-working memory.
  49. - */
  50. - mchbar_write32(0x0530, 0x06060005);
  51. - mchbar_write32(0x0680, 0x06060606);
  52. - mchbar_write32(0x0684, 0x08070606);
  53. - mchbar_write32(0x0688, 0x0e0e0c0a);
  54. - mchbar_write32(0x068c, 0x0e0e0e0e);
  55. - mchbar_write32(0x0698, 0x06060606);
  56. - mchbar_write32(0x069c, 0x08070606);
  57. - mchbar_write32(0x06a0, 0x0c0c0b0a);
  58. - mchbar_write32(0x06a4, 0x0c0c0c0c);
  59. -
  60. - mchbar_write32(0x06c0, 0x02020202);
  61. - mchbar_write32(0x06c4, 0x03020202);
  62. - mchbar_write32(0x06c8, 0x04040403);
  63. - mchbar_write32(0x06cc, 0x04040404);
  64. - mchbar_write32(0x06d8, 0x02020202);
  65. - mchbar_write32(0x06dc, 0x03020202);
  66. - mchbar_write32(0x06e0, 0x04040403);
  67. - mchbar_write32(0x06e4, 0x04040404);
  68. -
  69. - mchbar_write32(0x0700, 0x02020202);
  70. - mchbar_write32(0x0704, 0x03020202);
  71. - mchbar_write32(0x0708, 0x04040403);
  72. - mchbar_write32(0x070c, 0x04040404);
  73. - mchbar_write32(0x0718, 0x02020202);
  74. - mchbar_write32(0x071c, 0x03020202);
  75. - mchbar_write32(0x0720, 0x04040403);
  76. - mchbar_write32(0x0724, 0x04040404);
  77. -
  78. - mchbar_write32(0x0740, 0x02020202);
  79. - mchbar_write32(0x0744, 0x03020202);
  80. - mchbar_write32(0x0748, 0x04040403);
  81. - mchbar_write32(0x074c, 0x04040404);
  82. - mchbar_write32(0x0758, 0x02020202);
  83. - mchbar_write32(0x075c, 0x03020202);
  84. - mchbar_write32(0x0760, 0x04040403);
  85. - mchbar_write32(0x0764, 0x04040404);
  86. -
  87. - mchbar_write32(0x0780, 0x06060606);
  88. - mchbar_write32(0x0784, 0x09070606);
  89. - mchbar_write32(0x0788, 0x0e0e0c0b);
  90. - mchbar_write32(0x078c, 0x0e0e0e0e);
  91. - mchbar_write32(0x0798, 0x06060606);
  92. - mchbar_write32(0x079c, 0x09070606);
  93. - mchbar_write32(0x07a0, 0x0d0d0c0b);
  94. - mchbar_write32(0x07a4, 0x0d0d0d0d);
  95. -
  96. - mchbar_write32(0x07c0, 0x06060606);
  97. - mchbar_write32(0x07c4, 0x09070606);
  98. - mchbar_write32(0x07c8, 0x0e0e0c0b);
  99. - mchbar_write32(0x07cc, 0x0e0e0e0e);
  100. - mchbar_write32(0x07d8, 0x06060606);
  101. - mchbar_write32(0x07dc, 0x09070606);
  102. - mchbar_write32(0x07e0, 0x0d0d0c0b);
  103. - mchbar_write32(0x07e4, 0x0d0d0d0d);
  104. -
  105. - mchbar_write32(0x0840, 0x06060606);
  106. - mchbar_write32(0x0844, 0x08070606);
  107. - mchbar_write32(0x0848, 0x0e0e0c0a);
  108. - mchbar_write32(0x084c, 0x0e0e0e0e);
  109. - mchbar_write32(0x0858, 0x06060606);
  110. - mchbar_write32(0x085c, 0x08070606);
  111. - mchbar_write32(0x0860, 0x0c0c0b0a);
  112. - mchbar_write32(0x0864, 0x0c0c0c0c);
  113. -
  114. - mchbar_write32(0x0880, 0x02020202);
  115. - mchbar_write32(0x0884, 0x03020202);
  116. - mchbar_write32(0x0888, 0x04040403);
  117. - mchbar_write32(0x088c, 0x04040404);
  118. - mchbar_write32(0x0898, 0x02020202);
  119. - mchbar_write32(0x089c, 0x03020202);
  120. - mchbar_write32(0x08a0, 0x04040403);
  121. - mchbar_write32(0x08a4, 0x04040404);
  122. + if (sysinfo->spd_type == DDR2) {
  123. + /*
  124. + * Program hardcoded DDR2-800 RCOMP SRAM codes. This must be done
  125. + * after receiver enable calibration, otherwise raminit sometimes
  126. + * completes with non-working memory.
  127. + */
  128. + mchbar_write32(0x0530, 0x06060005);
  129. + mchbar_write32(0x0680, 0x06060606);
  130. + mchbar_write32(0x0684, 0x08070606);
  131. + mchbar_write32(0x0688, 0x0e0e0c0a);
  132. + mchbar_write32(0x068c, 0x0e0e0e0e);
  133. + mchbar_write32(0x0698, 0x06060606);
  134. + mchbar_write32(0x069c, 0x08070606);
  135. + mchbar_write32(0x06a0, 0x0c0c0b0a);
  136. + mchbar_write32(0x06a4, 0x0c0c0c0c);
  137. +
  138. + mchbar_write32(0x06c0, 0x02020202);
  139. + mchbar_write32(0x06c4, 0x03020202);
  140. + mchbar_write32(0x06c8, 0x04040403);
  141. + mchbar_write32(0x06cc, 0x04040404);
  142. + mchbar_write32(0x06d8, 0x02020202);
  143. + mchbar_write32(0x06dc, 0x03020202);
  144. + mchbar_write32(0x06e0, 0x04040403);
  145. + mchbar_write32(0x06e4, 0x04040404);
  146. +
  147. + mchbar_write32(0x0700, 0x02020202);
  148. + mchbar_write32(0x0704, 0x03020202);
  149. + mchbar_write32(0x0708, 0x04040403);
  150. + mchbar_write32(0x070c, 0x04040404);
  151. + mchbar_write32(0x0718, 0x02020202);
  152. + mchbar_write32(0x071c, 0x03020202);
  153. + mchbar_write32(0x0720, 0x04040403);
  154. + mchbar_write32(0x0724, 0x04040404);
  155. +
  156. + mchbar_write32(0x0740, 0x02020202);
  157. + mchbar_write32(0x0744, 0x03020202);
  158. + mchbar_write32(0x0748, 0x04040403);
  159. + mchbar_write32(0x074c, 0x04040404);
  160. + mchbar_write32(0x0758, 0x02020202);
  161. + mchbar_write32(0x075c, 0x03020202);
  162. + mchbar_write32(0x0760, 0x04040403);
  163. + mchbar_write32(0x0764, 0x04040404);
  164. +
  165. + mchbar_write32(0x0780, 0x06060606);
  166. + mchbar_write32(0x0784, 0x09070606);
  167. + mchbar_write32(0x0788, 0x0e0e0c0b);
  168. + mchbar_write32(0x078c, 0x0e0e0e0e);
  169. + mchbar_write32(0x0798, 0x06060606);
  170. + mchbar_write32(0x079c, 0x09070606);
  171. + mchbar_write32(0x07a0, 0x0d0d0c0b);
  172. + mchbar_write32(0x07a4, 0x0d0d0d0d);
  173. +
  174. + mchbar_write32(0x07c0, 0x06060606);
  175. + mchbar_write32(0x07c4, 0x09070606);
  176. + mchbar_write32(0x07c8, 0x0e0e0c0b);
  177. + mchbar_write32(0x07cc, 0x0e0e0e0e);
  178. + mchbar_write32(0x07d8, 0x06060606);
  179. + mchbar_write32(0x07dc, 0x09070606);
  180. + mchbar_write32(0x07e0, 0x0d0d0c0b);
  181. + mchbar_write32(0x07e4, 0x0d0d0d0d);
  182. +
  183. + mchbar_write32(0x0840, 0x06060606);
  184. + mchbar_write32(0x0844, 0x08070606);
  185. + mchbar_write32(0x0848, 0x0e0e0c0a);
  186. + mchbar_write32(0x084c, 0x0e0e0e0e);
  187. + mchbar_write32(0x0858, 0x06060606);
  188. + mchbar_write32(0x085c, 0x08070606);
  189. + mchbar_write32(0x0860, 0x0c0c0b0a);
  190. + mchbar_write32(0x0864, 0x0c0c0c0c);
  191. +
  192. + mchbar_write32(0x0880, 0x02020202);
  193. + mchbar_write32(0x0884, 0x03020202);
  194. + mchbar_write32(0x0888, 0x04040403);
  195. + mchbar_write32(0x088c, 0x04040404);
  196. + mchbar_write32(0x0898, 0x02020202);
  197. + mchbar_write32(0x089c, 0x03020202);
  198. + mchbar_write32(0x08a0, 0x04040403);
  199. + mchbar_write32(0x08a4, 0x04040404);
  200. + }
  201. igd_compute_ggc(sysinfo);
  202. diff --git a/src/northbridge/intel/gm45/raminit_rcomp_calibration.c b/src/northbridge/intel/gm45/raminit_rcomp_calibration.c
  203. index b74765fd9c..5d4505e063 100644
  204. --- a/src/northbridge/intel/gm45/raminit_rcomp_calibration.c
  205. +++ b/src/northbridge/intel/gm45/raminit_rcomp_calibration.c
  206. @@ -198,7 +198,7 @@ void raminit_rcomp_calibration(int ddr_type, const stepping_t stepping) {
  207. reg = mchbar_read32(0x518);
  208. lut_idx[channel][group][PULL_UP] = (reg >> 24) & 0x7f;
  209. lut_idx[channel][group][PULL_DOWN] = (reg >> 16) & 0x7f;
  210. - if (i == 1) {
  211. + if ((i == 1) && (ddr_type == DDR2)) {
  212. magic_comp[0] = (reg >> 8) & 0x3f;
  213. magic_comp[1] = (reg >> 0) & 0x3f;
  214. }
  215. @@ -242,7 +242,8 @@ void raminit_rcomp_calibration(int ddr_type, const stepping_t stepping) {
  216. }
  217. mchbar += 0x0040;
  218. }
  219. -
  220. - mchbar_clrsetbits32(0x4d0, 0x3f << 26, magic_comp[0] << 26);
  221. - mchbar_clrsetbits32(0x4d0, 0x3f << 20, magic_comp[1] << 20);
  222. + if (ddr_type == DDR2) {
  223. + mchbar_clrsetbits32(0x4d0, 0x3f << 26, magic_comp[0] << 26);
  224. + mchbar_clrsetbits32(0x4d0, 0x3f << 20, magic_comp[1] << 20);
  225. + }
  226. }
  227. --
  228. 2.39.5