2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 * Copyright (c) 2016, NVIDIA CORPORATION.
6 * SPDX-License-Identifier: GPL-2.0+
12 /* See clk.h for background documentation. */
16 struct ofnode_phandle_args;
19 * struct clk_ops - The functions that a clock driver must implement.
23 * of_xlate - Translate a client's device-tree (OF) clock specifier.
25 * The clock core calls this function as the first step in implementing
26 * a client's clk_get_by_*() call.
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.
32 * At present, the clock API solely supports device-tree. If this
33 * changes, other xxx_xlate() functions may be added to support those
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.
40 int (*of_xlate)(struct clk *clock,
41 struct ofnode_phandle_args *args);
43 * request - Request a translated clock.
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
50 * @clock: The clock struct to request; this has been fille in by
51 * a previoux xxx_xlate() function call, or by the caller
53 * @return 0 if OK, or a negative error code.
55 int (*request)(struct clk *clock);
57 * free - Free a previously requested clock.
59 * This is the implementation of the client clk_free() API.
61 * @clock: The clock to free.
62 * @return 0 if OK, or a negative error code.
64 int (*free)(struct clk *clock);
66 * get_rate() - Get current clock rate.
68 * @clk: The clock to query.
69 * @return clock rate in Hz, or -ve error code
71 ulong (*get_rate)(struct clk *clk);
73 * set_rate() - Set current clock rate.
75 * @clk: The clock to manipulate.
76 * @rate: New clock rate in Hz.
77 * @return new rate, or -ve error code.
79 ulong (*set_rate)(struct clk *clk, ulong rate);
81 * enable() - Enable a clock.
83 * @clk: The clock to manipulate.
84 * @return zero on success, or -ve error code.
86 int (*enable)(struct clk *clk);
88 * disable() - Disable a clock.
90 * @clk: The clock to manipulate.
91 * @return zero on success, or -ve error code.
93 int (*disable)(struct clk *clk);