aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorStephen Boyd <stephen.boyd@linaro.org>2016-06-01 19:15:23 -0400
committerStephen Boyd <sboyd@codeaurora.org>2016-08-24 20:29:57 -0400
commita8b6e85db6a65132ebc85e38b6391669b37b36f8 (patch)
treebdc4888618180d0b8c5b14588f157a0a67971bad /drivers/clk
parent4cf915dfb8ede6e2673b4f1b2d2518ef4fe6620c (diff)
clk: rk808: Migrate to clk_hw based OF and registration APIs
Now that we have clk_hw based provider APIs to register clks, we can get rid of struct clk pointers while registering clks in these drivers, allowing us to move closer to a clear split of consumer and provider clk APIs. Cc: Chris Zhong <zyw@rock-chips.com> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk-rk808.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c
index 74383039761e..faa447e191ef 100644
--- a/drivers/clk/clk-rk808.c
+++ b/drivers/clk/clk-rk808.c
@@ -22,11 +22,8 @@
22#include <linux/mfd/rk808.h> 22#include <linux/mfd/rk808.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24 24
25#define RK808_NR_OUTPUT 2
26
27struct rk808_clkout { 25struct rk808_clkout {
28 struct rk808 *rk808; 26 struct rk808 *rk808;
29 struct clk_onecell_data clk_data;
30 struct clk_hw clkout1_hw; 27 struct clk_hw clkout1_hw;
31 struct clk_hw clkout2_hw; 28 struct clk_hw clkout2_hw;
32}; 29};
@@ -85,14 +82,28 @@ static const struct clk_ops rk808_clkout2_ops = {
85 .recalc_rate = rk808_clkout_recalc_rate, 82 .recalc_rate = rk808_clkout_recalc_rate,
86}; 83};
87 84
85static struct clk_hw *
86of_clk_rk808_get(struct of_phandle_args *clkspec, void *data)
87{
88 struct rk808_clkout *rk808_clkout = data;
89 unsigned int idx = clkspec->args[0];
90
91 if (idx >= 2) {
92 pr_err("%s: invalid index %u\n", __func__, idx);
93 return ERR_PTR(-EINVAL);
94 }
95
96 return idx ? &rk808_clkout->clkout2_hw : &rk808_clkout->clkout1_hw;
97}
98
88static int rk808_clkout_probe(struct platform_device *pdev) 99static int rk808_clkout_probe(struct platform_device *pdev)
89{ 100{
90 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); 101 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
91 struct i2c_client *client = rk808->i2c; 102 struct i2c_client *client = rk808->i2c;
92 struct device_node *node = client->dev.of_node; 103 struct device_node *node = client->dev.of_node;
93 struct clk_init_data init = {}; 104 struct clk_init_data init = {};
94 struct clk **clk_table;
95 struct rk808_clkout *rk808_clkout; 105 struct rk808_clkout *rk808_clkout;
106 int ret;
96 107
97 rk808_clkout = devm_kzalloc(&client->dev, 108 rk808_clkout = devm_kzalloc(&client->dev,
98 sizeof(*rk808_clkout), GFP_KERNEL); 109 sizeof(*rk808_clkout), GFP_KERNEL);
@@ -101,11 +112,6 @@ static int rk808_clkout_probe(struct platform_device *pdev)
101 112
102 rk808_clkout->rk808 = rk808; 113 rk808_clkout->rk808 = rk808;
103 114
104 clk_table = devm_kcalloc(&client->dev, RK808_NR_OUTPUT,
105 sizeof(struct clk *), GFP_KERNEL);
106 if (!clk_table)
107 return -ENOMEM;
108
109 init.parent_names = NULL; 115 init.parent_names = NULL;
110 init.num_parents = 0; 116 init.num_parents = 0;
111 init.name = "rk808-clkout1"; 117 init.name = "rk808-clkout1";
@@ -116,10 +122,9 @@ static int rk808_clkout_probe(struct platform_device *pdev)
116 of_property_read_string_index(node, "clock-output-names", 122 of_property_read_string_index(node, "clock-output-names",
117 0, &init.name); 123 0, &init.name);
118 124
119 clk_table[0] = devm_clk_register(&client->dev, 125 ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout1_hw);
120 &rk808_clkout->clkout1_hw); 126 if (ret)
121 if (IS_ERR(clk_table[0])) 127 return ret;
122 return PTR_ERR(clk_table[0]);
123 128
124 init.name = "rk808-clkout2"; 129 init.name = "rk808-clkout2";
125 init.ops = &rk808_clkout2_ops; 130 init.ops = &rk808_clkout2_ops;
@@ -129,16 +134,11 @@ static int rk808_clkout_probe(struct platform_device *pdev)
129 of_property_read_string_index(node, "clock-output-names", 134 of_property_read_string_index(node, "clock-output-names",
130 1, &init.name); 135 1, &init.name);
131 136
132 clk_table[1] = devm_clk_register(&client->dev, 137 ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout2_hw);
133 &rk808_clkout->clkout2_hw); 138 if (ret)
134 if (IS_ERR(clk_table[1])) 139 return ret;
135 return PTR_ERR(clk_table[1]);
136
137 rk808_clkout->clk_data.clks = clk_table;
138 rk808_clkout->clk_data.clk_num = RK808_NR_OUTPUT;
139 140
140 return of_clk_add_provider(node, of_clk_src_onecell_get, 141 return of_clk_add_hw_provider(node, of_clk_rk808_get, &rk808_clkout);
141 &rk808_clkout->clk_data);
142} 142}
143 143
144static int rk808_clkout_remove(struct platform_device *pdev) 144static int rk808_clkout_remove(struct platform_device *pdev)