Commit a8b6e85d authored by Stephen Boyd's avatar Stephen Boyd Committed by Stephen Boyd

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: default avatarStephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 4cf915df
...@@ -22,11 +22,8 @@ ...@@ -22,11 +22,8 @@
#include <linux/mfd/rk808.h> #include <linux/mfd/rk808.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#define RK808_NR_OUTPUT 2
struct rk808_clkout { struct rk808_clkout {
struct rk808 *rk808; struct rk808 *rk808;
struct clk_onecell_data clk_data;
struct clk_hw clkout1_hw; struct clk_hw clkout1_hw;
struct clk_hw clkout2_hw; struct clk_hw clkout2_hw;
}; };
...@@ -85,14 +82,28 @@ static const struct clk_ops rk808_clkout2_ops = { ...@@ -85,14 +82,28 @@ static const struct clk_ops rk808_clkout2_ops = {
.recalc_rate = rk808_clkout_recalc_rate, .recalc_rate = rk808_clkout_recalc_rate,
}; };
static struct clk_hw *
of_clk_rk808_get(struct of_phandle_args *clkspec, void *data)
{
struct rk808_clkout *rk808_clkout = data;
unsigned int idx = clkspec->args[0];
if (idx >= 2) {
pr_err("%s: invalid index %u\n", __func__, idx);
return ERR_PTR(-EINVAL);
}
return idx ? &rk808_clkout->clkout2_hw : &rk808_clkout->clkout1_hw;
}
static int rk808_clkout_probe(struct platform_device *pdev) static int rk808_clkout_probe(struct platform_device *pdev)
{ {
struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
struct i2c_client *client = rk808->i2c; struct i2c_client *client = rk808->i2c;
struct device_node *node = client->dev.of_node; struct device_node *node = client->dev.of_node;
struct clk_init_data init = {}; struct clk_init_data init = {};
struct clk **clk_table;
struct rk808_clkout *rk808_clkout; struct rk808_clkout *rk808_clkout;
int ret;
rk808_clkout = devm_kzalloc(&client->dev, rk808_clkout = devm_kzalloc(&client->dev,
sizeof(*rk808_clkout), GFP_KERNEL); sizeof(*rk808_clkout), GFP_KERNEL);
...@@ -101,11 +112,6 @@ static int rk808_clkout_probe(struct platform_device *pdev) ...@@ -101,11 +112,6 @@ static int rk808_clkout_probe(struct platform_device *pdev)
rk808_clkout->rk808 = rk808; rk808_clkout->rk808 = rk808;
clk_table = devm_kcalloc(&client->dev, RK808_NR_OUTPUT,
sizeof(struct clk *), GFP_KERNEL);
if (!clk_table)
return -ENOMEM;
init.parent_names = NULL; init.parent_names = NULL;
init.num_parents = 0; init.num_parents = 0;
init.name = "rk808-clkout1"; init.name = "rk808-clkout1";
...@@ -116,10 +122,9 @@ static int rk808_clkout_probe(struct platform_device *pdev) ...@@ -116,10 +122,9 @@ static int rk808_clkout_probe(struct platform_device *pdev)
of_property_read_string_index(node, "clock-output-names", of_property_read_string_index(node, "clock-output-names",
0, &init.name); 0, &init.name);
clk_table[0] = devm_clk_register(&client->dev, ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout1_hw);
&rk808_clkout->clkout1_hw); if (ret)
if (IS_ERR(clk_table[0])) return ret;
return PTR_ERR(clk_table[0]);
init.name = "rk808-clkout2"; init.name = "rk808-clkout2";
init.ops = &rk808_clkout2_ops; init.ops = &rk808_clkout2_ops;
...@@ -129,16 +134,11 @@ static int rk808_clkout_probe(struct platform_device *pdev) ...@@ -129,16 +134,11 @@ static int rk808_clkout_probe(struct platform_device *pdev)
of_property_read_string_index(node, "clock-output-names", of_property_read_string_index(node, "clock-output-names",
1, &init.name); 1, &init.name);
clk_table[1] = devm_clk_register(&client->dev, ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout2_hw);
&rk808_clkout->clkout2_hw); if (ret)
if (IS_ERR(clk_table[1])) return ret;
return PTR_ERR(clk_table[1]);
rk808_clkout->clk_data.clks = clk_table;
rk808_clkout->clk_data.clk_num = RK808_NR_OUTPUT;
return of_clk_add_provider(node, of_clk_src_onecell_get, return of_clk_add_hw_provider(node, of_clk_rk808_get, &rk808_clkout);
&rk808_clkout->clk_data);
} }
static int rk808_clkout_remove(struct platform_device *pdev) static int rk808_clkout_remove(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment