AM335x_sk_DDR3.mac 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. // -----------------------------------------------------------------------
  2. // This file contains the initial set up configuration for the AM335x.
  3. //-------------------------------------------------------------------------
  4. __var clk_in;
  5. CHGBIT (addr, mask, data)
  6. {
  7. __var reg;
  8. reg = __readMemory32(addr, "Memory");
  9. reg &= ~mask;
  10. reg |= data;
  11. __writeMemory32(reg, addr, "Memory");
  12. }
  13. CLRBIT (addr, mask)
  14. {
  15. __var reg;
  16. reg = __readMemory32(addr, "Memory");
  17. reg &= ~mask;
  18. __writeMemory32(reg, addr, "Memory");
  19. }
  20. SETBIT (addr, mask)
  21. {
  22. __var reg;
  23. reg = __readMemory32(addr, "Memory");
  24. reg |= mask;
  25. __writeMemory32(reg, addr, "Memory");
  26. }
  27. TESTBIT (addr, mask)
  28. {
  29. return(__readMemory32(addr, "Memory") & mask);
  30. }
  31. get_input_clock_frequency()
  32. {
  33. __var temp;
  34. temp = __readMemory32(((0x44E10000) + 0x40), "Memory");
  35. temp = temp >> 22;
  36. temp = temp & 0x3;
  37. if(temp == 0)
  38. {
  39. clk_in = 19; //19.2MHz
  40. __message "Input Clock Read from SYSBOOT[15:14]: 19.2MHz\n";
  41. }
  42. if(temp == 1)
  43. {
  44. clk_in = 24; //24MHz
  45. __message "Input Clock Read from SYSBOOT[15:14]: 24MHz\n";
  46. }
  47. if(temp == 2)
  48. {
  49. clk_in = 25; //25MHz
  50. __message "Input Clock Read from SYSBOOT[15:14]: 25MHz\n";
  51. }
  52. if(temp == 3)
  53. {
  54. clk_in = 26; //26MHz
  55. __message "Input Clock Read from SYSBOOT[15:14]: 26MHz\n";
  56. }
  57. }
  58. mpu_pll_config( clk_in, N, M, M2)
  59. {
  60. __var ref_clk,clk_out;
  61. __var clkmode,clksel,div_m2,idlest_dpll;
  62. __var temp,i;
  63. ref_clk = clk_in/(N+1);
  64. clk_out = (ref_clk*M)/M2;
  65. clkmode=__readMemory32((0x44E00000 + 0x488), "Memory");
  66. clksel= __readMemory32((0x44E00000 + 0x42C), "Memory");
  67. div_m2= __readMemory32((0x44E00000 + 0x4A8), "Memory");
  68. __message "**** Going to Bypass... \n";
  69. //put the DPLL in bypass mode
  70. __writeMemory32(0x4, (0x44E00000 + 0x488), "Memory");
  71. while(((__readMemory32((0x44E00000 + 0x420), "Memory") & 0x101) != 0x00000100)); //wait for bypass status
  72. __message "**** Bypassed, changing values... \n";
  73. //set multiply and divide values
  74. clksel = clksel & (~0x7FFFF);
  75. clksel = clksel | ((M <<0x8) | N);
  76. __writeMemory32(clksel, (0x44E00000 + 0x42C), "Memory");
  77. div_m2 = div_m2 & ~0x1F;
  78. div_m2 = div_m2 | M2;
  79. __writeMemory32(div_m2, (0x44E00000 + 0x4A8), "Memory");
  80. __message "**** Locking ARM PLL\n";
  81. //now lock the DPLL
  82. clkmode = clkmode | 0x7; //enables lock mode
  83. __writeMemory32(clkmode, (0x44E00000 + 0x488), "Memory");
  84. while(((__readMemory32((0x44E00000 + 0x420), "Memory") & 0x101) != 0x1)); //wait for lock
  85. }
  86. core_pll_config( clk_in, N, M, M4, M5, M6)
  87. {
  88. __var ref_clk,clk_out4,clk_out5,clk_out6;
  89. __var clkmode,clksel,div_m4,div_m5,div_m6,idlest_dpll;
  90. ref_clk = clk_in/(N+1);
  91. clk_out4 = (ref_clk*M)/M4; //M4=200MHz
  92. clk_out5 = (ref_clk*M)/M5; //M5=250MHz
  93. clk_out6 = (ref_clk*M)/M6; //M6=500MHz
  94. clkmode= __readMemory32((0x44E00000 + 0x490), "Memory");
  95. clksel= __readMemory32((0x44E00000 + 0x468), "Memory");
  96. div_m4= __readMemory32((0x44E00000 + 0x480), "Memory");
  97. div_m5= __readMemory32((0x44E00000 + 0x484), "Memory");
  98. div_m6= __readMemory32((0x44E00000 + 0x4D8), "Memory");
  99. //put DPLL in bypass mode
  100. clkmode = (clkmode & 0xfffffff8)|0x00000004;
  101. __writeMemory32(clkmode, (0x44E00000 + 0x490), "Memory");
  102. while((__readMemory32((0x44E00000 + 0x45C), "Memory") & 0x00000100 )!=0x00000100); //wait for bypass status
  103. __message "**** Core Bypassed\n";
  104. //set multiply and divide values
  105. clksel = clksel & (~0x7FFFF);
  106. clksel = clksel | ((M <<0x8) | N);
  107. __writeMemory32(clksel, (0x44E00000 + 0x468), "Memory");
  108. div_m4= M4; //200MHz
  109. __writeMemory32(div_m4, (0x44E00000 + 0x480), "Memory");
  110. div_m5= M5; //250MHz
  111. __writeMemory32(div_m5, (0x44E00000 + 0x484), "Memory");
  112. div_m6= M6; //500MHz
  113. __writeMemory32(div_m6, (0x44E00000 + 0x4D8), "Memory");
  114. __message "**** Now locking Core...\n";
  115. //now lock the PLL
  116. clkmode =(clkmode&0xfffffff8)|0x00000007;
  117. __writeMemory32(clkmode, (0x44E00000 + 0x490), "Memory");
  118. while((__readMemory32((0x44E00000 + 0x45C), "Memory") & 0x00000001 )!=0x00000001);
  119. __message "**** Core locked\n";
  120. }
  121. ddr_pll_config( clk_in, N, M, M2)
  122. {
  123. __var ref_clk,clk_out ;
  124. __var clkmode,clksel,div_m2,idlest_dpll;
  125. ref_clk = clk_in/(N+1);
  126. clk_out = (ref_clk*M)/M2;
  127. clkmode=__readMemory32((0x44E00000 + 0x494), "Memory");
  128. clksel= __readMemory32((0x44E00000 + 0x440), "Memory");
  129. div_m2= __readMemory32((0x44E00000 + 0x4A0), "Memory");
  130. clkmode =(clkmode&0xfffffff8)|0x00000004;
  131. __writeMemory32(clkmode, (0x44E00000 + 0x494), "Memory");
  132. while((__readMemory32((0x44E00000 + 0x434), "Memory") & 0x00000100 )!=0x00000100);
  133. __message "**** DDR DPLL Bypassed\n";
  134. clksel = clksel & (~0x7FFFF);
  135. clksel = clksel | ((M <<0x8) | N);
  136. __writeMemory32(clksel, (0x44E00000 + 0x440), "Memory");
  137. div_m2 = __readMemory32((0x44E00000 + 0x4A0), "Memory");
  138. div_m2 = (div_m2&0xFFFFFFE0) | M2;
  139. __writeMemory32(div_m2, (0x44E00000 + 0x4A0), "Memory");
  140. clkmode =(clkmode&0xfffffff8)|0x00000007;
  141. __writeMemory32(clkmode, (0x44E00000 + 0x494), "Memory");
  142. while((__readMemory32((0x44E00000 + 0x434), "Memory") & 0x00000001 )!=0x00000001);
  143. __message "**** DDR DPLL Locked\n";
  144. }
  145. per_pll_config( clk_in, N, M, M2)
  146. {
  147. __var ref_clk,clk_out;
  148. __var clkmode,clksel,div_m2,idlest_dpll;
  149. ref_clk = clk_in/(N+1);
  150. clk_out = (ref_clk*M)/M2;
  151. clkmode=__readMemory32((0x44E00000 + 0x48C), "Memory");
  152. clksel= __readMemory32((0x44E00000 + 0x49C), "Memory");
  153. div_m2= __readMemory32((0x44E00000 + 0x4AC), "Memory");
  154. clkmode =(clkmode&0xfffffff8)|0x00000004;
  155. __writeMemory32(clkmode, (0x44E00000 + 0x48C), "Memory");
  156. while((__readMemory32((0x44E00000 + 0x470), "Memory") & 0x00000100 )!=0x00000100);
  157. __message "**** PER DPLL Bypassed\n";
  158. clksel = clksel & (~0x7FFFF);
  159. clksel = clksel | ((M <<0x8) | N);
  160. __writeMemory32(clksel, (0x44E00000 + 0x49C), "Memory");
  161. div_m2= 0xFFFFFF80 | M2;
  162. __writeMemory32(div_m2, (0x44E00000 + 0x4AC), "Memory");
  163. clkmode =(clkmode&0xfffffff8)|0x00000007;
  164. __writeMemory32(clkmode,(0x44E00000 + 0x48C), "Memory");
  165. while((__readMemory32((0x44E00000 + 0x470), "Memory") & 0x00000001 )!=0x00000001);
  166. __message "**** PER DPLL Locked\n";
  167. }
  168. disp_pll_config( clk_in, N, M, M2)
  169. {
  170. __var ref_clk,clk_out;
  171. __var clkmode,clksel,div_m2,idlest_dpll;
  172. __message "**** DISP PLL Config is in progress .......... \n";
  173. ref_clk = clk_in/(N+1);
  174. clk_out = (ref_clk*M)/M2;
  175. clkmode=__readMemory32((0x44E00000 + 0x498), "Memory");
  176. clksel= __readMemory32((0x44E00000 + 0x454), "Memory");
  177. div_m2= __readMemory32((0x44E00000 + 0x4A4), "Memory");
  178. clkmode =(clkmode&0xfffffff8)|0x00000004;
  179. __writeMemory32(clkmode, (0x44E00000 + 0x498), "Memory");
  180. while((__readMemory32((0x44E00000 + 0x448), "Memory") & 0x00000100 )!=0x00000100);
  181. clksel = clksel & (~0x7FFFF);
  182. clksel = clksel | ((M <<0x8) | N);
  183. __writeMemory32(clksel, (0x44E00000 + 0x454), "Memory");
  184. div_m2= 0xFFFFFFE0 | M2;
  185. __writeMemory32(div_m2, (0x44E00000 + 0x4A4), "Memory");
  186. clkmode =(clkmode&0xfffffff8)|0x00000007;
  187. __writeMemory32(clkmode, (0x44E00000 + 0x498), "Memory");
  188. while((__readMemory32((0x44E00000 + 0x448), "Memory") & 0x00000001 )!=0x00000001);
  189. __message "**** DISP PLL Config is DONE .......... \n";
  190. }
  191. arm_opp120_config()
  192. {
  193. __message "**** Subarctic ALL ADPLL Config for OPP == OPP100 is In Progress ......... \n";
  194. get_input_clock_frequency();
  195. if (clk_in == 24)
  196. {
  197. mpu_pll_config(clk_in, 23, 550, 1);
  198. core_pll_config(clk_in, 23, 1000, 10, 8, 4);
  199. ddr_pll_config(clk_in, 23, 303, 1);
  200. per_pll_config(clk_in, 23, 960, 5);
  201. disp_pll_config(clk_in, 23, 48, 1);
  202. __message "**** Subarctic ALL ADPLL Config for OPP == OPP100 is Done ......... \n";
  203. }
  204. else
  205. {
  206. __message "**** Subarctic PLL Config failed!! Check SYSBOOT[15:14] for proper input freq config \n";
  207. }
  208. }
  209. emif_prcm_clk_enable()
  210. {
  211. __message "EMIF PRCM is in progress ....... \n";
  212. __writeMemory32(0x2, (0x44E00000 + 0x0D0), "Memory");
  213. __writeMemory32(0x2, (0x44E00000 + 0x028), "Memory");
  214. while(__readMemory32((0x44E00000 + 0x028), "Memory")!= 0x02);
  215. __message "EMIF PRCM Done \n";
  216. }
  217. vtp_enable()
  218. {
  219. /* Write 1 to enable VTP */
  220. __writeMemory32((__readMemory32(((0x44E10000) + 0x0E0C), "Memory") | 0x00000040),((0x44E10000) + 0x0E0C) , "Memory");
  221. /* Write 0 to CLRZ bit */
  222. __writeMemory32((__readMemory32(((0x44E10000) + 0x0E0C), "Memory") & 0xFFFFFFFE),((0x44E10000) + 0x0E0C) ,"Memory");
  223. /* Write 1 to CLRZ bit */
  224. __writeMemory32((__readMemory32(((0x44E10000) + 0x0E0C), "Memory") | 0x00000001),((0x44E10000) + 0x0E0C) , "Memory");
  225. __message "Waiting for VTP Ready .......\n";
  226. while((__readMemory32(((0x44E10000) + 0x0E0C), "Memory") & 0x00000020) != 0x00000020);
  227. __message "VTP Enable Done \n";
  228. }
  229. cmd_macro_config( REG_PHY_CTRL_SLAVE_RATIO_value, CMD_REG_PHY_CTRL_SLAVE_FORCE_value, CMD_REG_PHY_CTRL_SLAVE_DELAY_value, PHY_DLL_LOCK_DIFF_value, CMD_PHY_INVERT_CLKOUT_value)
  230. {
  231. __message "\DDR PHY CMD0 Register configuration is in progress ....... \n";
  232. __writeMemory32(REG_PHY_CTRL_SLAVE_RATIO_value, (0x01C + (0x44E12000)), "Memory");
  233. __writeMemory32(CMD_REG_PHY_CTRL_SLAVE_FORCE_value, (0x020 + (0x44E12000)), "Memory");
  234. __writeMemory32(CMD_REG_PHY_CTRL_SLAVE_DELAY_value, (0x024 + (0x44E12000)), "Memory");
  235. __writeMemory32(PHY_DLL_LOCK_DIFF_value, (0x028 + (0x44E12000)), "Memory");
  236. __writeMemory32(CMD_PHY_INVERT_CLKOUT_value, (0x02C + (0x44E12000)), "Memory");
  237. __message "\DDR PHY CMD1 Register configuration is in progress ....... \n";
  238. __writeMemory32(REG_PHY_CTRL_SLAVE_RATIO_value, (0x050 + (0x44E12000)), "Memory");
  239. __writeMemory32(CMD_REG_PHY_CTRL_SLAVE_FORCE_value, (0x054 + (0x44E12000)), "Memory");
  240. __writeMemory32(CMD_REG_PHY_CTRL_SLAVE_DELAY_value, (0x058 + (0x44E12000)), "Memory");
  241. __writeMemory32(PHY_DLL_LOCK_DIFF_value, (0x05C + (0x44E12000)), "Memory");
  242. __writeMemory32(CMD_PHY_INVERT_CLKOUT_value, (0x060 + (0x44E12000)), "Memory");
  243. __message "\DDR PHY CMD2 Register configuration is in progress ....... \n";
  244. __writeMemory32(REG_PHY_CTRL_SLAVE_RATIO_value, (0x084 + (0x44E12000)), "Memory");
  245. __writeMemory32(CMD_REG_PHY_CTRL_SLAVE_FORCE_value, (0x088 + (0x44E12000)), "Memory");
  246. __writeMemory32(CMD_REG_PHY_CTRL_SLAVE_DELAY_value, (0x08C + (0x44E12000)), "Memory");
  247. __writeMemory32(PHY_DLL_LOCK_DIFF_value, (0x090 + (0x44E12000)), "Memory");
  248. __writeMemory32(CMD_PHY_INVERT_CLKOUT_value, (0x094 + (0x44E12000)), "Memory");
  249. }
  250. data_macro_config( dataMacroNum, PHY_RD_DQS_SLAVE_RATIO_value, PHY_WR_DQS_SLAVE_RATIO_value, REG_PHY_WRLVL_INIT_RATIO_value,
  251. REG_PHY_GATELVL_INIT_RATIO_value, REG_PHY_FIFO_WE_SLAVE_RATIO_value, REG_PHY_WR_DATA_SLAVE_RATIO_value)
  252. {
  253. __var offset;
  254. if(dataMacroNum == 0)
  255. {
  256. offset = 0x00;
  257. __message "DDR PHY DATA0 Register configuration is in progress ....... \n";
  258. }
  259. else if(dataMacroNum == 1)
  260. {
  261. offset = 0xA4;
  262. __message "DDR PHY DATA1 Register configuration is in progress ....... \n";
  263. }
  264. __writeMemory32(((PHY_RD_DQS_SLAVE_RATIO_value<<30)|(PHY_RD_DQS_SLAVE_RATIO_value<<20)|(PHY_RD_DQS_SLAVE_RATIO_value<<10)|(PHY_RD_DQS_SLAVE_RATIO_value<<0)), ((0x0C8 + (0x44E12000)) + offset), "Memory");
  265. __writeMemory32(PHY_RD_DQS_SLAVE_RATIO_value>>2, ((0x0CC + (0x44E12000)) + offset), "Memory");
  266. __writeMemory32(((PHY_WR_DQS_SLAVE_RATIO_value<<30)|(PHY_WR_DQS_SLAVE_RATIO_value<<20)|(PHY_WR_DQS_SLAVE_RATIO_value<<10)|(PHY_WR_DQS_SLAVE_RATIO_value<<0)), ((0x0DC + (0x44E12000)) + offset), "Memory");
  267. __writeMemory32(PHY_WR_DQS_SLAVE_RATIO_value>>2, ((0x0E0 + (0x44E12000)) + offset), "Memory");
  268. __writeMemory32(((REG_PHY_WRLVL_INIT_RATIO_value<<30)|(REG_PHY_WRLVL_INIT_RATIO_value<<20)|(REG_PHY_WRLVL_INIT_RATIO_value<<10)|(REG_PHY_WRLVL_INIT_RATIO_value<<0)), ((0x0F0 + (0x44E12000)) + offset), "Memory");
  269. __writeMemory32(REG_PHY_WRLVL_INIT_RATIO_value>>2, ((0x0F4 + (0x44E12000)) + offset), "Memory");
  270. __writeMemory32(((REG_PHY_GATELVL_INIT_RATIO_value<<30)|(REG_PHY_GATELVL_INIT_RATIO_value<<20)|(REG_PHY_GATELVL_INIT_RATIO_value<<10)|(REG_PHY_GATELVL_INIT_RATIO_value<<0)), ((0x0FC + (0x44E12000)) + offset), "Memory");
  271. __writeMemory32(REG_PHY_GATELVL_INIT_RATIO_value>>2, ((0x100 + (0x44E12000)) + offset), "Memory");
  272. __writeMemory32(((REG_PHY_FIFO_WE_SLAVE_RATIO_value<<30)|(REG_PHY_FIFO_WE_SLAVE_RATIO_value<<20)|(REG_PHY_FIFO_WE_SLAVE_RATIO_value<<10)|(REG_PHY_FIFO_WE_SLAVE_RATIO_value<<0)), ((0x108 + (0x44E12000)) + offset), "Memory");
  273. __writeMemory32(REG_PHY_FIFO_WE_SLAVE_RATIO_value>>2,((0x10C + (0x44E12000)) + offset), "Memory");
  274. __writeMemory32(((REG_PHY_WR_DATA_SLAVE_RATIO_value<<30)|(REG_PHY_WR_DATA_SLAVE_RATIO_value<<20)|(REG_PHY_WR_DATA_SLAVE_RATIO_value<<10)|(REG_PHY_WR_DATA_SLAVE_RATIO_value<<0)),((0x120 + (0x44E12000)) + offset), "Memory");
  275. __writeMemory32(REG_PHY_WR_DATA_SLAVE_RATIO_value>>2, ((0x124 + (0x44E12000)) + offset), "Memory");
  276. __writeMemory32(0x0,((0x138 + (0x44E12000)) + offset), "Memory");
  277. }
  278. emif_mmr_config( Read_Latency, Timing1, Timing2, Timing3, Sdram_Config, Ref_Ctrl)
  279. {
  280. __var i;
  281. __message "emif Timing register configuration is in progress ....... \n";
  282. __writeMemory32(Read_Latency, (0x4C000000 + 0x0E4), "Memory");
  283. __writeMemory32(Read_Latency, (0x4C000000 + 0x0E8), "Memory");
  284. __writeMemory32(Read_Latency, (0x4C000000 + 0x0EC), "Memory");
  285. __writeMemory32(Timing1, (0x4C000000 + 0x018), "Memory");
  286. __writeMemory32(Timing1, (0x4C000000 + 0x01C), "Memory");
  287. __writeMemory32(Timing2, (0x4C000000 + 0x020), "Memory");
  288. __writeMemory32(Timing2, (0x4C000000 + 0x024), "Memory");
  289. __writeMemory32(Timing3, (0x4C000000 + 0x028), "Memory");
  290. __writeMemory32(Timing3, (0x4C000000 + 0x02C), "Memory");
  291. __writeMemory32(Sdram_Config, (0x4C000000 + 0x008), "Memory");
  292. __writeMemory32(Sdram_Config, (0x4C000000 + 0x00C), "Memory");
  293. __writeMemory32(0x00004650, (0x4C000000 + 0x010), "Memory");
  294. __writeMemory32(0x00004650, (0x4C000000 + 0x014), "Memory");
  295. for(i=0;i<5000;i++)
  296. {
  297. }
  298. __writeMemory32(Ref_Ctrl, (0x4C000000 + 0x010), "Memory");
  299. __writeMemory32(Ref_Ctrl, (0x4C000000 + 0x014), "Memory");
  300. __writeMemory32(Sdram_Config, (0x4C000000 + 0x008), "Memory");
  301. __writeMemory32(Sdram_Config, (0x4C000000 + 0x00C), "Memory");
  302. __message "emif Timing register configuration is done ....... \n";
  303. }
  304. gpio_module_clk_config()
  305. {
  306. __var buff;
  307. buff = __readMemory32((0x400 + 0x44E00000 + 0x8), "Memory");
  308. buff |= 0x2;
  309. __writeMemory32(buff, (0x400 + 0x44E00000 + 0x8), "Memory");
  310. while((__readMemory32((0x400 + 0x44E00000 + 0x8), "Memory") & 0x3) != 0x2);
  311. buff = __readMemory32((0x400 + 0x44E00000 + 0x8), "Memory");
  312. buff |= 0x00040000;
  313. __writeMemory32(buff, (0x400 + 0x44E00000 + 0x8), "Memory");
  314. while((__readMemory32((0x400 + 0x44E00000 + 0x8), "Memory") & 0x00040000) != 0x00040000);
  315. while((__readMemory32((0x400 + 0x44E00000 + 0x8), "Memory") & 0x00030000) != 0x0);
  316. while((__readMemory32((0x400 + 0x44E00000), "Memory") & 0x00000100) != 0x00000100);
  317. __message "GPIO module clock configuration is done ....... \n";
  318. }
  319. phy_config_cmd()
  320. {
  321. __var i;
  322. for(i = 0; i < 3; i++)
  323. {
  324. __message "DDR PHY CMD Register configuration is in progress ....... \n";
  325. __writeMemory32(0x40, ((0x44E12000 + 0x01c) + (i * 0x34)), "Memory");
  326. __writeMemory32(0x1, ((0x44E12000 + 0x02c) + (i * 0x34)), "Memory");
  327. }
  328. }
  329. phy_config_data()
  330. {
  331. __var i;
  332. for(i = 0; i < 2; i++)
  333. {
  334. __message "DDR PHY Data Register configuration is in progress ....... \n";
  335. __writeMemory32(0x3B, ((0x44E12000 + 0x0c8) + (i * 0xA4)), "Memory");
  336. __writeMemory32(0x85, ((0x44E12000 + 0x0DC) + (i * 0xA4)), "Memory");
  337. __writeMemory32(0x100, ((0x44E12000 + 0x108) + (i * 0xA4)), "Memory");
  338. __writeMemory32(0xC1, ((0x44E12000 + 0x120) + (i * 0xA4)), "Memory");
  339. }
  340. }
  341. ddr3_emif_config()
  342. {
  343. __message "**** AM335x OPP120 DDR3 EMIF and PHY configuration is in progress......... \n";
  344. emif_prcm_clk_enable();
  345. __message "DDR PHY Configuration In progress \n";
  346. /* Perform GPIO module clock configuration. */
  347. gpio_module_clk_config();
  348. __writeMemory32(0x00000067, (0x44E10000 + 0x964), "Memory");
  349. __writeMemory32((__readMemory32((0x44E07000 + 0x130), "Memory") & 0xFFFFFFFE), (0x44E07000 + 0x130), "Memory");
  350. __writeMemory32((__readMemory32((0x44E07000 + 0x10), "Memory") | 0x02), (0x44E07000 + 0x10), "Memory");
  351. /* Wait until GPIO module is reset. */
  352. while(!(__readMemory32((0x44E07000 + 0x114), "Memory") & 0x01));
  353. __writeMemory32((__readMemory32((0x44E07000 + 0x134), "Memory") & ~(1 << 7)), (0x44E07000 + 0x134), "Memory");
  354. __writeMemory32((1 << 7), (0x44E07000 + 0x194), "Memory");
  355. __writeMemory32((__readMemory32((0x44E10000 + 0x0E0C), "Memory") & 0xFFFFFFFE), (0x44E10000 + 0x0E0C), "Memory");
  356. __writeMemory32((__readMemory32((0x44E10000 + 0x0E0C), "Memory") | 0x00000001), (0x44E10000 + 0x0E0C), "Memory");
  357. vtp_enable();
  358. phy_config_cmd();
  359. phy_config_data();
  360. __writeMemory32(0x18B, (0x1404 + 0x44E10000), "Memory");
  361. __writeMemory32(0x18B, (0x1408 + 0x44E10000), "Memory");
  362. __writeMemory32(0x18B, (0x140C + 0x44E10000), "Memory");
  363. __writeMemory32(0x18B, (0x1440 + 0x44E10000), "Memory");
  364. __writeMemory32(0x18B, (0x1444 + 0x44E10000), "Memory");
  365. __writeMemory32((__readMemory32((0x0E04 + 0x44E10000), "Memory") & ~0x10000000), (0x0E04 + 0x44E10000), "Memory");
  366. __writeMemory32((__readMemory32((0x131C + 0x44E10000), "Memory") | 0x00000001), (0x131C + 0x44E10000), "Memory");
  367. __message "EMIF Timing register configuration is in progress ....... \n";
  368. __writeMemory32(0x06, (0x0E4 + 0x4C000000), "Memory");
  369. __writeMemory32(0x06, (0x0E8 + 0x4C000000), "Memory");
  370. __writeMemory32(0x06, (0x0EC + 0x4C000000), "Memory");
  371. __writeMemory32(0x0888A39B, (0x018 + 0x4C000000), "Memory");
  372. __writeMemory32(0x0888A39B, (0x01C + 0x4C000000), "Memory");
  373. __writeMemory32(0x26337FDA, (0x020 + 0x4C000000), "Memory");
  374. __writeMemory32(0x26337FDA, (0x024 + 0x4C000000), "Memory");
  375. __writeMemory32(0x501F830F, (0x028 + 0x4C000000), "Memory");
  376. __writeMemory32(0x501F830F, (0x02C + 0x4C000000), "Memory");
  377. __writeMemory32(0x0000093B, (0x010 + 0x4C000000), "Memory");
  378. __writeMemory32(0x0000093B, (0x014 + 0x4C000000), "Memory");
  379. __writeMemory32(0x50074BE4, (0x0C8 + 0x4C000000), "Memory");
  380. __writeMemory32(0x61C04AB2, (0x008 + 0x4C000000), "Memory");
  381. __message "EMIF Timing register configuration is done ....... \n";
  382. if((__readMemory32((0x4C000000 + 0x004), "Memory") & 0x4) == 0x4)
  383. {
  384. __message "PHY is READY!!\n";
  385. }
  386. __message "DDR PHY Configuration done \n";
  387. __message "**** AM335x OPP120 DDR3 EMIF and PHY configuration is done......... \n";
  388. }
  389. am335x_evm_initialization()
  390. {
  391. __var psc_base;
  392. __var reg;
  393. __var module_offest;
  394. __message " AM335x EVM-SK Initialization is in progress .......... \n";
  395. arm_opp120_config();
  396. ddr3_emif_config();
  397. __message " AM335x EVM-SK Initialization is done .......... \n";
  398. }
  399. execUserPreload()
  400. {
  401. am335x_evm_initialization();
  402. }