qos_init_h3_v20.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Copyright (c) 2015-2024, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdint.h>
  7. #include <common/debug.h>
  8. #include "../qos_common.h"
  9. #include "../qos_reg.h"
  10. #include "qos_init_h3_v20.h"
  11. #define RCAR_QOS_VERSION "rev.0.21"
  12. #define QOSWT_TIME_BANK0 20000000U /* unit:ns */
  13. #define QOSWT_WTEN_ENABLE 0x1U
  14. #define QOSCTRL_REF_ARS_ARBSTOPCYCLE_H3_20 (SL_INIT_SSLOTCLK_H3_20 - 0x5U)
  15. #define OSWT_WTREF_SLOT0_EN_REQ1_SLOT 3U
  16. #define OSWT_WTREF_SLOT0_EN_REQ2_SLOT 9U
  17. #define QOSWT_WTREF_SLOT0_EN \
  18. ((0x1U << OSWT_WTREF_SLOT0_EN_REQ1_SLOT) | \
  19. (0x1U << OSWT_WTREF_SLOT0_EN_REQ2_SLOT))
  20. #define QOSWT_WTREF_SLOT1_EN \
  21. ((0x1U << OSWT_WTREF_SLOT0_EN_REQ1_SLOT) | \
  22. (0x1U << OSWT_WTREF_SLOT0_EN_REQ2_SLOT))
  23. #define QOSWT_WTSET0_REQ_SSLOT0 5U
  24. #define WT_BASE_SUB_SLOT_NUM0 12U
  25. #define QOSWT_WTSET0_PERIOD0_H3_20 \
  26. ((QOSWT_TIME_BANK0 / QOSWT_WTSET0_CYCLE_H3_20) - 1U)
  27. #define QOSWT_WTSET0_SSLOT0 (QOSWT_WTSET0_REQ_SSLOT0 - 1U)
  28. #define QOSWT_WTSET0_SLOTSLOT0 (WT_BASE_SUB_SLOT_NUM0 - 1U)
  29. #define QOSWT_WTSET1_PERIOD1_H3_20 \
  30. ((QOSWT_TIME_BANK0 / QOSWT_WTSET0_CYCLE_H3_20) - 1U)
  31. #define QOSWT_WTSET1_SSLOT1 (QOSWT_WTSET0_REQ_SSLOT0 - 1U)
  32. #define QOSWT_WTSET1_SLOTSLOT1 (WT_BASE_SUB_SLOT_NUM0 - 1U)
  33. #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT
  34. #if RCAR_REF_INT == RCAR_REF_DEFAULT
  35. #include "qos_init_h3_v20_mstat195.h"
  36. #else
  37. #include "qos_init_h3_v20_mstat390.h"
  38. #endif
  39. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  40. #if RCAR_REF_INT == RCAR_REF_DEFAULT
  41. #include "qos_init_h3_v20_qoswt195.h"
  42. #else
  43. #include "qos_init_h3_v20_qoswt390.h"
  44. #endif
  45. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  46. #endif
  47. struct rcar_gen3_dbsc_qos_settings h3_v20_qos[] = {
  48. /* BUFCAM settings */
  49. { DBSC_DBCAM0CNF1, 0x00048218U },
  50. { DBSC_DBCAM0CNF2, 0x000000F4U },
  51. { DBSC_DBCAM0CNF3, 0x00000000U },
  52. { DBSC_DBSCHCNT0, 0x000F0037U },
  53. { DBSC_DBSCHSZ0, 0x00000001U },
  54. { DBSC_DBSCHRW0, 0x22421111U },
  55. /* DDR3 */
  56. { DBSC_SCFCTST2, 0x012F1123U },
  57. /* QoS Settings */
  58. { DBSC_DBSCHQOS00, 0x00000F00U },
  59. { DBSC_DBSCHQOS01, 0x00000B00U },
  60. { DBSC_DBSCHQOS02, 0x00000000U },
  61. { DBSC_DBSCHQOS03, 0x00000000U },
  62. { DBSC_DBSCHQOS40, 0x00000300U },
  63. { DBSC_DBSCHQOS41, 0x000002F0U },
  64. { DBSC_DBSCHQOS42, 0x00000200U },
  65. { DBSC_DBSCHQOS43, 0x00000100U },
  66. { DBSC_DBSCHQOS90, 0x00000100U },
  67. { DBSC_DBSCHQOS91, 0x000000F0U },
  68. { DBSC_DBSCHQOS92, 0x000000A0U },
  69. { DBSC_DBSCHQOS93, 0x00000040U },
  70. { DBSC_DBSCHQOS120, 0x00000040U },
  71. { DBSC_DBSCHQOS121, 0x00000030U },
  72. { DBSC_DBSCHQOS122, 0x00000020U },
  73. { DBSC_DBSCHQOS123, 0x00000010U },
  74. { DBSC_DBSCHQOS130, 0x00000100U },
  75. { DBSC_DBSCHQOS131, 0x000000F0U },
  76. { DBSC_DBSCHQOS132, 0x000000A0U },
  77. { DBSC_DBSCHQOS133, 0x00000040U },
  78. { DBSC_DBSCHQOS140, 0x000000C0U },
  79. { DBSC_DBSCHQOS141, 0x000000B0U },
  80. { DBSC_DBSCHQOS142, 0x00000080U },
  81. { DBSC_DBSCHQOS143, 0x00000040U },
  82. { DBSC_DBSCHQOS150, 0x00000040U },
  83. { DBSC_DBSCHQOS151, 0x00000030U },
  84. { DBSC_DBSCHQOS152, 0x00000020U },
  85. { DBSC_DBSCHQOS153, 0x00000010U },
  86. };
  87. void qos_init_h3_v20(void)
  88. {
  89. rcar_qos_dbsc_setting(h3_v20_qos, ARRAY_SIZE(h3_v20_qos), true);
  90. /* DRAM Split Address mapping */
  91. #if (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_4CH) || \
  92. (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_AUTO)
  93. NOTICE("BL2: DRAM Split is 4ch\n");
  94. io_write_32(AXI_ADSPLCR0, ADSPLCR0_ADRMODE_DEFAULT
  95. | ADSPLCR0_SPLITSEL(0xFFU)
  96. | ADSPLCR0_AREA(0x1BU)
  97. | ADSPLCR0_SWP);
  98. io_write_32(AXI_ADSPLCR1, 0x00000000U);
  99. io_write_32(AXI_ADSPLCR2, 0x00001054U);
  100. io_write_32(AXI_ADSPLCR3, 0x00000000U);
  101. #elif RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_2CH
  102. NOTICE("BL2: DRAM Split is 2ch\n");
  103. io_write_32(AXI_ADSPLCR0, 0x00000000U);
  104. io_write_32(AXI_ADSPLCR1, ADSPLCR0_ADRMODE_DEFAULT
  105. | ADSPLCR0_SPLITSEL(0xFFU)
  106. | ADSPLCR0_AREA(0x1BU)
  107. | ADSPLCR0_SWP);
  108. io_write_32(AXI_ADSPLCR2, 0x00001004U);
  109. io_write_32(AXI_ADSPLCR3, 0x00000000U);
  110. #else
  111. NOTICE("BL2: DRAM Split is OFF\n");
  112. #endif
  113. #if !(RCAR_QOS_TYPE == RCAR_QOS_NONE)
  114. #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT
  115. NOTICE("BL2: QoS is default setting(%s)\n", RCAR_QOS_VERSION);
  116. #endif
  117. #if RCAR_REF_INT == RCAR_REF_DEFAULT
  118. NOTICE("BL2: DRAM refresh interval 1.95 usec\n");
  119. #else
  120. NOTICE("BL2: DRAM refresh interval 3.9 usec\n");
  121. #endif
  122. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  123. NOTICE("BL2: Periodic Write DQ Training\n");
  124. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  125. io_write_32(QOSCTRL_RAS, 0x00000044U);
  126. io_write_64(QOSCTRL_DANN, 0x0404010002020201UL);
  127. io_write_32(QOSCTRL_DANT, 0x0020100AU);
  128. io_write_32(QOSCTRL_INSFC, 0x06330001U);
  129. io_write_32(QOSCTRL_RACNT0, 0x00010003U);
  130. /* GPU Boost Mode */
  131. io_write_32(QOSCTRL_STATGEN0, 0x00000001U);
  132. io_write_32(QOSCTRL_SL_INIT,
  133. SL_INIT_REFFSSLOT | SL_INIT_SLOTSSLOT |
  134. SL_INIT_SSLOTCLK_H3_20);
  135. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  136. io_write_32(QOSCTRL_REF_ARS,
  137. ((QOSCTRL_REF_ARS_ARBSTOPCYCLE_H3_20 << 16)));
  138. #else
  139. io_write_32(QOSCTRL_REF_ARS, 0x00330000U);
  140. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  141. uint32_t i;
  142. for (i = 0U; i < ARRAY_SIZE(mstat_fix); i++) {
  143. io_write_64(QOSBW_FIX_QOS_BANK0 + i * 8, mstat_fix[i]);
  144. io_write_64(QOSBW_FIX_QOS_BANK1 + i * 8, mstat_fix[i]);
  145. }
  146. for (i = 0U; i < ARRAY_SIZE(mstat_be); i++) {
  147. io_write_64(QOSBW_BE_QOS_BANK0 + i * 8, mstat_be[i]);
  148. io_write_64(QOSBW_BE_QOS_BANK1 + i * 8, mstat_be[i]);
  149. }
  150. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  151. for (i = 0U; i < ARRAY_SIZE(qoswt_fix); i++) {
  152. io_write_64(QOSWT_FIX_WTQOS_BANK0 + i * 8,
  153. qoswt_fix[i]);
  154. io_write_64(QOSWT_FIX_WTQOS_BANK1 + i * 8,
  155. qoswt_fix[i]);
  156. }
  157. for (i = 0U; i < ARRAY_SIZE(qoswt_be); i++) {
  158. io_write_64(QOSWT_BE_WTQOS_BANK0 + i * 8, qoswt_be[i]);
  159. io_write_64(QOSWT_BE_WTQOS_BANK1 + i * 8, qoswt_be[i]);
  160. }
  161. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  162. /* 3DG bus Leaf setting */
  163. io_write_32(GPU_ACT0, 0x00000000U);
  164. io_write_32(GPU_ACT1, 0x00000000U);
  165. io_write_32(GPU_ACT2, 0x00000000U);
  166. io_write_32(GPU_ACT3, 0x00000000U);
  167. io_write_32(GPU_ACT4, 0x00000000U);
  168. io_write_32(GPU_ACT5, 0x00000000U);
  169. io_write_32(GPU_ACT6, 0x00000000U);
  170. io_write_32(GPU_ACT7, 0x00000000U);
  171. /* RT bus Leaf setting */
  172. io_write_32(RT_ACT0, 0x00000000U);
  173. io_write_32(RT_ACT1, 0x00000000U);
  174. /* CCI bus Leaf setting */
  175. io_write_32(CPU_ACT0, 0x00000003U);
  176. io_write_32(CPU_ACT1, 0x00000003U);
  177. io_write_32(CPU_ACT2, 0x00000003U);
  178. io_write_32(CPU_ACT3, 0x00000003U);
  179. io_write_32(QOSCTRL_RAEN, 0x00000001U);
  180. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  181. /* re-write training setting */
  182. io_write_32(QOSWT_WTREF,
  183. ((QOSWT_WTREF_SLOT1_EN << 16) | QOSWT_WTREF_SLOT0_EN));
  184. io_write_32(QOSWT_WTSET0,
  185. ((QOSWT_WTSET0_PERIOD0_H3_20 << 16) |
  186. (QOSWT_WTSET0_SSLOT0 << 8) | QOSWT_WTSET0_SLOTSLOT0));
  187. io_write_32(QOSWT_WTSET1,
  188. ((QOSWT_WTSET1_PERIOD1_H3_20 << 16) |
  189. (QOSWT_WTSET1_SSLOT1 << 8) | QOSWT_WTSET1_SLOTSLOT1));
  190. io_write_32(QOSWT_WTEN, QOSWT_WTEN_ENABLE);
  191. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  192. io_write_32(QOSCTRL_STATQC, 0x00000001U);
  193. #else
  194. NOTICE("BL2: QoS is None\n");
  195. io_write_32(QOSCTRL_RAEN, 0x00000001U);
  196. #endif /* !(RCAR_QOS_TYPE == RCAR_QOS_NONE) */
  197. }