ddr3_training_ip.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 DDR3_TIP_VERSION_STRING "DDR3 Training Sequence - Ver TIP-1.29."
  11. #define MAX_CS_NUM 4
  12. #define MAX_TOTAL_BUS_NUM (MAX_INTERFACE_NUM * MAX_BUS_NUM)
  13. #define MAX_DQ_NUM 40
  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 CENTRALIZATION_RX_MASK_BIT 0x00100000
  36. #define CENTRALIZATION_TX_MASK_BIT 0x00200000
  37. #define TX_EMPHASIS_MASK_BIT 0x00400000
  38. #define PER_BIT_READ_LEVELING_TF_MASK_BIT 0x00800000
  39. #define VREF_CALIBRATION_MASK_BIT 0x01000000
  40. enum hws_result {
  41. TEST_FAILED = 0,
  42. TEST_SUCCESS = 1,
  43. NO_TEST_DONE = 2
  44. };
  45. enum hws_training_result {
  46. RESULT_PER_BIT,
  47. RESULT_PER_BYTE
  48. };
  49. enum auto_tune_stage {
  50. INIT_CONTROLLER,
  51. STATIC_LEVELING,
  52. SET_LOW_FREQ,
  53. LOAD_PATTERN,
  54. SET_MEDIUM_FREQ,
  55. WRITE_LEVELING,
  56. LOAD_PATTERN_2,
  57. READ_LEVELING,
  58. WRITE_LEVELING_SUPP,
  59. PBS_RX,
  60. PBS_TX,
  61. SET_TARGET_FREQ,
  62. ADJUST_DQS,
  63. WRITE_LEVELING_TF,
  64. READ_LEVELING_TF,
  65. WRITE_LEVELING_SUPP_TF,
  66. DM_PBS_TX,
  67. VREF_CALIBRATION,
  68. CENTRALIZATION_RX,
  69. CENTRALIZATION_TX,
  70. TX_EMPHASIS,
  71. LOAD_PATTERN_HIGH,
  72. PER_BIT_READ_LEVELING_TF,
  73. MAX_STAGE_LIMIT
  74. };
  75. enum hws_access_type {
  76. ACCESS_TYPE_UNICAST = 0,
  77. ACCESS_TYPE_MULTICAST = 1
  78. };
  79. enum hws_algo_type {
  80. ALGO_TYPE_DYNAMIC,
  81. ALGO_TYPE_STATIC
  82. };
  83. struct init_cntr_param {
  84. int is_ctrl64_bit;
  85. int do_mrs_phy;
  86. int init_phy;
  87. int msys_init;
  88. };
  89. struct pattern_info {
  90. u8 num_of_phases_tx;
  91. u8 tx_burst_size;
  92. u8 delay_between_bursts;
  93. u8 num_of_phases_rx;
  94. u32 start_addr;
  95. u8 pattern_len;
  96. };
  97. /* CL value for each frequency */
  98. struct cl_val_per_freq {
  99. u8 cl_val[DDR_FREQ_LIMIT];
  100. };
  101. struct cs_element {
  102. u8 cs_num;
  103. u8 num_of_cs;
  104. };
  105. struct mode_info {
  106. /* 32 bits representing MRS bits */
  107. u32 reg_mr0[MAX_INTERFACE_NUM];
  108. u32 reg_mr1[MAX_INTERFACE_NUM];
  109. u32 reg_mr2[MAX_INTERFACE_NUM];
  110. u32 reg_m_r3[MAX_INTERFACE_NUM];
  111. /*
  112. * Each element in array represent read_data_sample register delay for
  113. * a specific interface.
  114. * Each register, 4 bits[0+CS*8 to 4+CS*8] represent Number of DDR
  115. * cycles from read command until data is ready to be fetched from
  116. * the PHY, when accessing CS.
  117. */
  118. u32 read_data_sample[MAX_INTERFACE_NUM];
  119. /*
  120. * Each element in array represent read_data_sample register delay for
  121. * a specific interface.
  122. * Each register, 4 bits[0+CS*8 to 4+CS*8] represent the total delay
  123. * from read command until opening the read mask, when accessing CS.
  124. * This field defines the delay in DDR cycles granularity.
  125. */
  126. u32 read_data_ready[MAX_INTERFACE_NUM];
  127. };
  128. struct hws_tip_freq_config_info {
  129. u8 is_supported;
  130. u8 bw_per_freq;
  131. u8 rate_per_freq;
  132. };
  133. struct hws_cs_config_info {
  134. u32 cs_reg_value;
  135. u32 cs_cbe_value;
  136. };
  137. struct dfx_access {
  138. u8 pipe;
  139. u8 client;
  140. };
  141. struct hws_xsb_info {
  142. struct dfx_access *dfx_table;
  143. };
  144. int ddr3_tip_register_dq_table(u32 dev_num, u32 *table);
  145. int hws_ddr3_tip_select_ddr_controller(u32 dev_num, int enable);
  146. int hws_ddr3_tip_init_controller(u32 dev_num,
  147. struct init_cntr_param *init_cntr_prm);
  148. int hws_ddr3_tip_load_topology_map(u32 dev_num,
  149. struct hws_topology_map *topology);
  150. int hws_ddr3_tip_run_alg(u32 dev_num, enum hws_algo_type algo_type);
  151. int hws_ddr3_tip_mode_read(u32 dev_num, struct mode_info *mode_info);
  152. int ddr3_tip_is_pup_lock(u32 *pup_buf, enum hws_training_result read_mode);
  153. u8 ddr3_tip_get_buf_min(u8 *buf_ptr);
  154. u8 ddr3_tip_get_buf_max(u8 *buf_ptr);
  155. #endif /* _DDR3_TRAINING_IP_H_ */