2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/types.h>
16 int soc_clk_dump(void);
20 * get_rate() - Get current clock rate
22 * @dev: Device to check (UCLASS_CLK)
23 * @return clock rate in Hz, or -ve error code
25 ulong (*get_rate)(struct udevice *dev);
28 * set_rate() - Set current clock rate
30 * @dev: Device to adjust
31 * @rate: New clock rate in Hz
32 * @return new rate, or -ve error code
34 ulong (*set_rate)(struct udevice *dev, ulong rate);
37 * enable() - Enable the clock for a peripheral
39 * @dev: clock provider
40 * @periph: Peripheral ID to enable
41 * @return zero on success, or -ve error code
43 int (*enable)(struct udevice *dev, int periph);
46 * get_periph_rate() - Get clock rate for a peripheral
48 * @dev: Device to check (UCLASS_CLK)
49 * @periph: Peripheral ID to check
50 * @return clock rate in Hz, or -ve error code
52 ulong (*get_periph_rate)(struct udevice *dev, int periph);
55 * set_periph_rate() - Set current clock rate for a peripheral
57 * @dev: Device to update (UCLASS_CLK)
58 * @periph: Peripheral ID to update
59 * @return new clock rate in Hz, or -ve error code
61 ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
64 #define clk_get_ops(dev) ((struct clk_ops *)(dev)->driver->ops)
67 * clk_get_rate() - Get current clock rate
69 * @dev: Device to check (UCLASS_CLK)
70 * @return clock rate in Hz, or -ve error code
72 ulong clk_get_rate(struct udevice *dev);
75 * clk_set_rate() - Set current clock rate
77 * @dev: Device to adjust
78 * @rate: New clock rate in Hz
79 * @return new rate, or -ve error code
81 ulong clk_set_rate(struct udevice *dev, ulong rate);
84 * clk_enable() - Enable the clock for a peripheral
86 * @dev: clock provider
87 * @periph: Peripheral ID to enable
88 * @return zero on success, or -ve error code
90 int clk_enable(struct udevice *dev, int periph);
93 * clk_get_periph_rate() - Get current clock rate for a peripheral
95 * @dev: Device to check (UCLASS_CLK)
96 * @return clock rate in Hz, -ve error code
98 ulong clk_get_periph_rate(struct udevice *dev, int periph);
101 * clk_set_periph_rate() - Set current clock rate for a peripheral
103 * @dev: Device to update (UCLASS_CLK)
104 * @periph: Peripheral ID to update
105 * @return new clock rate in Hz, or -ve error code
107 ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
109 #if CONFIG_IS_ENABLED(OF_CONTROL)
111 * clk_get_by_index() - look up a clock referenced by a device
113 * Parse a device's 'clocks' list, returning information on the indexed clock,
114 * ensuring that it is activated.
116 * @dev: Device containing the clock reference
117 * @index: Clock index to return (0 = first)
118 * @clk_devp: Returns clock device
119 * @return: Peripheral ID for the device to control. This is the first
120 * argument after the clock node phandle. If there is no arguemnt,
121 * returns 0. Return -ve error code on any error
123 int clk_get_by_index(struct udevice *dev, int index, struct udevice **clk_devp);
125 static inline int clk_get_by_index(struct udevice *dev, int index,
126 struct udevice **clk_devp)