blob: c184c4bffcf7b7ade69cc400bfa38119197994fc [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Stephen Warren135aa952016-06-17 09:44:00 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren135aa952016-06-17 09:44:00 -06004 */
5
6#ifndef __SANDBOX_CLK_H
7#define __SANDBOX_CLK_H
8
9#include <common.h>
10
11struct 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 */
19enum sandbox_clk_id {
20 SANDBOX_CLK_ID_SPI,
21 SANDBOX_CLK_ID_I2C,
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020022 SANDBOX_CLK_ID_UART1,
23 SANDBOX_CLK_ID_UART2,
Sean Anderson4a3390f2020-06-24 06:41:12 -040024 SANDBOX_CLK_ID_BUS,
Stephen Warren135aa952016-06-17 09:44:00 -060025
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 */
35enum sandbox_clk_test_id {
36 SANDBOX_CLK_TEST_ID_FIXED,
37 SANDBOX_CLK_TEST_ID_SPI,
38 SANDBOX_CLK_TEST_ID_I2C,
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020039 SANDBOX_CLK_TEST_ID_DEVM1,
40 SANDBOX_CLK_TEST_ID_DEVM2,
41 SANDBOX_CLK_TEST_ID_DEVM_NULL,
Stephen Warren135aa952016-06-17 09:44:00 -060042
43 SANDBOX_CLK_TEST_ID_COUNT,
44};
45
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020046#define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
47
Stephen Warren135aa952016-06-17 09:44:00 -060048/**
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 */
55ulong 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 */
63int sandbox_clk_query_enable(struct udevice *dev, int id);
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020064/**
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 */
71int sandbox_clk_query_requested(struct udevice *dev, int id);
Stephen Warren135aa952016-06-17 09:44:00 -060072
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 */
80int sandbox_clk_test_get(struct udevice *dev);
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020081
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 */
89int sandbox_clk_test_devm_get(struct udevice *dev);
90
Stephen Warren135aa952016-06-17 09:44:00 -060091/**
Neil Armstrong65388d02018-04-03 11:44:19 +020092 * 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 */
98int sandbox_clk_test_get_bulk(struct udevice *dev);
99/**
Stephen Warren135aa952016-06-17 09:44:00 -0600100 * 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 */
107ulong 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 */
116ulong 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 */
125int sandbox_clk_test_enable(struct udevice *dev, int id);
126/**
Neil Armstrong65388d02018-04-03 11:44:19 +0200127 * 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 */
133int sandbox_clk_test_enable_bulk(struct udevice *dev);
134/**
Stephen Warren135aa952016-06-17 09:44:00 -0600135 * 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 */
142int sandbox_clk_test_disable(struct udevice *dev, int id);
143/**
Neil Armstrong65388d02018-04-03 11:44:19 +0200144 * 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 */
150int sandbox_clk_test_disable_bulk(struct udevice *dev);
151/**
Stephen Warren135aa952016-06-17 09:44:00 -0600152 * 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 */
158int sandbox_clk_test_free(struct udevice *dev);
Neil Armstrong65388d02018-04-03 11:44:19 +0200159/**
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 */
166int sandbox_clk_test_release_bulk(struct udevice *dev);
Fabrice Gasnier1fe243a2018-07-24 16:31:28 +0200167/**
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 */
174int sandbox_clk_test_valid(struct udevice *dev);
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +0200175/**
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 */
182struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
Stephen Warren135aa952016-06-17 09:44:00 -0600183
184#endif