qos_init_g2m_v11.c 7.4 KB

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