sequencer.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 (rwcfg->mem_data_mask_width \
  9. / rwcfg->mem_if_write_dqs_width)
  10. #define RW_MGR_NUM_TRUE_DM_PER_WRITE_GROUP (rwcfg->true_mem_data_mask_width \
  11. / rwcfg->mem_if_write_dqs_width)
  12. #define RW_MGR_NUM_DQS_PER_WRITE_GROUP (rwcfg->mem_if_read_dqs_width \
  13. / rwcfg->mem_if_write_dqs_width)
  14. #define NUM_RANKS_PER_SHADOW_REG (rwcfg->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 NUM_SHADOW_REGS 1
  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 SCC_MGR_GROUP_COUNTER_OFFSET 0x0000
  56. #define SCC_MGR_DQS_IN_DELAY_OFFSET 0x0100
  57. #define SCC_MGR_DQS_EN_PHASE_OFFSET 0x0200
  58. #define SCC_MGR_DQS_EN_DELAY_OFFSET 0x0300
  59. #define SCC_MGR_DQDQS_OUT_PHASE_OFFSET 0x0400
  60. #define SCC_MGR_OCT_OUT1_DELAY_OFFSET 0x0500
  61. #define SCC_MGR_IO_OUT1_DELAY_OFFSET 0x0700
  62. #define SCC_MGR_IO_IN_DELAY_OFFSET 0x0900
  63. /* HHP-HPS-specific versions of some commands */
  64. #define SCC_MGR_DQS_EN_DELAY_GATE_OFFSET 0x0600
  65. #define SCC_MGR_IO_OE_DELAY_OFFSET 0x0800
  66. #define SCC_MGR_HHP_GLOBALS_OFFSET 0x0A00
  67. #define SCC_MGR_HHP_RFILE_OFFSET 0x0B00
  68. #define SCC_MGR_AFI_CAL_INIT_OFFSET 0x0D00
  69. #define SDR_PHYGRP_SCCGRP_ADDRESS (SOCFPGA_SDR_ADDRESS | 0x0)
  70. #define SDR_PHYGRP_PHYMGRGRP_ADDRESS (SOCFPGA_SDR_ADDRESS | 0x1000)
  71. #define SDR_PHYGRP_RWMGRGRP_ADDRESS (SOCFPGA_SDR_ADDRESS | 0x2000)
  72. #define SDR_PHYGRP_DATAMGRGRP_ADDRESS (SOCFPGA_SDR_ADDRESS | 0x4000)
  73. #define SDR_PHYGRP_REGFILEGRP_ADDRESS (SOCFPGA_SDR_ADDRESS | 0x4800)
  74. #define PHY_MGR_CAL_RESET (0)
  75. #define PHY_MGR_CAL_SUCCESS (1)
  76. #define PHY_MGR_CAL_FAIL (2)
  77. #define CALIB_SKIP_DELAY_LOOPS (1 << 0)
  78. #define CALIB_SKIP_ALL_BITS_CHK (1 << 1)
  79. #define CALIB_SKIP_DELAY_SWEEPS (1 << 2)
  80. #define CALIB_SKIP_VFIFO (1 << 3)
  81. #define CALIB_SKIP_LFIFO (1 << 4)
  82. #define CALIB_SKIP_WLEVEL (1 << 5)
  83. #define CALIB_SKIP_WRITES (1 << 6)
  84. #define CALIB_SKIP_FULL_TEST (1 << 7)
  85. #define CALIB_SKIP_ALL (CALIB_SKIP_VFIFO | \
  86. CALIB_SKIP_LFIFO | CALIB_SKIP_WLEVEL | \
  87. CALIB_SKIP_WRITES | CALIB_SKIP_FULL_TEST)
  88. #define CALIB_IN_RTL_SIM (1 << 8)
  89. /* Scan chain manager command addresses */
  90. #define READ_SCC_OCT_OUT2_DELAY 0
  91. #define READ_SCC_DQ_OUT2_DELAY 0
  92. #define READ_SCC_DQS_IO_OUT2_DELAY 0
  93. #define READ_SCC_DM_IO_OUT2_DELAY 0
  94. /* HHP-HPS-specific values */
  95. #define SCC_MGR_HHP_EXTRAS_OFFSET 0
  96. #define SCC_MGR_HHP_DQSE_MAP_OFFSET 1
  97. /* PHY Debug mode flag constants */
  98. #define PHY_DEBUG_IN_DEBUG_MODE 0x00000001
  99. #define PHY_DEBUG_ENABLE_CAL_RPT 0x00000002
  100. #define PHY_DEBUG_ENABLE_MARGIN_RPT 0x00000004
  101. #define PHY_DEBUG_SWEEP_ALL_GROUPS 0x00000008
  102. #define PHY_DEBUG_DISABLE_GUARANTEED_READ 0x00000010
  103. #define PHY_DEBUG_ENABLE_NON_DESTRUCTIVE_CALIBRATION 0x00000020
  104. struct socfpga_sdr_rw_load_manager {
  105. u32 load_cntr0;
  106. u32 load_cntr1;
  107. u32 load_cntr2;
  108. u32 load_cntr3;
  109. };
  110. struct socfpga_sdr_rw_load_jump_manager {
  111. u32 load_jump_add0;
  112. u32 load_jump_add1;
  113. u32 load_jump_add2;
  114. u32 load_jump_add3;
  115. };
  116. struct socfpga_sdr_reg_file {
  117. u32 signature;
  118. u32 debug_data_addr;
  119. u32 cur_stage;
  120. u32 fom;
  121. u32 failing_stage;
  122. u32 debug1;
  123. u32 debug2;
  124. u32 dtaps_per_ptap;
  125. u32 trk_sample_count;
  126. u32 trk_longidle;
  127. u32 delays;
  128. u32 trk_rw_mgr_addr;
  129. u32 trk_read_dqs_width;
  130. u32 trk_rfsh;
  131. };
  132. /* parameter variable holder */
  133. struct param_type {
  134. u32 read_correct_mask;
  135. u32 read_correct_mask_vg;
  136. u32 write_correct_mask;
  137. u32 write_correct_mask_vg;
  138. };
  139. /* global variable holder */
  140. struct gbl_type {
  141. uint32_t phy_debug_mode_flags;
  142. /* current read latency */
  143. uint32_t curr_read_lat;
  144. /* error code */
  145. uint32_t error_substage;
  146. uint32_t error_stage;
  147. uint32_t error_group;
  148. /* figure-of-merit in, figure-of-merit out */
  149. uint32_t fom_in;
  150. uint32_t fom_out;
  151. /*USER Number of RW Mgr NOP cycles between
  152. write command and write data */
  153. uint32_t rw_wl_nop_cycles;
  154. };
  155. struct socfpga_sdr_scc_mgr {
  156. u32 dqs_ena;
  157. u32 dqs_io_ena;
  158. u32 dq_ena;
  159. u32 dm_ena;
  160. u32 __padding1[4];
  161. u32 update;
  162. u32 __padding2[7];
  163. u32 active_rank;
  164. };
  165. /* PHY manager configuration registers. */
  166. struct socfpga_phy_mgr_cfg {
  167. u32 phy_rlat;
  168. u32 reset_mem_stbl;
  169. u32 mux_sel;
  170. u32 cal_status;
  171. u32 cal_debug_info;
  172. u32 vfifo_rd_en_ovrd;
  173. u32 afi_wlat;
  174. u32 afi_rlat;
  175. };
  176. /* PHY manager command addresses. */
  177. struct socfpga_phy_mgr_cmd {
  178. u32 inc_vfifo_fr;
  179. u32 inc_vfifo_hard_phy;
  180. u32 fifo_reset;
  181. u32 inc_vfifo_fr_hr;
  182. u32 inc_vfifo_qr;
  183. };
  184. struct socfpga_data_mgr {
  185. u32 __padding1;
  186. u32 t_wl_add;
  187. u32 mem_t_add;
  188. u32 t_rl_add;
  189. };
  190. #endif /* _SEQUENCER_H_ */