Merge tag 'dm-pull-29oct19' of git://git.denx.de/u-boot-dm
[oweals/u-boot.git] / arch / sandbox / include / asm / clk.h
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
25         SANDBOX_CLK_ID_COUNT,
26 };
27
28 /**
29  * enum sandbox_clk_test_id - Identity of the clocks consumed by the sandbox
30  * clock test device.
31  *
32  * These are the IDs the clock consumer knows the clocks as.
33  */
34 enum sandbox_clk_test_id {
35         SANDBOX_CLK_TEST_ID_FIXED,
36         SANDBOX_CLK_TEST_ID_SPI,
37         SANDBOX_CLK_TEST_ID_I2C,
38         SANDBOX_CLK_TEST_ID_DEVM1,
39         SANDBOX_CLK_TEST_ID_DEVM2,
40         SANDBOX_CLK_TEST_ID_DEVM_NULL,
41
42         SANDBOX_CLK_TEST_ID_COUNT,
43 };
44
45 #define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
46
47 /**
48  * sandbox_clk_query_rate - Query the current rate 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 ulong sandbox_clk_query_rate(struct udevice *dev, int id);
55 /**
56  * sandbox_clk_query_enable - Query the enable 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_enable(struct udevice *dev, int id);
63 /**
64  * sandbox_clk_query_requested - Query the requested state of a sandbox clock.
65  *
66  * @dev:        The sandbox clock provider device.
67  * @id:         The clock to query.
68  * @return:     The rate of the clock.
69  */
70 int sandbox_clk_query_requested(struct udevice *dev, int id);
71
72 /**
73  * sandbox_clk_test_get - Ask the sandbox clock test device to request its
74  * clocks.
75  *
76  * @dev:        The sandbox clock test (client) devivce.
77  * @return:     0 if OK, or a negative error code.
78  */
79 int sandbox_clk_test_get(struct udevice *dev);
80
81 /**
82  * sandbox_clk_test_devm_get - Ask the sandbox clock test device to request its
83  * clocks using the managed API.
84  *
85  * @dev:        The sandbox clock test (client) devivce.
86  * @return:     0 if OK, or a negative error code.
87  */
88 int sandbox_clk_test_devm_get(struct udevice *dev);
89
90 /**
91  * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its
92  * clocks with the bulk clk API.
93  *
94  * @dev:        The sandbox clock test (client) devivce.
95  * @return:     0 if OK, or a negative error code.
96  */
97 int sandbox_clk_test_get_bulk(struct udevice *dev);
98 /**
99  * sandbox_clk_test_get_rate - Ask the sandbox clock test device to query a
100  * clock's rate.
101  *
102  * @dev:        The sandbox clock test (client) devivce.
103  * @id:         The test device's clock ID to query.
104  * @return:     The rate of the clock.
105  */
106 ulong sandbox_clk_test_get_rate(struct udevice *dev, int id);
107 /**
108  * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a
109  * clock's rate.
110  *
111  * @dev:        The sandbox clock test (client) devivce.
112  * @id:         The test device's clock ID to configure.
113  * @return:     The new rate of the clock.
114  */
115 ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate);
116 /**
117  * sandbox_clk_test_enable - Ask the sandbox clock test device to enable a
118  * clock.
119  *
120  * @dev:        The sandbox clock test (client) devivce.
121  * @id:         The test device's clock ID to configure.
122  * @return:     0 if OK, or a negative error code.
123  */
124 int sandbox_clk_test_enable(struct udevice *dev, int id);
125 /**
126  * sandbox_clk_test_enable_bulk - Ask the sandbox clock test device to enable
127  * all clocks in it's clock bulk struct.
128  *
129  * @dev:        The sandbox clock test (client) devivce.
130  * @return:     0 if OK, or a negative error code.
131  */
132 int sandbox_clk_test_enable_bulk(struct udevice *dev);
133 /**
134  * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
135  * clock.
136  *
137  * @dev:        The sandbox clock test (client) devivce.
138  * @id:         The test device's clock ID to configure.
139  * @return:     0 if OK, or a negative error code.
140  */
141 int sandbox_clk_test_disable(struct udevice *dev, int id);
142 /**
143  * sandbox_clk_test_disable_bulk - Ask the sandbox clock test device to disable
144  * all clocks in it's clock bulk struct.
145  *
146  * @dev:        The sandbox clock test (client) devivce.
147  * @return:     0 if OK, or a negative error code.
148  */
149 int sandbox_clk_test_disable_bulk(struct udevice *dev);
150 /**
151  * sandbox_clk_test_free - Ask the sandbox clock test device to free its
152  * clocks.
153  *
154  * @dev:        The sandbox clock test (client) devivce.
155  * @return:     0 if OK, or a negative error code.
156  */
157 int sandbox_clk_test_free(struct udevice *dev);
158 /**
159  * sandbox_clk_test_release_bulk - Ask the sandbox clock test device to release
160  * all clocks in it's clock bulk struct.
161  *
162  * @dev:        The sandbox clock test (client) devivce.
163  * @return:     0 if OK, or a negative error code.
164  */
165 int sandbox_clk_test_release_bulk(struct udevice *dev);
166 /**
167  * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
168  * clocks are valid.
169  *
170  * @dev:        The sandbox clock test (client) devivce.
171  * @return:     0 if OK, or a negative error code.
172  */
173 int sandbox_clk_test_valid(struct udevice *dev);
174 /**
175  * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
176  * clocks are valid.
177  *
178  * @dev:        The sandbox clock test (client) devivce.
179  * @return:     0 if OK, or a negative error code.
180  */
181 struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
182
183 #endif