Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
clk.c File Reference
#include <linux/clk-private.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/err.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/of.h>

Go to the source code of this file.

Functions

 late_initcall (clk_disable_unused)
 
const char__clk_get_name (struct clk *clk)
 
struct clk_hw * __clk_get_hw (struct clk *clk)
 
u8 __clk_get_num_parents (struct clk *clk)
 
struct clk__clk_get_parent (struct clk *clk)
 
int __clk_get_enable_count (struct clk *clk)
 
int __clk_get_prepare_count (struct clk *clk)
 
unsigned long __clk_get_rate (struct clk *clk)
 
unsigned long __clk_get_flags (struct clk *clk)
 
int __clk_is_enabled (struct clk *clk)
 
struct clk__clk_lookup (const char *name)
 
void __clk_unprepare (struct clk *clk)
 
void clk_unprepare (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_unprepare)
 
int __clk_prepare (struct clk *clk)
 
int clk_prepare (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_prepare)
 
void clk_disable (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_disable)
 
int clk_enable (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_enable)
 
unsigned long __clk_round_rate (struct clk *clk, unsigned long rate)
 
long clk_round_rate (struct clk *clk, unsigned long rate)
 
 EXPORT_SYMBOL_GPL (clk_round_rate)
 
unsigned long clk_get_rate (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_get_rate)
 
int clk_set_rate (struct clk *clk, unsigned long rate)
 
 EXPORT_SYMBOL_GPL (clk_set_rate)
 
struct clkclk_get_parent (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_get_parent)
 
void __clk_reparent (struct clk *clk, struct clk *new_parent)
 
int clk_set_parent (struct clk *clk, struct clk *parent)
 
 EXPORT_SYMBOL_GPL (clk_set_parent)
 
int __clk_init (struct device *dev, struct clk *clk)
 
struct clk__clk_register (struct device *dev, struct clk_hw *hw)
 
 EXPORT_SYMBOL_GPL (__clk_register)
 
struct clkclk_register (struct device *dev, struct clk_hw *hw)
 
 EXPORT_SYMBOL_GPL (clk_register)
 
void clk_unregister (struct clk *clk)
 
 EXPORT_SYMBOL_GPL (clk_unregister)
 
int clk_notifier_register (struct clk *clk, struct notifier_block *nb)
 
 EXPORT_SYMBOL_GPL (clk_notifier_register)
 
int clk_notifier_unregister (struct clk *clk, struct notifier_block *nb)
 
 EXPORT_SYMBOL_GPL (clk_notifier_unregister)
 

Function Documentation

int __clk_get_enable_count ( struct clk clk)
inline

Definition at line 272 of file clk.c.

unsigned long __clk_get_flags ( struct clk clk)
inline

Definition at line 303 of file clk.c.

struct clk_hw* __clk_get_hw ( struct clk clk)
read

Definition at line 257 of file clk.c.

const char* __clk_get_name ( struct clk clk)
inline

Definition at line 252 of file clk.c.

u8 __clk_get_num_parents ( struct clk clk)
inline

Definition at line 262 of file clk.c.

struct clk* __clk_get_parent ( struct clk clk)
read

Definition at line 267 of file clk.c.

int __clk_get_prepare_count ( struct clk clk)
inline

Definition at line 277 of file clk.c.

unsigned long __clk_get_rate ( struct clk clk)

Definition at line 282 of file clk.c.

int __clk_init ( struct device dev,
struct clk clk 
)

__clk_init - initialize the data structures in a struct clk : device initializing this clk, placeholder for now : clk being initialized

Initializes the lists in struct clk, queries the hardware for the parent and rate and sets them both.

Definition at line 1196 of file clk.c.

int __clk_is_enabled ( struct clk clk)

Definition at line 308 of file clk.c.

struct clk* __clk_lookup ( const char name)
read

Definition at line 347 of file clk.c.

int __clk_prepare ( struct clk clk)

Definition at line 413 of file clk.c.

struct clk* __clk_register ( struct device dev,
struct clk_hw *  hw 
)
read

__clk_register - register a clock and return a cookie.

Same as clk_register, except that the .clk field inside hw shall point to a preallocated (generally statically allocated) struct clk. None of the fields of the struct clk need to be initialized.

The data pointed to by .init and .clk field shall NOT be marked as init data.

