clk.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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_set_rate - Ask the sandbox clock test device to set a
  98. * clock's rate.
  99. *
  100. * @dev: The sandbox clock test (client) devivce.
  101. * @id: The test device's clock ID to configure.
  102. * @return: The new rate of the clock.
  103. */
  104. ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate);
  105. /**
  106. * sandbox_clk_test_enable - Ask the sandbox clock test device to enable a
  107. * clock.
  108. *
  109. * @dev: The sandbox clock test (client) devivce.
  110. * @id: The test device's clock ID to configure.
  111. * @return: 0 if OK, or a negative error code.
  112. */
  113. int sandbox_clk_test_enable(struct udevice *dev, int id);
  114. /**
  115. * sandbox_clk_test_enable_bulk - Ask the sandbox clock test device to enable
  116. * all clocks in it's clock bulk struct.
  117. *
  118. * @dev: The sandbox clock test (client) devivce.
  119. * @return: 0 if OK, or a negative error code.
  120. */
  121. int sandbox_clk_test_enable_bulk(struct udevice *dev);
  122. /**
  123. * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
  124. * clock.
  125. *
  126. * @dev: The sandbox clock test (client) devivce.
  127. * @id: The test device's clock ID to configure.
  128. * @return: 0 if OK, or a negative error code.
  129. */
  130. int sandbox_clk_test_disable(struct udevice *dev, int id);
  131. /**
  132. * sandbox_clk_test_disable_bulk - Ask the sandbox clock test device to disable
  133. * all clocks in it's clock bulk struct.
  134. *
  135. * @dev: The sandbox clock test (client) devivce.
  136. * @return: 0 if OK, or a negative error code.
  137. */
  138. int sandbox_clk_test_disable_bulk(struct udevice *dev);
  139. /**
  140. * sandbox_clk_test_free - Ask the sandbox clock test device to free its
  141. * clocks.
  142. *
  143. * @dev: The sandbox clock test (client) devivce.
  144. * @return: 0 if OK, or a negative error code.
  145. */
  146. int sandbox_clk_test_free(struct udevice *dev);
  147. /**
  148. * sandbox_clk_test_release_bulk - Ask the sandbox clock test device to release
  149. * all clocks in it's clock bulk struct.
  150. *
  151. * @dev: The sandbox clock test (client) devivce.
  152. * @return: 0 if OK, or a negative error code.
  153. */
  154. int sandbox_clk_test_release_bulk(struct udevice *dev);
  155. /**
  156. * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
  157. * clocks are valid.
  158. *
  159. * @dev: The sandbox clock test (client) devivce.
  160. * @return: 0 if OK, or a negative error code.
  161. */
  162. int sandbox_clk_test_valid(struct udevice *dev);
  163. /**
  164. * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
  165. * clocks are valid.
  166. *
  167. * @dev: The sandbox clock test (client) devivce.
  168. * @return: 0 if OK, or a negative error code.
  169. */
  170. struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
  171. #endif