aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clk.h
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-09-22 06:30:50 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-09-27 04:25:02 -0400
commit40d3e0f4942ec12c4521fe1b2a2b774164cd2c80 (patch)
tree2c1fb0c4f3e298a2dcf4d8ddb32b4b1577408833 /include/linux/clk.h
parent6cfa6279edbffa921b7d8c9519bfd83a24ba508e (diff)
clk: provide prepare/unprepare functions
As discussed previously, there's the need on some platforms to run some parts of clk_enable() in contexts which can schedule. The solution which was agreed upon was to provide clk_prepare() and clk_unprepare() to contain this parts, while clk_enable() and clk_disable() perform the atomic part. This patch provides a common definition for clk_prepare() and clk_unprepare() in linux/clk.h, and provides an upgrade path for existing implementation and drivers: drivers can start using clk_prepare() and clk_unprepare() once this patch is merged without having to wait for platform support. Platforms can then start to provide these additional functions. Eventually, HAVE_CLK_PREPARE will be removed from the kernel, and everyone will have to provide these new APIs. Acked-by: Saravana Kannan <skannan@codeaurora.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'include/linux/clk.h')
-rw-r--r--include/linux/clk.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 1d37f42ac294..7213b52b2c0e 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -11,6 +11,8 @@
11#ifndef __LINUX_CLK_H 11#ifndef __LINUX_CLK_H
12#define __LINUX_CLK_H 12#define __LINUX_CLK_H
13 13
14#include <linux/kernel.h>
15
14struct device; 16struct device;
15 17
16/* 18/*
@@ -41,11 +43,31 @@ struct clk;
41struct clk *clk_get(struct device *dev, const char *id); 43struct clk *clk_get(struct device *dev, const char *id);
42 44
43/** 45/**
46 * clk_prepare - prepare a clock source
47 * @clk: clock source
48 *
49 * This prepares the clock source for use.
50 *
51 * Must not be called from within atomic context.
52 */
53#ifdef CONFIG_HAVE_CLK_PREPARE
54int clk_prepare(struct clk *clk);
55#else
56static inline int clk_prepare(struct clk *clk)
57{
58 might_sleep();
59 return 0;
60}
61#endif
62
63/**
44 * clk_enable - inform the system when the clock source should be running. 64 * clk_enable - inform the system when the clock source should be running.
45 * @clk: clock source 65 * @clk: clock source
46 * 66 *
47 * If the clock can not be enabled/disabled, this should return success. 67 * If the clock can not be enabled/disabled, this should return success.
48 * 68 *
69 * May be called from atomic contexts.
70 *
49 * Returns success (0) or negative errno. 71 * Returns success (0) or negative errno.
50 */ 72 */
51int clk_enable(struct clk *clk); 73int clk_enable(struct clk *clk);
@@ -57,6 +79,8 @@ int clk_enable(struct clk *clk);
57 * Inform the system that a clock source is no longer required by 79 * Inform the system that a clock source is no longer required by
58 * a driver and may be shut down. 80 * a driver and may be shut down.
59 * 81 *
82 * May be called from atomic contexts.
83 *
60 * Implementation detail: if the clock source is shared between 84 * Implementation detail: if the clock source is shared between
61 * multiple drivers, clk_enable() calls must be balanced by the 85 * multiple drivers, clk_enable() calls must be balanced by the
62 * same number of clk_disable() calls for the clock source to be 86 * same number of clk_disable() calls for the clock source to be
@@ -64,6 +88,25 @@ int clk_enable(struct clk *clk);
64 */ 88 */
65void clk_disable(struct clk *clk); 89void clk_disable(struct clk *clk);
66 90
91
92/**
93 * clk_unprepare - undo preparation of a clock source
94 * @clk: clock source
95 *
96 * This undoes a previously prepared clock. The caller must balance
97 * the number of prepare and unprepare calls.
98 *
99 * Must not be called from within atomic context.
100 */
101#ifdef CONFIG_HAVE_CLK_PREPARE
102void clk_unprepare(struct clk *clk);
103#else
104static inline void clk_unprepare(struct clk *clk)
105{
106 might_sleep();
107}
108#endif
109
67/** 110/**
68 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. 111 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
69 * This is only valid once the clock source has been enabled. 112 * This is only valid once the clock source has been enabled.