clock.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
  4. * Copyright (c) 2019, Linaro Limited
  5. */
  6. #ifndef SCMI_MSG_CLOCK_H
  7. #define SCMI_MSG_CLOCK_H
  8. #include <stdint.h>
  9. #include <lib/utils_def.h>
  10. #define SCMI_PROTOCOL_VERSION_CLOCK 0x20000U
  11. /*
  12. * Identifiers of the SCMI Clock Management Protocol commands
  13. */
  14. enum scmi_clock_command_id {
  15. SCMI_CLOCK_ATTRIBUTES = 0x003,
  16. SCMI_CLOCK_DESCRIBE_RATES = 0x004,
  17. SCMI_CLOCK_RATE_SET = 0x005,
  18. SCMI_CLOCK_RATE_GET = 0x006,
  19. SCMI_CLOCK_CONFIG_SET = 0x007,
  20. };
  21. /* Protocol attributes */
  22. #define SCMI_CLOCK_CLOCK_COUNT_MASK GENMASK(15, 0)
  23. #define SCMI_CLOCK_MAX_PENDING_TRANSITIONS_MASK GENMASK(23, 16)
  24. #define SCMI_CLOCK_PROTOCOL_ATTRIBUTES(_max_pending, _clk_count) \
  25. ((((_max_pending) << 16) & SCMI_CLOCK_MAX_PENDING_TRANSITIONS_MASK) | \
  26. (((_clk_count) & SCMI_CLOCK_CLOCK_COUNT_MASK)))
  27. struct scmi_clock_attributes_a2p {
  28. uint32_t clock_id;
  29. };
  30. #define SCMI_CLOCK_NAME_LENGTH_MAX 16U
  31. struct scmi_clock_attributes_p2a {
  32. int32_t status;
  33. uint32_t attributes;
  34. char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
  35. };
  36. /*
  37. * Clock Rate Get
  38. */
  39. struct scmi_clock_rate_get_a2p {
  40. uint32_t clock_id;
  41. };
  42. struct scmi_clock_rate_get_p2a {
  43. int32_t status;
  44. uint32_t rate[2];
  45. };
  46. /*
  47. * Clock Rate Set
  48. */
  49. /* If set, set the new clock rate asynchronously */
  50. #define SCMI_CLOCK_RATE_SET_ASYNC_POS 0
  51. /* If set, do not send a delayed asynchronous response */
  52. #define SCMI_CLOCK_RATE_SET_NO_DELAYED_RESPONSE_POS 1
  53. /* Round up, if set, otherwise round down */
  54. #define SCMI_CLOCK_RATE_SET_ROUND_UP_POS 2
  55. /* If set, the platform chooses the appropriate rounding mode */
  56. #define SCMI_CLOCK_RATE_SET_ROUND_AUTO_POS 3
  57. #define SCMI_CLOCK_RATE_SET_ASYNC_MASK \
  58. BIT(SCMI_CLOCK_RATE_SET_ASYNC_POS)
  59. #define SCMI_CLOCK_RATE_SET_NO_DELAYED_RESPONSE_MASK \
  60. BIT(SCMI_CLOCK_RATE_SET_NO_DELAYED_RESPONSE_POS)
  61. #define SCMI_CLOCK_RATE_SET_ROUND_UP_MASK \
  62. BIT(SCMI_CLOCK_RATE_SET_ROUND_UP_POS)
  63. #define SCMI_CLOCK_RATE_SET_ROUND_AUTO_MASK \
  64. BIT(SCMI_CLOCK_RATE_SET_ROUND_AUTO_POS)
  65. struct scmi_clock_rate_set_a2p {
  66. uint32_t flags;
  67. uint32_t clock_id;
  68. uint32_t rate[2];
  69. };
  70. struct scmi_clock_rate_set_p2a {
  71. int32_t status;
  72. };
  73. /*
  74. * Clock Config Set
  75. */
  76. #define SCMI_CLOCK_CONFIG_SET_ENABLE_POS 0
  77. #define SCMI_CLOCK_CONFIG_SET_ENABLE_MASK \
  78. BIT(SCMI_CLOCK_CONFIG_SET_ENABLE_POS)
  79. struct scmi_clock_config_set_a2p {
  80. uint32_t clock_id;
  81. uint32_t attributes;
  82. };
  83. struct scmi_clock_config_set_p2a {
  84. int32_t status;
  85. };
  86. /*
  87. * Clock Describe Rates
  88. */
  89. #define SCMI_CLOCK_RATE_FORMAT_RANGE 1U
  90. #define SCMI_CLOCK_RATE_FORMAT_LIST 0U
  91. #define SCMI_CLOCK_DESCRIBE_RATES_REMAINING_MASK GENMASK_32(31, 16)
  92. #define SCMI_CLOCK_DESCRIBE_RATES_REMAINING_POS 16
  93. #define SCMI_CLOCK_DESCRIBE_RATES_FORMAT_MASK BIT(12)
  94. #define SCMI_CLOCK_DESCRIBE_RATES_FORMAT_POS 12
  95. #define SCMI_CLOCK_DESCRIBE_RATES_COUNT_MASK GENMASK_32(11, 0)
  96. #define SCMI_CLOCK_DESCRIBE_RATES_NUM_RATES_FLAGS(_count, _fmt, _rem_rates) \
  97. ( \
  98. ((_count) & SCMI_CLOCK_DESCRIBE_RATES_COUNT_MASK) | \
  99. (((_rem_rates) << SCMI_CLOCK_DESCRIBE_RATES_REMAINING_POS) & \
  100. SCMI_CLOCK_DESCRIBE_RATES_REMAINING_MASK) | \
  101. (((_fmt) << SCMI_CLOCK_DESCRIBE_RATES_FORMAT_POS) & \
  102. SCMI_CLOCK_DESCRIBE_RATES_FORMAT_MASK) \
  103. )
  104. struct scmi_clock_rate {
  105. uint32_t low;
  106. uint32_t high;
  107. };
  108. struct scmi_clock_describe_rates_a2p {
  109. uint32_t clock_id;
  110. uint32_t rate_index;
  111. };
  112. struct scmi_clock_describe_rates_p2a {
  113. int32_t status;
  114. uint32_t num_rates_flags;
  115. struct scmi_clock_rate rates[];
  116. };
  117. #endif /* SCMI_MSG_CLOCK_H */