ddr3_training_ip.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) Marvell International Ltd. and its affiliates
  4. */
  5. #ifndef _DDR3_TRAINING_IP_H_
  6. #define _DDR3_TRAINING_IP_H_
  7. #include "ddr3_training_ip_def.h"
  8. #include "ddr_topology_def.h"
  9. #include "ddr_training_ip_db.h"
  10. #define MAX_CS_NUM 4
  11. #define MAX_TOTAL_BUS_NUM (MAX_INTERFACE_NUM * MAX_BUS_NUM)
  12. #define TIP_ENG_LOCK 0x02000000
  13. #define TIP_TX_DLL_RANGE_MAX 64
  14. #define GET_MIN(arg1, arg2) ((arg1) < (arg2)) ? (arg1) : (arg2)
  15. #define GET_MAX(arg1, arg2) ((arg1) < (arg2)) ? (arg2) : (arg1)
  16. #define INIT_CONTROLLER_MASK_BIT 0x00000001
  17. #define STATIC_LEVELING_MASK_BIT 0x00000002
  18. #define SET_LOW_FREQ_MASK_BIT 0x00000004
  19. #define LOAD_PATTERN_MASK_BIT 0x00000008
  20. #define SET_MEDIUM_FREQ_MASK_BIT 0x00000010
  21. #define WRITE_LEVELING_MASK_BIT 0x00000020
  22. #define LOAD_PATTERN_2_MASK_BIT 0x00000040
  23. #define READ_LEVELING_MASK_BIT 0x00000080
  24. #define SW_READ_LEVELING_MASK_BIT 0x00000100
  25. #define WRITE_LEVELING_SUPP_MASK_BIT 0x00000200
  26. #define PBS_RX_MASK_BIT 0x00000400
  27. #define PBS_TX_MASK_BIT 0x00000800
  28. #define SET_TARGET_FREQ_MASK_BIT 0x00001000
  29. #define ADJUST_DQS_MASK_BIT 0x00002000
  30. #define WRITE_LEVELING_TF_MASK_BIT 0x00004000
  31. #define LOAD_PATTERN_HIGH_MASK_BIT 0x00008000
  32. #define READ_LEVELING_TF_MASK_BIT 0x00010000
  33. #define WRITE_LEVELING_SUPP_TF_MASK_BIT 0x00020000
  34. #define DM_PBS_TX_MASK_BIT 0x00040000
  35. #define RL_DQS_BURST_MASK_BIT 0x00080000
  36. #define CENTRALIZATION_RX_MASK_BIT 0x00100000
  37. #define CENTRALIZATION_TX_MASK_BIT 0x00200000
  38. #define TX_EMPHASIS_MASK_BIT 0x00400000
  39. #define PER_BIT_READ_LEVELING_TF_MASK_BIT 0x00800000
  40. #define VREF_CALIBRATION_MASK_BIT 0x01000000
  41. #define WRITE_LEVELING_LF_MASK_BIT 0x02000000
  42. /* DDR4 Specific Training Mask bits */
  43. enum hws_result {
  44. TEST_FAILED = 0,
  45. TEST_SUCCESS = 1,
  46. NO_TEST_DONE = 2
  47. };
  48. enum hws_training_result {
  49. RESULT_PER_BIT,
  50. RESULT_PER_BYTE
  51. };
  52. enum auto_tune_stage {
  53. INIT_CONTROLLER,
  54. STATIC_LEVELING,
  55. SET_LOW_FREQ,
  56. LOAD_PATTERN,
  57. SET_MEDIUM_FREQ,
  58. WRITE_LEVELING,
  59. LOAD_PATTERN_2,
  60. READ_LEVELING,
  61. WRITE_LEVELING_SUPP,
  62. PBS_RX,
  63. PBS_TX,
  64. SET_TARGET_FREQ,
  65. ADJUST_DQS,
  66. WRITE_LEVELING_TF,
  67. READ_LEVELING_TF,
  68. WRITE_LEVELING_SUPP_TF,
  69. DM_PBS_TX,
  70. VREF_CALIBRATION,
  71. CENTRALIZATION_RX,
  72. CENTRALIZATION_TX,
  73. TX_EMPHASIS,
  74. LOAD_PATTERN_HIGH,
  75. PER_BIT_READ_LEVELING_TF,
  76. WRITE_LEVELING_LF,
  77. MAX_STAGE_LIMIT
  78. };
  79. enum hws_access_type {
  80. ACCESS_TYPE_UNICAST = 0,
  81. ACCESS_TYPE_MULTICAST = 1
  82. };
  83. enum hws_algo_type {
  84. ALGO_TYPE_DYNAMIC,
  85. ALGO_TYPE_STATIC
  86. };
  87. struct init_cntr_param {
  88. int is_ctrl64_bit;
  89. int do_mrs_phy;
  90. int init_phy;
  91. int msys_init;
  92. };
  93. struct pattern_info {
  94. u8 num_of_phases_tx;
  95. u8 tx_burst_size;
  96. u8 delay_between_bursts;
  97. u8 num_of_phases_rx;
  98. u32 start_addr;
  99. u8 pattern_len;
  100. };
  101. /* CL value for each frequency */
  102. struct cl_val_per_freq {
  103. u8 cl_val[DDR_FREQ_LAST];
  104. };
  105. struct cs_element {
  106. u8 cs_num;
  107. u8 num_of_cs;
  108. };
  109. struct mode_info {
  110. /* 32 bits representing MRS bits */
  111. u32 reg_mr0[MAX_INTERFACE_NUM];
  112. u32 reg_mr1[MAX_INTERFACE_NUM];
  113. u32 reg_mr2[MAX_INTERFACE_NUM];
  114. u32 reg_m_r3[MAX_INTERFACE_NUM];
  115. /*
  116. * Each element in array represent read_data_sample register delay for
  117. * a specific interface.
  118. * Each register, 4 bits[0+CS*8 to 4+CS*8] represent Number of DDR
  119. * cycles from read command until data is ready to be fetched from
  120. * the PHY, when accessing CS.
  121. */
  122. u32 read_data_sample[MAX_INTERFACE_NUM];
  123. /*
  124. * Each element in array represent read_data_sample register delay for
  125. * a specific interface.
  126. * Each register, 4 bits[0+CS*8 to 4+CS*8] represent the total delay
  127. * from read command until opening the read mask, when accessing CS.
  128. * This field defines the delay in DDR cycles granularity.
  129. */
  130. u32 read_data_ready[MAX_INTERFACE_NUM];
  131. };
  132. struct hws_tip_freq_config_info {
  133. u8 is_supported;
  134. u8 bw_per_freq;
  135. u8 rate_per_freq;
  136. };
  137. struct hws_cs_config_info {
  138. u32 cs_reg_value;
  139. u32 cs_cbe_value;
  140. };
  141. struct dfx_access {
  142. u8 pipe;
  143. u8 client;
  144. };
  145. struct hws_xsb_info {
  146. struct dfx_access *dfx_table;
  147. };
  148. int ddr3_tip_register_dq_table(u32 dev_num, u32 *table);
  149. int hws_ddr3_tip_select_ddr_controller(u32 dev_num, int enable);
  150. int hws_ddr3_tip_init_controller(u32 dev_num,
  151. struct init_cntr_param *init_cntr_prm);
  152. int hws_ddr3_tip_load_topology_map(u32 dev_num,
  153. struct mv_ddr_topology_map *topology);
  154. int hws_ddr3_tip_run_alg(u32 dev_num, enum hws_algo_type algo_type);
  155. int hws_ddr3_tip_mode_read(u32 dev_num, struct mode_info *mode_info);
  156. int hws_ddr3_tip_read_training_result(u32 dev_num,
  157. enum hws_result result[MAX_STAGE_LIMIT][MAX_INTERFACE_NUM]);
  158. int ddr3_tip_is_pup_lock(u32 *pup_buf, enum hws_training_result read_mode);
  159. u8 ddr3_tip_get_buf_min(u8 *buf_ptr);
  160. u8 ddr3_tip_get_buf_max(u8 *buf_ptr);
  161. uint64_t mv_ddr_get_memory_size_per_cs_in_bits(void);
  162. uint64_t mv_ddr_get_total_memory_size_in_bits(void);
  163. #endif /* _DDR3_TRAINING_IP_H_ */