aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris BREZILLON <b.brezillon@overkiz.com>2013-12-21 04:34:48 -0500
committerMike Turquette <mturquette@linaro.org>2013-12-23 02:14:28 -0500
commit0903ea60173fab226a867ceb080b2e0269a6c975 (patch)
tree426e65588ada203d419495126323d0a009dcdee0
parent5279fc402ae59361a224d641d5823b21b4206232 (diff)
clk: add accuracy support for fixed clock
This patch adds support for accuracy retrieval on fixed clocks. It also adds a new dt property called 'clock-accuracy' to define the clock accuracy. This can be usefull for oscillator (RC, crystal, ...) definitions which are always given an accuracy characteristic. Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/clock/fixed-clock.txt3
-rw-r--r--drivers/clk/clk-fixed-rate.c43
-rw-r--r--include/linux/clk-provider.h4
3 files changed, 44 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/clock/fixed-clock.txt b/Documentation/devicetree/bindings/clock/fixed-clock.txt
index 0b1fe7824093..48ea0ad8ad46 100644
--- a/Documentation/devicetree/bindings/clock/fixed-clock.txt
+++ b/Documentation/devicetree/bindings/clock/fixed-clock.txt
@@ -10,6 +10,8 @@ Required properties:
10- clock-frequency : frequency of clock in Hz. Should be a single cell. 10- clock-frequency : frequency of clock in Hz. Should be a single cell.
11 11
12Optional properties: 12Optional properties:
13- clock-accuracy : accuracy of clock in ppb (parts per billion).
14 Should be a single cell.
13- gpios : From common gpio binding; gpio connection to clock enable pin. 15- gpios : From common gpio binding; gpio connection to clock enable pin.
14- clock-output-names : From common clock binding. 16- clock-output-names : From common clock binding.
15 17
@@ -18,4 +20,5 @@ Example:
18 compatible = "fixed-clock"; 20 compatible = "fixed-clock";
19 #clock-cells = <0>; 21 #clock-cells = <0>;
20 clock-frequency = <1000000000>; 22 clock-frequency = <1000000000>;
23 clock-accuracy = <100>;
21 }; 24 };
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c
index 1ed591ab8b1d..0fc56ab6e844 100644
--- a/drivers/clk/clk-fixed-rate.c
+++ b/drivers/clk/clk-fixed-rate.c
@@ -34,22 +34,31 @@ static unsigned long clk_fixed_rate_recalc_rate(struct clk_hw *hw,
34 return to_clk_fixed_rate(hw)->fixed_rate; 34 return to_clk_fixed_rate(hw)->fixed_rate;
35} 35}
36 36
37static unsigned long clk_fixed_rate_recalc_accuracy(struct clk_hw *hw,
38 unsigned long parent_accuracy)
39{
40 return to_clk_fixed_rate(hw)->fixed_accuracy;
41}
42
37const struct clk_ops clk_fixed_rate_ops = { 43const struct clk_ops clk_fixed_rate_ops = {
38 .recalc_rate = clk_fixed_rate_recalc_rate, 44 .recalc_rate = clk_fixed_rate_recalc_rate,
45 .recalc_accuracy = clk_fixed_rate_recalc_accuracy,
39}; 46};
40EXPORT_SYMBOL_GPL(clk_fixed_rate_ops); 47EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);
41 48
42/** 49/**
43 * clk_register_fixed_rate - register fixed-rate clock with the clock framework 50 * clk_register_fixed_rate_with_accuracy - register fixed-rate clock with the
51 * clock framework
44 * @dev: device that is registering this clock 52 * @dev: device that is registering this clock
45 * @name: name of this clock 53 * @name: name of this clock
46 * @parent_name: name of clock's parent 54 * @parent_name: name of clock's parent
47 * @flags: framework-specific flags 55 * @flags: framework-specific flags
48 * @fixed_rate: non-adjustable clock rate 56 * @fixed_rate: non-adjustable clock rate
57 * @fixed_accuracy: non-adjustable clock rate
49 */ 58 */
50struct clk *clk_register_fixed_rate(struct device *dev, const char *name, 59struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
51 const char *parent_name, unsigned long flags, 60 const char *name, const char *parent_name, unsigned long flags,
52 unsigned long fixed_rate) 61 unsigned long fixed_rate, unsigned long fixed_accuracy)
53{ 62{
54 struct clk_fixed_rate *fixed; 63 struct clk_fixed_rate *fixed;
55 struct clk *clk; 64 struct clk *clk;
@@ -70,16 +79,33 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
70 79
71 /* struct clk_fixed_rate assignments */ 80 /* struct clk_fixed_rate assignments */
72 fixed->fixed_rate = fixed_rate; 81 fixed->fixed_rate = fixed_rate;
82 fixed->fixed_accuracy = fixed_accuracy;
73 fixed->hw.init = &init; 83 fixed->hw.init = &init;
74 84
75 /* register the clock */ 85 /* register the clock */
76 clk = clk_register(dev, &fixed->hw); 86 clk = clk_register(dev, &fixed->hw);
77
78 if (IS_ERR(clk)) 87 if (IS_ERR(clk))
79 kfree(fixed); 88 kfree(fixed);
80 89
81 return clk; 90 return clk;
82} 91}
92EXPORT_SYMBOL_GPL(clk_register_fixed_rate_with_accuracy);
93
94/**
95 * clk_register_fixed_rate - register fixed-rate clock with the clock framework
96 * @dev: device that is registering this clock
97 * @name: name of this clock
98 * @parent_name: name of clock's parent
99 * @flags: framework-specific flags
100 * @fixed_rate: non-adjustable clock rate
101 */
102struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
103 const char *parent_name, unsigned long flags,
104 unsigned long fixed_rate)
105{
106 return clk_register_fixed_rate_with_accuracy(dev, name, parent_name,
107 flags, fixed_rate, 0);
108}
83EXPORT_SYMBOL_GPL(clk_register_fixed_rate); 109EXPORT_SYMBOL_GPL(clk_register_fixed_rate);
84 110
85#ifdef CONFIG_OF 111#ifdef CONFIG_OF
@@ -91,13 +117,18 @@ void of_fixed_clk_setup(struct device_node *node)
91 struct clk *clk; 117 struct clk *clk;
92 const char *clk_name = node->name; 118 const char *clk_name = node->name;
93 u32 rate; 119 u32 rate;
120 u32 accuracy = 0;
94 121
95 if (of_property_read_u32(node, "clock-frequency", &rate)) 122 if (of_property_read_u32(node, "clock-frequency", &rate))
96 return; 123 return;
97 124
125 of_property_read_u32(node, "clock-accuracy", &accuracy);
126
98 of_property_read_string(node, "clock-output-names", &clk_name); 127 of_property_read_string(node, "clock-output-names", &clk_name);
99 128
100 clk = clk_register_fixed_rate(NULL, clk_name, NULL, CLK_IS_ROOT, rate); 129 clk = clk_register_fixed_rate_with_accuracy(NULL, clk_name, NULL,
130 CLK_IS_ROOT, rate,
131 accuracy);
101 if (!IS_ERR(clk)) 132 if (!IS_ERR(clk))
102 of_clk_add_provider(node, of_clk_src_simple_get, clk); 133 of_clk_add_provider(node, of_clk_src_simple_get, clk);
103} 134}
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 16d182c28ce6..5429f5db5037 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -204,6 +204,7 @@ struct clk_hw {
204struct clk_fixed_rate { 204struct clk_fixed_rate {
205 struct clk_hw hw; 205 struct clk_hw hw;
206 unsigned long fixed_rate; 206 unsigned long fixed_rate;
207 unsigned long fixed_accuracy;
207 u8 flags; 208 u8 flags;
208}; 209};
209 210
@@ -211,6 +212,9 @@ extern const struct clk_ops clk_fixed_rate_ops;
211struct clk *clk_register_fixed_rate(struct device *dev, const char *name, 212struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
212 const char *parent_name, unsigned long flags, 213 const char *parent_name, unsigned long flags,
213 unsigned long fixed_rate); 214 unsigned long fixed_rate);
215struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
216 const char *name, const char *parent_name, unsigned long flags,
217 unsigned long fixed_rate, unsigned long fixed_accuracy);
214 218
215void of_fixed_clk_setup(struct device_node *np); 219void of_fixed_clk_setup(struct device_node *np);
216 220