diff options
| author | Grant Likely <grant.likely@secretlab.ca> | 2012-04-09 15:50:06 -0400 |
|---|---|---|
| committer | Mike Turquette <mturquette@linaro.org> | 2012-07-11 20:58:45 -0400 |
| commit | 766e6a4ec602d0c107553b91b3434fe9c03474f4 (patch) | |
| tree | aa9bbba36954d927e931cc50c6a28ef9cced571c /include/linux | |
| parent | a613163dff04cbfcb7d66b06ef4a5f65498ee59b (diff) | |
clk: add DT clock binding support
Based on work 1st by Ben Herrenschmidt and Jeremy Kerr, then by Grant
Likely, this patch adds support to clk_get to allow drivers to retrieve
clock data from the device tree.
Platforms scan for clocks in DT with of_clk_init and a match table, and
the register a provider through of_clk_add_provider. The provider's
clk_src_get function will be called when a device references the
provider's OF node for a clock reference.
v6 (Rob Herring):
- Return error values instead of NULL to match clock framework
expectations
v5 (Rob Herring):
- Move from drivers/of into common clock subsystem
- Squashed "dt/clock: add a simple provider get function" and
"dt/clock: add function to get parent clock name"
- Rebase to 3.4-rc1
- Drop CONFIG_OF_CLOCK and just use CONFIG_OF
- Add missing EXPORT_SYMBOL to various functions
- s/clock-output-name/clock-output-names/
- Define that fixed-clock binding is a single output
v4 (Rob Herring):
- Rework for common clk subsystem
- Add of_clk_get_parent_name function
v3: - Clarified documentation
v2: - fixed errant ';' causing compile error
- Editorial fixes from Shawn Guo
- merged in adding lookup to clkdev
- changed property names to match established convention. After
working with the binding a bit it really made more sense to follow the
lead of 'reg', 'gpios' and 'interrupts' by making the input simply
'clocks' & 'clock-names' instead of 'clock-input-*', and to only use
clock-output* for the producer nodes. (Sorry Shawn, this will mean
you need to change some code, but it should be trivial)
- Add ability to inherit clocks from parent nodes by using an empty
'clock-ranges' property. Useful for busses. I could use some feedback
on the new property name, 'clock-ranges' doesn't feel right to me.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Reviewed-by: Shawn Guo <shawn.guo@freescale.com>
Cc: Sascha Hauer <kernel@pengutronix.de>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/clk-provider.h | 14 | ||||
| -rw-r--r-- | include/linux/clk.h | 19 |
2 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 06ad617664a2..7c9c691102b5 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h | |||
| @@ -347,5 +347,19 @@ void __clk_unprepare(struct clk *clk); | |||
| 347 | void __clk_reparent(struct clk *clk, struct clk *new_parent); | 347 | void __clk_reparent(struct clk *clk, struct clk *new_parent); |
| 348 | unsigned long __clk_round_rate(struct clk *clk, unsigned long rate); | 348 | unsigned long __clk_round_rate(struct clk *clk, unsigned long rate); |
| 349 | 349 | ||
| 350 | struct of_device_id; | ||
| 351 | |||
| 352 | typedef void (*of_clk_init_cb_t)(struct device_node *); | ||
| 353 | |||
| 354 | int of_clk_add_provider(struct device_node *np, | ||
| 355 | struct clk *(*clk_src_get)(struct of_phandle_args *args, | ||
| 356 | void *data), | ||
| 357 | void *data); | ||
| 358 | void of_clk_del_provider(struct device_node *np); | ||
| 359 | struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, | ||
| 360 | void *data); | ||
| 361 | const char *of_clk_get_parent_name(struct device_node *np, int index); | ||
| 362 | void of_clk_init(const struct of_device_id *matches); | ||
| 363 | |||
| 350 | #endif /* CONFIG_COMMON_CLK */ | 364 | #endif /* CONFIG_COMMON_CLK */ |
| 351 | #endif /* CLK_PROVIDER_H */ | 365 | #endif /* CLK_PROVIDER_H */ |
diff --git a/include/linux/clk.h b/include/linux/clk.h index ad5c43e8ae8a..8b70342e7e0b 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
| @@ -310,4 +310,23 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id); | |||
| 310 | int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, | 310 | int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, |
| 311 | struct device *dev); | 311 | struct device *dev); |
| 312 | 312 | ||
| 313 | struct device_node; | ||
| 314 | struct of_phandle_args; | ||
| 315 | |||
| 316 | #ifdef CONFIG_OF | ||
| 317 | struct clk *of_clk_get(struct device_node *np, int index); | ||
| 318 | struct clk *of_clk_get_by_name(struct device_node *np, const char *name); | ||
| 319 | struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); | ||
| 320 | #else | ||
| 321 | static inline struct clk *of_clk_get(struct device_node *np, int index) | ||
| 322 | { | ||
| 323 | return NULL; | ||
| 324 | } | ||
| 325 | static inline struct clk *of_clk_get_by_name(struct device_node *np, | ||
| 326 | const char *name) | ||
| 327 | { | ||
| 328 | return NULL; | ||
| 329 | } | ||
| 330 | #endif | ||
| 331 | |||
| 313 | #endif | 332 | #endif |
