ctrl_regs.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * Version 2 as published by the Free Software Foundation.
  7. */
  8. /*
  9. * Generic driver for Freescale DDR/DDR2/DDR3 memory controller.
  10. * Based on code from spd_sdram.c
  11. * Author: James Yang [at freescale.com]
  12. */
  13. #include <common.h>
  14. #include <asm/fsl_ddr_sdram.h>
  15. #include "ddr.h"
  16. extern unsigned int picos_to_mclk(unsigned int picos);
  17. /*
  18. * Determine Rtt value.
  19. *
  20. * This should likely be either board or controller specific.
  21. *
  22. * Rtt(nominal):
  23. * 0 = Rtt disabled
  24. * 1 = 75 ohm
  25. * 2 = 150 ohm
  26. * 3 = 50 ohm
  27. *
  28. * FIXME: Apparently 8641 needs a value of 2
  29. * FIXME: Old code seys if 667 MHz or higher, use 3 on 8572
  30. *
  31. * FIXME: There was some effort down this line earlier:
  32. *
  33. * unsigned int i;
  34. * for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL/2; i++) {
  35. * if (popts->dimmslot[i].num_valid_cs
  36. * && (popts->cs_local_opts[2*i].odt_rd_cfg
  37. * || popts->cs_local_opts[2*i].odt_wr_cfg)) {
  38. * rtt = 2;
  39. * break;
  40. * }
  41. * }
  42. */
  43. static inline int fsl_ddr_get_rtt(void)
  44. {
  45. int rtt;
  46. #if defined(CONFIG_FSL_DDR1)
  47. rtt = 0;
  48. #elif defined(CONFIG_FSL_DDR2)
  49. rtt = 3;
  50. #else
  51. #error "Need Rtt value for DDR3"
  52. #endif
  53. return rtt;
  54. }
  55. /* Chip Select Configuration (CSn_CONFIG) */
  56. static void set_csn_config(int i, fsl_ddr_cfg_regs_t *ddr,
  57. const memctl_options_t *popts,
  58. const dimm_params_t *dimm_params)
  59. {
  60. unsigned int cs_n_en = 0; /* Chip Select enable */
  61. unsigned int intlv_en = 0; /* Memory controller interleave enable */
  62. unsigned int intlv_ctl = 0; /* Interleaving control */
  63. unsigned int ap_n_en = 0; /* Chip select n auto-precharge enable */
  64. unsigned int odt_rd_cfg = 0; /* ODT for reads configuration */
  65. unsigned int odt_wr_cfg = 0; /* ODT for writes configuration */
  66. unsigned int ba_bits_cs_n = 0; /* Num of bank bits for SDRAM on CSn */
  67. unsigned int row_bits_cs_n = 0; /* Num of row bits for SDRAM on CSn */
  68. unsigned int col_bits_cs_n = 0; /* Num of ocl bits for SDRAM on CSn */
  69. /* Compute CS_CONFIG only for existing ranks of each DIMM. */
  70. if ((((i&1) == 0)
  71. && (dimm_params[i/2].n_ranks == 1))
  72. || (dimm_params[i/2].n_ranks == 2)) {
  73. unsigned int n_banks_per_sdram_device;
  74. cs_n_en = 1;
  75. if (i == 0) {
  76. /* These fields only available in CS0_CONFIG */
  77. intlv_en = popts->memctl_interleaving;
  78. intlv_ctl = popts->memctl_interleaving_mode;
  79. }
  80. ap_n_en = popts->cs_local_opts[i].auto_precharge;
  81. odt_rd_cfg = popts->cs_local_opts[i].odt_rd_cfg;
  82. odt_wr_cfg = popts->cs_local_opts[i].odt_wr_cfg;
  83. n_banks_per_sdram_device
  84. = dimm_params[i/2].n_banks_per_sdram_device;
  85. ba_bits_cs_n = __ilog2(n_banks_per_sdram_device) - 2;
  86. row_bits_cs_n = dimm_params[i/2].n_row_addr - 12;
  87. col_bits_cs_n = dimm_params[i/2].n_col_addr - 8;
  88. }
  89. ddr->cs[i].config = (0
  90. | ((cs_n_en & 0x1) << 31)
  91. | ((intlv_en & 0x3) << 29)
  92. | ((intlv_ctl & 0xf) << 24)
  93. | ((ap_n_en & 0x1) << 23)
  94. /* XXX: some implementation only have 1 bit starting at left */
  95. | ((odt_rd_cfg & 0x7) << 20)
  96. /* XXX: Some implementation only have 1 bit starting at left */
  97. | ((odt_wr_cfg & 0x7) << 16)
  98. | ((ba_bits_cs_n & 0x3) << 14)
  99. | ((row_bits_cs_n & 0x7) << 8)
  100. | ((col_bits_cs_n & 0x7) << 0)
  101. );
  102. debug("FSLDDR: cs[%d]_config = 0x%08x\n", i,ddr->cs[i].config);
  103. }
  104. /* Chip Select Configuration 2 (CSn_CONFIG_2) */
  105. /* FIXME: 8572 */
  106. static void set_csn_config_2(int i, fsl_ddr_cfg_regs_t *ddr)
  107. {
  108. unsigned int pasr_cfg = 0; /* Partial array self refresh config */
  109. ddr->cs[i].config_2 = ((pasr_cfg & 7) << 24);
  110. debug("FSLDDR: cs[%d]_config_2 = 0x%08x\n", i, ddr->cs[i].config_2);
  111. }
  112. /* -3E = 667 CL5, -25 = CL6 800, -25E = CL5 800 */
  113. #if defined(CONFIG_FSL_DDR2)
  114. /*
  115. * DDR SDRAM Timing Configuration 0 (TIMING_CFG_0)
  116. *
  117. * Avoid writing for DDR I. The new PQ38 DDR controller
  118. * dreams up non-zero default values to be backwards compatible.
  119. */
  120. static void set_timing_cfg_0(fsl_ddr_cfg_regs_t *ddr)
  121. {
  122. unsigned char trwt_mclk = 0; /* Read-to-write turnaround */
  123. unsigned char twrt_mclk = 0; /* Write-to-read turnaround */
  124. /* 7.5 ns on -3E; 0 means WL - CL + BL/2 + 1 */
  125. unsigned char trrt_mclk = 0; /* Read-to-read turnaround */
  126. unsigned char twwt_mclk = 0; /* Write-to-write turnaround */
  127. /* Active powerdown exit timing (tXARD and tXARDS). */
  128. unsigned char act_pd_exit_mclk;
  129. /* Precharge powerdown exit timing (tXP). */
  130. unsigned char pre_pd_exit_mclk;
  131. /* Precharge powerdown exit timing (tAXPD). */
  132. unsigned char taxpd_mclk;
  133. /* Mode register set cycle time (tMRD). */
  134. unsigned char tmrd_mclk;
  135. /* (tXARD and tXARDS). Empirical? */
  136. act_pd_exit_mclk = 2;
  137. /* XXX: tXARD = 2, tXARDS = 7 - AL. * Empirical? */
  138. pre_pd_exit_mclk = 6;
  139. /* FIXME: tXP = 2 on Micron 667 MHz DIMM */
  140. taxpd_mclk = 8;
  141. tmrd_mclk = 2;
  142. ddr->timing_cfg_0 = (0
  143. | ((trwt_mclk & 0x3) << 30) /* RWT */
  144. | ((twrt_mclk & 0x3) << 28) /* WRT */
  145. | ((trrt_mclk & 0x3) << 26) /* RRT */
  146. | ((twwt_mclk & 0x3) << 24) /* WWT */
  147. | ((act_pd_exit_mclk & 0x7) << 20) /* ACT_PD_EXIT */
  148. | ((pre_pd_exit_mclk & 0x7) << 16) /* PRE_PD_EXIT */
  149. | ((taxpd_mclk & 0xf) << 8) /* ODT_PD_EXIT */
  150. | ((tmrd_mclk & 0xf) << 0) /* MRS_CYC */
  151. );
  152. debug("FSLDDR: timing_cfg_0 = 0x%08x\n", ddr->timing_cfg_0);
  153. }
  154. #endif /* defined(CONFIG_FSL_DDR2) */
  155. /* DDR SDRAM Timing Configuration 3 (TIMING_CFG_3) */
  156. static void set_timing_cfg_3(fsl_ddr_cfg_regs_t *ddr,
  157. const common_timing_params_t *common_dimm)
  158. {
  159. /* Extended Activate to precharge interval (tRAS) */
  160. unsigned int ext_acttopre = 0;
  161. unsigned int ext_refrec; /* Extended refresh recovery time (tRFC) */
  162. unsigned int ext_caslat = 0; /* Extended MCAS latency from READ cmd */
  163. unsigned int cntl_adj = 0; /* Control Adjust */
  164. ext_refrec = (picos_to_mclk(common_dimm->tRFC_ps) - 8) >> 4;
  165. ddr->timing_cfg_3 = (0
  166. | ((ext_acttopre & 0x1) << 24)
  167. | ((ext_refrec & 0x7) << 16)
  168. | ((ext_caslat & 0x1) << 12)
  169. | ((cntl_adj & 0x7) << 0)
  170. );
  171. debug("FSLDDR: timing_cfg_3 = 0x%08x\n", ddr->timing_cfg_3);
  172. }
  173. /* DDR SDRAM Timing Configuration 1 (TIMING_CFG_1) */
  174. static void set_timing_cfg_1(fsl_ddr_cfg_regs_t *ddr,
  175. const common_timing_params_t *common_dimm,
  176. unsigned int cas_latency)
  177. {
  178. /* Precharge-to-activate interval (tRP) */
  179. unsigned char pretoact_mclk;
  180. /* Activate to precharge interval (tRAS) */
  181. unsigned char acttopre_mclk;
  182. /* Activate to read/write interval (tRCD) */
  183. unsigned char acttorw_mclk;
  184. /* CASLAT */
  185. unsigned char caslat_ctrl;
  186. /* Refresh recovery time (tRFC) ; trfc_low */
  187. unsigned char refrec_ctrl;
  188. /* Last data to precharge minimum interval (tWR) */
  189. unsigned char wrrec_mclk;
  190. /* Activate-to-activate interval (tRRD) */
  191. unsigned char acttoact_mclk;
  192. /* Last write data pair to read command issue interval (tWTR) */
  193. unsigned char wrtord_mclk;
  194. pretoact_mclk = picos_to_mclk(common_dimm->tRP_ps);
  195. acttopre_mclk = picos_to_mclk(common_dimm->tRAS_ps);
  196. acttorw_mclk = picos_to_mclk(common_dimm->tRCD_ps);
  197. /*
  198. * Translate CAS Latency to a DDR controller field value:
  199. *
  200. * CAS Lat DDR I DDR II Ctrl
  201. * Clocks SPD Bit SPD Bit Value
  202. * ------- ------- ------- -----
  203. * 1.0 0 0001
  204. * 1.5 1 0010
  205. * 2.0 2 2 0011
  206. * 2.5 3 0100
  207. * 3.0 4 3 0101
  208. * 3.5 5 0110
  209. * 4.0 4 0111
  210. * 4.5 1000
  211. * 5.0 5 1001
  212. */
  213. #if defined(CONFIG_FSL_DDR1)
  214. caslat_ctrl = (cas_latency + 1) & 0x07;
  215. #elif defined(CONFIG_FSL_DDR2)
  216. caslat_ctrl = 2 * cas_latency - 1;
  217. #else
  218. #error "Need CAS Latency help for DDR3 in fsl_ddr_sdram.c"
  219. #endif
  220. refrec_ctrl = picos_to_mclk(common_dimm->tRFC_ps) - 8;
  221. wrrec_mclk = picos_to_mclk(common_dimm->tWR_ps);
  222. acttoact_mclk = picos_to_mclk(common_dimm->tRRD_ps);
  223. wrtord_mclk = picos_to_mclk(common_dimm->tWTR_ps);
  224. ddr->timing_cfg_1 = (0
  225. | ((pretoact_mclk & 0x07) << 28)
  226. | ((acttopre_mclk & 0x0F) << 24)
  227. | ((acttorw_mclk & 0x7) << 20)
  228. | ((caslat_ctrl & 0xF) << 16)
  229. | ((refrec_ctrl & 0xF) << 12)
  230. | ((wrrec_mclk & 0x07) << 8)
  231. | ((acttoact_mclk & 0x07) << 4)
  232. | ((wrtord_mclk & 0x07) << 0)
  233. );
  234. debug("FSLDDR: timing_cfg_1 = 0x%08x\n", ddr->timing_cfg_1);
  235. }
  236. /* DDR SDRAM Timing Configuration 2 (TIMING_CFG_2) */
  237. static void set_timing_cfg_2(fsl_ddr_cfg_regs_t *ddr,
  238. const memctl_options_t *popts,
  239. const common_timing_params_t *common_dimm,
  240. unsigned int cas_latency,
  241. unsigned int additive_latency)
  242. {
  243. /* Additive latency */
  244. unsigned char add_lat_mclk;
  245. /* CAS-to-preamble override */
  246. unsigned short cpo;
  247. /* Write latency */
  248. unsigned char wr_lat;
  249. /* Read to precharge (tRTP) */
  250. unsigned char rd_to_pre;
  251. /* Write command to write data strobe timing adjustment */
  252. unsigned char wr_data_delay;
  253. /* Minimum CKE pulse width (tCKE) */
  254. unsigned char cke_pls;
  255. /* Window for four activates (tFAW) */
  256. unsigned short four_act;
  257. /* FIXME add check that this must be less than acttorw_mclk */
  258. add_lat_mclk = additive_latency;
  259. cpo = popts->cpo_override;
  260. #if defined(CONFIG_FSL_DDR1)
  261. /*
  262. * This is a lie. It should really be 1, but if it is
  263. * set to 1, bits overlap into the old controller's
  264. * otherwise unused ACSM field. If we leave it 0, then
  265. * the HW will magically treat it as 1 for DDR 1. Oh Yea.
  266. */
  267. wr_lat = 0;
  268. #elif defined(CONFIG_FSL_DDR2)
  269. wr_lat = cas_latency + additive_latency - 1;
  270. #else
  271. #error "Fix WR_LAT for DDR3"
  272. #endif
  273. rd_to_pre = picos_to_mclk(common_dimm->tRTP_ps);
  274. wr_data_delay = popts->write_data_delay;
  275. cke_pls = picos_to_mclk(popts->tCKE_clock_pulse_width_ps);
  276. four_act = picos_to_mclk(popts->tFAW_window_four_activates_ps);
  277. ddr->timing_cfg_2 = (0
  278. | ((add_lat_mclk & 0x7) << 28)
  279. | ((cpo & 0x1f) << 23)
  280. | ((wr_lat & 0x7) << 19)
  281. | ((rd_to_pre & 0x7) << 13)
  282. | ((wr_data_delay & 0x7) << 10)
  283. | ((cke_pls & 0x7) << 6)
  284. | ((four_act & 0x1f) << 0)
  285. );
  286. debug("FSLDDR: timing_cfg_2 = 0x%08x\n", ddr->timing_cfg_2);
  287. }
  288. /* DDR SDRAM control configuration (DDR_SDRAM_CFG) */
  289. static void set_ddr_sdram_cfg(fsl_ddr_cfg_regs_t *ddr,
  290. const memctl_options_t *popts,
  291. const common_timing_params_t *common_dimm)
  292. {
  293. unsigned int mem_en; /* DDR SDRAM interface logic enable */
  294. unsigned int sren; /* Self refresh enable (during sleep) */
  295. unsigned int ecc_en; /* ECC enable. */
  296. unsigned int rd_en; /* Registered DIMM enable */
  297. unsigned int sdram_type; /* Type of SDRAM */
  298. unsigned int dyn_pwr; /* Dynamic power management mode */
  299. unsigned int dbw; /* DRAM dta bus width */
  300. unsigned int eight_be; /* 8-beat burst enable */
  301. unsigned int ncap = 0; /* Non-concurrent auto-precharge */
  302. unsigned int threeT_en; /* Enable 3T timing */
  303. unsigned int twoT_en; /* Enable 2T timing */
  304. unsigned int ba_intlv_ctl; /* Bank (CS) interleaving control */
  305. unsigned int x32_en = 0; /* x32 enable */
  306. unsigned int pchb8 = 0; /* precharge bit 8 enable */
  307. unsigned int hse; /* Global half strength override */
  308. unsigned int mem_halt = 0; /* memory controller halt */
  309. unsigned int bi = 0; /* Bypass initialization */
  310. mem_en = 1;
  311. sren = popts->self_refresh_in_sleep;
  312. if (common_dimm->all_DIMMs_ECC_capable) {
  313. /* Allow setting of ECC only if all DIMMs are ECC. */
  314. ecc_en = popts->ECC_mode;
  315. } else {
  316. ecc_en = 0;
  317. }
  318. rd_en = (common_dimm->all_DIMMs_registered
  319. && !common_dimm->all_DIMMs_unbuffered);
  320. sdram_type = CONFIG_FSL_SDRAM_TYPE;
  321. dyn_pwr = popts->dynamic_power;
  322. dbw = popts->data_bus_width;
  323. eight_be = 0; /* always 0 for DDR2 */
  324. threeT_en = popts->threeT_en;
  325. twoT_en = popts->twoT_en;
  326. ba_intlv_ctl = popts->ba_intlv_ctl;
  327. hse = popts->half_strength_driver_enable;
  328. ddr->ddr_sdram_cfg = (0
  329. | ((mem_en & 0x1) << 31)
  330. | ((sren & 0x1) << 30)
  331. | ((ecc_en & 0x1) << 29)
  332. | ((rd_en & 0x1) << 28)
  333. | ((sdram_type & 0x7) << 24)
  334. | ((dyn_pwr & 0x1) << 21)
  335. | ((dbw & 0x3) << 19)
  336. | ((eight_be & 0x1) << 18)
  337. | ((ncap & 0x1) << 17)
  338. | ((threeT_en & 0x1) << 16)
  339. | ((twoT_en & 0x1) << 15)
  340. | ((ba_intlv_ctl & 0x7F) << 8)
  341. | ((x32_en & 0x1) << 5)
  342. | ((pchb8 & 0x1) << 4)
  343. | ((hse & 0x1) << 3)
  344. | ((mem_halt & 0x1) << 1)
  345. | ((bi & 0x1) << 0)
  346. );
  347. debug("FSLDDR: ddr_sdram_cfg = 0x%08x\n", ddr->ddr_sdram_cfg);
  348. }
  349. /* DDR SDRAM control configuration 2 (DDR_SDRAM_CFG_2) */
  350. static void set_ddr_sdram_cfg_2(fsl_ddr_cfg_regs_t *ddr,
  351. const memctl_options_t *popts)
  352. {
  353. unsigned int frc_sr = 0; /* Force self refresh */
  354. unsigned int sr_ie = 0; /* Self-refresh interrupt enable */
  355. unsigned int dll_rst_dis; /* DLL reset disable */
  356. unsigned int dqs_cfg; /* DQS configuration */
  357. unsigned int odt_cfg; /* ODT configuration */
  358. unsigned int num_pr; /* Number of posted refreshes */
  359. unsigned int obc_cfg; /* On-The-Fly Burst Chop Cfg */
  360. unsigned int ap_en; /* Address Parity Enable */
  361. unsigned int d_init; /* DRAM data initialization */
  362. unsigned int rcw_en = 0; /* Register Control Word Enable */
  363. unsigned int md_en = 0; /* Mirrored DIMM Enable */
  364. dll_rst_dis = 1; /* Make this configurable */
  365. dqs_cfg = popts->DQS_config;
  366. if (popts->cs_local_opts[0].odt_rd_cfg
  367. || popts->cs_local_opts[0].odt_wr_cfg) {
  368. /* FIXME */
  369. odt_cfg = 2;
  370. } else {
  371. odt_cfg = 0;
  372. }
  373. num_pr = 1; /* Make this configurable */
  374. /*
  375. * 8572 manual says
  376. * {TIMING_CFG_1[PRETOACT]
  377. * + [DDR_SDRAM_CFG_2[NUM_PR]
  378. * * ({EXT_REFREC || REFREC} + 8 + 2)]}
  379. * << DDR_SDRAM_INTERVAL[REFINT]
  380. */
  381. obc_cfg = 0; /* Make this configurable? */
  382. ap_en = 0; /* Make this configurable? */
  383. #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  384. /* Use the DDR controller to auto initialize memory. */
  385. d_init = 1;
  386. ddr->ddr_data_init = CONFIG_MEM_INIT_VALUE;
  387. debug("DDR: ddr_data_init = 0x%08x\n", ddr->ddr_data_init);
  388. #else
  389. /* Memory will be initialized via DMA, or not at all. */
  390. d_init = 0;
  391. #endif
  392. ddr->ddr_sdram_cfg_2 = (0
  393. | ((frc_sr & 0x1) << 31)
  394. | ((sr_ie & 0x1) << 30)
  395. | ((dll_rst_dis & 0x1) << 29)
  396. | ((dqs_cfg & 0x3) << 26)
  397. | ((odt_cfg & 0x3) << 21)
  398. | ((num_pr & 0xf) << 12)
  399. | ((obc_cfg & 0x1) << 6)
  400. | ((ap_en & 0x1) << 5)
  401. | ((d_init & 0x1) << 4)
  402. | ((rcw_en & 0x1) << 2)
  403. | ((md_en & 0x1) << 0)
  404. );
  405. debug("FSLDDR: ddr_sdram_cfg_2 = 0x%08x\n", ddr->ddr_sdram_cfg_2);
  406. }
  407. /* DDR SDRAM Mode configuration 2 (DDR_SDRAM_MODE_2) */
  408. static void set_ddr_sdram_mode_2(fsl_ddr_cfg_regs_t *ddr)
  409. {
  410. unsigned short esdmode2 = 0; /* Extended SDRAM mode 2 */
  411. unsigned short esdmode3 = 0; /* Extended SDRAM mode 3 */
  412. ddr->ddr_sdram_mode_2 = (0
  413. | ((esdmode2 & 0xFFFF) << 16)
  414. | ((esdmode3 & 0xFFFF) << 0)
  415. );
  416. debug("FSLDDR: ddr_sdram_mode_2 = 0x%08x\n", ddr->ddr_sdram_mode_2);
  417. }
  418. /* DDR SDRAM Interval Configuration (DDR_SDRAM_INTERVAL) */
  419. static void set_ddr_sdram_interval(fsl_ddr_cfg_regs_t *ddr,
  420. const memctl_options_t *popts,
  421. const common_timing_params_t *common_dimm)
  422. {
  423. unsigned int refint; /* Refresh interval */
  424. unsigned int bstopre; /* Precharge interval */
  425. refint = picos_to_mclk(common_dimm->refresh_rate_ps);
  426. bstopre = popts->bstopre;
  427. /* refint field used 0x3FFF in earlier controllers */
  428. ddr->ddr_sdram_interval = (0
  429. | ((refint & 0xFFFF) << 16)
  430. | ((bstopre & 0x3FFF) << 0)
  431. );
  432. debug("FSLDDR: ddr_sdram_interval = 0x%08x\n", ddr->ddr_sdram_interval);
  433. }
  434. /* DDR SDRAM Mode configuration set (DDR_SDRAM_MODE) */
  435. static void set_ddr_sdram_mode(fsl_ddr_cfg_regs_t *ddr,
  436. const memctl_options_t *popts,
  437. const common_timing_params_t *common_dimm,
  438. unsigned int cas_latency,
  439. unsigned int additive_latency)
  440. {
  441. unsigned short esdmode; /* Extended SDRAM mode */
  442. unsigned short sdmode; /* SDRAM mode */
  443. /*
  444. * FIXME: This ought to be pre-calculated in a
  445. * technology-specific routine,
  446. * e.g. compute_DDR2_mode_register(), and then the
  447. * sdmode and esdmode passed in as part of common_dimm.
  448. */
  449. /* Extended Mode Register */
  450. unsigned int mrs = 0; /* Mode Register Set */
  451. unsigned int outputs = 0; /* 0=Enabled, 1=Disabled */
  452. unsigned int rdqs_en = 0; /* RDQS Enable: 0=no, 1=yes */
  453. unsigned int dqs_en = 0; /* DQS# Enable: 0=enable, 1=disable */
  454. unsigned int ocd = 0; /* 0x0=OCD not supported,
  455. 0x7=OCD default state */
  456. unsigned int rtt;
  457. unsigned int al; /* Posted CAS# additive latency (AL) */
  458. unsigned int ods = 0; /* Output Drive Strength:
  459. 0 = Full strength (18ohm)
  460. 1 = Reduced strength (4ohm) */
  461. unsigned int dll_en = 0; /* DLL Enable 0=Enable (Normal),
  462. 1=Disable (Test/Debug) */
  463. /* Mode Register (MR) */
  464. unsigned int mr; /* Mode Register Definition */
  465. unsigned int pd; /* Power-Down Mode */
  466. unsigned int wr; /* Write Recovery */
  467. unsigned int dll_res; /* DLL Reset */
  468. unsigned int mode; /* Normal=0 or Test=1 */
  469. unsigned int caslat = 0;/* CAS# latency */
  470. /* BT: Burst Type (0=Sequential, 1=Interleaved) */
  471. unsigned int bt;
  472. unsigned int bl; /* BL: Burst Length */
  473. #if defined(CONFIG_FSL_DDR2)
  474. const unsigned int mclk_ps = get_memory_clk_period_ps();
  475. #endif
  476. rtt = fsl_ddr_get_rtt();
  477. al = additive_latency;
  478. esdmode = (0
  479. | ((mrs & 0x3) << 14)
  480. | ((outputs & 0x1) << 12)
  481. | ((rdqs_en & 0x1) << 11)
  482. | ((dqs_en & 0x1) << 10)
  483. | ((ocd & 0x7) << 7)
  484. | ((rtt & 0x2) << 5) /* rtt field is split */
  485. | ((al & 0x7) << 3)
  486. | ((rtt & 0x1) << 2) /* rtt field is split */
  487. | ((ods & 0x1) << 1)
  488. | ((dll_en & 0x1) << 0)
  489. );
  490. mr = 0; /* FIXME: CHECKME */
  491. /*
  492. * 0 = Fast Exit (Normal)
  493. * 1 = Slow Exit (Low Power)
  494. */
  495. pd = 0;
  496. #if defined(CONFIG_FSL_DDR1)
  497. wr = 0; /* Historical */
  498. #elif defined(CONFIG_FSL_DDR2)
  499. wr = (common_dimm->tWR_ps + mclk_ps - 1) / mclk_ps - 1;
  500. #else
  501. #error "Write tWR_auto for DDR3"
  502. #endif
  503. dll_res = 0;
  504. mode = 0;
  505. #if defined(CONFIG_FSL_DDR1)
  506. if (1 <= cas_latency && cas_latency <= 4) {
  507. unsigned char mode_caslat_table[4] = {
  508. 0x5, /* 1.5 clocks */
  509. 0x2, /* 2.0 clocks */
  510. 0x6, /* 2.5 clocks */
  511. 0x3 /* 3.0 clocks */
  512. };
  513. caslat = mode_caslat_table[cas_latency - 1];
  514. } else {
  515. printf("Warning: unknown cas_latency %d\n", cas_latency);
  516. }
  517. #elif defined(CONFIG_FSL_DDR2)
  518. caslat = cas_latency;
  519. #else
  520. #error "Fix the mode CAS Latency for DDR3"
  521. #endif
  522. bt = 0;
  523. switch (popts->burst_length) {
  524. case 4:
  525. bl = 2;
  526. break;
  527. case 8:
  528. bl = 3;
  529. break;
  530. default:
  531. printf("Error: invalid burst length of %u specified. "
  532. " Defaulting to 4 beats.\n",
  533. popts->burst_length);
  534. bl = 2;
  535. break;
  536. }
  537. sdmode = (0
  538. | ((mr & 0x3) << 14)
  539. | ((pd & 0x1) << 12)
  540. | ((wr & 0x7) << 9)
  541. | ((dll_res & 0x1) << 8)
  542. | ((mode & 0x1) << 7)
  543. | ((caslat & 0x7) << 4)
  544. | ((bt & 0x1) << 3)
  545. | ((bl & 0x7) << 0)
  546. );
  547. ddr->ddr_sdram_mode = (0
  548. | ((esdmode & 0xFFFF) << 16)
  549. | ((sdmode & 0xFFFF) << 0)
  550. );
  551. debug("FSLDDR: ddr_sdram_mode = 0x%08x\n", ddr->ddr_sdram_mode);
  552. }
  553. /* DDR SDRAM Data Initialization (DDR_DATA_INIT) */
  554. static void set_ddr_data_init(fsl_ddr_cfg_regs_t *ddr)
  555. {
  556. unsigned int init_value; /* Initialization value */
  557. init_value = 0xDEADBEEF;
  558. ddr->ddr_data_init = init_value;
  559. }
  560. /*
  561. * DDR SDRAM Clock Control (DDR_SDRAM_CLK_CNTL)
  562. * The old controller on the 8540/60 doesn't have this register.
  563. * Hope it's OK to set it (to 0) anyway.
  564. */
  565. static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
  566. const memctl_options_t *popts)
  567. {
  568. unsigned int clk_adjust; /* Clock adjust */
  569. clk_adjust = popts->clk_adjust;
  570. ddr->ddr_sdram_clk_cntl = (clk_adjust & 0xF) << 23;
  571. }
  572. /* DDR Initialization Address (DDR_INIT_ADDR) */
  573. static void set_ddr_init_addr(fsl_ddr_cfg_regs_t *ddr)
  574. {
  575. unsigned int init_addr = 0; /* Initialization address */
  576. ddr->ddr_init_addr = init_addr;
  577. }
  578. /* DDR Initialization Address (DDR_INIT_EXT_ADDR) */
  579. static void set_ddr_init_ext_addr(fsl_ddr_cfg_regs_t *ddr)
  580. {
  581. unsigned int uia = 0; /* Use initialization address */
  582. unsigned int init_ext_addr = 0; /* Initialization address */
  583. ddr->ddr_init_ext_addr = (0
  584. | ((uia & 0x1) << 31)
  585. | (init_ext_addr & 0xF)
  586. );
  587. }
  588. /* DDR SDRAM Timing Configuration 4 (TIMING_CFG_4) */
  589. static void set_timing_cfg_4(fsl_ddr_cfg_regs_t *ddr)
  590. {
  591. unsigned int rwt = 0; /* Read-to-write turnaround for same CS */
  592. unsigned int wrt = 0; /* Write-to-read turnaround for same CS */
  593. unsigned int rrt = 0; /* Read-to-read turnaround for same CS */
  594. unsigned int wwt = 0; /* Write-to-write turnaround for same CS */
  595. unsigned int dll_lock = 0; /* DDR SDRAM DLL Lock Time */
  596. ddr->timing_cfg_4 = (0
  597. | ((rwt & 0xf) << 28)
  598. | ((wrt & 0xf) << 24)
  599. | ((rrt & 0xf) << 20)
  600. | ((wwt & 0xf) << 16)
  601. | (dll_lock & 0x3)
  602. );
  603. debug("FSLDDR: timing_cfg_4 = 0x%08x\n", ddr->timing_cfg_4);
  604. }
  605. /* DDR SDRAM Timing Configuration 5 (TIMING_CFG_5) */
  606. static void set_timing_cfg_5(fsl_ddr_cfg_regs_t *ddr)
  607. {
  608. unsigned int rodt_on = 0; /* Read to ODT on */
  609. unsigned int rodt_off = 0; /* Read to ODT off */
  610. unsigned int wodt_on = 0; /* Write to ODT on */
  611. unsigned int wodt_off = 0; /* Write to ODT off */
  612. ddr->timing_cfg_5 = (0
  613. | ((rodt_on & 0xf) << 24)
  614. | ((rodt_off & 0xf) << 20)
  615. | ((wodt_on & 0xf) << 12)
  616. | ((wodt_off & 0xf) << 8)
  617. );
  618. debug("FSLDDR: timing_cfg_5 = 0x%08x\n", ddr->timing_cfg_5);
  619. }
  620. /* DDR ZQ Calibration Control (DDR_ZQ_CNTL) */
  621. static void set_ddr_zq_cntl(fsl_ddr_cfg_regs_t *ddr)
  622. {
  623. unsigned int zq_en = 0; /* ZQ Calibration Enable */
  624. unsigned int zqinit = 0;/* POR ZQ Calibration Time (tZQinit) */
  625. /* Normal Operation Full Calibration Time (tZQoper) */
  626. unsigned int zqoper = 0;
  627. /* Normal Operation Short Calibration Time (tZQCS) */
  628. unsigned int zqcs = 0;
  629. ddr->ddr_zq_cntl = (0
  630. | ((zq_en & 0x1) << 31)
  631. | ((zqinit & 0xF) << 24)
  632. | ((zqoper & 0xF) << 16)
  633. | ((zqcs & 0xF) << 8)
  634. );
  635. }
  636. /* DDR Write Leveling Control (DDR_WRLVL_CNTL) */
  637. static void set_ddr_wrlvl_cntl(fsl_ddr_cfg_regs_t *ddr)
  638. {
  639. unsigned int wrlvl_en = 0; /* Write Leveling Enable */
  640. /*
  641. * First DQS pulse rising edge after margining mode
  642. * is programmed (tWL_MRD)
  643. */
  644. unsigned int wrlvl_mrd = 0;
  645. /* ODT delay after margining mode is programmed (tWL_ODTEN) */
  646. unsigned int wrlvl_odten = 0;
  647. /* DQS/DQS_ delay after margining mode is programmed (tWL_DQSEN) */
  648. unsigned int wrlvl_dqsen = 0;
  649. /* WRLVL_SMPL: Write leveling sample time */
  650. unsigned int wrlvl_smpl = 0;
  651. /* WRLVL_WLR: Write leveling repeition time */
  652. unsigned int wrlvl_wlr = 0;
  653. /* WRLVL_START: Write leveling start time */
  654. unsigned int wrlvl_start = 0;
  655. ddr->ddr_wrlvl_cntl = (0
  656. | ((wrlvl_en & 0x1) << 31)
  657. | ((wrlvl_mrd & 0x7) << 24)
  658. | ((wrlvl_odten & 0x7) << 20)
  659. | ((wrlvl_dqsen & 0x7) << 16)
  660. | ((wrlvl_smpl & 0xf) << 12)
  661. | ((wrlvl_wlr & 0x7) << 8)
  662. | ((wrlvl_start & 0xF) << 0)
  663. );
  664. }
  665. /* DDR Self Refresh Counter (DDR_SR_CNTR) */
  666. static void set_ddr_sr_cntr(fsl_ddr_cfg_regs_t *ddr)
  667. {
  668. unsigned int sr_it = 0; /* Self Refresh Idle Threshold */
  669. ddr->ddr_sr_cntr = (sr_it & 0xF) << 16;
  670. }
  671. /* DDR Pre-Drive Conditioning Control (DDR_PD_CNTL) */
  672. static void set_ddr_pd_cntl(fsl_ddr_cfg_regs_t *ddr)
  673. {
  674. /* Termination value during pre-drive conditioning */
  675. unsigned int tvpd = 0;
  676. unsigned int pd_en = 0; /* Pre-Drive Conditioning Enable */
  677. unsigned int pdar = 0; /* Pre-Drive After Read */
  678. unsigned int pdaw = 0; /* Pre-Drive After Write */
  679. unsigned int pd_on = 0; /* Pre-Drive Conditioning On */
  680. unsigned int pd_off = 0; /* Pre-Drive Conditioning Off */
  681. ddr->ddr_pd_cntl = (0
  682. | ((pd_en & 0x1) << 31)
  683. | ((tvpd & 0x7) << 28)
  684. | ((pdar & 0x7F) << 20)
  685. | ((pdaw & 0x7F) << 12)
  686. | ((pd_on & 0x1F) << 6)
  687. | ((pd_off & 0x1F) << 0)
  688. );
  689. }
  690. /* DDR SDRAM Register Control Word 1 (DDR_SDRAM_RCW_1) */
  691. static void set_ddr_sdram_rcw_1(fsl_ddr_cfg_regs_t *ddr)
  692. {
  693. unsigned int rcw0 = 0; /* RCW0: Register Control Word 0 */
  694. unsigned int rcw1 = 0; /* RCW1: Register Control Word 1 */
  695. unsigned int rcw2 = 0; /* RCW2: Register Control Word 2 */
  696. unsigned int rcw3 = 0; /* RCW3: Register Control Word 3 */
  697. unsigned int rcw4 = 0; /* RCW4: Register Control Word 4 */
  698. unsigned int rcw5 = 0; /* RCW5: Register Control Word 5 */
  699. unsigned int rcw6 = 0; /* RCW6: Register Control Word 6 */
  700. unsigned int rcw7 = 0; /* RCW7: Register Control Word 7 */
  701. ddr->ddr_sdram_rcw_1 = (0
  702. | ((rcw0 & 0xF) << 28)
  703. | ((rcw1 & 0xF) << 24)
  704. | ((rcw2 & 0xF) << 20)
  705. | ((rcw3 & 0xF) << 16)
  706. | ((rcw4 & 0xF) << 12)
  707. | ((rcw5 & 0xF) << 8)
  708. | ((rcw6 & 0xF) << 4)
  709. | ((rcw7 & 0xF) << 0)
  710. );
  711. }
  712. /* DDR SDRAM Register Control Word 2 (DDR_SDRAM_RCW_2) */
  713. static void set_ddr_sdram_rcw_2(fsl_ddr_cfg_regs_t *ddr)
  714. {
  715. unsigned int rcw8 = 0; /* RCW0: Register Control Word 8 */
  716. unsigned int rcw9 = 0; /* RCW1: Register Control Word 9 */
  717. unsigned int rcw10 = 0; /* RCW2: Register Control Word 10 */
  718. unsigned int rcw11 = 0; /* RCW3: Register Control Word 11 */
  719. unsigned int rcw12 = 0; /* RCW4: Register Control Word 12 */
  720. unsigned int rcw13 = 0; /* RCW5: Register Control Word 13 */
  721. unsigned int rcw14 = 0; /* RCW6: Register Control Word 14 */
  722. unsigned int rcw15 = 0; /* RCW7: Register Control Word 15 */
  723. ddr->ddr_sdram_rcw_2 = (0
  724. | ((rcw8 & 0xF) << 28)
  725. | ((rcw9 & 0xF) << 24)
  726. | ((rcw10 & 0xF) << 20)
  727. | ((rcw11 & 0xF) << 16)
  728. | ((rcw12 & 0xF) << 12)
  729. | ((rcw13 & 0xF) << 8)
  730. | ((rcw14 & 0xF) << 4)
  731. | ((rcw15 & 0xF) << 0)
  732. );
  733. }
  734. unsigned int
  735. check_fsl_memctl_config_regs(const fsl_ddr_cfg_regs_t *ddr)
  736. {
  737. unsigned int res = 0;
  738. /*
  739. * Check that DDR_SDRAM_CFG[RD_EN] and DDR_SDRAM_CFG[2T_EN] are
  740. * not set at the same time.
  741. */
  742. if (ddr->ddr_sdram_cfg & 0x10000000
  743. && ddr->ddr_sdram_cfg & 0x00008000) {
  744. printf("Error: DDR_SDRAM_CFG[RD_EN] and DDR_SDRAM_CFG[2T_EN] "
  745. " should not be set at the same time.\n");
  746. res++;
  747. }
  748. return res;
  749. }
  750. unsigned int
  751. compute_fsl_memctl_config_regs(const memctl_options_t *popts,
  752. fsl_ddr_cfg_regs_t *ddr,
  753. const common_timing_params_t *common_dimm,
  754. const dimm_params_t *dimm_params,
  755. unsigned int dbw_cap_adj)
  756. {
  757. unsigned int i;
  758. unsigned int cas_latency;
  759. unsigned int additive_latency;
  760. memset(ddr, 0, sizeof(fsl_ddr_cfg_regs_t));
  761. if (common_dimm == NULL) {
  762. printf("Error: subset DIMM params struct null pointer\n");
  763. return 1;
  764. }
  765. /*
  766. * Process overrides first.
  767. *
  768. * FIXME: somehow add dereated caslat to this
  769. */
  770. cas_latency = (popts->cas_latency_override)
  771. ? popts->cas_latency_override_value
  772. : common_dimm->lowest_common_SPD_caslat;
  773. additive_latency = (popts->additive_latency_override)
  774. ? popts->additive_latency_override_value
  775. : common_dimm->additive_latency;
  776. /* Chip Select Memory Bounds (CSn_BNDS) */
  777. for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
  778. phys_size_t sa = 0;
  779. phys_size_t ea = 0;
  780. if (popts->ba_intlv_ctl && (i > 0) &&
  781. ((popts->ba_intlv_ctl & 0x60) != FSL_DDR_CS2_CS3 )) {
  782. /* Don't set up boundaries for other CS
  783. * other than CS0, if bank interleaving
  784. * is enabled and not CS2+CS3 interleaved.
  785. */
  786. break;
  787. }
  788. if (dimm_params[i/2].n_ranks == 0) {
  789. debug("Skipping setup of CS%u "
  790. "because n_ranks on DIMM %u is 0\n", i, i/2);
  791. continue;
  792. }
  793. if (popts->memctl_interleaving && popts->ba_intlv_ctl) {
  794. /*
  795. * This works superbank 2CS
  796. * There are 2 memory controllers configured
  797. * identically, memory is interleaved between them,
  798. * and each controller uses rank interleaving within
  799. * itself. Therefore the starting and ending address
  800. * on each controller is twice the amount present on
  801. * each controller.
  802. */
  803. unsigned long long rank_density
  804. = dimm_params[0].capacity;
  805. ea = (2 * (rank_density >> dbw_cap_adj)) - 1;
  806. }
  807. else if (!popts->memctl_interleaving && popts->ba_intlv_ctl) {
  808. /*
  809. * If memory interleaving between controllers is NOT
  810. * enabled, the starting address for each memory
  811. * controller is distinct. However, because rank
  812. * interleaving is enabled, the starting and ending
  813. * addresses of the total memory on that memory
  814. * controller needs to be programmed into its
  815. * respective CS0_BNDS.
  816. */
  817. unsigned long long rank_density
  818. = dimm_params[i/2].rank_density;
  819. switch (popts->ba_intlv_ctl & FSL_DDR_CS0_CS1_CS2_CS3) {
  820. case FSL_DDR_CS0_CS1_CS2_CS3:
  821. /* CS0+CS1+CS2+CS3 interleaving, only CS0_CNDS
  822. * needs to be set.
  823. */
  824. sa = common_dimm->base_address;
  825. ea = sa + (4 * (rank_density >> dbw_cap_adj))-1;
  826. break;
  827. case FSL_DDR_CS0_CS1_AND_CS2_CS3:
  828. /* CS0+CS1 and CS2+CS3 interleaving, CS0_CNDS
  829. * and CS2_CNDS need to be set.
  830. */
  831. if (!(i&1)) {
  832. sa = dimm_params[i/2].base_address;
  833. ea = sa + (i * (rank_density >>
  834. dbw_cap_adj)) - 1;
  835. }
  836. break;
  837. case FSL_DDR_CS0_CS1:
  838. /* CS0+CS1 interleaving, CS0_CNDS needs
  839. * to be set
  840. */
  841. sa = common_dimm->base_address;
  842. ea = sa + (2 * (rank_density >> dbw_cap_adj))-1;
  843. break;
  844. case FSL_DDR_CS2_CS3:
  845. /* CS2+CS3 interleaving*/
  846. if (i == 2) {
  847. sa = dimm_params[i/2].base_address;
  848. ea = sa + (2 * (rank_density >>
  849. dbw_cap_adj)) - 1;
  850. }
  851. break;
  852. default: /* No bank(chip-select) interleaving */
  853. break;
  854. }
  855. }
  856. else if (popts->memctl_interleaving && !popts->ba_intlv_ctl) {
  857. /*
  858. * Only the rank on CS0 of each memory controller may
  859. * be used if memory controller interleaving is used
  860. * without rank interleaving within each memory
  861. * controller. However, the ending address programmed
  862. * into each CS0 must be the sum of the amount of
  863. * memory in the two CS0 ranks.
  864. */
  865. if (i == 0) {
  866. unsigned long long rank_density
  867. = dimm_params[0].rank_density;
  868. ea = (2 * (rank_density >> dbw_cap_adj)) - 1;
  869. }
  870. }
  871. else if (!popts->memctl_interleaving && !popts->ba_intlv_ctl) {
  872. /*
  873. * No rank interleaving and no memory controller
  874. * interleaving.
  875. */
  876. unsigned long long rank_density
  877. = dimm_params[i/2].rank_density;
  878. sa = dimm_params[i/2].base_address;
  879. ea = sa + (rank_density >> dbw_cap_adj) - 1;
  880. if (i&1) {
  881. if ((dimm_params[i/2].n_ranks == 1)) {
  882. /* Odd chip select, single-rank dimm */
  883. sa = 0;
  884. ea = 0;
  885. } else {
  886. /* Odd chip select, dual-rank DIMM */
  887. sa += rank_density >> dbw_cap_adj;
  888. ea += rank_density >> dbw_cap_adj;
  889. }
  890. }
  891. }
  892. sa >>= 24;
  893. ea >>= 24;
  894. ddr->cs[i].bnds = (0
  895. | ((sa & 0xFFF) << 16) /* starting address MSB */
  896. | ((ea & 0xFFF) << 0) /* ending address MSB */
  897. );
  898. debug("FSLDDR: cs[%d]_bnds = 0x%08x\n", i, ddr->cs[i].bnds);
  899. set_csn_config(i, ddr, popts, dimm_params);
  900. set_csn_config_2(i, ddr);
  901. }
  902. #if defined(CONFIG_FSL_DDR2)
  903. set_timing_cfg_0(ddr);
  904. #endif
  905. set_timing_cfg_3(ddr, common_dimm);
  906. set_timing_cfg_1(ddr, common_dimm, cas_latency);
  907. set_timing_cfg_2(ddr, popts, common_dimm,
  908. cas_latency, additive_latency);
  909. set_ddr_sdram_cfg(ddr, popts, common_dimm);
  910. set_ddr_sdram_cfg_2(ddr, popts);
  911. set_ddr_sdram_mode(ddr, popts, common_dimm,
  912. cas_latency, additive_latency);
  913. set_ddr_sdram_mode_2(ddr);
  914. set_ddr_sdram_interval(ddr, popts, common_dimm);
  915. set_ddr_data_init(ddr);
  916. set_ddr_sdram_clk_cntl(ddr, popts);
  917. set_ddr_init_addr(ddr);
  918. set_ddr_init_ext_addr(ddr);
  919. set_timing_cfg_4(ddr);
  920. set_timing_cfg_5(ddr);
  921. set_ddr_zq_cntl(ddr);
  922. set_ddr_wrlvl_cntl(ddr);
  923. set_ddr_pd_cntl(ddr);
  924. set_ddr_sr_cntr(ddr);
  925. set_ddr_sdram_rcw_1(ddr);
  926. set_ddr_sdram_rcw_2(ddr);
  927. return check_fsl_memctl_config_regs(ddr);
  928. }