spl.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Nelson Integration, LLC
  4. * Author: Eric Nelson <eric@nelint.com>
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/iomux.h>
  9. #include <asm/arch/clock.h>
  10. #include <asm/arch/crm_regs.h>
  11. #include <asm/arch/mx6-ddr.h>
  12. #include <asm/arch/mx6-pins.h>
  13. #include <asm/arch/sys_proto.h>
  14. #include <spl.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
  17. PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
  18. PAD_CTL_SRE_FAST | PAD_CTL_HYS)
  19. static iomux_v3_cfg_t const uart_pads[] = {
  20. #ifdef CONFIG_UART2_EIM_D26_27
  21. IOMUX_PADS(PAD_EIM_D26__UART2_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
  22. IOMUX_PADS(PAD_EIM_D27__UART2_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
  23. #elif defined(CONFIG_UART1_CSI0_DAT10_11)
  24. IOMUX_PADS(PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
  25. IOMUX_PADS(PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
  26. #elif defined(CONFIG_UART1_SD3_DAT6_7)
  27. IOMUX_PADS(PAD_SD3_DAT6__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
  28. IOMUX_PADS(PAD_SD3_DAT7__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
  29. #elif defined(CONFIG_UART1_UART1)
  30. MX6_PAD_UART1_TXD__UART1_TXD | MUX_PAD_CTRL(UART_PAD_CTRL),
  31. MX6_PAD_UART1_RXD__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL),
  32. #else
  33. #error select UART console pads
  34. #endif
  35. };
  36. #ifdef CONFIG_DDR3
  37. #define GRP_DDRTYPE 0x000C0000
  38. #else
  39. #define GRP_DDRTYPE 0x00080000
  40. #endif
  41. /* all existing designs have this disabled */
  42. #define DDR_PKE 0
  43. /* use Kconfig for ODT and DRIVE_STRENGTH */
  44. #define DDR_ODT \
  45. (CONFIG_DDR_ODT << 8)
  46. #define DRAM_DRIVE_STRENGTH \
  47. (CONFIG_DRAM_DRIVE_STRENGTH << 3)
  48. /* configure MX6Q/DUAL mmdc DDR io registers */
  49. static struct mx6dq_iomux_ddr_regs const mx6dq_ddr_ioregs = {
  50. /* SDCLK[0:1], CAS, RAS, Reset: Differential input, 40ohm */
  51. .dram_sdclk_0 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  52. .dram_sdclk_1 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  53. .dram_cas = DDR_ODT + DRAM_DRIVE_STRENGTH,
  54. .dram_ras = DDR_ODT + DRAM_DRIVE_STRENGTH,
  55. .dram_reset = DDR_ODT + DRAM_DRIVE_STRENGTH,
  56. /* SDCKE[0:1]: 100k pull-up */
  57. .dram_sdcke0 = 0x00003000,
  58. .dram_sdcke1 = 0x00003000,
  59. /* SDBA2: pull-up disabled */
  60. .dram_sdba2 = 0x00000000,
  61. /* SDODT[0:1]: 100k pull-up, 40 ohm */
  62. .dram_sdodt0 = 0x00003000 + DRAM_DRIVE_STRENGTH,
  63. .dram_sdodt1 = 0x00003000 + DRAM_DRIVE_STRENGTH,
  64. /* SDQS[0:7]: Differential input, 40 ohm */
  65. .dram_sdqs0 = DRAM_DRIVE_STRENGTH,
  66. .dram_sdqs1 = DRAM_DRIVE_STRENGTH,
  67. .dram_sdqs2 = DRAM_DRIVE_STRENGTH,
  68. .dram_sdqs3 = DRAM_DRIVE_STRENGTH,
  69. .dram_sdqs4 = DRAM_DRIVE_STRENGTH,
  70. .dram_sdqs5 = DRAM_DRIVE_STRENGTH,
  71. .dram_sdqs6 = DRAM_DRIVE_STRENGTH,
  72. .dram_sdqs7 = DRAM_DRIVE_STRENGTH,
  73. /* DQM[0:7]: Differential input, 40 ohm */
  74. .dram_dqm0 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  75. .dram_dqm1 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  76. .dram_dqm2 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  77. .dram_dqm3 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  78. .dram_dqm4 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  79. .dram_dqm5 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  80. .dram_dqm6 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  81. .dram_dqm7 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  82. };
  83. /* configure MX6Q/DUAL mmdc GRP io registers */
  84. static struct mx6dq_iomux_grp_regs const mx6dq_grp_ioregs = {
  85. /* DDR3 */
  86. .grp_ddr_type = GRP_DDRTYPE,
  87. .grp_ddrmode_ctl = DDR_ODT,
  88. /* disable DDR pullups */
  89. .grp_ddrpke = DDR_PKE,
  90. /* ADDR[00:16], SDBA[0:1]: 40 ohm */
  91. .grp_addds = DRAM_DRIVE_STRENGTH,
  92. /* CS0/CS1/SDBA2/CKE0/CKE1/SDWE: 40 ohm */
  93. .grp_ctlds = DRAM_DRIVE_STRENGTH,
  94. /* DATA[00:63]: Differential input, 40 ohm */
  95. .grp_ddrmode = DDR_ODT,
  96. .grp_b0ds = DRAM_DRIVE_STRENGTH,
  97. .grp_b1ds = DRAM_DRIVE_STRENGTH,
  98. .grp_b2ds = DRAM_DRIVE_STRENGTH,
  99. .grp_b3ds = DRAM_DRIVE_STRENGTH,
  100. .grp_b4ds = DRAM_DRIVE_STRENGTH,
  101. .grp_b5ds = DRAM_DRIVE_STRENGTH,
  102. .grp_b6ds = DRAM_DRIVE_STRENGTH,
  103. .grp_b7ds = DRAM_DRIVE_STRENGTH,
  104. };
  105. static struct mx6sdl_iomux_ddr_regs const mx6sdl_ddr_ioregs = {
  106. /* SDCLK[0:1], CAS, RAS, Reset: Differential input, 40ohm */
  107. .dram_sdclk_0 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  108. .dram_sdclk_1 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  109. .dram_cas = DDR_ODT + DRAM_DRIVE_STRENGTH,
  110. .dram_ras = DDR_ODT + DRAM_DRIVE_STRENGTH,
  111. .dram_reset = DDR_ODT + DRAM_DRIVE_STRENGTH,
  112. /* SDCKE[0:1]: 100k pull-up */
  113. .dram_sdcke0 = 0x00003000,
  114. .dram_sdcke1 = 0x00003000,
  115. /* SDBA2: pull-up disabled */
  116. .dram_sdba2 = 0x00000000,
  117. /* SDODT[0:1]: 100k pull-up, 40 ohm */
  118. .dram_sdodt0 = 0x00003000 + DRAM_DRIVE_STRENGTH,
  119. .dram_sdodt1 = 0x00003000 + DRAM_DRIVE_STRENGTH,
  120. /* SDQS[0:7]: Differential input, 40 ohm */
  121. .dram_sdqs0 = DRAM_DRIVE_STRENGTH,
  122. .dram_sdqs1 = DRAM_DRIVE_STRENGTH,
  123. .dram_sdqs2 = DRAM_DRIVE_STRENGTH,
  124. .dram_sdqs3 = DRAM_DRIVE_STRENGTH,
  125. .dram_sdqs4 = DRAM_DRIVE_STRENGTH,
  126. .dram_sdqs5 = DRAM_DRIVE_STRENGTH,
  127. .dram_sdqs6 = DRAM_DRIVE_STRENGTH,
  128. .dram_sdqs7 = DRAM_DRIVE_STRENGTH,
  129. /* DQM[0:7]: Differential input, 40 ohm */
  130. .dram_dqm0 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  131. .dram_dqm1 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  132. .dram_dqm2 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  133. .dram_dqm3 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  134. .dram_dqm4 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  135. .dram_dqm5 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  136. .dram_dqm6 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  137. .dram_dqm7 = DDR_ODT + DRAM_DRIVE_STRENGTH,
  138. };
  139. /* configure MX6SOLO/DUALLITE mmdc GRP io registers */
  140. static struct mx6sdl_iomux_grp_regs const mx6sdl_grp_ioregs = {
  141. /* DDR3 */
  142. .grp_ddr_type = GRP_DDRTYPE,
  143. /* SDQS[0:7]: Differential input, 40 ohm */
  144. .grp_ddrmode_ctl = DDR_ODT,
  145. /* disable DDR pullups */
  146. .grp_ddrpke = DDR_PKE,
  147. /* ADDR[00:16], SDBA[0:1]: 40 ohm */
  148. .grp_addds = DRAM_DRIVE_STRENGTH,
  149. /* CS0/CS1/SDBA2/CKE0/CKE1/SDWE: 40 ohm */
  150. .grp_ctlds = DRAM_DRIVE_STRENGTH,
  151. /* DATA[00:63]: Differential input, 40 ohm */
  152. .grp_ddrmode = DDR_ODT,
  153. .grp_b0ds = DRAM_DRIVE_STRENGTH,
  154. .grp_b1ds = DRAM_DRIVE_STRENGTH,
  155. .grp_b2ds = DRAM_DRIVE_STRENGTH,
  156. .grp_b3ds = DRAM_DRIVE_STRENGTH,
  157. .grp_b4ds = DRAM_DRIVE_STRENGTH,
  158. .grp_b5ds = DRAM_DRIVE_STRENGTH,
  159. .grp_b6ds = DRAM_DRIVE_STRENGTH,
  160. .grp_b7ds = DRAM_DRIVE_STRENGTH,
  161. };
  162. const struct mx6sl_iomux_ddr_regs mx6sl_ddr_ioregs = {
  163. .dram_sdqs0 = DRAM_DRIVE_STRENGTH,
  164. .dram_sdqs1 = DRAM_DRIVE_STRENGTH,
  165. .dram_sdqs2 = DRAM_DRIVE_STRENGTH,
  166. .dram_sdqs3 = DRAM_DRIVE_STRENGTH,
  167. .dram_dqm0 = DRAM_DRIVE_STRENGTH,
  168. .dram_dqm1 = DRAM_DRIVE_STRENGTH,
  169. .dram_dqm2 = DRAM_DRIVE_STRENGTH,
  170. .dram_dqm3 = DRAM_DRIVE_STRENGTH,
  171. .dram_cas = DRAM_DRIVE_STRENGTH,
  172. .dram_ras = DRAM_DRIVE_STRENGTH,
  173. .dram_sdclk_0 = DRAM_DRIVE_STRENGTH,
  174. .dram_reset = DRAM_DRIVE_STRENGTH,
  175. .dram_sdba2 = 0x00020000,
  176. .dram_odt0 = 0x00030000 + DRAM_DRIVE_STRENGTH,
  177. .dram_odt1 = 0x00030000 + DRAM_DRIVE_STRENGTH,
  178. };
  179. const struct mx6sl_iomux_grp_regs mx6sl_grp_ioregs = {
  180. .grp_b0ds = DRAM_DRIVE_STRENGTH,
  181. .grp_b1ds = DRAM_DRIVE_STRENGTH,
  182. .grp_b2ds = DRAM_DRIVE_STRENGTH,
  183. .grp_b3ds = DRAM_DRIVE_STRENGTH,
  184. .grp_addds = DRAM_DRIVE_STRENGTH,
  185. .grp_ctlds = DRAM_DRIVE_STRENGTH,
  186. .grp_ddrmode_ctl = DDR_ODT,
  187. .grp_ddrpke = DDR_PKE,
  188. .grp_ddrmode = DDR_ODT,
  189. .grp_ddr_type = GRP_DDRTYPE,
  190. };
  191. static struct mx6_ddr_sysinfo const sysinfo = {
  192. /* width of data bus:0=16,1=32,2=64 */
  193. #if CONFIG_DDRWIDTH == 32
  194. .dsize = 1,
  195. #elif CONFIG_DDRWIDTH == 64
  196. .dsize = 2,
  197. #else
  198. #error missing CONFIG_DDRWIDTH
  199. #endif
  200. /* config for full 4GB range so that get_mem_size() works */
  201. .cs_density = 32, /* 32Gb per CS */
  202. /* # of chip selects */
  203. .ncs = CONFIG_DDRCS,
  204. .cs1_mirror = 0,
  205. .bi_on = 1, /* Bank interleaving enabled */
  206. .rtt_nom = CONFIG_RTT_NOM,
  207. .rtt_wr = CONFIG_RTT_WR,
  208. .ralat = CONFIG_RALAT, /* Read additional latency */
  209. .walat = CONFIG_WALAT, /* Write additional latency */
  210. .mif3_mode = 3, /* Command prediction working mode */
  211. #ifdef CONFIG_DDR3
  212. .rst_to_cke = 0x23, /* 33 cycles, 500us (JEDEC default) */
  213. .sde_to_rst = 0x10, /* JEDEC value for LPDDR2 - 200us */
  214. .pd_fast_exit = 0, /* immaterial for calibration */
  215. .ddr_type = DDR_TYPE_DDR3,
  216. #else
  217. .rst_to_cke = 0x10, /* JEDEC value for LPDDR2: 200us */
  218. .sde_to_rst = 0, /* LPDDR2 does not need this field */
  219. .pd_fast_exit = 0, /* immaterial for calibration */
  220. .ddr_type = DDR_TYPE_LPDDR2,
  221. #endif
  222. .refsel = CONFIG_REFSEL,
  223. .refr = CONFIG_REFR,
  224. };
  225. #ifdef CONFIG_MT41K512M16TNA
  226. /* Micron MT41K512M16TNA-125 */
  227. static struct mx6_ddr3_cfg const ddrtype = {
  228. .mem_speed = 1600,
  229. .density = 8,
  230. .width = 16,
  231. .banks = 8,
  232. .rowaddr = 15,
  233. .coladdr = 10,
  234. .pagesz = 1,
  235. .trcd = 1375,
  236. .trcmin = 5062,
  237. .trasmin = 3750,
  238. };
  239. #elif defined(CONFIG_MT41K128M16JT)
  240. /* Micron MT41K128M16JT-125 */
  241. static struct mx6_ddr3_cfg const ddrtype = {
  242. .mem_speed = 1600,
  243. .density = 2,
  244. .width = 16,
  245. .banks = 8,
  246. .rowaddr = 14,
  247. .coladdr = 10,
  248. .pagesz = 2,
  249. .trcd = 1375,
  250. .trcmin = 4875,
  251. .trasmin = 3500,
  252. };
  253. #elif defined(CONFIG_H5TQ4G63AFR)
  254. /* Hynix H5TQ4G63AFR */
  255. static struct mx6_ddr3_cfg const ddrtype = {
  256. .mem_speed = 1600,
  257. .density = 4,
  258. .width = 16,
  259. .banks = 8,
  260. .rowaddr = 15,
  261. .coladdr = 10,
  262. .pagesz = 2,
  263. .trcd = 1375,
  264. .trcmin = 4875,
  265. .trasmin = 3500,
  266. };
  267. #elif defined CONFIG_H5TQ2G63DFR
  268. /* Hynix H5TQ2G63DFR */
  269. static struct mx6_ddr3_cfg const ddrtype = {
  270. .mem_speed = 1333,
  271. .density = 2,
  272. .width = 16,
  273. .banks = 8,
  274. .rowaddr = 14,
  275. .coladdr = 10,
  276. .pagesz = 2,
  277. .trcd = 1350,
  278. .trcmin = 4950,
  279. .trasmin = 3600,
  280. };
  281. #elif defined(CONFIG_MT42L256M32D2LG)
  282. /* Micron MT42L256M32D2LG */
  283. static struct mx6_lpddr2_cfg ddrtype = {
  284. .mem_speed = 800,
  285. .density = 4,
  286. .width = 32,
  287. .banks = 8,
  288. .rowaddr = 14,
  289. .coladdr = 10,
  290. .trcd_lp = 2000,
  291. .trppb_lp = 2000,
  292. .trpab_lp = 2250,
  293. .trasmin = 4200,
  294. };
  295. #elif defined(CONFIG_MT29PZZZ4D4BKESK)
  296. /* Micron MT29PZZZ4D4BKESK */
  297. static struct mx6_lpddr2_cfg ddrtype = {
  298. .mem_speed = 800,
  299. .density = 4,
  300. .width = 32,
  301. .banks = 8,
  302. .rowaddr = 14,
  303. .coladdr = 10,
  304. .trcd_lp = 2000,
  305. .trppb_lp = 2000,
  306. .trpab_lp = 2250,
  307. .trasmin = 4200,
  308. };
  309. #else
  310. #error please select DDR type using menuconfig
  311. #endif
  312. static void ccgr_init(void)
  313. {
  314. struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
  315. /* FIXME: these should probably be checked, especially
  316. * for i.MX6SL, UL, ULL
  317. */
  318. writel(0x00C03F3F, &ccm->CCGR0);
  319. writel(0x0030FC03, &ccm->CCGR1);
  320. writel(0x0FFFC000, &ccm->CCGR2);
  321. writel(0x3FF00000, &ccm->CCGR3);
  322. writel(0x00FFF300, &ccm->CCGR4);
  323. writel(0x0F0000C3, &ccm->CCGR5);
  324. writel(0x000003FF, &ccm->CCGR6);
  325. }
  326. static void display_calibration(struct mx6_mmdc_calibration *calib)
  327. {
  328. printf(".p0_mpdgctrl0\t= 0x%08X\n", calib->p0_mpdgctrl0);
  329. printf(".p0_mpdgctrl1\t= 0x%08X\n", calib->p0_mpdgctrl1);
  330. printf(".p0_mprddlctl\t= 0x%08X\n", calib->p0_mprddlctl);
  331. printf(".p0_mpwrdlctl\t= 0x%08X\n", calib->p0_mpwrdlctl);
  332. printf(".p0_mpwldectrl0\t= 0x%08X\n", calib->p0_mpwldectrl0);
  333. printf(".p0_mpwldectrl1\t= 0x%08X\n", calib->p0_mpwldectrl1);
  334. if (sysinfo.dsize == 2) {
  335. printf(".p1_mpdgctrl0\t= 0x%08X\n", calib->p1_mpdgctrl0);
  336. printf(".p1_mpdgctrl1\t= 0x%08X\n", calib->p1_mpdgctrl1);
  337. printf(".p1_mprddlctl\t= 0x%08X\n", calib->p1_mprddlctl);
  338. printf(".p1_mpwrdlctl\t= 0x%08X\n", calib->p1_mpwrdlctl);
  339. printf(".p1_mpwldectrl0\t= 0x%08X\n", calib->p1_mpwldectrl0);
  340. printf(".p1_mpwldectrl1\t= 0x%08X\n", calib->p1_mpwldectrl1);
  341. }
  342. #ifdef CONFIG_IMXIMAGE_OUTPUT
  343. printf("DATA 4 MX6_MMDC_P0_MPDGCTRL0\t= 0x%08X\n", calib->p0_mpdgctrl0);
  344. printf("DATA 4 MX6_MMDC_P0_MPDGCTRL1\t= 0x%08X\n", calib->p0_mpdgctrl1);
  345. printf("DATA 4 MX6_MMDC_P0_MPRDDLCTL\t= 0x%08X\n", calib->p0_mprddlctl);
  346. printf("DATA 4 MX6_MMDC_P0_MPWRDLCTL\t= 0x%08X\n", calib->p0_mpwrdlctl);
  347. printf("DATA 4 MX6_MMDC_P0_MPWLDECTRL0\t= 0x%08X\n",
  348. calib->p0_mpwldectrl0);
  349. printf("DATA 4 MX6_MMDC_P0_MPWLDECTRL1\t= 0x%08X\n",
  350. calib->p0_mpwldectrl1);
  351. if (sysinfo.dsize == 2) {
  352. printf("DATA 4 MX6_MMDC_P1_MPDGCTRL0\t= 0x%08X\n",
  353. calib->p1_mpdgctrl0);
  354. printf("DATA 4 MX6_MMDC_P1_MPDGCTRL1\t= 0x%08X\n",
  355. calib->p1_mpdgctrl1);
  356. printf("DATA 4 MX6_MMDC_P1_MPRDDLCTL\t= 0x%08X\n",
  357. calib->p1_mprddlctl);
  358. printf("DATA 4 MX6_MMDC_P1_MPWRDLCTL\t= 0x%08X\n",
  359. calib->p1_mpwrdlctl);
  360. printf("DATA 4 MX6_MMDC_P1_MPWLDECTRL0\t= 0x%08X\n",
  361. calib->p1_mpwldectrl0);
  362. printf("DATA 4 MX6_MMDC_P1_MPWLDECTRL1\t= 0x%08X\n",
  363. calib->p1_mpwldectrl1);
  364. }
  365. #endif
  366. }
  367. /*
  368. * called from C runtime startup code (arch/arm/lib/crt0.S:_main)
  369. * - we have a stack and a place to store GD, both in SRAM
  370. * - no variable global data is available
  371. */
  372. void board_init_f(ulong dummy)
  373. {
  374. int errs;
  375. struct mx6_mmdc_calibration calibration = {0};
  376. memset((void *)gd, 0, sizeof(struct global_data));
  377. /* write leveling calibration defaults */
  378. calibration.p0_mpwrdlctl = 0x40404040;
  379. calibration.p1_mpwrdlctl = 0x40404040;
  380. /* setup AIPS and disable watchdog */
  381. arch_cpu_init();
  382. ccgr_init();
  383. SETUP_IOMUX_PADS(uart_pads);
  384. /* setup GP timer */
  385. timer_init();
  386. /* UART clocks enabled and gd valid - init serial console */
  387. preloader_console_init();
  388. if (sysinfo.dsize != 1) {
  389. if (is_cpu_type(MXC_CPU_MX6SX) ||
  390. is_cpu_type(MXC_CPU_MX6UL) ||
  391. is_cpu_type(MXC_CPU_MX6ULL) ||
  392. is_cpu_type(MXC_CPU_MX6SL)) {
  393. printf("cpu type 0x%x doesn't support 64-bit bus\n",
  394. get_cpu_type());
  395. reset_cpu(0);
  396. }
  397. }
  398. #ifdef CONFIG_MX6SL
  399. mx6sl_dram_iocfg(CONFIG_DDRWIDTH, &mx6sl_ddr_ioregs,
  400. &mx6sl_grp_ioregs);
  401. #else
  402. if (is_cpu_type(MXC_CPU_MX6Q)) {
  403. mx6dq_dram_iocfg(CONFIG_DDRWIDTH, &mx6dq_ddr_ioregs,
  404. &mx6dq_grp_ioregs);
  405. } else {
  406. mx6sdl_dram_iocfg(CONFIG_DDRWIDTH, &mx6sdl_ddr_ioregs,
  407. &mx6sdl_grp_ioregs);
  408. }
  409. #endif
  410. mx6_dram_cfg(&sysinfo, &calibration, &ddrtype);
  411. errs = mmdc_do_write_level_calibration(&sysinfo);
  412. if (errs) {
  413. printf("error %d from write level calibration\n", errs);
  414. } else {
  415. errs = mmdc_do_dqs_calibration(&sysinfo);
  416. if (errs) {
  417. printf("error %d from dqs calibration\n", errs);
  418. } else {
  419. printf("completed successfully\n");
  420. mmdc_read_calibration(&sysinfo, &calibration);
  421. display_calibration(&calibration);
  422. }
  423. }
  424. }