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