diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 19:43:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 19:43:54 -0400 |
commit | 362ed48dee509abe24cf84b7e137c7a29a8f4d2d (patch) | |
tree | f2c2397afa517becf3ff3d8ac4c5c542dfed9795 /include | |
parent | 61f3d0a9883d965b498edeb673235bddc92770fd (diff) | |
parent | 1e435256d625c203660f0105f1155cd2af283051 (diff) |
Merge tag 'clk-for-linus-3.10' of git://git.linaro.org/people/mturquette/linux
Pull clock framework update from Michael Turquette:
"The common clock framework changes for 3.10 include many fixes for
existing platforms, as well as adoption of the framework by new
platforms and devices.
Some long-needed fixes to the core framework are here as well as new
features such as improved initialization of clocks from DT as well as
framework reentrancy for nested clock operations."
* tag 'clk-for-linus-3.10' of git://git.linaro.org/people/mturquette/linux: (44 commits)
clk: add clk_ignore_unused option to keep boot clocks on
clk: ux500: fix mismatched types
clk: vexpress: Add separate SP810 driver
clk: si5351: make clk-si5351 depend on CONFIG_OF
clk: export __clk_get_flags for modular clock providers
clk: vt8500: Missing breaks in vtwm_pll_round_rate/_set_rate.
clk: sunxi: Unify oscillator clock
clk: composite: allow fixed rates & fixed dividers
clk: composite: rename 'div' references to 'rate'
clk: add si5351 i2c common clock driver
clk: add device tree fixed-factor-clock binding support
clk: Properly handle notifier return values
clk: ux500: abx500: Define clock tree for ab850x
clk: ux500: Add support for sysctrl clocks
clk: mvebu: Fix valid value range checking for cpu_freq_select
clk: Fixup locking issues for clk_set_parent
clk: Fixup errorhandling for clk_set_parent
clk: Restructure code for __clk_reparent
clk: sunxi: drop an unnecesary kmalloc
clk: sunxi: drop CLK_IGNORE_UNUSED
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/clk-private.h | 2 | ||||
-rw-r--r-- | include/linux/clk-provider.h | 63 | ||||
-rw-r--r-- | include/linux/clk.h | 8 | ||||
-rw-r--r-- | include/linux/clk/sunxi.h | 22 | ||||
-rw-r--r-- | include/linux/platform_data/si5351.h | 114 |
5 files changed, 201 insertions, 8 deletions
diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h index 9c7f5807824b..dd7adff76e81 100644 --- a/include/linux/clk-private.h +++ b/include/linux/clk-private.h | |||
@@ -152,7 +152,7 @@ struct clk { | |||
152 | }, \ | 152 | }, \ |
153 | .reg = _reg, \ | 153 | .reg = _reg, \ |
154 | .shift = _shift, \ | 154 | .shift = _shift, \ |
155 | .width = _width, \ | 155 | .mask = BIT(_width) - 1, \ |
156 | .flags = _mux_flags, \ | 156 | .flags = _mux_flags, \ |
157 | .lock = _lock, \ | 157 | .lock = _lock, \ |
158 | }; \ | 158 | }; \ |
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 7f197d7addb0..11860985fecb 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h | |||
@@ -45,6 +45,14 @@ struct clk_hw; | |||
45 | * undo any work done in the @prepare callback. Called with | 45 | * undo any work done in the @prepare callback. Called with |
46 | * prepare_lock held. | 46 | * prepare_lock held. |
47 | * | 47 | * |
48 | * @is_prepared: Queries the hardware to determine if the clock is prepared. | ||
49 | * This function is allowed to sleep. Optional, if this op is not | ||
50 | * set then the prepare count will be used. | ||
51 | * | ||
52 | * @unprepare_unused: Unprepare the clock atomically. Only called from | ||
53 | * clk_disable_unused for prepare clocks with special needs. | ||
54 | * Called with prepare mutex held. This function may sleep. | ||
55 | * | ||
48 | * @enable: Enable the clock atomically. This must not return until the | 56 | * @enable: Enable the clock atomically. This must not return until the |
49 | * clock is generating a valid clock signal, usable by consumer | 57 | * clock is generating a valid clock signal, usable by consumer |
50 | * devices. Called with enable_lock held. This function must not | 58 | * devices. Called with enable_lock held. This function must not |
@@ -108,6 +116,8 @@ struct clk_hw; | |||
108 | struct clk_ops { | 116 | struct clk_ops { |
109 | int (*prepare)(struct clk_hw *hw); | 117 | int (*prepare)(struct clk_hw *hw); |
110 | void (*unprepare)(struct clk_hw *hw); | 118 | void (*unprepare)(struct clk_hw *hw); |
119 | int (*is_prepared)(struct clk_hw *hw); | ||
120 | void (*unprepare_unused)(struct clk_hw *hw); | ||
111 | int (*enable)(struct clk_hw *hw); | 121 | int (*enable)(struct clk_hw *hw); |
112 | void (*disable)(struct clk_hw *hw); | 122 | void (*disable)(struct clk_hw *hw); |
113 | int (*is_enabled)(struct clk_hw *hw); | 123 | int (*is_enabled)(struct clk_hw *hw); |
@@ -239,9 +249,14 @@ struct clk_div_table { | |||
239 | * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the | 249 | * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the |
240 | * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is | 250 | * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is |
241 | * the raw value read from the register, with the value of zero considered | 251 | * the raw value read from the register, with the value of zero considered |
242 | * invalid | 252 | * invalid, unless CLK_DIVIDER_ALLOW_ZERO is set. |
243 | * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from | 253 | * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from |
244 | * the hardware register | 254 | * the hardware register |
255 | * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors. For dividers which have | ||
256 | * CLK_DIVIDER_ONE_BASED set, it is possible to end up with a zero divisor. | ||
257 | * Some hardware implementations gracefully handle this case and allow a | ||
258 | * zero divisor by not modifying their input clock | ||
259 | * (divide by one / bypass). | ||
245 | */ | 260 | */ |
246 | struct clk_divider { | 261 | struct clk_divider { |
247 | struct clk_hw hw; | 262 | struct clk_hw hw; |
@@ -255,6 +270,7 @@ struct clk_divider { | |||
255 | 270 | ||
256 | #define CLK_DIVIDER_ONE_BASED BIT(0) | 271 | #define CLK_DIVIDER_ONE_BASED BIT(0) |
257 | #define CLK_DIVIDER_POWER_OF_TWO BIT(1) | 272 | #define CLK_DIVIDER_POWER_OF_TWO BIT(1) |
273 | #define CLK_DIVIDER_ALLOW_ZERO BIT(2) | ||
258 | 274 | ||
259 | extern const struct clk_ops clk_divider_ops; | 275 | extern const struct clk_ops clk_divider_ops; |
260 | struct clk *clk_register_divider(struct device *dev, const char *name, | 276 | struct clk *clk_register_divider(struct device *dev, const char *name, |
@@ -274,7 +290,7 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name, | |||
274 | * @reg: register controlling multiplexer | 290 | * @reg: register controlling multiplexer |
275 | * @shift: shift to multiplexer bit field | 291 | * @shift: shift to multiplexer bit field |
276 | * @width: width of mutliplexer bit field | 292 | * @width: width of mutliplexer bit field |
277 | * @num_clks: number of parent clocks | 293 | * @flags: hardware-specific flags |
278 | * @lock: register lock | 294 | * @lock: register lock |
279 | * | 295 | * |
280 | * Clock with multiple selectable parents. Implements .get_parent, .set_parent | 296 | * Clock with multiple selectable parents. Implements .get_parent, .set_parent |
@@ -287,8 +303,9 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name, | |||
287 | struct clk_mux { | 303 | struct clk_mux { |
288 | struct clk_hw hw; | 304 | struct clk_hw hw; |
289 | void __iomem *reg; | 305 | void __iomem *reg; |
306 | u32 *table; | ||
307 | u32 mask; | ||
290 | u8 shift; | 308 | u8 shift; |
291 | u8 width; | ||
292 | u8 flags; | 309 | u8 flags; |
293 | spinlock_t *lock; | 310 | spinlock_t *lock; |
294 | }; | 311 | }; |
@@ -297,11 +314,19 @@ struct clk_mux { | |||
297 | #define CLK_MUX_INDEX_BIT BIT(1) | 314 | #define CLK_MUX_INDEX_BIT BIT(1) |
298 | 315 | ||
299 | extern const struct clk_ops clk_mux_ops; | 316 | extern const struct clk_ops clk_mux_ops; |
317 | |||
300 | struct clk *clk_register_mux(struct device *dev, const char *name, | 318 | struct clk *clk_register_mux(struct device *dev, const char *name, |
301 | const char **parent_names, u8 num_parents, unsigned long flags, | 319 | const char **parent_names, u8 num_parents, unsigned long flags, |
302 | void __iomem *reg, u8 shift, u8 width, | 320 | void __iomem *reg, u8 shift, u8 width, |
303 | u8 clk_mux_flags, spinlock_t *lock); | 321 | u8 clk_mux_flags, spinlock_t *lock); |
304 | 322 | ||
323 | struct clk *clk_register_mux_table(struct device *dev, const char *name, | ||
324 | const char **parent_names, u8 num_parents, unsigned long flags, | ||
325 | void __iomem *reg, u8 shift, u32 mask, | ||
326 | u8 clk_mux_flags, u32 *table, spinlock_t *lock); | ||
327 | |||
328 | void of_fixed_factor_clk_setup(struct device_node *node); | ||
329 | |||
305 | /** | 330 | /** |
306 | * struct clk_fixed_factor - fixed multiplier and divider clock | 331 | * struct clk_fixed_factor - fixed multiplier and divider clock |
307 | * | 332 | * |
@@ -325,6 +350,37 @@ struct clk *clk_register_fixed_factor(struct device *dev, const char *name, | |||
325 | const char *parent_name, unsigned long flags, | 350 | const char *parent_name, unsigned long flags, |
326 | unsigned int mult, unsigned int div); | 351 | unsigned int mult, unsigned int div); |
327 | 352 | ||
353 | /*** | ||
354 | * struct clk_composite - aggregate clock of mux, divider and gate clocks | ||
355 | * | ||
356 | * @hw: handle between common and hardware-specific interfaces | ||
357 | * @mux_hw: handle between composite and hardware-specific mux clock | ||
358 | * @rate_hw: handle between composite and hardware-specific rate clock | ||
359 | * @gate_hw: handle between composite and hardware-specific gate clock | ||
360 | * @mux_ops: clock ops for mux | ||
361 | * @rate_ops: clock ops for rate | ||
362 | * @gate_ops: clock ops for gate | ||
363 | */ | ||
364 | struct clk_composite { | ||
365 | struct clk_hw hw; | ||
366 | struct clk_ops ops; | ||
367 | |||
368 | struct clk_hw *mux_hw; | ||
369 | struct clk_hw *rate_hw; | ||
370 | struct clk_hw *gate_hw; | ||
371 | |||
372 | const struct clk_ops *mux_ops; | ||
373 | const struct clk_ops *rate_ops; | ||
374 | const struct clk_ops *gate_ops; | ||
375 | }; | ||
376 | |||
377 | struct clk *clk_register_composite(struct device *dev, const char *name, | ||
378 | const char **parent_names, int num_parents, | ||
379 | struct clk_hw *mux_hw, const struct clk_ops *mux_ops, | ||
380 | struct clk_hw *rate_hw, const struct clk_ops *rate_ops, | ||
381 | struct clk_hw *gate_hw, const struct clk_ops *gate_ops, | ||
382 | unsigned long flags); | ||
383 | |||
328 | /** | 384 | /** |
329 | * clk_register - allocate a new clock, register it and return an opaque cookie | 385 | * clk_register - allocate a new clock, register it and return an opaque cookie |
330 | * @dev: device that is registering this clock | 386 | * @dev: device that is registering this clock |
@@ -351,6 +407,7 @@ unsigned int __clk_get_enable_count(struct clk *clk); | |||
351 | unsigned int __clk_get_prepare_count(struct clk *clk); | 407 | unsigned int __clk_get_prepare_count(struct clk *clk); |
352 | unsigned long __clk_get_rate(struct clk *clk); | 408 | unsigned long __clk_get_rate(struct clk *clk); |
353 | unsigned long __clk_get_flags(struct clk *clk); | 409 | unsigned long __clk_get_flags(struct clk *clk); |
410 | bool __clk_is_prepared(struct clk *clk); | ||
354 | bool __clk_is_enabled(struct clk *clk); | 411 | bool __clk_is_enabled(struct clk *clk); |
355 | struct clk *__clk_lookup(const char *name); | 412 | struct clk *__clk_lookup(const char *name); |
356 | 413 | ||
diff --git a/include/linux/clk.h b/include/linux/clk.h index b3ac22d0fc1f..9a6d04524b1a 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
@@ -28,16 +28,16 @@ struct clk; | |||
28 | * PRE_RATE_CHANGE - called immediately before the clk rate is changed, | 28 | * PRE_RATE_CHANGE - called immediately before the clk rate is changed, |
29 | * to indicate that the rate change will proceed. Drivers must | 29 | * to indicate that the rate change will proceed. Drivers must |
30 | * immediately terminate any operations that will be affected by the | 30 | * immediately terminate any operations that will be affected by the |
31 | * rate change. Callbacks may either return NOTIFY_DONE or | 31 | * rate change. Callbacks may either return NOTIFY_DONE, NOTIFY_OK, |
32 | * NOTIFY_STOP. | 32 | * NOTIFY_STOP or NOTIFY_BAD. |
33 | * | 33 | * |
34 | * ABORT_RATE_CHANGE: called if the rate change failed for some reason | 34 | * ABORT_RATE_CHANGE: called if the rate change failed for some reason |
35 | * after PRE_RATE_CHANGE. In this case, all registered notifiers on | 35 | * after PRE_RATE_CHANGE. In this case, all registered notifiers on |
36 | * the clk will be called with ABORT_RATE_CHANGE. Callbacks must | 36 | * the clk will be called with ABORT_RATE_CHANGE. Callbacks must |
37 | * always return NOTIFY_DONE. | 37 | * always return NOTIFY_DONE or NOTIFY_OK. |
38 | * | 38 | * |
39 | * POST_RATE_CHANGE - called after the clk rate change has successfully | 39 | * POST_RATE_CHANGE - called after the clk rate change has successfully |
40 | * completed. Callbacks must always return NOTIFY_DONE. | 40 | * completed. Callbacks must always return NOTIFY_DONE or NOTIFY_OK. |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | #define PRE_RATE_CHANGE BIT(0) | 43 | #define PRE_RATE_CHANGE BIT(0) |
diff --git a/include/linux/clk/sunxi.h b/include/linux/clk/sunxi.h new file mode 100644 index 000000000000..e074fdd5a236 --- /dev/null +++ b/include/linux/clk/sunxi.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Maxime Ripard | ||
3 | * | ||
4 | * Maxime Ripard <maxime.ripard@free-electrons.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef __LINUX_CLK_SUNXI_H_ | ||
18 | #define __LINUX_CLK_SUNXI_H_ | ||
19 | |||
20 | void __init sunxi_init_clocks(void); | ||
21 | |||
22 | #endif | ||
diff --git a/include/linux/platform_data/si5351.h b/include/linux/platform_data/si5351.h new file mode 100644 index 000000000000..92dabcaf6499 --- /dev/null +++ b/include/linux/platform_data/si5351.h | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Si5351A/B/C programmable clock generator platform_data. | ||
3 | */ | ||
4 | |||
5 | #ifndef __LINUX_PLATFORM_DATA_SI5351_H__ | ||
6 | #define __LINUX_PLATFORM_DATA_SI5351_H__ | ||
7 | |||
8 | struct clk; | ||
9 | |||
10 | /** | ||
11 | * enum si5351_variant - SiLabs Si5351 chip variant | ||
12 | * @SI5351_VARIANT_A: Si5351A (8 output clocks, XTAL input) | ||
13 | * @SI5351_VARIANT_A3: Si5351A MSOP10 (3 output clocks, XTAL input) | ||
14 | * @SI5351_VARIANT_B: Si5351B (8 output clocks, XTAL/VXCO input) | ||
15 | * @SI5351_VARIANT_C: Si5351C (8 output clocks, XTAL/CLKIN input) | ||
16 | */ | ||
17 | enum si5351_variant { | ||
18 | SI5351_VARIANT_A = 1, | ||
19 | SI5351_VARIANT_A3 = 2, | ||
20 | SI5351_VARIANT_B = 3, | ||
21 | SI5351_VARIANT_C = 4, | ||
22 | }; | ||
23 | |||
24 | /** | ||
25 | * enum si5351_pll_src - Si5351 pll clock source | ||
26 | * @SI5351_PLL_SRC_DEFAULT: default, do not change eeprom config | ||
27 | * @SI5351_PLL_SRC_XTAL: pll source clock is XTAL input | ||
28 | * @SI5351_PLL_SRC_CLKIN: pll source clock is CLKIN input (Si5351C only) | ||
29 | */ | ||
30 | enum si5351_pll_src { | ||
31 | SI5351_PLL_SRC_DEFAULT = 0, | ||
32 | SI5351_PLL_SRC_XTAL = 1, | ||
33 | SI5351_PLL_SRC_CLKIN = 2, | ||
34 | }; | ||
35 | |||
36 | /** | ||
37 | * enum si5351_multisynth_src - Si5351 multisynth clock source | ||
38 | * @SI5351_MULTISYNTH_SRC_DEFAULT: default, do not change eeprom config | ||
39 | * @SI5351_MULTISYNTH_SRC_VCO0: multisynth source clock is VCO0 | ||
40 | * @SI5351_MULTISYNTH_SRC_VCO1: multisynth source clock is VCO1/VXCO | ||
41 | */ | ||
42 | enum si5351_multisynth_src { | ||
43 | SI5351_MULTISYNTH_SRC_DEFAULT = 0, | ||
44 | SI5351_MULTISYNTH_SRC_VCO0 = 1, | ||
45 | SI5351_MULTISYNTH_SRC_VCO1 = 2, | ||
46 | }; | ||
47 | |||
48 | /** | ||
49 | * enum si5351_clkout_src - Si5351 clock output clock source | ||
50 | * @SI5351_CLKOUT_SRC_DEFAULT: default, do not change eeprom config | ||
51 | * @SI5351_CLKOUT_SRC_MSYNTH_N: clkout N source clock is multisynth N | ||
52 | * @SI5351_CLKOUT_SRC_MSYNTH_0_4: clkout N source clock is multisynth 0 (N<4) | ||
53 | * or 4 (N>=4) | ||
54 | * @SI5351_CLKOUT_SRC_XTAL: clkout N source clock is XTAL | ||
55 | * @SI5351_CLKOUT_SRC_CLKIN: clkout N source clock is CLKIN (Si5351C only) | ||
56 | */ | ||
57 | enum si5351_clkout_src { | ||
58 | SI5351_CLKOUT_SRC_DEFAULT = 0, | ||
59 | SI5351_CLKOUT_SRC_MSYNTH_N = 1, | ||
60 | SI5351_CLKOUT_SRC_MSYNTH_0_4 = 2, | ||
61 | SI5351_CLKOUT_SRC_XTAL = 3, | ||
62 | SI5351_CLKOUT_SRC_CLKIN = 4, | ||
63 | }; | ||
64 | |||
65 | /** | ||
66 | * enum si5351_drive_strength - Si5351 clock output drive strength | ||
67 | * @SI5351_DRIVE_DEFAULT: default, do not change eeprom config | ||
68 | * @SI5351_DRIVE_2MA: 2mA clock output drive strength | ||
69 | * @SI5351_DRIVE_4MA: 4mA clock output drive strength | ||
70 | * @SI5351_DRIVE_6MA: 6mA clock output drive strength | ||
71 | * @SI5351_DRIVE_8MA: 8mA clock output drive strength | ||
72 | */ | ||
73 | enum si5351_drive_strength { | ||
74 | SI5351_DRIVE_DEFAULT = 0, | ||
75 | SI5351_DRIVE_2MA = 2, | ||
76 | SI5351_DRIVE_4MA = 4, | ||
77 | SI5351_DRIVE_6MA = 6, | ||
78 | SI5351_DRIVE_8MA = 8, | ||
79 | }; | ||
80 | |||
81 | /** | ||
82 | * struct si5351_clkout_config - Si5351 clock output configuration | ||
83 | * @clkout: clkout number | ||
84 | * @multisynth_src: multisynth source clock | ||
85 | * @clkout_src: clkout source clock | ||
86 | * @pll_master: if true, clkout can also change pll rate | ||
87 | * @drive: output drive strength | ||
88 | * @rate: initial clkout rate, or default if 0 | ||
89 | */ | ||
90 | struct si5351_clkout_config { | ||
91 | enum si5351_multisynth_src multisynth_src; | ||
92 | enum si5351_clkout_src clkout_src; | ||
93 | enum si5351_drive_strength drive; | ||
94 | bool pll_master; | ||
95 | unsigned long rate; | ||
96 | }; | ||
97 | |||
98 | /** | ||
99 | * struct si5351_platform_data - Platform data for the Si5351 clock driver | ||
100 | * @variant: Si5351 chip variant | ||
101 | * @clk_xtal: xtal input clock | ||
102 | * @clk_clkin: clkin input clock | ||
103 | * @pll_src: array of pll source clock setting | ||
104 | * @clkout: array of clkout configuration | ||
105 | */ | ||
106 | struct si5351_platform_data { | ||
107 | enum si5351_variant variant; | ||
108 | struct clk *clk_xtal; | ||
109 | struct clk *clk_clkin; | ||
110 | enum si5351_pll_src pll_src[2]; | ||
111 | struct si5351_clkout_config clkout[8]; | ||
112 | }; | ||
113 | |||
114 | #endif | ||