lc_common_dimm_params.c 17 KB

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