ctrl_regs.c 31 KB

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