blob: 75933eb8841fb86bdf7efc999dfe0a4bffa68928 [file] [log] [blame]
Stephen Warren135aa952016-06-17 09:44:00 -06001/*
2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 * Copyright (c) 2016, NVIDIA CORPORATION.
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#ifndef _CLK_UCLASS_H
10#define _CLK_UCLASS_H
11
12/* See clk.h for background documentation. */
13
14#include <clk.h>
Simon Glassa4e0ef52017-05-18 20:09:40 -060015
16struct ofnode_phandle_args;
Stephen Warren135aa952016-06-17 09:44:00 -060017
18/**
19 * struct clk_ops - The functions that a clock driver must implement.
20 */
21struct clk_ops {
22 /**
23 * of_xlate - Translate a client's device-tree (OF) clock specifier.
24 *
25 * The clock core calls this function as the first step in implementing
26 * a client's clk_get_by_*() call.
27 *
28 * If this function pointer is set to NULL, the clock core will use a
29 * default implementation, which assumes #clock-cells = <1>, and that
30 * the DT cell contains a simple integer clock ID.
31 *
32 * At present, the clock API solely supports device-tree. If this
33 * changes, other xxx_xlate() functions may be added to support those
34 * other mechanisms.
35 *
36 * @clock: The clock struct to hold the translation result.
37 * @args: The clock specifier values from device tree.
38 * @return 0 if OK, or a negative error code.
39 */
40 int (*of_xlate)(struct clk *clock,
Simon Glassa4e0ef52017-05-18 20:09:40 -060041 struct ofnode_phandle_args *args);
Stephen Warren135aa952016-06-17 09:44:00 -060042 /**
43 * request - Request a translated clock.
44 *
45 * The clock core calls this function as the second step in
46 * implementing a client's clk_get_by_*() call, following a successful
47 * xxx_xlate() call, or as the only step in implementing a client's
48 * clk_request() call.
49 *
50 * @clock: The clock struct to request; this has been fille in by
51 * a previoux xxx_xlate() function call, or by the caller
52 * of clk_request().
53 * @return 0 if OK, or a negative error code.
54 */
55 int (*request)(struct clk *clock);
56 /**
57 * free - Free a previously requested clock.
58 *
59 * This is the implementation of the client clk_free() API.
60 *
61 * @clock: The clock to free.
62 * @return 0 if OK, or a negative error code.
63 */
64 int (*free)(struct clk *clock);
65 /**
66 * get_rate() - Get current clock rate.
67 *
68 * @clk: The clock to query.
69 * @return clock rate in Hz, or -ve error code
70 */
71 ulong (*get_rate)(struct clk *clk);
72 /**
73 * set_rate() - Set current clock rate.
74 *
75 * @clk: The clock to manipulate.
76 * @rate: New clock rate in Hz.
77 * @return new rate, or -ve error code.
78 */
79 ulong (*set_rate)(struct clk *clk, ulong rate);
80 /**
Philipp Tomsichf7d10462018-01-08 11:15:08 +010081 * set_parent() - Set current clock parent
82 *
83 * @clk: The clock to manipulate.
84 * @parent: New clock parent.
85 * @return zero on success, or -ve error code.
86 */
87 int (*set_parent)(struct clk *clk, struct clk *parent);
88 /**
Stephen Warren135aa952016-06-17 09:44:00 -060089 * enable() - Enable a clock.
90 *
91 * @clk: The clock to manipulate.
92 * @return zero on success, or -ve error code.
93 */
94 int (*enable)(struct clk *clk);
95 /**
96 * disable() - Disable a clock.
97 *
98 * @clk: The clock to manipulate.
99 * @return zero on success, or -ve error code.
100 */
101 int (*disable)(struct clk *clk);
102};
103
104#endif