gw_ventana_spl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * Copyright (C) 2014 Gateworks Corporation
  3. * Author: Tim Harvey <tharvey@gateworks.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/crm_regs.h>
  10. #include <asm/arch/mx6-ddr.h>
  11. #include <asm/arch/mx6-pins.h>
  12. #include <asm/arch/sys_proto.h>
  13. #include <asm/imx-common/boot_mode.h>
  14. #include <asm/imx-common/iomux-v3.h>
  15. #include <asm/imx-common/mxc_i2c.h>
  16. #include <environment.h>
  17. #include <spl.h>
  18. #include "gsc.h"
  19. #include "common.h"
  20. DECLARE_GLOBAL_DATA_PTR;
  21. #define RTT_NOM_120OHM /* use 120ohm Rtt_nom vs 60ohm (lower power) */
  22. #define GSC_EEPROM_DDR_SIZE 0x2B /* enum (512,1024,2048) MB */
  23. #define GSC_EEPROM_DDR_WIDTH 0x2D /* enum (32,64) bit */
  24. /* configure MX6Q/DUAL mmdc DDR io registers */
  25. struct mx6dq_iomux_ddr_regs mx6dq_ddr_ioregs = {
  26. /* SDCLK[0:1], CAS, RAS, Reset: Differential input, 40ohm */
  27. .dram_sdclk_0 = 0x00020030,
  28. .dram_sdclk_1 = 0x00020030,
  29. .dram_cas = 0x00020030,
  30. .dram_ras = 0x00020030,
  31. .dram_reset = 0x00020030,
  32. /* SDCKE[0:1]: 100k pull-up */
  33. .dram_sdcke0 = 0x00003000,
  34. .dram_sdcke1 = 0x00003000,
  35. /* SDBA2: pull-up disabled */
  36. .dram_sdba2 = 0x00000000,
  37. /* SDODT[0:1]: 100k pull-up, 40 ohm */
  38. .dram_sdodt0 = 0x00003030,
  39. .dram_sdodt1 = 0x00003030,
  40. /* SDQS[0:7]: Differential input, 40 ohm */
  41. .dram_sdqs0 = 0x00000030,
  42. .dram_sdqs1 = 0x00000030,
  43. .dram_sdqs2 = 0x00000030,
  44. .dram_sdqs3 = 0x00000030,
  45. .dram_sdqs4 = 0x00000030,
  46. .dram_sdqs5 = 0x00000030,
  47. .dram_sdqs6 = 0x00000030,
  48. .dram_sdqs7 = 0x00000030,
  49. /* DQM[0:7]: Differential input, 40 ohm */
  50. .dram_dqm0 = 0x00020030,
  51. .dram_dqm1 = 0x00020030,
  52. .dram_dqm2 = 0x00020030,
  53. .dram_dqm3 = 0x00020030,
  54. .dram_dqm4 = 0x00020030,
  55. .dram_dqm5 = 0x00020030,
  56. .dram_dqm6 = 0x00020030,
  57. .dram_dqm7 = 0x00020030,
  58. };
  59. /* configure MX6Q/DUAL mmdc GRP io registers */
  60. struct mx6dq_iomux_grp_regs mx6dq_grp_ioregs = {
  61. /* DDR3 */
  62. .grp_ddr_type = 0x000c0000,
  63. .grp_ddrmode_ctl = 0x00020000,
  64. /* disable DDR pullups */
  65. .grp_ddrpke = 0x00000000,
  66. /* ADDR[00:16], SDBA[0:1]: 40 ohm */
  67. .grp_addds = 0x00000030,
  68. /* CS0/CS1/SDBA2/CKE0/CKE1/SDWE: 40 ohm */
  69. .grp_ctlds = 0x00000030,
  70. /* DATA[00:63]: Differential input, 40 ohm */
  71. .grp_ddrmode = 0x00020000,
  72. .grp_b0ds = 0x00000030,
  73. .grp_b1ds = 0x00000030,
  74. .grp_b2ds = 0x00000030,
  75. .grp_b3ds = 0x00000030,
  76. .grp_b4ds = 0x00000030,
  77. .grp_b5ds = 0x00000030,
  78. .grp_b6ds = 0x00000030,
  79. .grp_b7ds = 0x00000030,
  80. };
  81. /* configure MX6SOLO/DUALLITE mmdc DDR io registers */
  82. struct mx6sdl_iomux_ddr_regs mx6sdl_ddr_ioregs = {
  83. /* SDCLK[0:1], CAS, RAS, Reset: Differential input, 40ohm */
  84. .dram_sdclk_0 = 0x00020030,
  85. .dram_sdclk_1 = 0x00020030,
  86. .dram_cas = 0x00020030,
  87. .dram_ras = 0x00020030,
  88. .dram_reset = 0x00020030,
  89. /* SDCKE[0:1]: 100k pull-up */
  90. .dram_sdcke0 = 0x00003000,
  91. .dram_sdcke1 = 0x00003000,
  92. /* SDBA2: pull-up disabled */
  93. .dram_sdba2 = 0x00000000,
  94. /* SDODT[0:1]: 100k pull-up, 40 ohm */
  95. .dram_sdodt0 = 0x00003030,
  96. .dram_sdodt1 = 0x00003030,
  97. /* SDQS[0:7]: Differential input, 40 ohm */
  98. .dram_sdqs0 = 0x00000030,
  99. .dram_sdqs1 = 0x00000030,
  100. .dram_sdqs2 = 0x00000030,
  101. .dram_sdqs3 = 0x00000030,
  102. .dram_sdqs4 = 0x00000030,
  103. .dram_sdqs5 = 0x00000030,
  104. .dram_sdqs6 = 0x00000030,
  105. .dram_sdqs7 = 0x00000030,
  106. /* DQM[0:7]: Differential input, 40 ohm */
  107. .dram_dqm0 = 0x00020030,
  108. .dram_dqm1 = 0x00020030,
  109. .dram_dqm2 = 0x00020030,
  110. .dram_dqm3 = 0x00020030,
  111. .dram_dqm4 = 0x00020030,
  112. .dram_dqm5 = 0x00020030,
  113. .dram_dqm6 = 0x00020030,
  114. .dram_dqm7 = 0x00020030,
  115. };
  116. /* configure MX6SOLO/DUALLITE mmdc GRP io registers */
  117. struct mx6sdl_iomux_grp_regs mx6sdl_grp_ioregs = {
  118. /* DDR3 */
  119. .grp_ddr_type = 0x000c0000,
  120. /* SDQS[0:7]: Differential input, 40 ohm */
  121. .grp_ddrmode_ctl = 0x00020000,
  122. /* disable DDR pullups */
  123. .grp_ddrpke = 0x00000000,
  124. /* ADDR[00:16], SDBA[0:1]: 40 ohm */
  125. .grp_addds = 0x00000030,
  126. /* CS0/CS1/SDBA2/CKE0/CKE1/SDWE: 40 ohm */
  127. .grp_ctlds = 0x00000030,
  128. /* DATA[00:63]: Differential input, 40 ohm */
  129. .grp_ddrmode = 0x00020000,
  130. .grp_b0ds = 0x00000030,
  131. .grp_b1ds = 0x00000030,
  132. .grp_b2ds = 0x00000030,
  133. .grp_b3ds = 0x00000030,
  134. .grp_b4ds = 0x00000030,
  135. .grp_b5ds = 0x00000030,
  136. .grp_b6ds = 0x00000030,
  137. .grp_b7ds = 0x00000030,
  138. };
  139. /* MT41K64M16JT-125 (1Gb density) */
  140. static struct mx6_ddr3_cfg mt41k64m16jt_125 = {
  141. .mem_speed = 1600,
  142. .density = 1,
  143. .width = 16,
  144. .banks = 8,
  145. .rowaddr = 13,
  146. .coladdr = 10,
  147. .pagesz = 2,
  148. .trcd = 1375,
  149. .trcmin = 4875,
  150. .trasmin = 3500,
  151. };
  152. /* MT41K128M16JT-125 (2Gb density) */
  153. static struct mx6_ddr3_cfg mt41k128m16jt_125 = {
  154. .mem_speed = 1600,
  155. .density = 2,
  156. .width = 16,
  157. .banks = 8,
  158. .rowaddr = 14,
  159. .coladdr = 10,
  160. .pagesz = 2,
  161. .trcd = 1375,
  162. .trcmin = 4875,
  163. .trasmin = 3500,
  164. };
  165. /* MT41K256M16HA-125 (4Gb density) */
  166. static struct mx6_ddr3_cfg mt41k256m16ha_125 = {
  167. .mem_speed = 1600,
  168. .density = 4,
  169. .width = 16,
  170. .banks = 8,
  171. .rowaddr = 15,
  172. .coladdr = 10,
  173. .pagesz = 2,
  174. .trcd = 1375,
  175. .trcmin = 4875,
  176. .trasmin = 3500,
  177. };
  178. /*
  179. * calibration - these are the various CPU/DDR3 combinations we support
  180. */
  181. static struct mx6_mmdc_calibration mx6sdl_64x16_mmdc_calib = {
  182. /* write leveling calibration determine */
  183. .p0_mpwldectrl0 = 0x004C004E,
  184. .p0_mpwldectrl1 = 0x00440044,
  185. /* Read DQS Gating calibration */
  186. .p0_mpdgctrl0 = 0x42440247,
  187. .p0_mpdgctrl1 = 0x02310232,
  188. /* Read Calibration: DQS delay relative to DQ read access */
  189. .p0_mprddlctl = 0x45424746,
  190. /* Write Calibration: DQ/DM delay relative to DQS write access */
  191. .p0_mpwrdlctl = 0x33382C31,
  192. };
  193. static struct mx6_mmdc_calibration mx6dq_256x16_mmdc_calib = {
  194. /* write leveling calibration determine */
  195. .p0_mpwldectrl0 = 0x001B0016,
  196. .p0_mpwldectrl1 = 0x000C000E,
  197. /* Read DQS Gating calibration */
  198. .p0_mpdgctrl0 = 0x4324033A,
  199. .p0_mpdgctrl1 = 0x00000000,
  200. /* Read Calibration: DQS delay relative to DQ read access */
  201. .p0_mprddlctl = 0x40403438,
  202. /* Write Calibration: DQ/DM delay relative to DQS write access */
  203. .p0_mpwrdlctl = 0x40403D36,
  204. };
  205. static struct mx6_mmdc_calibration mx6sdl_256x16_mmdc_calib = {
  206. /* write leveling calibration determine */
  207. .p0_mpwldectrl0 = 0x00420043,
  208. .p0_mpwldectrl1 = 0x0016001A,
  209. /* Read DQS Gating calibration */
  210. .p0_mpdgctrl0 = 0x4238023B,
  211. .p0_mpdgctrl1 = 0x00000000,
  212. /* Read Calibration: DQS delay relative to DQ read access */
  213. .p0_mprddlctl = 0x40404849,
  214. /* Write Calibration: DQ/DM delay relative to DQS write access */
  215. .p0_mpwrdlctl = 0x40402E2F,
  216. };
  217. static struct mx6_mmdc_calibration mx6dq_128x32_mmdc_calib = {
  218. /* write leveling calibration determine */
  219. .p0_mpwldectrl0 = 0x00190017,
  220. .p0_mpwldectrl1 = 0x00140026,
  221. /* Read DQS Gating calibration */
  222. .p0_mpdgctrl0 = 0x43380347,
  223. .p0_mpdgctrl1 = 0x433C034D,
  224. /* Read Calibration: DQS delay relative to DQ read access */
  225. .p0_mprddlctl = 0x3C313539,
  226. /* Write Calibration: DQ/DM delay relative to DQS write access */
  227. .p0_mpwrdlctl = 0x36393C39,
  228. };
  229. static struct mx6_mmdc_calibration mx6sdl_128x32_mmdc_calib = {
  230. /* write leveling calibration determine */
  231. .p0_mpwldectrl0 = 0x003C003C,
  232. .p0_mpwldectrl1 = 0x001F002A,
  233. /* Read DQS Gating calibration */
  234. .p0_mpdgctrl0 = 0x42410244,
  235. .p0_mpdgctrl1 = 0x4234023A,
  236. /* Read Calibration: DQS delay relative to DQ read access */
  237. .p0_mprddlctl = 0x484A4C4B,
  238. /* Write Calibration: DQ/DM delay relative to DQS write access */
  239. .p0_mpwrdlctl = 0x33342B32,
  240. };
  241. static struct mx6_mmdc_calibration mx6dq_128x64_mmdc_calib = {
  242. /* write leveling calibration determine */
  243. .p0_mpwldectrl0 = 0x00190017,
  244. .p0_mpwldectrl1 = 0x00140026,
  245. .p1_mpwldectrl0 = 0x0021001C,
  246. .p1_mpwldectrl1 = 0x0011001D,
  247. /* Read DQS Gating calibration */
  248. .p0_mpdgctrl0 = 0x43380347,
  249. .p0_mpdgctrl1 = 0x433C034D,
  250. .p1_mpdgctrl0 = 0x032C0324,
  251. .p1_mpdgctrl1 = 0x03310232,
  252. /* Read Calibration: DQS delay relative to DQ read access */
  253. .p0_mprddlctl = 0x3C313539,
  254. .p1_mprddlctl = 0x37343141,
  255. /* Write Calibration: DQ/DM delay relative to DQS write access */
  256. .p0_mpwrdlctl = 0x36393C39,
  257. .p1_mpwrdlctl = 0x42344438,
  258. };
  259. static struct mx6_mmdc_calibration mx6sdl_128x64_mmdc_calib = {
  260. /* write leveling calibration determine */
  261. .p0_mpwldectrl0 = 0x003C003C,
  262. .p0_mpwldectrl1 = 0x001F002A,
  263. .p1_mpwldectrl0 = 0x00330038,
  264. .p1_mpwldectrl1 = 0x0022003F,
  265. /* Read DQS Gating calibration */
  266. .p0_mpdgctrl0 = 0x42410244,
  267. .p0_mpdgctrl1 = 0x4234023A,
  268. .p1_mpdgctrl0 = 0x022D022D,
  269. .p1_mpdgctrl1 = 0x021C0228,
  270. /* Read Calibration: DQS delay relative to DQ read access */
  271. .p0_mprddlctl = 0x484A4C4B,
  272. .p1_mprddlctl = 0x4B4D4E4B,
  273. /* Write Calibration: DQ/DM delay relative to DQS write access */
  274. .p0_mpwrdlctl = 0x33342B32,
  275. .p1_mpwrdlctl = 0x3933332B,
  276. };
  277. static struct mx6_mmdc_calibration mx6dq_256x32_mmdc_calib = {
  278. /* write leveling calibration determine */
  279. .p0_mpwldectrl0 = 0x001E001A,
  280. .p0_mpwldectrl1 = 0x0026001F,
  281. /* Read DQS Gating calibration */
  282. .p0_mpdgctrl0 = 0x43370349,
  283. .p0_mpdgctrl1 = 0x032D0327,
  284. /* Read Calibration: DQS delay relative to DQ read access */
  285. .p0_mprddlctl = 0x3D303639,
  286. /* Write Calibration: DQ/DM delay relative to DQS write access */
  287. .p0_mpwrdlctl = 0x32363934,
  288. };
  289. static struct mx6_mmdc_calibration mx6sdl_256x32_mmdc_calib = {
  290. /* write leveling calibration determine */
  291. .p0_mpwldectrl0 = 0X00480047,
  292. .p0_mpwldectrl1 = 0X003D003F,
  293. /* Read DQS Gating calibration */
  294. .p0_mpdgctrl0 = 0X423E0241,
  295. .p0_mpdgctrl1 = 0X022B022C,
  296. /* Read Calibration: DQS delay relative to DQ read access */
  297. .p0_mprddlctl = 0X49454A4A,
  298. /* Write Calibration: DQ/DM delay relative to DQS write access */
  299. .p0_mpwrdlctl = 0X2E372C32,
  300. };
  301. static struct mx6_mmdc_calibration mx6dq_256x64_mmdc_calib = {
  302. /* write leveling calibration determine */
  303. .p0_mpwldectrl0 = 0X00220021,
  304. .p0_mpwldectrl1 = 0X00200030,
  305. .p1_mpwldectrl0 = 0X002D0027,
  306. .p1_mpwldectrl1 = 0X00150026,
  307. /* Read DQS Gating calibration */
  308. .p0_mpdgctrl0 = 0x43330342,
  309. .p0_mpdgctrl1 = 0x0339034A,
  310. .p1_mpdgctrl0 = 0x032F0325,
  311. .p1_mpdgctrl1 = 0x032F022E,
  312. /* Read Calibration: DQS delay relative to DQ read access */
  313. .p0_mprddlctl = 0X3A2E3437,
  314. .p1_mprddlctl = 0X35312F3F,
  315. /* Write Calibration: DQ/DM delay relative to DQS write access */
  316. .p0_mpwrdlctl = 0X33363B37,
  317. .p1_mpwrdlctl = 0X40304239,
  318. };
  319. static void spl_dram_init(int width, int size_mb, int board_model)
  320. {
  321. struct mx6_ddr3_cfg *mem = NULL;
  322. struct mx6_mmdc_calibration *calib = NULL;
  323. struct mx6_ddr_sysinfo sysinfo = {
  324. /* width of data bus:0=16,1=32,2=64 */
  325. .dsize = width/32,
  326. /* config for full 4GB range so that get_mem_size() works */
  327. .cs_density = 32, /* 32Gb per CS */
  328. /* single chip select */
  329. .ncs = 1,
  330. .cs1_mirror = 0,
  331. .rtt_wr = 1 /*DDR3_RTT_60_OHM*/, /* RTT_Wr = RZQ/4 */
  332. #ifdef RTT_NOM_120OHM
  333. .rtt_nom = 2 /*DDR3_RTT_120_OHM*/, /* RTT_Nom = RZQ/2 */
  334. #else
  335. .rtt_nom = 1 /*DDR3_RTT_60_OHM*/, /* RTT_Nom = RZQ/4 */
  336. #endif
  337. .walat = 1, /* Write additional latency */
  338. .ralat = 5, /* Read additional latency */
  339. .mif3_mode = 3, /* Command prediction working mode */
  340. .bi_on = 1, /* Bank interleaving enabled */
  341. .sde_to_rst = 0x10, /* 14 cycles, 200us (JEDEC default) */
  342. .rst_to_cke = 0x23, /* 33 cycles, 500us (JEDEC default) */
  343. .pd_fast_exit = 1, /* enable precharge power-down fast exit */
  344. .ddr_type = DDR_TYPE_DDR3,
  345. };
  346. /*
  347. * MMDC Calibration requires the following data:
  348. * mx6_mmdc_calibration - board-specific calibration (routing delays)
  349. * these calibration values depend on board routing, SoC, and DDR
  350. * mx6_ddr_sysinfo - board-specific memory architecture (width/cs/etc)
  351. * mx6_ddr_cfg - chip specific timing/layout details
  352. */
  353. if (width == 16 && size_mb == 128) {
  354. mem = &mt41k64m16jt_125;
  355. if (is_cpu_type(MXC_CPU_MX6Q))
  356. ;
  357. else
  358. calib = &mx6sdl_64x16_mmdc_calib;
  359. debug("1gB density\n");
  360. } else if (width == 16 && size_mb == 256) {
  361. /* 1x 2Gb density chip - same calib as 2x 2Gb */
  362. mem = &mt41k128m16jt_125;
  363. if (is_cpu_type(MXC_CPU_MX6Q))
  364. calib = &mx6dq_128x32_mmdc_calib;
  365. else
  366. calib = &mx6sdl_128x32_mmdc_calib;
  367. debug("2gB density\n");
  368. } else if (width == 16 && size_mb == 512) {
  369. mem = &mt41k256m16ha_125;
  370. if (is_cpu_type(MXC_CPU_MX6Q))
  371. calib = &mx6dq_256x16_mmdc_calib;
  372. else
  373. calib = &mx6sdl_256x16_mmdc_calib;
  374. debug("4gB density\n");
  375. } else if (width == 32 && size_mb == 256) {
  376. /* Same calib as width==16, size==128 */
  377. mem = &mt41k64m16jt_125;
  378. if (is_cpu_type(MXC_CPU_MX6Q))
  379. ;
  380. else
  381. calib = &mx6sdl_64x16_mmdc_calib;
  382. debug("1gB density\n");
  383. } else if (width == 32 && size_mb == 512) {
  384. mem = &mt41k128m16jt_125;
  385. if (is_cpu_type(MXC_CPU_MX6Q))
  386. calib = &mx6dq_128x32_mmdc_calib;
  387. else
  388. calib = &mx6sdl_128x32_mmdc_calib;
  389. debug("2gB density\n");
  390. } else if (width == 32 && size_mb == 1024) {
  391. mem = &mt41k256m16ha_125;
  392. if (is_cpu_type(MXC_CPU_MX6Q))
  393. calib = &mx6dq_256x32_mmdc_calib;
  394. else
  395. calib = &mx6sdl_256x32_mmdc_calib;
  396. debug("4gB density\n");
  397. } else if (width == 64 && size_mb == 512) {
  398. mem = &mt41k64m16jt_125;
  399. debug("1gB density\n");
  400. } else if (width == 64 && size_mb == 1024) {
  401. mem = &mt41k128m16jt_125;
  402. if (is_cpu_type(MXC_CPU_MX6Q))
  403. calib = &mx6dq_128x64_mmdc_calib;
  404. else
  405. calib = &mx6sdl_128x64_mmdc_calib;
  406. debug("2gB density\n");
  407. } else if (width == 64 && size_mb == 2048) {
  408. mem = &mt41k256m16ha_125;
  409. if (is_cpu_type(MXC_CPU_MX6Q))
  410. calib = &mx6dq_256x64_mmdc_calib;
  411. debug("4gB density\n");
  412. }
  413. if (!(mem && calib)) {
  414. puts("Error: Invalid Calibration/Board Configuration\n");
  415. printf("MEM : %s\n", mem ? "OKAY" : "NULL");
  416. printf("CALIB : %s\n", calib ? "OKAY" : "NULL");
  417. printf("CPUTYPE: %s\n",
  418. is_cpu_type(MXC_CPU_MX6Q) ? "IMX6Q" : "IMX6DL");
  419. printf("SIZE_MB: %d\n", size_mb);
  420. printf("WIDTH : %d\n", width);
  421. hang();
  422. }
  423. if (is_cpu_type(MXC_CPU_MX6Q))
  424. mx6dq_dram_iocfg(width, &mx6dq_ddr_ioregs,
  425. &mx6dq_grp_ioregs);
  426. else
  427. mx6sdl_dram_iocfg(width, &mx6sdl_ddr_ioregs,
  428. &mx6sdl_grp_ioregs);
  429. mx6_dram_cfg(&sysinfo, calib, mem);
  430. }
  431. static void ccgr_init(void)
  432. {
  433. struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
  434. writel(0x00C03F3F, &ccm->CCGR0);
  435. writel(0x0030FC03, &ccm->CCGR1);
  436. writel(0x0FFFC000, &ccm->CCGR2);
  437. writel(0x3FF00000, &ccm->CCGR3);
  438. writel(0xFFFFF300, &ccm->CCGR4); /* enable NAND/GPMI/BCH clks */
  439. writel(0x0F0000C3, &ccm->CCGR5);
  440. writel(0x000003FF, &ccm->CCGR6);
  441. }
  442. static void gpr_init(void)
  443. {
  444. struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
  445. /* enable AXI cache for VDOA/VPU/IPU */
  446. writel(0xF00000CF, &iomux->gpr[4]);
  447. /* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */
  448. writel(0x007F007F, &iomux->gpr[6]);
  449. writel(0x007F007F, &iomux->gpr[7]);
  450. }
  451. /*
  452. * called from C runtime startup code (arch/arm/lib/crt0.S:_main)
  453. * - we have a stack and a place to store GD, both in SRAM
  454. * - no variable global data is available
  455. */
  456. void board_init_f(ulong dummy)
  457. {
  458. struct ventana_board_info ventana_info;
  459. int board_model;
  460. /* setup clock gating */
  461. ccgr_init();
  462. /* setup AIPS and disable watchdog */
  463. arch_cpu_init();
  464. /* setup AXI */
  465. gpr_init();
  466. /* iomux and setup of i2c */
  467. setup_iomux_uart();
  468. setup_ventana_i2c();
  469. /* setup GP timer */
  470. timer_init();
  471. /* UART clocks enabled and gd valid - init serial console */
  472. preloader_console_init();
  473. /* read/validate EEPROM info to determine board model and SDRAM cfg */
  474. board_model = read_eeprom(CONFIG_I2C_GSC, &ventana_info);
  475. /* configure model-specific gpio */
  476. setup_iomux_gpio(board_model, &ventana_info);
  477. /* provide some some default: 32bit 128MB */
  478. if (GW_UNKNOWN == board_model)
  479. hang();
  480. /* configure MMDC for SDRAM width/size and per-model calibration */
  481. spl_dram_init(8 << ventana_info.sdram_width,
  482. 16 << ventana_info.sdram_size,
  483. board_model);
  484. /* Clear the BSS. */
  485. memset(__bss_start, 0, __bss_end - __bss_start);
  486. /* disable boot watchdog */
  487. gsc_boot_wd_disable();
  488. }
  489. /* called from board_init_r after gd setup if CONFIG_SPL_BOARD_INIT defined */
  490. /* its our chance to print info about boot device */
  491. void spl_board_init(void)
  492. {
  493. /* determine boot device from SRC_SBMR1 (BOOT_CFG[4:1]) or SRC_GPR9 */
  494. u32 boot_device = spl_boot_device();
  495. switch (boot_device) {
  496. case BOOT_DEVICE_MMC1:
  497. puts("Booting from MMC\n");
  498. break;
  499. case BOOT_DEVICE_NAND:
  500. puts("Booting from NAND\n");
  501. break;
  502. case BOOT_DEVICE_SATA:
  503. puts("Booting from SATA\n");
  504. break;
  505. default:
  506. puts("Unknown boot device\n");
  507. }
  508. /* PMIC init */
  509. setup_pmic();
  510. }
  511. #ifdef CONFIG_SPL_OS_BOOT
  512. /* return 1 if we wish to boot to uboot vs os (falcon mode) */
  513. int spl_start_uboot(void)
  514. {
  515. int ret = 1;
  516. debug("%s\n", __func__);
  517. #ifdef CONFIG_SPL_ENV_SUPPORT
  518. env_init();
  519. env_relocate_spec();
  520. debug("boot_os=%s\n", getenv("boot_os"));
  521. if (getenv_yesno("boot_os") == 1)
  522. ret = 0;
  523. #endif
  524. debug("%s booting %s\n", __func__, ret ? "uboot" : "linux");
  525. return ret;
  526. }
  527. #endif
  528. void reset_cpu(ulong addr)
  529. {
  530. }