blob: 68a8687f578e84a18e52d38c8818bba5560bf4f6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Stephen Warrena9622432016-06-17 09:44:00 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warrena9622432016-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 Hiblot98e84182019-10-22 14:00:05 +020022 SANDBOX_CLK_ID_UART1,
23 SANDBOX_CLK_ID_UART2,
Sean Andersonb7860542020-06-24 06:41:12 -040024 SANDBOX_CLK_ID_BUS,
Stephen Warrena9622432016-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 Hiblot98e84182019-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 Warrena9622432016-06-17 09:44:00 -060042
43 SANDBOX_CLK_TEST_ID_COUNT,
44};
45
Jean-Jacques Hiblot98e84182019-10-22 14:00:05 +020046#define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
47
Stephen Warrena9622432016-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 Hiblot98e84182019-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 Warrena9622432016-06-17 09:44:00 -060072
73/**
74 * sandbox_clk_test_get - Ask the sandbox clock test device to request its
75 * clocks.
76 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +010077 * @dev: The sandbox clock test (client) device.
Stephen Warrena9622432016-06-17 09:44:00 -060078 * @return: 0 if OK, or a negative error code.
79 */
80int sandbox_clk_test_get(struct udevice *dev);
Jean-Jacques Hiblot98e84182019-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 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +010086 * @dev: The sandbox clock test (client) device.
Jean-Jacques Hiblot98e84182019-10-22 14:00:05 +020087 * @return: 0 if OK, or a negative error code.
88 */
89int sandbox_clk_test_devm_get(struct udevice *dev);
90
Stephen Warrena9622432016-06-17 09:44:00 -060091/**
Neil Armstrong567a38b2018-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 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +010095 * @dev: The sandbox clock test (client) device.
Neil Armstrong567a38b2018-04-03 11:44:19 +020096 * @return: 0 if OK, or a negative error code.
97 */
98int sandbox_clk_test_get_bulk(struct udevice *dev);
99/**
Stephen Warrena9622432016-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 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100103 * @dev: The sandbox clock test (client) device.
Stephen Warrena9622432016-06-17 09:44:00 -0600104 * @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/**
Dario Binacchib7f85892020-12-30 00:06:31 +0100109 * 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 */
116ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate);
117/**
Stephen Warrena9622432016-06-17 09:44:00 -0600118 * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a
119 * clock's rate.
120 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100121 * @dev: The sandbox clock test (client) device.
Stephen Warrena9622432016-06-17 09:44:00 -0600122 * @id: The test device's clock ID to configure.
123 * @return: The new rate of the clock.
124 */
125ulong 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 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100130 * @dev: The sandbox clock test (client) device.
Stephen Warrena9622432016-06-17 09:44:00 -0600131 * @id: The test device's clock ID to configure.
132 * @return: 0 if OK, or a negative error code.
133 */
134int sandbox_clk_test_enable(struct udevice *dev, int id);
135/**
Neil Armstrong567a38b2018-04-03 11:44:19 +0200136 * sandbox_clk_test_enable_bulk - Ask the sandbox clock test device to enable
137 * all clocks in it's clock bulk struct.
138 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100139 * @dev: The sandbox clock test (client) device.
Neil Armstrong567a38b2018-04-03 11:44:19 +0200140 * @return: 0 if OK, or a negative error code.
141 */
142int sandbox_clk_test_enable_bulk(struct udevice *dev);
143/**
Stephen Warrena9622432016-06-17 09:44:00 -0600144 * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
145 * clock.
146 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100147 * @dev: The sandbox clock test (client) device.
Stephen Warrena9622432016-06-17 09:44:00 -0600148 * @id: The test device's clock ID to configure.
149 * @return: 0 if OK, or a negative error code.
150 */
151int sandbox_clk_test_disable(struct udevice *dev, int id);
152/**
Neil Armstrong567a38b2018-04-03 11:44:19 +0200153 * sandbox_clk_test_disable_bulk - Ask the sandbox clock test device to disable
154 * all clocks in it's clock bulk struct.
155 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100156 * @dev: The sandbox clock test (client) device.
Neil Armstrong567a38b2018-04-03 11:44:19 +0200157 * @return: 0 if OK, or a negative error code.
158 */
159int sandbox_clk_test_disable_bulk(struct udevice *dev);
160/**
Stephen Warrena9622432016-06-17 09:44:00 -0600161 * sandbox_clk_test_free - Ask the sandbox clock test device to free its
162 * clocks.
163 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100164 * @dev: The sandbox clock test (client) device.
Stephen Warrena9622432016-06-17 09:44:00 -0600165 * @return: 0 if OK, or a negative error code.
166 */
167int sandbox_clk_test_free(struct udevice *dev);
Neil Armstrong567a38b2018-04-03 11:44:19 +0200168/**
169 * sandbox_clk_test_release_bulk - Ask the sandbox clock test device to release
170 * all clocks in it's clock bulk struct.
171 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100172 * @dev: The sandbox clock test (client) device.
Neil Armstrong567a38b2018-04-03 11:44:19 +0200173 * @return: 0 if OK, or a negative error code.
174 */
175int sandbox_clk_test_release_bulk(struct udevice *dev);
Fabrice Gasnier11192712018-07-24 16:31:28 +0200176/**
177 * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
178 * clocks are valid.
179 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100180 * @dev: The sandbox clock test (client) device.
Fabrice Gasnier11192712018-07-24 16:31:28 +0200181 * @return: 0 if OK, or a negative error code.
182 */
183int sandbox_clk_test_valid(struct udevice *dev);
Jean-Jacques Hiblot98e84182019-10-22 14:00:05 +0200184/**
185 * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
186 * clocks are valid.
187 *
Dario Binacchi6a02d3f2021-02-14 15:17:43 +0100188 * @dev: The sandbox clock test (client) device.
Jean-Jacques Hiblot98e84182019-10-22 14:00:05 +0200189 * @return: 0 if OK, or a negative error code.
190 */
191struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
Stephen Warrena9622432016-06-17 09:44:00 -0600192
193#endif