qos_init_m3_v11.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * Copyright (c) 2017-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_m3_v11.h"
  11. #define RCAR_QOS_VERSION "rev.0.19"
  12. #define QOSWT_TIME_BANK0 20000000U /* unit:ns */
  13. #define QOSWT_WTEN_ENABLE 0x1U
  14. #define QOSCTRL_REF_ARS_ARBSTOPCYCLE_M3_11 (SL_INIT_SSLOTCLK_M3_11 - 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_M3_11 \
  26. ((QOSWT_TIME_BANK0 / QOSWT_WTSET0_CYCLE_M3_11) - 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_M3_11 \
  30. ((QOSWT_TIME_BANK0 / QOSWT_WTSET0_CYCLE_M3_11) - 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_m3_v11_mstat195.h"
  36. #else
  37. #include "qos_init_m3_v11_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_m3_v11_qoswt195.h"
  42. #else
  43. #include "qos_init_m3_v11_qoswt390.h"
  44. #endif
  45. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  46. #endif
  47. struct rcar_gen3_dbsc_qos_settings m3_v11_qos[] = {
  48. /* BUFCAM settings */
  49. { DBSC_DBCAM0CNF1, 0x00048218U },
  50. { DBSC_DBCAM0CNF2, 0x000000F4 },
  51. { DBSC_DBCAM0CNF3, 0x00000000 },
  52. { DBSC_DBSCHCNT0, 0x000F0037 },
  53. { DBSC_DBSCHSZ0, 0x00000001 },
  54. { DBSC_DBSCHRW0, 0x22421111 },
  55. /* DDR3 */
  56. { DBSC_SCFCTST2, 0x012F1123 },
  57. /* QoS Settings */
  58. { DBSC_DBSCHQOS00, 0x00000F00 },
  59. { DBSC_DBSCHQOS01, 0x00000B00 },
  60. { DBSC_DBSCHQOS02, 0x00000000 },
  61. { DBSC_DBSCHQOS03, 0x00000000 },
  62. { DBSC_DBSCHQOS40, 0x00000300 },
  63. { DBSC_DBSCHQOS41, 0x000002F0 },
  64. { DBSC_DBSCHQOS42, 0x00000200 },
  65. { DBSC_DBSCHQOS43, 0x00000100 },
  66. { DBSC_DBSCHQOS90, 0x00000100 },
  67. { DBSC_DBSCHQOS91, 0x000000F0 },
  68. { DBSC_DBSCHQOS92, 0x000000A0 },
  69. { DBSC_DBSCHQOS93, 0x00000040 },
  70. { DBSC_DBSCHQOS120, 0x00000040 },
  71. { DBSC_DBSCHQOS121, 0x00000030 },
  72. { DBSC_DBSCHQOS122, 0x00000020 },
  73. { DBSC_DBSCHQOS123, 0x00000010 },
  74. { DBSC_DBSCHQOS130, 0x00000100 },
  75. { DBSC_DBSCHQOS131, 0x000000F0 },
  76. { DBSC_DBSCHQOS132, 0x000000A0 },
  77. { DBSC_DBSCHQOS133, 0x00000040 },
  78. { DBSC_DBSCHQOS140, 0x000000C0 },
  79. { DBSC_DBSCHQOS141, 0x000000B0 },
  80. { DBSC_DBSCHQOS142, 0x00000080 },
  81. { DBSC_DBSCHQOS143, 0x00000040 },
  82. { DBSC_DBSCHQOS150, 0x00000040 },
  83. { DBSC_DBSCHQOS151, 0x00000030 },
  84. { DBSC_DBSCHQOS152, 0x00000020 },
  85. { DBSC_DBSCHQOS153, 0x00000010 },
  86. };
  87. void qos_init_m3_v11(void)
  88. {
  89. rcar_qos_dbsc_setting(m3_v11_qos, ARRAY_SIZE(m3_v11_qos), false);
  90. /* DRAM Split Address mapping */
  91. #if RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_4CH
  92. #if RCAR_LSI == RCAR_M3
  93. #error "Don't set DRAM Split 4ch(M3)"
  94. #else
  95. ERROR("DRAM Split 4ch not supported.(M3)");
  96. panic();
  97. #endif
  98. #elif (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_2CH) || \
  99. (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_AUTO)
  100. NOTICE("BL2: DRAM Split is 2ch\n");
  101. io_write_32(AXI_ADSPLCR0, 0x00000000U);
  102. io_write_32(AXI_ADSPLCR1, ADSPLCR0_ADRMODE_DEFAULT
  103. | ADSPLCR0_SPLITSEL(0xFFU)
  104. | ADSPLCR0_AREA(0x1CU)
  105. | ADSPLCR0_SWP);
  106. io_write_32(AXI_ADSPLCR2, 0x00001004U);
  107. io_write_32(AXI_ADSPLCR3, 0x00000000U);
  108. #else
  109. NOTICE("BL2: DRAM Split is OFF\n");
  110. #endif
  111. #if !(RCAR_QOS_TYPE == RCAR_QOS_NONE)
  112. #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT
  113. NOTICE("BL2: QoS is default setting(%s)\n", RCAR_QOS_VERSION);
  114. #endif
  115. #if RCAR_REF_INT == RCAR_REF_DEFAULT
  116. NOTICE("BL2: DRAM refresh interval 1.95 usec\n");
  117. #else
  118. NOTICE("BL2: DRAM refresh interval 3.9 usec\n");
  119. #endif
  120. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  121. NOTICE("BL2: Periodic Write DQ Training\n");
  122. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  123. io_write_32(QOSCTRL_RAS, 0x00000044U);
  124. io_write_64(QOSCTRL_DANN, 0x0404020002020201UL);
  125. io_write_32(QOSCTRL_DANT, 0x0020100AU);
  126. io_write_32(QOSCTRL_INSFC, 0x06330001U);
  127. io_write_32(QOSCTRL_RACNT0, 0x02010003U); /* GPU Boost Mode ON */
  128. io_write_32(QOSCTRL_SL_INIT,
  129. SL_INIT_REFFSSLOT | SL_INIT_SLOTSSLOT |
  130. SL_INIT_SSLOTCLK_M3_11);
  131. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  132. io_write_32(QOSCTRL_REF_ARS,
  133. ((QOSCTRL_REF_ARS_ARBSTOPCYCLE_M3_11 << 16)));
  134. #else
  135. io_write_32(QOSCTRL_REF_ARS, 0x00330000U);
  136. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  137. uint32_t i;
  138. for (i = 0U; i < ARRAY_SIZE(mstat_fix); i++) {
  139. io_write_64(QOSBW_FIX_QOS_BANK0 + i * 8, mstat_fix[i]);
  140. io_write_64(QOSBW_FIX_QOS_BANK1 + i * 8, mstat_fix[i]);
  141. }
  142. for (i = 0U; i < ARRAY_SIZE(mstat_be); i++) {
  143. io_write_64(QOSBW_BE_QOS_BANK0 + i * 8, mstat_be[i]);
  144. io_write_64(QOSBW_BE_QOS_BANK1 + i * 8, mstat_be[i]);
  145. }
  146. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  147. for (i = 0U; i < ARRAY_SIZE(qoswt_fix); i++) {
  148. io_write_64(QOSWT_FIX_WTQOS_BANK0 + i * 8, qoswt_fix[i]);
  149. io_write_64(QOSWT_FIX_WTQOS_BANK1 + i * 8, qoswt_fix[i]);
  150. }
  151. for (i = 0U; i < ARRAY_SIZE(qoswt_be); i++) {
  152. io_write_64(QOSWT_BE_WTQOS_BANK0 + i * 8, qoswt_be[i]);
  153. io_write_64(QOSWT_BE_WTQOS_BANK1 + i * 8, qoswt_be[i]);
  154. }
  155. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  156. /* 3DG bus Leaf setting */
  157. io_write_32(GPU_ACT_GRD, 0x00001234U);
  158. io_write_32(GPU_ACT0, 0x00000000U);
  159. io_write_32(GPU_ACT1, 0x00000000U);
  160. io_write_32(GPU_ACT2, 0x00000000U);
  161. io_write_32(GPU_ACT3, 0x00000000U);
  162. /* RT bus Leaf setting */
  163. io_write_32(RT_ACT0, 0x00000000U);
  164. io_write_32(RT_ACT1, 0x00000000U);
  165. /* CCI bus Leaf setting */
  166. io_write_32(CPU_ACT0, 0x00000003U);
  167. io_write_32(CPU_ACT1, 0x00000003U);
  168. io_write_32(CPU_ACT2, 0x00000003U);
  169. io_write_32(CPU_ACT3, 0x00000003U);
  170. io_write_32(QOSCTRL_RAEN, 0x00000001U);
  171. #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE
  172. /* re-write training setting */
  173. io_write_32(QOSWT_WTREF,
  174. ((QOSWT_WTREF_SLOT1_EN << 16) | QOSWT_WTREF_SLOT0_EN));
  175. io_write_32(QOSWT_WTSET0,
  176. ((QOSWT_WTSET0_PERIOD0_M3_11 << 16) |
  177. (QOSWT_WTSET0_SSLOT0 << 8) | QOSWT_WTSET0_SLOTSLOT0));
  178. io_write_32(QOSWT_WTSET1,
  179. ((QOSWT_WTSET1_PERIOD1_M3_11 << 16) |
  180. (QOSWT_WTSET1_SSLOT1 << 8) | QOSWT_WTSET1_SLOTSLOT1));
  181. io_write_32(QOSWT_WTEN, QOSWT_WTEN_ENABLE);
  182. #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
  183. io_write_32(QOSCTRL_STATQC, 0x00000001U);
  184. #else
  185. NOTICE("BL2: QoS is None\n");
  186. io_write_32(QOSCTRL_RAEN, 0x00000001U);
  187. #endif /* !(RCAR_QOS_TYPE == RCAR_QOS_NONE) */
  188. }