1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2016, NVIDIA CORPORATION.
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,
22 	SANDBOX_CLK_ID_UART1,
23 	SANDBOX_CLK_ID_UART2,
24 	SANDBOX_CLK_ID_BUS,
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,
39 	SANDBOX_CLK_TEST_ID_DEVM1,
40 	SANDBOX_CLK_TEST_ID_DEVM2,
41 	SANDBOX_CLK_TEST_ID_DEVM_NULL,
42 
43 	SANDBOX_CLK_TEST_ID_COUNT,
44 };
45 
46 #define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
47 
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);
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);
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) device.
78  * @return:	0 if OK, or a negative error code.
79  */
80 int sandbox_clk_test_get(struct udevice *dev);
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) device.
87  * @return:	0 if OK, or a negative error code.
88  */
89 int sandbox_clk_test_devm_get(struct udevice *dev);
90 
91 /**
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) device.
96  * @return:	0 if OK, or a negative error code.
97  */
98 int sandbox_clk_test_get_bulk(struct udevice *dev);
99 /**
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) device.
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_round_rate - Ask the sandbox clock test device to round a
110  * clock's rate.
111  *
112  * @dev:	The sandbox clock test (client) device.
113  * @id:		The test device's clock ID to configure.
114  * @return:	The rounded rate of the clock.
115  */
116 ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate);
117 /**
118  * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a
119  * clock's rate.
120  *
121  * @dev:	The sandbox clock test (client) device.
122  * @id:		The test device's clock ID to configure.
123  * @return:	The new rate of the clock.
124  */
125 ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate);
126 /**
127  * sandbox_clk_test_enable - Ask the sandbox clock test device to enable a
128  * clock.
129  *
130  * @dev:	The sandbox clock test (client) device.
131  * @id:		The test device's clock ID to configure.
132  * @return:	0 if OK, or a negative error code.
133  */
134 int sandbox_clk_test_enable(struct udevice *dev, int id);
135 /**
136  * sandbox_clk_test_enable_bulk - Ask the sandbox clock test device to enable
137  * all clocks in it's clock bulk struct.
138  *
139  * @dev:	The sandbox clock test (client) device.
140  * @return:	0 if OK, or a negative error code.
141  */
142 int sandbox_clk_test_enable_bulk(struct udevice *dev);
143 /**
144  * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
145  * clock.
146  *
147  * @dev:	The sandbox clock test (client) device.
148  * @id:		The test device's clock ID to configure.
149  * @return:	0 if OK, or a negative error code.
150  */
151 int sandbox_clk_test_disable(struct udevice *dev, int id);
152 /**
153  * sandbox_clk_test_disable_bulk - Ask the sandbox clock test device to disable
154  * all clocks in it's clock bulk struct.
155  *
156  * @dev:	The sandbox clock test (client) device.
157  * @return:	0 if OK, or a negative error code.
158  */
159 int sandbox_clk_test_disable_bulk(struct udevice *dev);
160 /**
161  * sandbox_clk_test_free - Ask the sandbox clock test device to free its
162  * clocks.
163  *
164  * @dev:	The sandbox clock test (client) device.
165  * @return:	0 if OK, or a negative error code.
166  */
167 int sandbox_clk_test_free(struct udevice *dev);
168 /**
169  * sandbox_clk_test_release_bulk - Ask the sandbox clock test device to release
170  * all clocks in it's clock bulk struct.
171  *
172  * @dev:	The sandbox clock test (client) device.
173  * @return:	0 if OK, or a negative error code.
174  */
175 int sandbox_clk_test_release_bulk(struct udevice *dev);
176 /**
177  * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
178  * clocks are valid.
179  *
180  * @dev:	The sandbox clock test (client) device.
181  * @return:	0 if OK, or a negative error code.
182  */
183 int sandbox_clk_test_valid(struct udevice *dev);
184 /**
185  * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
186  * clocks are valid.
187  *
188  * @dev:	The sandbox clock test (client) device.
189  * @return:	0 if OK, or a negative error code.
190  */
191 struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
192 
193 #endif
194