aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSaravana Kannan <skannan@codeaurora.org>2012-04-26 01:58:56 -0400
committerMike Turquette <mturquette@linaro.org>2012-05-01 21:13:20 -0400
commit0197b3ea0f66cd2a11417f58fe1812858ea77908 (patch)
tree73b49012db637bb7f7dad53ee2edf2c6d651ffda /include
parente447c50e3af5dcad3075c80bd1bdc4e2024b8186 (diff)
clk: Use a separate struct for holding init data.
Create a struct clk_init_data to hold all data that needs to be passed from the platfrom specific driver to the common clock framework during clock registration. Add a pointer to this struct inside clk_hw. This has several advantages: * Completely hides struct clk from many clock platform drivers and static clock initialization code that don't care for static initialization of the struct clks. * For platforms that want to do complete static initialization, it removed the need to directly mess with the struct clk's fields while still allowing to statically allocate struct clk. This keeps the code more future proof even if they include clk-private.h. * Simplifies the generic clk_register() function and allows adding optional fields in the future without modifying the function signature. * Simplifies the static initialization of clocks on all platforms by removing the need for forward delcarations or convoluted macros. Signed-off-by: Saravana Kannan <skannan@codeaurora.org> [mturquette@linaro.org: kept DEFINE_CLK_* macros and __clk_init] Signed-off-by: Mike Turquette <mturquette@linaro.org> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Jeremy Kerr <jeremy.kerr@canonical.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Arnd Bergman <arnd.bergmann@linaro.org> Cc: Paul Walmsley <paul@pwsan.com> Cc: Shawn Guo <shawn.guo@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Jamie Iles <jamie@jamieiles.com> Cc: Richard Zhao <richard.zhao@linaro.org> Cc: Saravana Kannan <skannan@codeaurora.org> Cc: Magnus Damm <magnus.damm@gmail.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Linus Walleij <linus.walleij@stericsson.com> Cc: Stephen Boyd <sboyd@codeaurora.org> Cc: Amit Kucheria <amit.kucheria@linaro.org> Cc: Deepak Saxena <dsaxena@linaro.org> Cc: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'include')
-rw-r--r--include/linux/clk-private.h2
-rw-r--r--include/linux/clk-provider.h59
2 files changed, 40 insertions, 21 deletions
diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h
index 6ebec83f1a77..b258532162b8 100644
--- a/include/linux/clk-private.h
+++ b/include/linux/clk-private.h
@@ -167,5 +167,7 @@ struct clk {
167 */ 167 */
168int __clk_init(struct device *dev, struct clk *clk); 168int __clk_init(struct device *dev, struct clk *clk);
169 169
170struct clk *__clk_register(struct device *dev, struct clk_hw *hw);
171
170#endif /* CONFIG_COMMON_CLK */ 172#endif /* CONFIG_COMMON_CLK */
171#endif /* CLK_PRIVATE_H */ 173#endif /* CLK_PRIVATE_H */
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 8f2148942b87..5db3412106b3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -15,19 +15,6 @@
15 15
16#ifdef CONFIG_COMMON_CLK 16#ifdef CONFIG_COMMON_CLK
17 17
18/**
19 * struct clk_hw - handle for traversing from a struct clk to its corresponding
20 * hardware-specific structure. struct clk_hw should be declared within struct
21 * clk_foo and then referenced by the struct clk instance that uses struct
22 * clk_foo's clk_ops
23 *
24 * clk: pointer to the struct clk instance that points back to this struct
25 * clk_hw instance
26 */
27struct clk_hw {
28 struct clk *clk;
29};
30
31/* 18/*
32 * flags used across common struct clk. these flags should only affect the 19 * flags used across common struct clk. these flags should only affect the
33 * top-level framework. custom flags for dealing with hardware specifics 20 * top-level framework. custom flags for dealing with hardware specifics
@@ -39,6 +26,8 @@ struct clk_hw {
39#define CLK_IGNORE_UNUSED BIT(3) /* do not gate even if unused */ 26#define CLK_IGNORE_UNUSED BIT(3) /* do not gate even if unused */
40#define CLK_IS_ROOT BIT(4) /* root clk, has no parent */ 27#define CLK_IS_ROOT BIT(4) /* root clk, has no parent */
41 28
29struct clk_hw;
30
42/** 31/**
43 * struct clk_ops - Callback operations for hardware clocks; these are to 32 * struct clk_ops - Callback operations for hardware clocks; these are to
44 * be provided by the clock implementation, and will be called by drivers 33 * be provided by the clock implementation, and will be called by drivers
@@ -122,6 +111,41 @@ struct clk_ops {
122 void (*init)(struct clk_hw *hw); 111 void (*init)(struct clk_hw *hw);
123}; 112};
124 113
114/**
115 * struct clk_init_data - holds init data that's common to all clocks and is
116 * shared between the clock provider and the common clock framework.
117 *
118 * @name: clock name
119 * @ops: operations this clock supports
120 * @parent_names: array of string names for all possible parents
121 * @num_parents: number of possible parents
122 * @flags: framework-level hints and quirks
123 */
124struct clk_init_data {
125 const char *name;
126 const struct clk_ops *ops;
127 const char **parent_names;
128 u8 num_parents;
129 unsigned long flags;
130};
131
132/**
133 * struct clk_hw - handle for traversing from a struct clk to its corresponding
134 * hardware-specific structure. struct clk_hw should be declared within struct
135 * clk_foo and then referenced by the struct clk instance that uses struct
136 * clk_foo's clk_ops
137 *
138 * @clk: pointer to the struct clk instance that points back to this struct
139 * clk_hw instance
140 *
141 * @init: pointer to struct clk_init_data that contains the init data shared
142 * with the common clock framework.
143 */
144struct clk_hw {
145 struct clk *clk;
146 struct clk_init_data *init;
147};
148
125/* 149/*
126 * DOC: Basic clock implementations common to many platforms 150 * DOC: Basic clock implementations common to many platforms
127 * 151 *
@@ -255,12 +279,7 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
255/** 279/**
256 * clk_register - allocate a new clock, register it and return an opaque cookie 280 * clk_register - allocate a new clock, register it and return an opaque cookie
257 * @dev: device that is registering this clock 281 * @dev: device that is registering this clock
258 * @name: clock name
259 * @ops: operations this clock supports
260 * @hw: link to hardware-specific clock data 282 * @hw: link to hardware-specific clock data
261 * @parent_names: array of string names for all possible parents
262 * @num_parents: number of possible parents
263 * @flags: framework-level hints and quirks
264 * 283 *
265 * clk_register is the primary interface for populating the clock tree with new 284 * clk_register is the primary interface for populating the clock tree with new
266 * clock nodes. It returns a pointer to the newly allocated struct clk which 285 * clock nodes. It returns a pointer to the newly allocated struct clk which
@@ -268,9 +287,7 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
268 * rest of the clock API. In the event of an error clk_register will return an 287 * rest of the clock API. In the event of an error clk_register will return an
269 * error code; drivers must test for an error code after calling clk_register. 288 * error code; drivers must test for an error code after calling clk_register.
270 */ 289 */
271struct clk *clk_register(struct device *dev, const char *name, 290struct clk *clk_register(struct device *dev, struct clk_hw *hw);
272 const struct clk_ops *ops, struct clk_hw *hw,
273 const char **parent_names, u8 num_parents, unsigned long flags);
274 291
275/* helper functions */ 292/* helper functions */
276const char *__clk_get_name(struct clk *clk); 293const char *__clk_get_name(struct clk *clk);