qos_init_g2e_v10.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_init_g2e_v10.h"
  10. #include "../qos_common.h"
  11. #include "../qos_reg.h"
  12. #define RCAR_QOS_VERSION "rev.0.05"
  13. #define REF_ARS_ARBSTOPCYCLE_G2E (((SL_INIT_SSLOTCLK_G2E) - 5U) << 16U)
  14. #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT
  15. #if RCAR_REF_INT == RCAR_REF_DEFAULT
  16. #include "qos_init_g2e_v10_mstat390.h"
  17. #else
  18. #include "qos_init_g2e_v10_mstat780.h"
  19. #endif /* RCAR_REF_INT == RCAR_REF_DEFAULT */
  20. #endif /* RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT */
  21. static const struct rcar_gen3_dbsc_qos_settings g2e_qos[] = {
  22. /* BUFCAM settings */
  23. { DBSC_DBCAM0CNF1, 0x00043218U },
  24. { DBSC_DBCAM0CNF2, 0x000000F4U },
  25. { DBSC_DBSCHCNT0, 0x000F0037U },
  26. { DBSC_DBSCHSZ0, 0x00000001U },
  27. { DBSC_DBSCHRW0, 0x22421111U },
  28. /* DDR3 */
  29. { DBSC_SCFCTST2, 0x012F1123U },
  30. /* QoS Settings */
  31. { DBSC_DBSCHQOS00, 0x00000F00U },
  32. { DBSC_DBSCHQOS01, 0x00000B00U },
  33. { DBSC_DBSCHQOS02, 0x00000000U },
  34. { DBSC_DBSCHQOS03, 0x00000000U },
  35. { DBSC_DBSCHQOS40, 0x00000300U },
  36. { DBSC_DBSCHQOS41, 0x000002F0U },
  37. { DBSC_DBSCHQOS42, 0x00000200U },
  38. { DBSC_DBSCHQOS43, 0x00000100U },
  39. { DBSC_DBSCHQOS90, 0x00000100U },
  40. { DBSC_DBSCHQOS91, 0x000000F0U },
  41. { DBSC_DBSCHQOS92, 0x000000A0U },
  42. { DBSC_DBSCHQOS93, 0x00000040U },
  43. { DBSC_DBSCHQOS130, 0x00000100U },
  44. { DBSC_DBSCHQOS131, 0x000000F0U },
  45. { DBSC_DBSCHQOS132, 0x000000A0U },
  46. { DBSC_DBSCHQOS133, 0x00000040U },
  47. { DBSC_DBSCHQOS140, 0x000000C0U },
  48. { DBSC_DBSCHQOS141, 0x000000B0U },
  49. { DBSC_DBSCHQOS142, 0x00000080U },
  50. { DBSC_DBSCHQOS143, 0x00000040U },
  51. { DBSC_DBSCHQOS150, 0x00000040U },
  52. { DBSC_DBSCHQOS151, 0x00000030U },
  53. { DBSC_DBSCHQOS152, 0x00000020U },
  54. { DBSC_DBSCHQOS153, 0x00000010U },
  55. };
  56. void qos_init_g2e_v10(void)
  57. {
  58. rzg_qos_dbsc_setting(g2e_qos, ARRAY_SIZE(g2e_qos), true);
  59. /* DRAM Split Address mapping */
  60. #if RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_4CH
  61. #if RCAR_LSI == RCAR_RZ_G2E
  62. #error "Don't set DRAM Split 4ch(G2E)"
  63. #else
  64. ERROR("DRAM Split 4ch not supported.(G2E)");
  65. panic();
  66. #endif
  67. #elif (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_2CH)
  68. #if RCAR_LSI == RCAR_RZ_G2E
  69. #error "Don't set DRAM Split 2ch(G2E)"
  70. #else
  71. ERROR("DRAM Split 2ch not supported.(G2E)");
  72. panic();
  73. #endif
  74. #else
  75. NOTICE("BL2: DRAM Split is OFF\n");
  76. #endif
  77. #if !(RCAR_QOS_TYPE == RCAR_QOS_NONE)
  78. #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT
  79. NOTICE("BL2: QoS is default setting(%s)\n", RCAR_QOS_VERSION);
  80. #endif
  81. #if RCAR_REF_INT == RCAR_REF_DEFAULT
  82. NOTICE("BL2: DRAM refresh interval 3.9 usec\n");
  83. #else
  84. NOTICE("BL2: DRAM refresh interval 7.8 usec\n");
  85. #endif
  86. mmio_write_32(QOSCTRL_RAS, 0x00000020U);
  87. mmio_write_64(QOSCTRL_DANN, 0x0404020002020201UL);
  88. mmio_write_32(QOSCTRL_DANT, 0x00100804U);
  89. mmio_write_32(QOSCTRL_FSS, 0x0000000AU);
  90. mmio_write_32(QOSCTRL_INSFC, 0x06330001U);
  91. mmio_write_32(QOSCTRL_EARLYR, 0x00000000U);
  92. mmio_write_32(QOSCTRL_RACNT0, 0x00010003U);
  93. mmio_write_32(QOSCTRL_SL_INIT, SL_INIT_REFFSSLOT |
  94. SL_INIT_SLOTSSLOT | SL_INIT_SSLOTCLK_G2E);
  95. mmio_write_32(QOSCTRL_REF_ARS, REF_ARS_ARBSTOPCYCLE_G2E);
  96. /* QOSBW SRAM setting */
  97. uint32_t i;
  98. for (i = 0U; i < ARRAY_SIZE(mstat_fix); i++) {
  99. mmio_write_64(QOSBW_FIX_QOS_BANK0 + i * 8U, mstat_fix[i]);
  100. mmio_write_64(QOSBW_FIX_QOS_BANK1 + i * 8U, mstat_fix[i]);
  101. }
  102. for (i = 0U; i < ARRAY_SIZE(mstat_be); i++) {
  103. mmio_write_64(QOSBW_BE_QOS_BANK0 + i * 8U, mstat_be[i]);
  104. mmio_write_64(QOSBW_BE_QOS_BANK1 + i * 8U, mstat_be[i]);
  105. }
  106. /* RT bus Leaf setting */
  107. mmio_write_32(RT_ACT0, 0x00000000U);
  108. mmio_write_32(RT_ACT1, 0x00000000U);
  109. /* CCI bus Leaf setting */
  110. mmio_write_32(CPU_ACT0, 0x00000003U);
  111. mmio_write_32(CPU_ACT1, 0x00000003U);
  112. mmio_write_32(QOSCTRL_RAEN, 0x00000001U);
  113. mmio_write_32(QOSCTRL_STATQC, 0x00000001U);
  114. #else
  115. NOTICE("BL2: QoS is None\n");
  116. mmio_write_32(QOSCTRL_RAEN, 0x00000001U);
  117. #endif
  118. }