sequencer.h 7.6 KB

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