__clk_register is only exposed via clk-private.h and is intended for use with very large numbers of clocks that need to be statically initialized. It is a layering violation to include clk-private.h from any code which implements a clock's .ops; as such any statically initialized clock data MUST be in a separate C file from the logic that implements it's operations. Returns 0 on success, otherwise an error code.

Definition at line 1343 of file clk.c.

void __clk_reparent ( struct clk clk,
struct clk new_parent 
)

Definition at line 1029 of file clk.c.

unsigned long __clk_round_rate ( struct clk clk,
unsigned long  rate 
)

__clk_round_rate - round the given rate for a clk : round the rate of this clock

Caller must hold prepare_lock. Useful for clk_ops such as .set_rate

Definition at line 566 of file clk.c.

void __clk_unprepare ( struct clk clk)

Definition at line 375 of file clk.c.

void clk_disable ( struct clk clk)

clk_disable - gate a clock : the clk being gated

clk_disable must not sleep, which differentiates it from clk_unprepare. In a simple case, clk_disable can be used instead of clk_unprepare to gate a clk if the operation is fast and will never sleep. One example is a SoC-internal clk which is controlled via simple register writes. In the complex case a clk gate operation may require a fast and a slow part. It is this reason that clk_unprepare and clk_disable are not mutually exclusive. In fact clk_disable must be called before clk_unprepare.

Definition at line 495 of file clk.c.

int clk_enable ( struct clk clk)

clk_enable - ungate a clock : the clk being ungated

clk_enable must not sleep, which differentiates it from clk_prepare. In a simple case, clk_enable can be used instead of clk_prepare to ungate a clk if the operation will never sleep. One example is a SoC-internal clk which is controlled via simple register writes. In the complex case a clk ungate operation may require a fast and a slow part. It is this reason that clk_enable and clk_prepare are not mutually exclusive. In fact clk_prepare must be called before clk_enable. Returns 0 on success, -EERROR otherwise.

Definition at line 547 of file clk.c.

struct clk* clk_get_parent ( struct clk clk)
read

clk_get_parent - return the parent of a clk : the clk whose parent gets returned

Simply returns clk->parent. Returns NULL if clk is NULL.

Definition at line 959 of file clk.c.

unsigned long clk_get_rate ( struct clk clk)

clk_get_rate - return the rate of clk : the clk whose rate is being returned

Simply returns the cached rate of the clk, unless CLK_GET_RATE_NOCACHE flag is set, which means a recalc_rate will be issued. If clk is NULL then returns 0.

Definition at line 693 of file clk.c.

int clk_notifier_register ( struct clk clk,
struct notifier_block nb 
)

clk_notifier_register - add a clk rate change notifier : struct clk * to watch : struct notifier_block * with callback info

Request notification when clk's rate changes. This uses an SRCU notifier because we want it to block and notifier unregistrations are uncommon. The callbacks associated with the notifier must not re-enter into the clk framework by calling any top-level clk APIs; this will cause a nested prepare_lock mutex.

Pre-change notifier callbacks will be passed the current, pre-change rate of the clk via struct clk_notifier_data.old_rate. The new, post-change rate of the clk is passed via struct clk_notifier_data.new_rate.

Post-change notifiers will pass the now-current, post-change rate of the clk in both struct clk_notifier_data.old_rate and struct clk_notifier_data.new_rate.

Abort-change notifiers are effectively the opposite of pre-change notifiers: the original pre-change clk rate is passed in via struct clk_notifier_data.new_rate and the failed post-change rate is passed in via struct clk_notifier_data.old_rate.

clk_notifier_register() must be called from non-atomic context. Returns -EINVAL if called with null arguments, -ENOMEM upon allocation failure; otherwise, passes along the return value of srcu_notifier_chain_register().

Definition at line 1479 of file clk.c.

int clk_notifier_unregister ( struct clk clk,
struct notifier_block nb 
)

clk_notifier_unregister - remove a clk rate change notifier : struct clk * : struct notifier_block * with callback info

Request no further notification for changes to 'clk' and frees memory allocated in clk_notifier_register.

Returns -EINVAL if called with null arguments; otherwise, passes along the return value of srcu_notifier_chain_unregister().

Definition at line 1528 of file clk.c.

int clk_prepare ( struct clk clk)

clk_prepare - prepare a clock source : the clk being prepared

