clk.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2016, NVIDIA CORPORATION.
  4. */
  5. #ifndef __SANDBOX_CLK_H
  6. #define __SANDBOX_CLK_H
  7. #include <common.h>
  8. struct udevice;
  9. /**
  10. * enum sandbox_clk_id - Identity of clocks implemented by the sandbox clock
  11. * provider.
  12. *
  13. * These IDs are within/relative-to the clock provider.
  14. */
  15. enum sandbox_clk_id {
  16. SANDBOX_CLK_ID_SPI,
  17. SANDBOX_CLK_ID_I2C,
  18. SANDBOX_CLK_ID_UART1,
  19. SANDBOX_CLK_ID_UART2,
  20. SANDBOX_CLK_ID_BUS,
  21. SANDBOX_CLK_ID_COUNT,
  22. };
  23. /**
  24. * enum sandbox_clk_test_id - Identity of the clocks consumed by the sandbox
  25. * clock test device.
  26. *
  27. * These are the IDs the clock consumer knows the clocks as.
  28. */
  29. enum sandbox_clk_test_id {
  30. SANDBOX_CLK_TEST_ID_FIXED,
  31. SANDBOX_CLK_TEST_ID_SPI,
  32. SANDBOX_CLK_TEST_ID_I2C,
  33. SANDBOX_CLK_TEST_ID_DEVM1,
  34. SANDBOX_CLK_TEST_ID_DEVM2,
  35. SANDBOX_CLK_TEST_ID_DEVM_NULL,
  36. SANDBOX_CLK_TEST_ID_COUNT,
  37. };
  38. #define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
  39. /**
  40. * sandbox_clk_query_rate - Query the current rate of a sandbox clock.
  41. *
  42. * @dev: The sandbox clock provider device.
  43. * @id: The clock to query.
  44. * @return: The rate of the clock.
  45. */
  46. ulong sandbox_clk_query_rate(struct udevice *dev, int id);
  47. /**
  48. * sandbox_clk_query_enable - Query the enable state of a sandbox clock.
  49. *
  50. * @dev: The sandbox clock provider device.
  51. * @id: The clock to query.
  52. * @return: The rate of the clock.
  53. */
  54. int sandbox_clk_query_enable(struct udevice *dev, int id);
  55. /**
  56. * sandbox_clk_query_requested - Query the requested state of a sandbox clock.
  57. *
  58. * @dev: The sandbox clock provider device.
  59. * @id: The clock to query.
  60. * @return: The rate of the clock.
  61. */
  62. int sandbox_clk_query_requested(struct udevice *dev, int id);
  63. /**
  64. * sandbox_clk_test_get - Ask the sandbox clock test device to request its
  65. * clocks.
  66. *
  67. * @dev: The sandbox clock test (client) devivce.
  68. * @return: 0 if OK, or a negative error code.
  69. */
  70. int sandbox_clk_test_get(struct udevice *dev);
  71. /**
  72. * sandbox_clk_test_devm_get - Ask the sandbox clock test device to request its
  73. * clocks using the managed API.
  74. *
  75. * @dev: The sandbox clock test (client) devivce.
  76. * @return: 0 if OK, or a negative error code.
  77. */
  78. int sandbox_clk_test_devm_get(struct udevice *dev);
  79. /**
  80. * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its
  81. * clocks with the bulk clk API.
  82. *
  83. * @dev: The sandbox clock test (client) devivce.
  84. * @return: 0 if OK, or a negative error code.
  85. */
  86. int sandbox_clk_test_get_bulk(struct udevice *dev);
  87. /**
  88. * sandbox_clk_test_get_rate - Ask the sandbox clock test device to query a
  89. * clock's rate.
  90. *
  91. * @dev: The sandbox clock test (client) devivce.
  92. * @id: The test device's clock ID to query.
  93. * @return: The rate of the clock.
  94. */
  95. ulong sandbox_clk_test_get_rate(struct udevice *dev, int id);
  96. /**
  97. * sandbox_clk_test_round_rate - Ask the sandbox clock test device to round a
  98. * clock's rate.
  99. *
  100. * @dev: The sandbox clock test (client) device.
  101. * @id: The test device's clock ID to configure.
  102. * @return: The rounded rate of the clock.
  103. */
  104. ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate);
  105. /**
  106. * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a
  107. * clock's rate.
  108. *
  109. * @dev: The sandbox clock test (client) devivce.
  110. * @id: The test device's clock ID to configure.
  111. * @return: The new rate of the clock.
  112. */
  113. ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate);
  114. /**
  115. * sandbox_clk_test_enable - Ask the sandbox clock test device to enable a
  116. * clock.
  117. *
  118. * @dev: The sandbox clock test (client) devivce.
  119. * @id: The test device's clock ID to configure.
  120. * @return: 0 if OK, or a negative error code.
  121. */
  122. int sandbox_clk_test_enable(struct udevice *dev, int id);
  123. /**
  124. * sandbox_clk_test_enable_bulk - Ask the sandbox clock test device to enable
  125. * all clocks in it's clock bulk struct.
  126. *
  127. * @dev: The sandbox clock test (client) devivce.
  128. * @return: 0 if OK, or a negative error code.
  129. */
  130. int sandbox_clk_test_enable_bulk(struct udevice *dev);
  131. /**
  132. * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
  133. * clock.
  134. *
  135. * @dev: The sandbox clock test (client) devivce.
  136. * @id: The test device's clock ID to configure.
  137. * @return: 0 if OK, or a negative error code.
  138. */
  139. int sandbox_clk_test_disable(struct udevice *dev, int id);
  140. /**
  141. * sandbox_clk_test_disable_bulk - Ask the sandbox clock test device to disable
  142. * all clocks in it's clock bulk struct.
  143. *
  144. * @dev: The sandbox clock test (client) devivce.
  145. * @return: 0 if OK, or a negative error code.
  146. */
  147. int sandbox_clk_test_disable_bulk(struct udevice *dev);
  148. /**
  149. * sandbox_clk_test_free - Ask the sandbox clock test device to free its
  150. * clocks.
  151. *
  152. * @dev: The sandbox clock test (client) devivce.
  153. * @return: 0 if OK, or a negative error code.
  154. */
  155. int sandbox_clk_test_free(struct udevice *dev);
  156. /**
  157. * sandbox_clk_test_release_bulk - Ask the sandbox clock test device to release
  158. * all clocks in it's clock bulk struct.
  159. *
  160. * @dev: The sandbox clock test (client) devivce.
  161. * @return: 0 if OK, or a negative error code.
  162. */
  163. int sandbox_clk_test_release_bulk(struct udevice *dev);
  164. /**
  165. * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
  166. * clocks are valid.
  167. *
  168. * @dev: The sandbox clock test (client) devivce.
  169. * @return: 0 if OK, or a negative error code.
  170. */
  171. int sandbox_clk_test_valid(struct udevice *dev);
  172. /**
  173. * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
  174. * clocks are valid.
  175. *
  176. * @dev: The sandbox clock test (client) devivce.
  177. * @return: 0 if OK, or a negative error code.
  178. */
  179. struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
  180. #endif