qos_common.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2021, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef QOS_COMMON_H
  7. #define QOS_COMMON_H
  8. #define RCAR_REF_DEFAULT 0U
  9. /* define used for get_refperiod. */
  10. /* REFPERIOD_CYCLE need smaller than QOSWT_WTSET0_CYCLEs */
  11. #if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF default */
  12. #define REFPERIOD_CYCLE /* unit:ns */ \
  13. ((126U * BASE_SUB_SLOT_NUM * 1000U) / 400U)
  14. #else /* REF option */
  15. #define REFPERIOD_CYCLE /* unit:ns */ \
  16. ((252U * BASE_SUB_SLOT_NUM * 1000U) / 400U)
  17. #endif
  18. #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RZ_G2M)
  19. /* define used for G2M */
  20. #if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
  21. #define SUB_SLOT_CYCLE_G2M_11 0x7EU /* 126 */
  22. #define SUB_SLOT_CYCLE_G2M_30 0x7EU /* 126 */
  23. #else /* REF 3.9usec */
  24. #define SUB_SLOT_CYCLE_G2M_11 0xFCU /* 252 */
  25. #define SUB_SLOT_CYCLE_G2M_30 0xFCU /* 252 */
  26. #endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
  27. #define SL_INIT_SSLOTCLK_G2M_11 (SUB_SLOT_CYCLE_G2M_11 - 1U)
  28. #define SL_INIT_SSLOTCLK_G2M_30 (SUB_SLOT_CYCLE_G2M_30 - 1U)
  29. #define QOSWT_WTSET0_CYCLE_G2M_11 /* unit:ns */ \
  30. ((SUB_SLOT_CYCLE_G2M_11 * BASE_SUB_SLOT_NUM * 1000U) / OPERATING_FREQ)
  31. #define QOSWT_WTSET0_CYCLE_G2M_30 /* unit:ns */ \
  32. ((SUB_SLOT_CYCLE_G2M_30 * BASE_SUB_SLOT_NUM * 1000U) / OPERATING_FREQ)
  33. #endif
  34. #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RZ_G2N)
  35. /* define used for G2N */
  36. #if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
  37. #define SUB_SLOT_CYCLE_G2N 0x7EU /* 126 */
  38. #else /* REF 3.9usec */
  39. #define SUB_SLOT_CYCLE_G2N 0xFCU /* 252 */
  40. #endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
  41. #define SL_INIT_SSLOTCLK_G2N (SUB_SLOT_CYCLE_G2N - 1U)
  42. #define QOSWT_WTSET0_CYCLE_G2N /* unit:ns */ \
  43. ((SUB_SLOT_CYCLE_G2N * BASE_SUB_SLOT_NUM * 1000U) / OPERATING_FREQ)
  44. #endif /* (RCAR_LSI == RZ_G2N) */
  45. #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RZ_G2H)
  46. /* define used for G2H */
  47. #if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
  48. #define SUB_SLOT_CYCLE_G2H 0x7EU /* 126 */
  49. #else /* REF 3.9usec */
  50. #define SUB_SLOT_CYCLE_G2H 0xFCU /* 252 */
  51. #endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
  52. #define SL_INIT_SSLOTCLK_G2H (SUB_SLOT_CYCLE_G2H - 1U)
  53. #define QOSWT_WTSET0_CYCLE_G2H /* unit:ns */ \
  54. ((SUB_SLOT_CYCLE_G2H * BASE_SUB_SLOT_NUM * 1000U) / OPERATING_FREQ)
  55. #endif
  56. #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RZ_G2E)
  57. /* define used for G2E */
  58. #if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 3.9usec */
  59. #define SUB_SLOT_CYCLE_G2E 0xAFU /* 175 */
  60. #else /* REF 7.8usec */
  61. #define SUB_SLOT_CYCLE_G2E 0x15EU /* 350 */
  62. #endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
  63. #define OPERATING_FREQ_G2E 266U /* MHz */
  64. #define SL_INIT_SSLOTCLK_G2E (SUB_SLOT_CYCLE_G2E - 1U)
  65. #endif
  66. #define OPERATING_FREQ 400U /* MHz */
  67. #define BASE_SUB_SLOT_NUM 0x6U
  68. #define SUB_SLOT_CYCLE 0x7EU /* 126 */
  69. #define QOSWT_WTSET0_CYCLE /* unit:ns */ \
  70. ((SUB_SLOT_CYCLE * BASE_SUB_SLOT_NUM * 1000U) / OPERATING_FREQ)
  71. #define SL_INIT_REFFSSLOT (0x3U << 24U)
  72. #define SL_INIT_SLOTSSLOT ((BASE_SUB_SLOT_NUM - 1U) << 16U)
  73. #define SL_INIT_SSLOTCLK (SUB_SLOT_CYCLE - 1U)
  74. typedef struct {
  75. uintptr_t addr;
  76. uint64_t value;
  77. } mstat_slot_t;
  78. struct rcar_gen3_dbsc_qos_settings {
  79. uint32_t reg;
  80. uint32_t val;
  81. };
  82. extern uint32_t qos_init_ddr_ch;
  83. extern uint8_t qos_init_ddr_phyvalid;
  84. void rzg_qos_dbsc_setting(const struct rcar_gen3_dbsc_qos_settings *qos,
  85. unsigned int qos_size, bool dbsc_wren);
  86. #endif /* QOS_COMMON_H */