clk_prepare may sleep, which differentiates it from clk_enable. In a simple case, clk_prepare can be used instead of clk_enable to ungate a clk if the operation may sleep. One example is a clk which is accessed over I2c. In the complex case a clk ungate operation may require a fast and a slow part. It is this reason that clk_prepare and clk_enable are not mutually exclusive. In fact clk_prepare must be called before clk_enable. Returns 0 on success, -EERROR otherwise.

Definition at line 451 of file clk.c.

struct clk* clk_register ( struct device dev,
struct clk_hw *  hw 
)
read

clk_register - allocate a new clock, register it and return an opaque cookie : device that is registering this clock : link to hardware-specific clock data

clk_register is the primary interface for populating the clock tree with new clock nodes. It returns a pointer to the newly allocated struct clk which cannot be dereferenced by driver code but may be used in conjuction with the rest of the clock API. In the event of an error clk_register will return an error code; drivers must test for an error code after calling clk_register.

Definition at line 1375 of file clk.c.

long clk_round_rate ( struct clk clk,
unsigned long  rate 
)

clk_round_rate - round the given rate for a clk : the clk for which we are rounding a rate : the rate which is to be rounded

Takes in a rate as input and rounds it to a rate that the clk can actually use which is then returned. If clk doesn't support round_rate operation then the parent rate is returned.

Definition at line 595 of file clk.c.

int clk_set_parent ( struct clk clk,
struct clk parent 
)

clk_set_parent - switch the parent of a mux clk : the mux clk whose input we are switching : the new input to clk

Re-parent clk to use parent as it's new input source. If clk has the CLK_SET_PARENT_GATE flag set then clk must be gated for this operation to succeed. After successfully changing clk's parent clk_set_parent will update the clk topology, sysfs topology and propagate rate recalculation via __clk_recalc_rates. Returns 0 on success, -EERROR otherwise.

Definition at line 1142 of file clk.c.

int clk_set_rate ( struct clk clk,
unsigned long  rate 
)

clk_set_rate - specify a new rate for clk : the clk whose rate is being changed : the new rate for clk

In the simplest case clk_set_rate will only adjust the rate of clk.

Setting the CLK_SET_RATE_PARENT flag allows the rate change operation to propagate up to clk's parent; whether or not this happens depends on the outcome of clk's .round_rate implementation. If *parent_rate is unchanged after calling .round_rate then upstream parent propagation is ignored. If *parent_rate comes back with a new rate for clk's parent then we propagate up to clk's parent and set it's rate. Upward propagation will continue until either a clk does not support the CLK_SET_RATE_PARENT flag or .round_rate stops requesting changes to clk's parent_rate.

Rate changes are accomplished via tree traversal that also recalculates the rates for the clocks and fires off POST_RATE_CHANGE notifiers.

Returns 0 on success, -EERROR otherwise.

Definition at line 906 of file clk.c.

void clk_unprepare ( struct clk clk)

clk_unprepare - undo preparation of a clock source : the clk being unprepare

clk_unprepare may sleep, which differentiates it from clk_disable. In a simple case, clk_unprepare can be used instead of clk_disable to gate a clk if the operation may sleep. One example is a clk which is accessed over I2c. In the complex case a clk gate operation may require a fast and a slow part. It is this reason that clk_unprepare and clk_disable are not mutually exclusive. In fact clk_disable must be called before clk_unprepare.

Definition at line 405 of file clk.c.

void clk_unregister ( struct clk clk)

clk_unregister - unregister a currently registered clock : clock to unregister

Currently unimplemented.

Definition at line 1444 of file clk.c.

EXPORT_SYMBOL_GPL ( clk_unprepare  )
EXPORT_SYMBOL_GPL ( clk_prepare  )
EXPORT_SYMBOL_GPL ( clk_disable  )
EXPORT_SYMBOL_GPL ( clk_enable  )
EXPORT_SYMBOL_GPL ( clk_round_rate  )
EXPORT_SYMBOL_GPL ( clk_get_rate  )
EXPORT_SYMBOL_GPL ( clk_set_rate  )
EXPORT_SYMBOL_GPL ( clk_get_parent  )
EXPORT_SYMBOL_GPL ( clk_set_parent  )
EXPORT_SYMBOL_GPL ( __clk_register  )
EXPORT_SYMBOL_GPL ( clk_register  )
EXPORT_SYMBOL_GPL ( clk_unregister  )
EXPORT_SYMBOL_GPL ( clk_notifier_register  )
EXPORT_SYMBOL_GPL ( clk_notifier_unregister  )
late_initcall ( clk_disable_unused  )