blob: 1573e4a13474edd025d54fc1bb154aa8a2499db2 [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,
Stephen Warren135aa952016-06-17 09:44:00 -060024
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 */
34enum sandbox_clk_test_id {
35 SANDBOX_CLK_TEST_ID_FIXED,
36 SANDBOX_CLK_TEST_ID_SPI,
37 SANDBOX_CLK_TEST_ID_I2C,
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020038 SANDBOX_CLK_TEST_ID_DEVM1,
39 SANDBOX_CLK_TEST_ID_DEVM2,
40 SANDBOX_CLK_TEST_ID_DEVM_NULL,
Stephen Warren135aa952016-06-17 09:44:00 -060041
42 SANDBOX_CLK_TEST_ID_COUNT,
43};
44
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020045#define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
46
Stephen Warren135aa952016-06-17 09:44:00 -060047/**
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 */
54ulong 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 */
62int sandbox_clk_query_enable(struct udevice *dev, int id);
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020063/**
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 */
70int sandbox_clk_query_requested(struct udevice *dev, int id);
Stephen Warren135aa952016-06-17 09:44:00 -060071
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 */
79int sandbox_clk_test_get(struct udevice *dev);
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +020080
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 */
88int sandbox_clk_test_devm_get(struct udevice *dev);
89
Stephen Warren135aa952016-06-17 09:44:00 -060090/**
Neil Armstrong65388d02018-04-03 11:44:19 +020091 * 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 */
97int sandbox_clk_test_get_bulk(struct udevice *dev);
98/**
Stephen Warren135aa952016-06-17 09:44:00 -060099 * 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 */
106ulong 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 */
115ulong 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 */
124int sandbox_clk_test_enable(struct udevice *dev, int id);
125/**
Neil Armstrong65388d02018-04-03 11:44:19 +0200126 * 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 */
132int sandbox_clk_test_enable_bulk(struct udevice *dev);
133/**
Stephen Warren135aa952016-06-17 09:44:00 -0600134 * 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 */
141int sandbox_clk_test_disable(struct udevice *dev, int id);
142/**
Neil Armstrong65388d02018-04-03 11:44:19 +0200143 * 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 */
149int sandbox_clk_test_disable_bulk(struct udevice *dev);
150/**
Stephen Warren135aa952016-06-17 09:44:00 -0600151 * 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 */
157int sandbox_clk_test_free(struct udevice *dev);
Neil Armstrong65388d02018-04-03 11:44:19 +0200158/**
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 */
165int sandbox_clk_test_release_bulk(struct udevice *dev);
Fabrice Gasnier1fe243a2018-07-24 16:31:28 +0200166/**
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 */
173int sandbox_clk_test_valid(struct udevice *dev);
Jean-Jacques Hiblotdd2e0ce2019-10-22 14:00:05 +0200174/**
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 */
181struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
Stephen Warren135aa952016-06-17 09:44:00 -0600182
183#endif