2 * linux/include/linux/clk.h
4 * Copyright (C) 2004 ARM Limited.
5 * Written by Deep Blue Solutions Limited.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
24 * struct clk - an machine class defined object / cookie.
29 * clk_get - lookup and obtain a reference to a clock producer.
30 * @dev: device for clock "consumer"
31 * @id: clock comsumer ID
33 * Returns a struct clk corresponding to the clock producer, or
34 * valid IS_ERR() condition containing errno. The implementation
35 * uses @dev and @id to determine the clock consumer, and thereby
36 * the clock producer. (IOW, @id may be identical strings, but
37 * clk_get may return different clock producers depending on @dev.)
39 * Drivers must assume that the clock source is not enabled.
41 * clk_get should not be called from within interrupt context.
43 struct clk
*clk_get(struct device
*dev
, const char *id
);
46 * clk_prepare - prepare a clock source
49 * This prepares the clock source for use.
51 * Must not be called from within atomic context.
53 #ifdef CONFIG_HAVE_CLK_PREPARE
54 int clk_prepare(struct clk
*clk
);
56 static inline int clk_prepare(struct clk
*clk
)
64 * clk_enable - inform the system when the clock source should be running.
67 * If the clock can not be enabled/disabled, this should return success.
69 * May be called from atomic contexts.
71 * Returns success (0) or negative errno.
73 int clk_enable(struct clk
*clk
);
76 * clk_disable - inform the system when the clock source is no longer required.
79 * Inform the system that a clock source is no longer required by
80 * a driver and may be shut down.
82 * May be called from atomic contexts.
84 * Implementation detail: if the clock source is shared between
85 * multiple drivers, clk_enable() calls must be balanced by the
86 * same number of clk_disable() calls for the clock source to be
89 void clk_disable(struct clk
*clk
);
93 * clk_unprepare - undo preparation of a clock source
96 * This undoes a previously prepared clock. The caller must balance
97 * the number of prepare and unprepare calls.
99 * Must not be called from within atomic context.
101 #ifdef CONFIG_HAVE_CLK_PREPARE
102 void clk_unprepare(struct clk
*clk
);
104 static inline void clk_unprepare(struct clk
*clk
)
111 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
112 * This is only valid once the clock source has been enabled.
115 unsigned long clk_get_rate(struct clk
*clk
);
118 * clk_put - "free" the clock source
121 * Note: drivers must ensure that all clk_enable calls made on this
122 * clock source are balanced by clk_disable calls prior to calling
125 * clk_put should not be called from within interrupt context.
127 void clk_put(struct clk
*clk
);
131 * The remaining APIs are optional for machine class support.
136 * clk_round_rate - adjust a rate to the exact rate a clock can provide
138 * @rate: desired clock rate in Hz
140 * Returns rounded clock rate in Hz, or negative errno.
142 long clk_round_rate(struct clk
*clk
, unsigned long rate
);
145 * clk_set_rate - set the clock rate for a clock source
147 * @rate: desired clock rate in Hz
149 * Returns success (0) or negative errno.
151 int clk_set_rate(struct clk
*clk
, unsigned long rate
);
154 * clk_set_parent - set the parent clock source for this clock
156 * @parent: parent clock source
158 * Returns success (0) or negative errno.
160 int clk_set_parent(struct clk
*clk
, struct clk
*parent
);
163 * clk_get_parent - get the parent clock source for this clock
166 * Returns struct clk corresponding to parent clock source, or
167 * valid IS_ERR() condition containing errno.
169 struct clk
*clk_get_parent(struct clk
*clk
);
172 * clk_get_sys - get a clock based upon the device name
173 * @dev_id: device name
174 * @con_id: connection ID
176 * Returns a struct clk corresponding to the clock producer, or
177 * valid IS_ERR() condition containing errno. The implementation
178 * uses @dev_id and @con_id to determine the clock consumer, and
179 * thereby the clock producer. In contrast to clk_get() this function
180 * takes the device name instead of the device itself for identification.
182 * Drivers must assume that the clock source is not enabled.
184 * clk_get_sys should not be called from within interrupt context.
186 struct clk
*clk_get_sys(const char *dev_id
, const char *con_id
);
189 * clk_add_alias - add a new clock alias
190 * @alias: name for clock alias
191 * @alias_dev_name: device name
192 * @id: platform specific clock name
195 * Allows using generic clock names for drivers by adding a new alias.
196 * Assumes clkdev, see clkdev.h for more info.
198 int clk_add_alias(const char *alias
, const char *alias_dev_name
, char *id
,
This page took 0.034059 seconds and 5 git commands to generate.