aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-fixed-rate.c
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 /drivers/clk/clk-fixed-rate.c
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>
Diffstat (limited to 'drivers/clk/clk-fixed-rate.c')
-rw-r--r--drivers/clk/clk-fixed-rate.c43
1 files changed, 37 insertions, 6 deletions
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}