hal_psram_fpga_cfg.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #define __APS_64__
  13. //#define CONFIG_USE_PSRAM
  14. //#define CONFIG_PSRAM_LP_HALF_SLEEP
  15. static void prvDelayUS(uint32_t us);
  16. static inline void prvRamPhyPadCfg(void)
  17. {
  18. // PSRAM PHY
  19. hwp_psramPhy->psram_rf_cfg_psram_type = 0x00000040;
  20. hwp_psramPhy->psram_rf_cfg_phy = 0x00000001;
  21. hwp_psramPhy->psram_drf_cfg = 0x00000001;
  22. hwp_psramPhy->psram_rf_cfg_dll_dl_0_wr_ads0 = 0x00000002;
  23. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads0 = 0x00000002;
  24. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads0 = 0x00000002;
  25. hwp_psramPhy->psram_rf_cfg_dll_dl_3_wr_ads0 = 0x00000002;
  26. hwp_psramPhy->psram_rf_cfg_dll_dl_4_wr_ads0 = 0x00001D0B;
  27. hwp_psramPhy->psram_rf_cfg_dll_dl_5_wr_ads0 = 0x06180B0D;
  28. hwp_psramPhy->psram_rf_cfg_dll_dl_6_wr_ads0 = 0x1D011F0A;
  29. hwp_psramPhy->psram_rf_cfg_dll_dl_7_wr_ads0 = 0x0C1C1708;
  30. hwp_psramPhy->psram_rf_cfg_dll_dl_8_wr_ads0 = 0x0A001B0E;
  31. hwp_psramPhy->psram_rf_cfg_dll_dl_9_wr_ads0 = 0x0018041C;
  32. hwp_psramPhy->psram_rf_cfg_dll_dl_0_wr_ads1 = 0x00000002;
  33. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads1 = 0x00000002;
  34. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads1 = 0x00000002;
  35. hwp_psramPhy->psram_rf_cfg_dll_dl_3_wr_ads1 = 0x00000002;
  36. hwp_psramPhy->psram_rf_cfg_dll_dl_4_wr_ads1 = 0x0000150F;
  37. hwp_psramPhy->psram_rf_cfg_dll_dl_5_wr_ads1 = 0x0B0D0008;
  38. hwp_psramPhy->psram_rf_cfg_dll_dl_6_wr_ads1 = 0x03060A12;
  39. hwp_psramPhy->psram_rf_cfg_dll_dl_7_wr_ads1 = 0x13161514;
  40. hwp_psramPhy->psram_rf_cfg_dll_dl_8_wr_ads1 = 0x08171C13;
  41. hwp_psramPhy->psram_rf_cfg_dll_dl_9_wr_ads1 = 0x00100D0A;
  42. hwp_psramPhy->psram_drf_cfg_reg_sel = 0x00000000;
  43. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f0 = 0x00000008;
  44. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f1 = 0x00000008;
  45. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f2 = 0x00000008;
  46. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f3 = 0x00000008;
  47. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f0 = 0x00000008;
  48. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f1 = 0x00000008;
  49. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f2 = 0x00000008;
  50. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f3 = 0x00000008;
  51. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f0 = 0x00000010;
  52. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f1 = 0x00000010;
  53. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f2 = 0x00000010;
  54. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f3 = 0x00000010;
  55. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f0 = 0x00000010;
  56. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f1 = 0x00000010;
  57. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f2 = 0x00000010;
  58. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f3 = 0x00000010;
  59. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f0 = 0x00000002;
  60. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f1 = 0x00000002;
  61. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f2 = 0x00000002;
  62. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f3 = 0x00000002;
  63. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f0 = 0x00000001;
  64. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f1 = 0x00000001;
  65. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f2 = 0x00000001;
  66. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f3 = 0x00000001;
  67. hwp_psramPhy->psram_drf_format_control = 0x00000001;
  68. hwp_psramPhy->psram_drf_t_rcd = 0x00000006;
  69. hwp_psramPhy->psram_drf_t_rddata_en = 0x00000006;
  70. hwp_psramPhy->psram_drf_t_cph_rd = 0x00000002;
  71. hwp_psramPhy->psram_drf_t_rddata_late = 0x00000002;
  72. hwp_psramPhy->psram_drf_t_rddata_valid_early = 0x00000003;
  73. hwp_psramPhy->psram_drf_t_cph_wr = 0x00000006;
  74. hwp_psramPhy->psram_drf_t_data_oe_ext = 0x00000011;
  75. hwp_psramPhy->psram_drf_t_dqs_oe_ext = 0x00000001;
  76. hwp_psramPhy->psram_drf_t_xphs = 0x0000000C;
  77. hwp_psramPhy->psram_rf_cfg_clock_gate = 0x0000001F;
  78. hwp_psramPhy->psram_rf_cfg_phy = 0x00000003;
  79. }
  80. static inline void prvRamPor(void)
  81. {
  82. hwp_pwrctrl->psram_hold_ctrl = 0;
  83. prvDelayUS(100000); // 100ms
  84. hwp_dmcCtrl->direct_cmd = 0x00000000;
  85. prvDelayUS(10000);
  86. hwp_dmcCtrl->direct_cmd = 0x1000003F;
  87. prvDelayUS(100000); // 100ms
  88. hwp_dmcCtrl->direct_cmd = 0x10001800;
  89. prvDelayUS(100000); // 100ms
  90. hwp_dmcCtrl->direct_cmd = 0x10008004;
  91. prvDelayUS(10000);
  92. // hwp_pwrctrl->psram_hold_ctrl = 1;
  93. }
  94. static inline void prvRamDmcCfg(void)
  95. {
  96. hwp_dmcCtrl->format_control = 0x11000101; // 32x16, BURST_2_DDR_BL4, ACC_GRANU_2_DDR_4N, ALIGN_BOUNDARY_2_COL_2BIT
  97. hwp_dmcCtrl->address_control = 0x20201; // 9_COL_BITS, 13_ROW_BITS, 2_BANK_BITS_4BK, 0_CHIP_BITS_1CS, 0_CHANNEL_BITS_1MEMIF
  98. hwp_dmcCtrl->decode_control = 0x20; // CHANNEL_CHIP_ROW_BANK_COL, PAGE_ADDR_11_10
  99. hwp_dmcCtrl->t_refi = 0x00000208;
  100. hwp_dmcCtrl->t_rfc = 0x00040004;
  101. hwp_dmcCtrl->t_mrr = 0x00000002;
  102. hwp_dmcCtrl->t_mrw = 0x00000005;
  103. hwp_dmcCtrl->t_rcd = 0x00000006;
  104. hwp_dmcCtrl->t_ras = 0x00000011;
  105. hwp_dmcCtrl->t_rp = 0x00000004;
  106. hwp_dmcCtrl->t_rpall = 0x00000004;
  107. hwp_dmcCtrl->t_rrd = 0x00000004;
  108. hwp_dmcCtrl->t_faw = 0x00000014;
  109. hwp_dmcCtrl->read_latency = 0x0000000e;
  110. hwp_dmcCtrl->t_rtr = 0x00000006;
  111. hwp_dmcCtrl->t_rtw = 0x0000000c;
  112. hwp_dmcCtrl->t_rtp = 0x00000008;
  113. hwp_dmcCtrl->write_latency = 0x0000000a;
  114. hwp_dmcCtrl->t_wr = 0x0000000c;
  115. hwp_dmcCtrl->t_wtr = 0x00090009;
  116. hwp_dmcCtrl->t_wtw = 0x000c000c;
  117. hwp_dmcCtrl->t_eckd = 0x0000000b;
  118. hwp_dmcCtrl->t_xckd = 0x0000000b;
  119. hwp_dmcCtrl->t_ep = 0x00000002;
  120. hwp_dmcCtrl->t_xp = 0x00030003;
  121. hwp_dmcCtrl->t_esr = 0x00000002;
  122. hwp_dmcCtrl->t_xsr = 0x00040004;
  123. hwp_dmcCtrl->t_srckd = 0x0000000b;
  124. hwp_dmcCtrl->t_cksrd = 0x0000000b;
  125. hwp_dmcCtrl->t_rddata_en = 0x00000006; // RL=6
  126. hwp_dmcCtrl->turnaround_priority = 0x00000022;
  127. hwp_dmcCtrl->hit_priority = 0x00000022;
  128. hwp_dmcCtrl->qos0_control = 0x00000f05;
  129. hwp_dmcCtrl->t_phywrlat = 0x00000103;
  130. }
  131. static inline void prvRamBootCfg(void)
  132. {
  133. hwp_dmcCtrl->memc_cmd = 0x00000003;
  134. prvDelayUS(100000); // 100ms
  135. // hwp_pwrctrl->psram_hold_ctrl = 0;
  136. }
  137. static inline void prvRamWakeCfg(void)
  138. {
  139. hwp_pwrctrl->psram_hold_ctrl = 0;
  140. hwp_dmcCtrl->memc_cmd = 0x00000003;
  141. prvDelayUS(10); // 10us
  142. }
  143. /////aps 64m/32m////////////////////
  144. static inline void prvPsramPhyConfig(void)
  145. {
  146. //rprintf("START APS32 PHY INIT" );
  147. hwp_psramPhy->psram_rf_cfg_phy = 0x1; //rf_phy_en=1,rf_phy_init_complete.
  148. hwp_psramPhy->psram_drf_cfg = 0x1; //select clk phase
  149. //ads0
  150. //#if definedCONFIG_POST_SIM
  151. //hwp_psramPhy->psram_rf_cfg_dll_dl_0_wr_ads0=0x80000008;
  152. //#else
  153. #if defined(__APS_128__) || defined(__APS_256__)
  154. hwp_psramPhy->psram_rf_cfg_psram_type = 0x42;
  155. #endif
  156. hwp_psramPhy->psram_rf_cfg_dll_dl_0_wr_ads0 = 0x80000008;
  157. //#endif
  158. #if defined(__APS_128__) || defined(__APS_256__)
  159. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads0 = 0x80080008;
  160. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads0 = 0x83190008;
  161. hwp_psramPhy->psram_rf_cfg_dll_dl_3_wr_ads0 = 0x00000002;
  162. #endif
  163. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  164. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads0 = 0x80050008;
  165. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads0 = 0x831f0008;
  166. //#endif
  167. hwp_psramPhy->psram_rf_cfg_dll_dl_3_wr_ads0 = 0x00000000;
  168. #endif
  169. #if defined(__APS_64__)
  170. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads0 = 0x80000008;
  171. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads0 = 0x80000008;
  172. hwp_psramPhy->psram_rf_cfg_dll_dl_3_wr_ads0 = 0x00000000; //0527
  173. #endif
  174. //#if definedCONFIG_POST_SIM
  175. //hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads0=0x83060008;
  176. //#else
  177. hwp_psramPhy->psram_rf_cfg_dll_dl_4_wr_ads0 = 0x1c08;
  178. hwp_psramPhy->psram_rf_cfg_dll_dl_5_wr_ads0 = 0x1409180a;
  179. hwp_psramPhy->psram_rf_cfg_dll_dl_6_wr_ads0 = 0x9001a;
  180. hwp_psramPhy->psram_rf_cfg_dll_dl_7_wr_ads0 = 0xa090a13;
  181. hwp_psramPhy->psram_rf_cfg_dll_dl_8_wr_ads0 = 0x61e1e11;
  182. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  183. hwp_psramPhy->psram_rf_cfg_dll_dl_9_wr_ads0 = 0x1f0d0a;
  184. #endif
  185. #if defined(__APS_64__) || defined(__APS_128__) || defined(__APS_256__)
  186. hwp_psramPhy->psram_rf_cfg_dll_dl_9_wr_ads0 = 0xb0c0a;
  187. #endif
  188. //ads1
  189. //#if definedCONFIG_POST_SIM
  190. //hwp_psramPhy->psram_rf_cfg_dll_dl_0_wr_ads1=0x80000008;
  191. //#else
  192. hwp_psramPhy->psram_rf_cfg_dll_dl_0_wr_ads1 = 0x80000008;
  193. //#endif
  194. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  195. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads1 = 0x80080008;
  196. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads1 = 0x801b0008;
  197. #endif
  198. #if defined(__APS_64__)
  199. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads1 = 0x80000008;
  200. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads1 = 0x80000008;
  201. #endif
  202. #if defined(__APS_128__) || defined(__APS_256__)
  203. hwp_psramPhy->psram_rf_cfg_dll_dl_1_wr_ads1 = 0x80170008;
  204. hwp_psramPhy->psram_rf_cfg_dll_dl_2_wr_ads1 = 0x831f0008;
  205. #endif
  206. hwp_psramPhy->psram_rf_cfg_dll_dl_3_wr_ads1 = 0x00000000;
  207. hwp_psramPhy->psram_rf_cfg_dll_dl_4_wr_ads1 = 0x1;
  208. hwp_psramPhy->psram_rf_cfg_dll_dl_5_wr_ads1 = 0x140b0e02;
  209. hwp_psramPhy->psram_rf_cfg_dll_dl_6_wr_ads1 = 0xd0c0901;
  210. #if defined(__APS_32__) || defined(__aps__64__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  211. hwp_psramPhy->psram_rf_cfg_dll_dl_7_wr_ads1 = 0x13161514;
  212. #endif
  213. #if defined(__APS_128__) || defined(__APS_256__)
  214. hwp_psramPhy->psram_rf_cfg_dll_dl_7_wr_ads1 = 0xa090a13;
  215. #endif
  216. hwp_psramPhy->psram_rf_cfg_dll_dl_8_wr_ads1 = 0x8171c13;
  217. hwp_psramPhy->psram_rf_cfg_dll_dl_9_wr_ads1 = 0x1f0d0a;
  218. //shift_sel16
  219. hwp_psramPhy->psram_drf_cfg_reg_sel = 0x0;
  220. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f0 = 0x8;
  221. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f1 = 0x8;
  222. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f2 = 0x8;
  223. hwp_psramPhy->psram_drf_cfg_dqs_ie_sel_f3 = 0x8;
  224. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f0 = 0x8;
  225. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f1 = 0x8;
  226. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f2 = 0x8;
  227. hwp_psramPhy->psram_drf_cfg_dqs_oe_sel_f3 = 0x8;
  228. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f0 = 0x10;
  229. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f1 = 0x10;
  230. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f2 = 0x10;
  231. hwp_psramPhy->psram_drf_cfg_dqs_out_sel_f3 = 0x10;
  232. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f0 = 0x10;
  233. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f1 = 0x10;
  234. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f2 = 0x10;
  235. hwp_psramPhy->psram_drf_cfg_dqs_gate_sel_f3 = 0x10;
  236. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f0 = 0x2;
  237. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f1 = 0x2;
  238. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f2 = 0x2;
  239. hwp_psramPhy->psram_drf_cfg_data_ie_sel_f3 = 0x2;
  240. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f0 = 0x1;
  241. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f1 = 0x1;
  242. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f2 = 0x1;
  243. hwp_psramPhy->psram_drf_cfg_data_oe_sel_f3 = 0x1;
  244. hwp_psramPhy->psram_drf_format_control = 0x1;
  245. hwp_psramPhy->psram_drf_t_rcd = 0x6;
  246. #if defined(__APS_128__) || defined(__APS_256__) || defined(__WB956__) || defined(__WB958__)
  247. hwp_psramPhy->psram_drf_t_phywrlat = 0x0;
  248. #endif
  249. hwp_psramPhy->psram_drf_t_rddata_en = 0x6;
  250. #if defined(__APS_32__) || defined(__APS_64__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  251. hwp_psramPhy->psram_drf_t_cph_rd = 0x2;
  252. #endif
  253. hwp_psramPhy->psram_drf_t_rddata_late = 0x2;
  254. hwp_psramPhy->psram_drf_t_rddata_valid_early = 0x3;
  255. #if defined(__APS_32__) || defined(__APS_64__) || defined(__WB955__)
  256. hwp_psramPhy->psram_drf_t_cph_wr = 0x61e6;
  257. #endif
  258. #if defined(__APS_128__) || defined(__APS_256__)
  259. hwp_psramPhy->psram_drf_t_cph_wr = 0x6;
  260. hwp_psramPhy->psram_drf_t_cph_rd = 0x5;
  261. #endif
  262. hwp_psramPhy->psram_drf_t_data_oe_ext = 0x11;
  263. hwp_psramPhy->psram_drf_t_dqs_oe_ext = 0x1;
  264. hwp_psramPhy->psram_drf_t_xphs = 0xc;
  265. hwp_psramPhy->psram_rf_cfg_clock_gate = 0x1f;
  266. #if definedCONFIG_POST_SIM
  267. hwp_psramPhy->io_rf_psram_drv_cfg = 0xa0;
  268. #endif
  269. hwp_psramPhy->io_rf_psram_drv_cfg = 0x1009;
  270. hwp_psramPhy->psram_rf_cfg_phy = 0x3; //rf_phy_en=1,rf_phy_init_complete.
  271. }
  272. static inline void prvPsramDmc400Config(void)
  273. {
  274. //rprintf("START APS32 DMC INIT" );
  275. hwp_dmcCtrl->format_control = 0x11000101;
  276. hwp_dmcCtrl->address_control = 0x20201;
  277. hwp_dmcCtrl->decode_control = 0x20;
  278. hwp_dmcCtrl->t_refi = 0x00000208;
  279. hwp_dmcCtrl->t_rfc = 0x00040004; // TODO
  280. hwp_dmcCtrl->t_mrr = 0x00000002;
  281. hwp_dmcCtrl->t_mrw = 0x00000005;
  282. hwp_dmcCtrl->t_rcd = 0x00000006;
  283. hwp_dmcCtrl->t_ras = 0x00000011;
  284. hwp_dmcCtrl->t_rp = 0x00000004;
  285. hwp_dmcCtrl->t_rpall = 0x00000004;
  286. hwp_dmcCtrl->t_rrd = 0x00000004;
  287. hwp_dmcCtrl->t_faw = 0x00000014;
  288. hwp_dmcCtrl->read_latency = 0x0000000e; // TODO
  289. hwp_dmcCtrl->t_rtr = 0x00000006; // TODO
  290. hwp_dmcCtrl->t_rtw = 0x0000000c; // TODO
  291. hwp_dmcCtrl->t_rtp = 0x00000008; // TODO
  292. hwp_dmcCtrl->write_latency = 0x0000000a; // TODO
  293. hwp_dmcCtrl->t_wr = 0x0000000c;
  294. hwp_dmcCtrl->t_wtr = 0x00090009; //initial version
  295. //hwp_dmcCtrl->t_wtr =0x00090012;
  296. hwp_dmcCtrl->t_wtw = 0x000c000c;
  297. hwp_dmcCtrl->t_eckd = 0x0000000b; // TODO
  298. hwp_dmcCtrl->t_xckd = 0x0000000b; // TODO
  299. hwp_dmcCtrl->t_ep = 0x00000002; // TODO
  300. hwp_dmcCtrl->t_xp = 0x00030003;
  301. hwp_dmcCtrl->t_esr = 0x00000002; // TODO
  302. hwp_dmcCtrl->t_xsr = 0x00040004;
  303. hwp_dmcCtrl->t_srckd = 0x0000000b; // TODO
  304. hwp_dmcCtrl->t_cksrd = 0x0000000b; // TODO
  305. hwp_dmcCtrl->t_rddata_en = 0x00000006; // RL=6
  306. //hwp_dmcCtrl->t_rddata_en =0x00000007; // RL=6
  307. #if defined(__APS_32__) || defined(__APS_64__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  308. hwp_dmcCtrl->t_phywrlat = 0x00000103; // tDQSS=1(0.75-1.25) + WL=3
  309. #endif
  310. #if defined(__APS_128__) || defined(__APS_256__)
  311. hwp_dmcCtrl->t_phywrlat = 0x00000108; // tDQSS=1(0.75-1.25) + WL=3
  312. #endif
  313. // DMC400 : 0x8 - memc_cmd
  314. // 2:0 - memc_cmd.
  315. // 0b000 : CONFIGURE
  316. // 0b001 : SLEEP
  317. // 0b010 : PAUSE
  318. // 0b011 : GO
  319. // 0b100 : INVALIDATE
  320. // hwp_dmcCtrl->memc_cmd = 0x3; // GO
  321. prvDelayUS(5);
  322. }
  323. static inline void prvPsramPor(void)
  324. {
  325. //rprintf("START APS32 POR INIT" );
  326. //*(volatile unsigned int*) REG_PWRCTRL_PSRAM_HOLD_CTRL = 0;
  327. hwp_pwrctrl->psram_hold_ctrl = 0;
  328. //TODO:t_PU>=150us
  329. //prvDelayUS(15000);//according to tb define the delay function
  330. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  331. hwp_psramPhy->psram_drf_t_cph_rd = 0x6;
  332. #endif
  333. prvDelayUS(5); //according to tb define the delay function
  334. hwp_dmcCtrl->direct_cmd = 0x0; //NOP
  335. //CONFIG psram MR63 for reset
  336. hwp_dmcCtrl->direct_cmd = 0x1000003f; //no
  337. //TODO t_RST>2us
  338. prvDelayUS(5);
  339. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  340. prvDelayUS(5); //according to tb define the delay function
  341. hwp_dmcCtrl->direct_cmd = 0x0; //NOP
  342. //CONFIG psram MR63 for reset
  343. hwp_dmcCtrl->direct_cmd = 0x1000003f;
  344. //TODO t_RST>2us
  345. prvDelayUS(5);
  346. hwp_psramPhy->psram_drf_t_cph_rd = 0x2;
  347. prvDelayUS(5);
  348. #endif
  349. #if defined(__APS_128__) || defined(__APS_256__)
  350. hwp_dmcCtrl->direct_cmd = 0x10001000;
  351. prvDelayUS(5);
  352. #endif
  353. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  354. hwp_dmcCtrl->direct_cmd = 0x10001900;
  355. #endif
  356. #if defined(__APS_64__)
  357. hwp_dmcCtrl->direct_cmd = 0x10001a00;
  358. #endif
  359. #if defined(__APS_32__) || defined(__APS_64__)
  360. prvDelayUS(5);
  361. hwp_dmcCtrl->direct_cmd = 0x10008004;
  362. #endif
  363. #if defined(__APS_128__) || defined(__APS_256__)
  364. hwp_dmcCtrl->direct_cmd = 0x10002004;
  365. prvDelayUS(10);
  366. hwp_dmcCtrl->direct_cmd = 0x10004708;
  367. #endif
  368. prvDelayUS(5);
  369. //*(volatile unsigned int*) REG_PWRCTRL_PSRAM_HOLD_CTRL = 1;
  370. hwp_pwrctrl->psram_hold_ctrl = 1; //no
  371. }
  372. static inline void prvPsramWarmPor(void)
  373. {
  374. //rprintf("START APS32 POR INIT" );
  375. //*(volatile unsigned int*) REG_PWRCTRL_PSRAM_HOLD_CTRL = 0;
  376. hwp_pwrctrl->psram_hold_ctrl = 0;
  377. //TODO:t_PU>=150us
  378. //prvDelayUS(15000);//according to tb define the delay function
  379. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  380. hwp_psramPhy->psram_drf_t_cph_rd = 0x6;
  381. #endif
  382. prvDelayUS(5); //according to tb define the delay function
  383. hwp_dmcCtrl->direct_cmd = 0x0; //NOP
  384. //CONFIG psram MR63 for reset
  385. //hwp_dmcCtrl->direct_cmd = 0x60000000;
  386. //hwp_dmcCtrl->direct_cmd = 0x1000003f;//no
  387. //TODO t_RST>2us
  388. prvDelayUS(5);
  389. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  390. prvDelayUS(5); //according to tb define the delay function
  391. hwp_dmcCtrl->direct_cmd = 0x0; //NOP
  392. //CONFIG psram MR63 for reset
  393. hwp_dmcCtrl->direct_cmd = 0x1000003f;
  394. //TODO t_RST>2us
  395. prvDelayUS(5);
  396. hwp_psramPhy->psram_drf_t_cph_rd = 0x2;
  397. prvDelayUS(5);
  398. #endif
  399. #if defined(__APS_128__) || defined(__APS_256__)
  400. hwp_dmcCtrl->direct_cmd = 0x10001000;
  401. prvDelayUS(5);
  402. #endif
  403. #if defined(__APS_32__) || defined(__WB955__) || defined(__WB956__) || defined(__WB958__)
  404. hwp_dmcCtrl->direct_cmd = 0x10001900;
  405. #endif
  406. #if defined(__APS_32__) || defined(__APS_64__)
  407. prvDelayUS(5);
  408. hwp_dmcCtrl->direct_cmd = 0x10008004;
  409. #endif
  410. #if defined(__APS_128__) || defined(__APS_256__)
  411. hwp_dmcCtrl->direct_cmd = 0x10002004;
  412. prvDelayUS(10);
  413. hwp_dmcCtrl->direct_cmd = 0x10004708;
  414. #endif
  415. prvDelayUS(5);
  416. //*(volatile unsigned int*) REG_PWRCTRL_PSRAM_HOLD_CTRL = 1;
  417. hwp_pwrctrl->psram_hold_ctrl = 1; //no
  418. }