sequencer.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*
  2. * Copyright Altera Corporation (C) 2012-2015
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef _SEQUENCER_H_
  7. #define _SEQUENCER_H_
  8. #define RW_MGR_NUM_DM_PER_WRITE_GROUP (RW_MGR_MEM_DATA_MASK_WIDTH \
  9. / RW_MGR_MEM_IF_WRITE_DQS_WIDTH)
  10. #define RW_MGR_NUM_TRUE_DM_PER_WRITE_GROUP (RW_MGR_TRUE_MEM_DATA_MASK_WIDTH \
  11. / RW_MGR_MEM_IF_WRITE_DQS_WIDTH)
  12. #define RW_MGR_NUM_DQS_PER_WRITE_GROUP (RW_MGR_MEM_IF_READ_DQS_WIDTH \
  13. / RW_MGR_MEM_IF_WRITE_DQS_WIDTH)
  14. #define NUM_RANKS_PER_SHADOW_REG (RW_MGR_MEM_NUMBER_OF_RANKS / NUM_SHADOW_REGS)
  15. #define RW_MGR_RUN_SINGLE_GROUP (BASE_RW_MGR)
  16. #define RW_MGR_RUN_ALL_GROUPS (BASE_RW_MGR + 0x0400)
  17. #define RW_MGR_DI_BASE (BASE_RW_MGR + 0x0020)
  18. #define RW_MGR_MEM_NUMBER_OF_RANKS 1
  19. #define NUM_SHADOW_REGS 1
  20. #define RW_MGR_RESET_READ_DATAPATH (BASE_RW_MGR + 0x1000)
  21. #define RW_MGR_SET_CS_AND_ODT_MASK (BASE_RW_MGR + 0x1400)
  22. #define RW_MGR_RANK_NONE 0xFF
  23. #define RW_MGR_RANK_ALL 0x00
  24. #define RW_MGR_ODT_MODE_OFF 0
  25. #define RW_MGR_ODT_MODE_READ_WRITE 1
  26. #define NUM_CALIB_REPEAT 1
  27. #define NUM_READ_TESTS 7
  28. #define NUM_READ_PB_TESTS 7
  29. #define NUM_WRITE_TESTS 15
  30. #define NUM_WRITE_PB_TESTS 31
  31. #define PASS_ALL_BITS 1
  32. #define PASS_ONE_BIT 0
  33. /* calibration stages */
  34. #define CAL_STAGE_NIL 0
  35. #define CAL_STAGE_VFIFO 1
  36. #define CAL_STAGE_WLEVEL 2
  37. #define CAL_STAGE_LFIFO 3
  38. #define CAL_STAGE_WRITES 4
  39. #define CAL_STAGE_FULLTEST 5
  40. #define CAL_STAGE_REFRESH 6
  41. #define CAL_STAGE_CAL_SKIPPED 7
  42. #define CAL_STAGE_CAL_ABORTED 8
  43. #define CAL_STAGE_VFIFO_AFTER_WRITES 9
  44. /* calibration substages */
  45. #define CAL_SUBSTAGE_NIL 0
  46. #define CAL_SUBSTAGE_GUARANTEED_READ 1
  47. #define CAL_SUBSTAGE_DQS_EN_PHASE 2
  48. #define CAL_SUBSTAGE_VFIFO_CENTER 3
  49. #define CAL_SUBSTAGE_WORKING_DELAY 1
  50. #define CAL_SUBSTAGE_LAST_WORKING_DELAY 2
  51. #define CAL_SUBSTAGE_WLEVEL_COPY 3
  52. #define CAL_SUBSTAGE_WRITES_CENTER 1
  53. #define CAL_SUBSTAGE_READ_LATENCY 1
  54. #define CAL_SUBSTAGE_REFRESH 1
  55. #define MAX_RANKS (RW_MGR_MEM_NUMBER_OF_RANKS)
  56. #define MAX_DQS (RW_MGR_MEM_IF_WRITE_DQS_WIDTH > \
  57. RW_MGR_MEM_IF_READ_DQS_WIDTH ? \
  58. RW_MGR_MEM_IF_WRITE_DQS_WIDTH : \
  59. RW_MGR_MEM_IF_READ_DQS_WIDTH)
  60. #define MAX_DQ (RW_MGR_MEM_DATA_WIDTH)
  61. #define MAX_DM (RW_MGR_MEM_DATA_MASK_WIDTH)
  62. /* length of VFIFO, from SW_MACROS */
  63. #define VFIFO_SIZE (READ_VALID_FIFO_SIZE)
  64. /* MarkW: how should these base addresses be done for A-V? */
  65. #define BASE_PTR_MGR 0x00040000
  66. #define BASE_SCC_MGR 0x00058000
  67. #define BASE_REG_FILE 0x00070000
  68. #define BASE_TIMER 0x00078000
  69. #define BASE_PHY_MGR 0x00088000
  70. #define BASE_RW_MGR 0x00090000
  71. #define BASE_DATA_MGR 0x00098000
  72. #define BASE_MMR 0x000C0000
  73. #define BASE_TRK_MGR 0x000D0000
  74. #define SCC_MGR_GROUP_COUNTER (BASE_SCC_MGR + 0x0000)
  75. #define SCC_MGR_DQS_IN_DELAY (BASE_SCC_MGR + 0x0100)
  76. #define SCC_MGR_DQS_EN_PHASE (BASE_SCC_MGR + 0x0200)
  77. #define SCC_MGR_DQS_EN_DELAY (BASE_SCC_MGR + 0x0300)
  78. #define SCC_MGR_DQDQS_OUT_PHASE (BASE_SCC_MGR + 0x0400)
  79. #define SCC_MGR_OCT_OUT1_DELAY (BASE_SCC_MGR + 0x0500)
  80. #define SCC_MGR_IO_OUT1_DELAY (BASE_SCC_MGR + 0x0700)
  81. #define SCC_MGR_IO_IN_DELAY (BASE_SCC_MGR + 0x0900)
  82. /* HHP-HPS-specific versions of some commands */
  83. #define SCC_MGR_DQS_EN_DELAY_GATE (BASE_SCC_MGR + 0x0600)
  84. #define SCC_MGR_IO_OE_DELAY (BASE_SCC_MGR + 0x0800)
  85. #define SCC_MGR_HHP_GLOBALS (BASE_SCC_MGR + 0x0A00)
  86. #define SCC_MGR_HHP_RFILE (BASE_SCC_MGR + 0x0B00)
  87. #define SCC_MGR_AFI_CAL_INIT (BASE_SCC_MGR + 0x0D00)
  88. #define SDR_PHYGRP_SCCGRP_ADDRESS 0x0
  89. #define SDR_PHYGRP_PHYMGRGRP_ADDRESS 0x1000
  90. #define SDR_PHYGRP_RWMGRGRP_ADDRESS 0x2000
  91. #define SDR_PHYGRP_DATAMGRGRP_ADDRESS 0x4000
  92. #define SDR_PHYGRP_REGFILEGRP_ADDRESS 0x4800
  93. #define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_OFFSET 0x150
  94. #define SDR_CTRLGRP_PHYCTRL_PHYCTRL_1_OFFSET 0x154
  95. #define SDR_CTRLGRP_PHYCTRL_PHYCTRL_2_OFFSET 0x158
  96. #define PHY_MGR_CAL_RESET (0)
  97. #define PHY_MGR_CAL_SUCCESS (1)
  98. #define PHY_MGR_CAL_FAIL (2)
  99. #define CALIB_SKIP_DELAY_LOOPS (1 << 0)
  100. #define CALIB_SKIP_ALL_BITS_CHK (1 << 1)
  101. #define CALIB_SKIP_DELAY_SWEEPS (1 << 2)
  102. #define CALIB_SKIP_VFIFO (1 << 3)
  103. #define CALIB_SKIP_LFIFO (1 << 4)
  104. #define CALIB_SKIP_WLEVEL (1 << 5)
  105. #define CALIB_SKIP_WRITES (1 << 6)
  106. #define CALIB_SKIP_FULL_TEST (1 << 7)
  107. #define CALIB_SKIP_ALL (CALIB_SKIP_VFIFO | \
  108. CALIB_SKIP_LFIFO | CALIB_SKIP_WLEVEL | \
  109. CALIB_SKIP_WRITES | CALIB_SKIP_FULL_TEST)
  110. #define CALIB_IN_RTL_SIM (1 << 8)
  111. /* Scan chain manager command addresses */
  112. #define READ_SCC_OCT_OUT2_DELAY 0
  113. #define READ_SCC_DQ_OUT2_DELAY 0
  114. #define READ_SCC_DQS_IO_OUT2_DELAY 0
  115. #define READ_SCC_DM_IO_OUT2_DELAY 0
  116. /* HHP-HPS-specific values */
  117. #define SCC_MGR_HHP_EXTRAS_OFFSET 0
  118. #define SCC_MGR_HHP_DQSE_MAP_OFFSET 1
  119. /* PHY Debug mode flag constants */
  120. #define PHY_DEBUG_IN_DEBUG_MODE 0x00000001
  121. #define PHY_DEBUG_ENABLE_CAL_RPT 0x00000002
  122. #define PHY_DEBUG_ENABLE_MARGIN_RPT 0x00000004
  123. #define PHY_DEBUG_SWEEP_ALL_GROUPS 0x00000008
  124. #define PHY_DEBUG_DISABLE_GUARANTEED_READ 0x00000010
  125. #define PHY_DEBUG_ENABLE_NON_DESTRUCTIVE_CALIBRATION 0x00000020
  126. /* Init and Reset delay constants - Only use if defined by sequencer_defines.h,
  127. * otherwise, revert to defaults
  128. * Default for Tinit = (0+1) * ((202+1) * (2 * 131 + 1) + 1) = 53532 =
  129. * 200.75us @ 266MHz
  130. */
  131. #ifdef TINIT_CNTR0_VAL
  132. #define SEQ_TINIT_CNTR0_VAL TINIT_CNTR0_VAL
  133. #else
  134. #define SEQ_TINIT_CNTR0_VAL 0
  135. #endif
  136. #ifdef TINIT_CNTR1_VAL
  137. #define SEQ_TINIT_CNTR1_VAL TINIT_CNTR1_VAL
  138. #else
  139. #define SEQ_TINIT_CNTR1_VAL 202
  140. #endif
  141. #ifdef TINIT_CNTR2_VAL
  142. #define SEQ_TINIT_CNTR2_VAL TINIT_CNTR2_VAL
  143. #else
  144. #define SEQ_TINIT_CNTR2_VAL 131
  145. #endif
  146. /* Default for Treset = (2+1) * ((252+1) * (2 * 131 + 1) + 1) = 133563 =
  147. * 500.86us @ 266MHz
  148. */
  149. #ifdef TRESET_CNTR0_VAL
  150. #define SEQ_TRESET_CNTR0_VAL TRESET_CNTR0_VAL
  151. #else
  152. #define SEQ_TRESET_CNTR0_VAL 2
  153. #endif
  154. #ifdef TRESET_CNTR1_VAL
  155. #define SEQ_TRESET_CNTR1_VAL TRESET_CNTR1_VAL
  156. #else
  157. #define SEQ_TRESET_CNTR1_VAL 252
  158. #endif
  159. #ifdef TRESET_CNTR2_VAL
  160. #define SEQ_TRESET_CNTR2_VAL TRESET_CNTR2_VAL
  161. #else
  162. #define SEQ_TRESET_CNTR2_VAL 131
  163. #endif
  164. #define RW_MGR_INST_ROM_WRITE BASE_RW_MGR + 0x1800
  165. #define RW_MGR_AC_ROM_WRITE BASE_RW_MGR + 0x1C00
  166. struct socfpga_sdr_rw_load_manager {
  167. u32 load_cntr0;
  168. u32 load_cntr1;
  169. u32 load_cntr2;
  170. u32 load_cntr3;
  171. };
  172. struct socfpga_sdr_rw_load_jump_manager {
  173. u32 load_jump_add0;
  174. u32 load_jump_add1;
  175. u32 load_jump_add2;
  176. u32 load_jump_add3;
  177. };
  178. struct socfpga_sdr_reg_file {
  179. u32 signature;
  180. u32 debug_data_addr;
  181. u32 cur_stage;
  182. u32 fom;
  183. u32 failing_stage;
  184. u32 debug1;
  185. u32 debug2;
  186. u32 dtaps_per_ptap;
  187. u32 trk_sample_count;
  188. u32 trk_longidle;
  189. u32 delays;
  190. u32 trk_rw_mgr_addr;
  191. u32 trk_read_dqs_width;
  192. u32 trk_rfsh;
  193. };
  194. /* parameter variable holder */
  195. struct param_type {
  196. uint32_t dm_correct_mask;
  197. uint32_t read_correct_mask;
  198. uint32_t read_correct_mask_vg;
  199. uint32_t write_correct_mask;
  200. uint32_t write_correct_mask_vg;
  201. /* set a particular entry to 1 if we need to skip a particular rank */
  202. uint32_t skip_ranks[MAX_RANKS];
  203. /* set a particular entry to 1 if we need to skip a particular group */
  204. uint32_t skip_groups;
  205. /* set a particular entry to 1 if the shadow register
  206. (which represents a set of ranks) needs to be skipped */
  207. uint32_t skip_shadow_regs[NUM_SHADOW_REGS];
  208. };
  209. /* global variable holder */
  210. struct gbl_type {
  211. uint32_t phy_debug_mode_flags;
  212. /* current read latency */
  213. uint32_t curr_read_lat;
  214. /* current write latency */
  215. uint32_t curr_write_lat;
  216. /* error code */
  217. uint32_t error_substage;
  218. uint32_t error_stage;
  219. uint32_t error_group;
  220. /* figure-of-merit in, figure-of-merit out */
  221. uint32_t fom_in;
  222. uint32_t fom_out;
  223. /*USER Number of RW Mgr NOP cycles between
  224. write command and write data */
  225. uint32_t rw_wl_nop_cycles;
  226. };
  227. struct socfpga_sdr_scc_mgr {
  228. u32 dqs_ena;
  229. u32 dqs_io_ena;
  230. u32 dq_ena;
  231. u32 dm_ena;
  232. u32 __padding1[4];
  233. u32 update;
  234. u32 __padding2[7];
  235. u32 active_rank;
  236. };
  237. /* PHY manager configuration registers. */
  238. struct socfpga_phy_mgr_cfg {
  239. u32 phy_rlat;
  240. u32 reset_mem_stbl;
  241. u32 mux_sel;
  242. u32 cal_status;
  243. u32 cal_debug_info;
  244. u32 vfifo_rd_en_ovrd;
  245. u32 afi_wlat;
  246. u32 afi_rlat;
  247. };
  248. /* PHY manager command addresses. */
  249. struct socfpga_phy_mgr_cmd {
  250. u32 inc_vfifo_fr;
  251. u32 inc_vfifo_hard_phy;
  252. u32 fifo_reset;
  253. u32 inc_vfifo_fr_hr;
  254. u32 inc_vfifo_qr;
  255. };
  256. struct socfpga_data_mgr {
  257. u32 __padding1;
  258. u32 t_wl_add;
  259. u32 mem_t_add;
  260. u32 t_rl_add;
  261. };
  262. #endif /* _SEQUENCER_H_ */