lc_common_dimm_params.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright 2008-2016 Freescale Semiconductor, Inc.
  4. * Copyright 2017-2018 NXP Semiconductor
  5. */
  6. #include <common.h>
  7. #include <fsl_ddr_sdram.h>
  8. #include <fsl_ddr.h>
  9. #if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
  10. static unsigned int
  11. compute_cas_latency(const unsigned int ctrl_num,
  12. const dimm_params_t *dimm_params,
  13. common_timing_params_t *outpdimm,
  14. unsigned int number_of_dimms)
  15. {
  16. unsigned int i;
  17. unsigned int common_caslat;
  18. unsigned int caslat_actual;
  19. unsigned int retry = 16;
  20. unsigned int tmp = ~0;
  21. const unsigned int mclk_ps = get_memory_clk_period_ps(ctrl_num);
  22. #ifdef CONFIG_SYS_FSL_DDR3
  23. const unsigned int taamax = 20000;
  24. #else
  25. const unsigned int taamax = 18000;
  26. #endif
  27. /* compute the common CAS latency supported between slots */
  28. for (i = 0; i < number_of_dimms; i++) {
  29. if (dimm_params[i].n_ranks)
  30. tmp &= dimm_params[i].caslat_x;
  31. }
  32. common_caslat = tmp;
  33. /* validate if the memory clk is in the range of dimms */
  34. if (mclk_ps < outpdimm->tckmin_x_ps) {
  35. printf("DDR clock (MCLK cycle %u ps) is faster than "
  36. "the slowest DIMM(s) (tCKmin %u ps) can support.\n",
  37. mclk_ps, outpdimm->tckmin_x_ps);
  38. }
  39. #ifdef CONFIG_SYS_FSL_DDR4
  40. if (mclk_ps > outpdimm->tckmax_ps) {
  41. printf("DDR clock (MCLK cycle %u ps) is slower than DIMM(s) (tCKmax %u ps) can support.\n",
  42. mclk_ps, outpdimm->tckmax_ps);
  43. }
  44. #endif
  45. /* determine the acutal cas latency */
  46. caslat_actual = (outpdimm->taamin_ps + mclk_ps - 1) / mclk_ps;
  47. /* check if the dimms support the CAS latency */
  48. while (!(common_caslat & (1 << caslat_actual)) && retry > 0) {
  49. caslat_actual++;
  50. retry--;
  51. }
  52. /* once the caculation of caslat_actual is completed
  53. * we must verify that this CAS latency value does not
  54. * exceed tAAmax, which is 20 ns for all DDR3 speed grades,
  55. * 18ns for all DDR4 speed grades.
  56. */
  57. if (caslat_actual * mclk_ps > taamax) {
  58. printf("The chosen cas latency %d is too large\n",
  59. caslat_actual);
  60. }
  61. outpdimm->lowest_common_spd_caslat = caslat_actual;
  62. debug("lowest_common_spd_caslat is 0x%x\n", caslat_actual);
  63. return 0;
  64. }
  65. #else /* for DDR1 and DDR2 */
  66. static unsigned int
  67. compute_cas_latency(const unsigned int ctrl_num,
  68. const dimm_params_t *dimm_params,
  69. common_timing_params_t *outpdimm,
  70. unsigned int number_of_dimms)
  71. {
  72. int i;
  73. const unsigned int mclk_ps = get_memory_clk_period_ps(ctrl_num);
  74. unsigned int lowest_good_caslat;
  75. unsigned int not_ok;
  76. unsigned int temp1, temp2;
  77. debug("using mclk_ps = %u\n", mclk_ps);
  78. if (mclk_ps > outpdimm->tckmax_ps) {
  79. printf("Warning: DDR clock (%u ps) is slower than DIMM(s) (tCKmax %u ps)\n",
  80. mclk_ps, outpdimm->tckmax_ps);
  81. }
  82. /*
  83. * Compute a CAS latency suitable for all DIMMs
  84. *
  85. * Strategy for SPD-defined latencies: compute only
  86. * CAS latency defined by all DIMMs.
  87. */
  88. /*
  89. * Step 1: find CAS latency common to all DIMMs using bitwise
  90. * operation.
  91. */
  92. temp1 = 0xFF;
  93. for (i = 0; i < number_of_dimms; i++) {
  94. if (dimm_params[i].n_ranks) {
  95. temp2 = 0;
  96. temp2 |= 1 << dimm_params[i].caslat_x;
  97. temp2 |= 1 << dimm_params[i].caslat_x_minus_1;
  98. temp2 |= 1 << dimm_params[i].caslat_x_minus_2;
  99. /*
  100. * If there was no entry for X-2 (X-1) in
  101. * the SPD, then caslat_x_minus_2
  102. * (caslat_x_minus_1) contains either 255 or
  103. * 0xFFFFFFFF because that's what the glorious
  104. * __ilog2 function returns for an input of 0.
  105. * On 32-bit PowerPC, left shift counts with bit
  106. * 26 set (that the value of 255 or 0xFFFFFFFF
  107. * will have), cause the destination register to
  108. * be 0. That is why this works.
  109. */
  110. temp1 &= temp2;
  111. }
  112. }
  113. /*
  114. * Step 2: check each common CAS latency against tCK of each
  115. * DIMM's SPD.
  116. */
  117. lowest_good_caslat = 0;
  118. temp2 = 0;
  119. while (temp1) {
  120. not_ok = 0;
  121. temp2 = __ilog2(temp1);
  122. debug("checking common caslat = %u\n", temp2);
  123. /* Check if this CAS latency will work on all DIMMs at tCK. */
  124. for (i = 0; i < number_of_dimms; i++) {
  125. if (!dimm_params[i].n_ranks)
  126. continue;
  127. if (dimm_params[i].caslat_x == temp2) {
  128. if (mclk_ps >= dimm_params[i].tckmin_x_ps) {
  129. debug("CL = %u ok on DIMM %u at tCK=%u ps with tCKmin_X_ps of %u\n",
  130. temp2, i, mclk_ps,
  131. dimm_params[i].tckmin_x_ps);
  132. continue;
  133. } else {
  134. not_ok++;
  135. }
  136. }
  137. if (dimm_params[i].caslat_x_minus_1 == temp2) {
  138. unsigned int tckmin_x_minus_1_ps
  139. = dimm_params[i].tckmin_x_minus_1_ps;
  140. if (mclk_ps >= tckmin_x_minus_1_ps) {
  141. debug("CL = %u ok on DIMM %u at tCK=%u ps with tckmin_x_minus_1_ps of %u\n",
  142. temp2, i, mclk_ps,
  143. tckmin_x_minus_1_ps);
  144. continue;
  145. } else {
  146. not_ok++;
  147. }
  148. }
  149. if (dimm_params[i].caslat_x_minus_2 == temp2) {
  150. unsigned int tckmin_x_minus_2_ps
  151. = dimm_params[i].tckmin_x_minus_2_ps;
  152. if (mclk_ps >= tckmin_x_minus_2_ps) {
  153. debug("CL = %u ok on DIMM %u at tCK=%u ps with tckmin_x_minus_2_ps of %u\n",
  154. temp2, i, mclk_ps,
  155. tckmin_x_minus_2_ps);
  156. continue;
  157. } else {
  158. not_ok++;
  159. }
  160. }
  161. }
  162. if (!not_ok)
  163. lowest_good_caslat = temp2;
  164. temp1 &= ~(1 << temp2);
  165. }
  166. debug("lowest common SPD-defined CAS latency = %u\n",
  167. lowest_good_caslat);
  168. outpdimm->lowest_common_spd_caslat = lowest_good_caslat;
  169. /*
  170. * Compute a common 'de-rated' CAS latency.
  171. *
  172. * The strategy here is to find the *highest* dereated cas latency
  173. * with the assumption that all of the DIMMs will support a dereated
  174. * CAS latency higher than or equal to their lowest dereated value.
  175. */
  176. temp1 = 0;
  177. for (i = 0; i < number_of_dimms; i++)
  178. temp1 = max(temp1, dimm_params[i].caslat_lowest_derated);
  179. outpdimm->highest_common_derated_caslat = temp1;
  180. debug("highest common dereated CAS latency = %u\n", temp1);
  181. return 0;
  182. }
  183. #endif
  184. /*
  185. * compute_lowest_common_dimm_parameters()
  186. *
  187. * Determine the worst-case DIMM timing parameters from the set of DIMMs
  188. * whose parameters have been computed into the array pointed to
  189. * by dimm_params.
  190. */
  191. unsigned int
  192. compute_lowest_common_dimm_parameters(const unsigned int ctrl_num,
  193. const dimm_params_t *dimm_params,
  194. common_timing_params_t *outpdimm,
  195. const unsigned int number_of_dimms)
  196. {
  197. unsigned int i, j;
  198. unsigned int tckmin_x_ps = 0;
  199. unsigned int tckmax_ps = 0xFFFFFFFF;
  200. unsigned int trcd_ps = 0;
  201. unsigned int trp_ps = 0;
  202. unsigned int tras_ps = 0;
  203. #if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
  204. unsigned int taamin_ps = 0;
  205. #endif
  206. #ifdef CONFIG_SYS_FSL_DDR4
  207. unsigned int twr_ps = 15000;
  208. unsigned int trfc1_ps = 0;
  209. unsigned int trfc2_ps = 0;
  210. unsigned int trfc4_ps = 0;
  211. unsigned int trrds_ps = 0;
  212. unsigned int trrdl_ps = 0;
  213. unsigned int tccdl_ps = 0;
  214. unsigned int trfc_slr_ps = 0;
  215. #else
  216. unsigned int twr_ps = 0;
  217. unsigned int twtr_ps = 0;
  218. unsigned int trfc_ps = 0;
  219. unsigned int trrd_ps = 0;
  220. unsigned int trtp_ps = 0;
  221. #endif
  222. unsigned int trc_ps = 0;
  223. unsigned int refresh_rate_ps = 0;
  224. unsigned int extended_op_srt = 1;
  225. #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
  226. unsigned int tis_ps = 0;
  227. unsigned int tih_ps = 0;
  228. unsigned int tds_ps = 0;
  229. unsigned int tdh_ps = 0;
  230. unsigned int tdqsq_max_ps = 0;
  231. unsigned int tqhs_ps = 0;
  232. #endif
  233. unsigned int temp1, temp2;
  234. unsigned int additive_latency = 0;
  235. temp1 = 0;
  236. for (i = 0; i < number_of_dimms; i++) {
  237. /*
  238. * If there are no ranks on this DIMM,
  239. * it probably doesn't exist, so skip it.
  240. */
  241. if (dimm_params[i].n_ranks == 0) {
  242. temp1++;
  243. continue;
  244. }
  245. if (dimm_params[i].n_ranks == 4 && i != 0) {
  246. printf("Found Quad-rank DIMM in wrong bank, ignored."
  247. " Software may not run as expected.\n");
  248. temp1++;
  249. continue;
  250. }
  251. /*
  252. * check if quad-rank DIMM is plugged if
  253. * CONFIG_CHIP_SELECT_QUAD_CAPABLE is not defined
  254. * Only the board with proper design is capable
  255. */
  256. #ifndef CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE
  257. if (dimm_params[i].n_ranks == 4 && \
  258. CONFIG_CHIP_SELECTS_PER_CTRL/CONFIG_DIMM_SLOTS_PER_CTLR < 4) {
  259. printf("Found Quad-rank DIMM, not able to support.");
  260. temp1++;
  261. continue;
  262. }
  263. #endif
  264. /*
  265. * Find minimum tckmax_ps to find fastest slow speed,
  266. * i.e., this is the slowest the whole system can go.
  267. */
  268. tckmax_ps = min(tckmax_ps,
  269. (unsigned int)dimm_params[i].tckmax_ps);
  270. #if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
  271. taamin_ps = max(taamin_ps,
  272. (unsigned int)dimm_params[i].taa_ps);
  273. #endif
  274. tckmin_x_ps = max(tckmin_x_ps,
  275. (unsigned int)dimm_params[i].tckmin_x_ps);
  276. trcd_ps = max(trcd_ps, (unsigned int)dimm_params[i].trcd_ps);
  277. trp_ps = max(trp_ps, (unsigned int)dimm_params[i].trp_ps);
  278. tras_ps = max(tras_ps, (unsigned int)dimm_params[i].tras_ps);
  279. #ifdef CONFIG_SYS_FSL_DDR4
  280. trfc1_ps = max(trfc1_ps,
  281. (unsigned int)dimm_params[i].trfc1_ps);
  282. trfc2_ps = max(trfc2_ps,
  283. (unsigned int)dimm_params[i].trfc2_ps);
  284. trfc4_ps = max(trfc4_ps,
  285. (unsigned int)dimm_params[i].trfc4_ps);
  286. trrds_ps = max(trrds_ps,
  287. (unsigned int)dimm_params[i].trrds_ps);
  288. trrdl_ps = max(trrdl_ps,
  289. (unsigned int)dimm_params[i].trrdl_ps);
  290. tccdl_ps = max(tccdl_ps,
  291. (unsigned int)dimm_params[i].tccdl_ps);
  292. trfc_slr_ps = max(trfc_slr_ps,
  293. (unsigned int)dimm_params[i].trfc_slr_ps);
  294. #else
  295. twr_ps = max(twr_ps, (unsigned int)dimm_params[i].twr_ps);
  296. twtr_ps = max(twtr_ps, (unsigned int)dimm_params[i].twtr_ps);
  297. trfc_ps = max(trfc_ps, (unsigned int)dimm_params[i].trfc_ps);
  298. trrd_ps = max(trrd_ps, (unsigned int)dimm_params[i].trrd_ps);
  299. trtp_ps = max(trtp_ps, (unsigned int)dimm_params[i].trtp_ps);
  300. #endif
  301. trc_ps = max(trc_ps, (unsigned int)dimm_params[i].trc_ps);
  302. #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
  303. tis_ps = max(tis_ps, (unsigned int)dimm_params[i].tis_ps);
  304. tih_ps = max(tih_ps, (unsigned int)dimm_params[i].tih_ps);
  305. tds_ps = max(tds_ps, (unsigned int)dimm_params[i].tds_ps);
  306. tdh_ps = max(tdh_ps, (unsigned int)dimm_params[i].tdh_ps);
  307. tqhs_ps = max(tqhs_ps, (unsigned int)dimm_params[i].tqhs_ps);
  308. /*
  309. * Find maximum tdqsq_max_ps to find slowest.
  310. *
  311. * FIXME: is finding the slowest value the correct
  312. * strategy for this parameter?
  313. */
  314. tdqsq_max_ps = max(tdqsq_max_ps,
  315. (unsigned int)dimm_params[i].tdqsq_max_ps);
  316. #endif
  317. refresh_rate_ps = max(refresh_rate_ps,
  318. (unsigned int)dimm_params[i].refresh_rate_ps);
  319. /* extended_op_srt is either 0 or 1, 0 having priority */
  320. extended_op_srt = min(extended_op_srt,
  321. (unsigned int)dimm_params[i].extended_op_srt);
  322. }
  323. outpdimm->ndimms_present = number_of_dimms - temp1;
  324. if (temp1 == number_of_dimms) {
  325. debug("no dimms this memory controller\n");
  326. return 0;
  327. }
  328. outpdimm->tckmin_x_ps = tckmin_x_ps;
  329. outpdimm->tckmax_ps = tckmax_ps;
  330. #if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
  331. outpdimm->taamin_ps = taamin_ps;
  332. #endif
  333. outpdimm->trcd_ps = trcd_ps;
  334. outpdimm->trp_ps = trp_ps;
  335. outpdimm->tras_ps = tras_ps;
  336. #ifdef CONFIG_SYS_FSL_DDR4
  337. outpdimm->trfc1_ps = trfc1_ps;
  338. outpdimm->trfc2_ps = trfc2_ps;
  339. outpdimm->trfc4_ps = trfc4_ps;
  340. outpdimm->trrds_ps = trrds_ps;
  341. outpdimm->trrdl_ps = trrdl_ps;
  342. outpdimm->tccdl_ps = tccdl_ps;
  343. outpdimm->trfc_slr_ps = trfc_slr_ps;
  344. #else
  345. outpdimm->twtr_ps = twtr_ps;
  346. outpdimm->trfc_ps = trfc_ps;
  347. outpdimm->trrd_ps = trrd_ps;
  348. outpdimm->trtp_ps = trtp_ps;
  349. #endif
  350. outpdimm->twr_ps = twr_ps;
  351. outpdimm->trc_ps = trc_ps;
  352. outpdimm->refresh_rate_ps = refresh_rate_ps;
  353. outpdimm->extended_op_srt = extended_op_srt;
  354. #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
  355. outpdimm->tis_ps = tis_ps;
  356. outpdimm->tih_ps = tih_ps;
  357. outpdimm->tds_ps = tds_ps;
  358. outpdimm->tdh_ps = tdh_ps;
  359. outpdimm->tdqsq_max_ps = tdqsq_max_ps;
  360. outpdimm->tqhs_ps = tqhs_ps;
  361. #endif
  362. /* Determine common burst length for all DIMMs. */
  363. temp1 = 0xff;
  364. for (i = 0; i < number_of_dimms; i++) {
  365. if (dimm_params[i].n_ranks) {
  366. temp1 &= dimm_params[i].burst_lengths_bitmask;
  367. }
  368. }
  369. outpdimm->all_dimms_burst_lengths_bitmask = temp1;
  370. /* Determine if all DIMMs registered buffered. */
  371. temp1 = temp2 = 0;
  372. for (i = 0; i < number_of_dimms; i++) {
  373. if (dimm_params[i].n_ranks) {
  374. if (dimm_params[i].registered_dimm) {
  375. temp1 = 1;
  376. #ifndef CONFIG_SPL_BUILD
  377. printf("Detected RDIMM %s\n",
  378. dimm_params[i].mpart);
  379. #endif
  380. } else {
  381. temp2 = 1;
  382. #ifndef CONFIG_SPL_BUILD
  383. printf("Detected UDIMM %s\n",
  384. dimm_params[i].mpart);
  385. #endif
  386. }
  387. }
  388. }
  389. outpdimm->all_dimms_registered = 0;
  390. outpdimm->all_dimms_unbuffered = 0;
  391. if (temp1 && !temp2) {
  392. outpdimm->all_dimms_registered = 1;
  393. } else if (!temp1 && temp2) {
  394. outpdimm->all_dimms_unbuffered = 1;
  395. } else {
  396. printf("ERROR: Mix of registered buffered and unbuffered "
  397. "DIMMs detected!\n");
  398. }
  399. temp1 = 0;
  400. if (outpdimm->all_dimms_registered)
  401. for (j = 0; j < 16; j++) {
  402. outpdimm->rcw[j] = dimm_params[0].rcw[j];
  403. for (i = 1; i < number_of_dimms; i++) {
  404. if (!dimm_params[i].n_ranks)
  405. continue;
  406. if (dimm_params[i].rcw[j] != dimm_params[0].rcw[j]) {
  407. temp1 = 1;
  408. break;
  409. }
  410. }
  411. }
  412. if (temp1 != 0)
  413. printf("ERROR: Mix different RDIMM detected!\n");
  414. /* calculate cas latency for all DDR types */
  415. if (compute_cas_latency(ctrl_num, dimm_params,
  416. outpdimm, number_of_dimms))
  417. return 1;
  418. /* Determine if all DIMMs ECC capable. */
  419. temp1 = 1;
  420. for (i = 0; i < number_of_dimms; i++) {
  421. if (dimm_params[i].n_ranks &&
  422. !(dimm_params[i].edc_config & EDC_ECC)) {
  423. temp1 = 0;
  424. break;
  425. }
  426. }
  427. if (temp1) {
  428. debug("all DIMMs ECC capable\n");
  429. } else {
  430. debug("Warning: not all DIMMs ECC capable, cant enable ECC\n");
  431. }
  432. outpdimm->all_dimms_ecc_capable = temp1;
  433. /*
  434. * Compute additive latency.
  435. *
  436. * For DDR1, additive latency should be 0.
  437. *
  438. * For DDR2, with ODT enabled, use "a value" less than ACTTORW,
  439. * which comes from Trcd, and also note that:
  440. * add_lat + caslat must be >= 4
  441. *
  442. * For DDR3, we use the AL=0
  443. *
  444. * When to use additive latency for DDR2:
  445. *
  446. * I. Because you are using CL=3 and need to do ODT on writes and
  447. * want functionality.
  448. * 1. Are you going to use ODT? (Does your board not have
  449. * additional termination circuitry for DQ, DQS, DQS_,
  450. * DM, RDQS, RDQS_ for x4/x8 configs?)
  451. * 2. If so, is your lowest supported CL going to be 3?
  452. * 3. If so, then you must set AL=1 because
  453. *
  454. * WL >= 3 for ODT on writes
  455. * RL = AL + CL
  456. * WL = RL - 1
  457. * ->
  458. * WL = AL + CL - 1
  459. * AL + CL - 1 >= 3
  460. * AL + CL >= 4
  461. * QED
  462. *
  463. * RL >= 3 for ODT on reads
  464. * RL = AL + CL
  465. *
  466. * Since CL aren't usually less than 2, AL=0 is a minimum,
  467. * so the WL-derived AL should be the -- FIXME?
  468. *
  469. * II. Because you are using auto-precharge globally and want to
  470. * use additive latency (posted CAS) to get more bandwidth.
  471. * 1. Are you going to use auto-precharge mode globally?
  472. *
  473. * Use addtivie latency and compute AL to be 1 cycle less than
  474. * tRCD, i.e. the READ or WRITE command is in the cycle
  475. * immediately following the ACTIVATE command..
  476. *
  477. * III. Because you feel like it or want to do some sort of
  478. * degraded-performance experiment.
  479. * 1. Do you just want to use additive latency because you feel
  480. * like it?
  481. *
  482. * Validation: AL is less than tRCD, and within the other
  483. * read-to-precharge constraints.
  484. */
  485. additive_latency = 0;
  486. #if defined(CONFIG_SYS_FSL_DDR2)
  487. if ((outpdimm->lowest_common_spd_caslat < 4) &&
  488. (picos_to_mclk(ctrl_num, trcd_ps) >
  489. outpdimm->lowest_common_spd_caslat)) {
  490. additive_latency = picos_to_mclk(ctrl_num, trcd_ps) -
  491. outpdimm->lowest_common_spd_caslat;
  492. if (mclk_to_picos(ctrl_num, additive_latency) > trcd_ps) {
  493. additive_latency = picos_to_mclk(ctrl_num, trcd_ps);
  494. debug("setting additive_latency to %u because it was "
  495. " greater than tRCD_ps\n", additive_latency);
  496. }
  497. }
  498. #endif
  499. /*
  500. * Validate additive latency
  501. *
  502. * AL <= tRCD(min)
  503. */
  504. if (mclk_to_picos(ctrl_num, additive_latency) > trcd_ps) {
  505. printf("Error: invalid additive latency exceeds tRCD(min).\n");
  506. return 1;
  507. }
  508. /*
  509. * RL = CL + AL; RL >= 3 for ODT_RD_CFG to be enabled
  510. * WL = RL - 1; WL >= 3 for ODT_WL_CFG to be enabled
  511. * ADD_LAT (the register) must be set to a value less
  512. * than ACTTORW if WL = 1, then AL must be set to 1
  513. * RD_TO_PRE (the register) must be set to a minimum
  514. * tRTP + AL if AL is nonzero
  515. */
  516. /*
  517. * Additive latency will be applied only if the memctl option to
  518. * use it.
  519. */
  520. outpdimm->additive_latency = additive_latency;
  521. debug("tCKmin_ps = %u\n", outpdimm->tckmin_x_ps);
  522. debug("trcd_ps = %u\n", outpdimm->trcd_ps);
  523. debug("trp_ps = %u\n", outpdimm->trp_ps);
  524. debug("tras_ps = %u\n", outpdimm->tras_ps);
  525. #ifdef CONFIG_SYS_FSL_DDR4
  526. debug("trfc1_ps = %u\n", trfc1_ps);
  527. debug("trfc2_ps = %u\n", trfc2_ps);
  528. debug("trfc4_ps = %u\n", trfc4_ps);
  529. debug("trrds_ps = %u\n", trrds_ps);
  530. debug("trrdl_ps = %u\n", trrdl_ps);
  531. debug("tccdl_ps = %u\n", tccdl_ps);
  532. debug("trfc_slr_ps = %u\n", trfc_slr_ps);
  533. #else
  534. debug("twtr_ps = %u\n", outpdimm->twtr_ps);
  535. debug("trfc_ps = %u\n", outpdimm->trfc_ps);
  536. debug("trrd_ps = %u\n", outpdimm->trrd_ps);
  537. #endif
  538. debug("twr_ps = %u\n", outpdimm->twr_ps);
  539. debug("trc_ps = %u\n", outpdimm->trc_ps);
  540. return 0;
  541. }