summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <stephen.boyd@linaro.org>2016-06-01 19:15:31 -0400
committerStephen Boyd <sboyd@codeaurora.org>2016-06-30 15:26:18 -0400
commitfb2cd7d07ae0146db95b68c4c31b2d96cd0e9575 (patch)
tree18ec4e14ca6c34e3e65e9841dbef170838cc7222
parent7b38d1b222b42cfed197290332a8e426fb77e8fe (diff)
clk: u300: Migrate to clk_hw based 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. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r--drivers/clk/clk-u300.c59
1 files changed, 33 insertions, 26 deletions
diff --git a/drivers/clk/clk-u300.c b/drivers/clk/clk-u300.c
index 95d1742dac30..ec8aafda6e24 100644
--- a/drivers/clk/clk-u300.c
+++ b/drivers/clk/clk-u300.c
@@ -689,7 +689,7 @@ static const struct clk_ops syscon_clk_ops = {
689 .set_rate = syscon_clk_set_rate, 689 .set_rate = syscon_clk_set_rate,
690}; 690};
691 691
692static struct clk * __init 692static struct clk_hw * __init
693syscon_clk_register(struct device *dev, const char *name, 693syscon_clk_register(struct device *dev, const char *name,
694 const char *parent_name, unsigned long flags, 694 const char *parent_name, unsigned long flags,
695 bool hw_ctrld, 695 bool hw_ctrld,
@@ -697,9 +697,10 @@ syscon_clk_register(struct device *dev, const char *name,
697 void __iomem *en_reg, u8 en_bit, 697 void __iomem *en_reg, u8 en_bit,
698 u16 clk_val) 698 u16 clk_val)
699{ 699{
700 struct clk *clk; 700 struct clk_hw *hw;
701 struct clk_syscon *sclk; 701 struct clk_syscon *sclk;
702 struct clk_init_data init; 702 struct clk_init_data init;
703 int ret;
703 704
704 sclk = kzalloc(sizeof(struct clk_syscon), GFP_KERNEL); 705 sclk = kzalloc(sizeof(struct clk_syscon), GFP_KERNEL);
705 if (!sclk) { 706 if (!sclk) {
@@ -722,11 +723,14 @@ syscon_clk_register(struct device *dev, const char *name,
722 sclk->en_bit = en_bit; 723 sclk->en_bit = en_bit;
723 sclk->clk_val = clk_val; 724 sclk->clk_val = clk_val;
724 725
725 clk = clk_register(dev, &sclk->hw); 726 hw = &sclk->hw;
726 if (IS_ERR(clk)) 727 ret = clk_hw_register(dev, hw);
728 if (ret) {
727 kfree(sclk); 729 kfree(sclk);
730 hw = ERR_PTR(ret);
731 }
728 732
729 return clk; 733 return hw;
730} 734}
731 735
732#define U300_CLK_TYPE_SLOW 0 736#define U300_CLK_TYPE_SLOW 0
@@ -868,7 +872,7 @@ static struct u300_clock const u300_clk_lookup[] __initconst = {
868 872
869static void __init of_u300_syscon_clk_init(struct device_node *np) 873static void __init of_u300_syscon_clk_init(struct device_node *np)
870{ 874{
871 struct clk *clk = ERR_PTR(-EINVAL); 875 struct clk_hw *hw = ERR_PTR(-EINVAL);
872 const char *clk_name = np->name; 876 const char *clk_name = np->name;
873 const char *parent_name; 877 const char *parent_name;
874 void __iomem *res_reg; 878 void __iomem *res_reg;
@@ -911,16 +915,15 @@ static void __init of_u300_syscon_clk_init(struct device_node *np)
911 const struct u300_clock *u3clk = &u300_clk_lookup[i]; 915 const struct u300_clock *u3clk = &u300_clk_lookup[i];
912 916
913 if (u3clk->type == clk_type && u3clk->id == clk_id) 917 if (u3clk->type == clk_type && u3clk->id == clk_id)
914 clk = syscon_clk_register(NULL, 918 hw = syscon_clk_register(NULL, clk_name, parent_name,
915 clk_name, parent_name, 919 0, u3clk->hw_ctrld,
916 0, u3clk->hw_ctrld, 920 res_reg, u3clk->id,
917 res_reg, u3clk->id, 921 en_reg, u3clk->id,
918 en_reg, u3clk->id, 922 u3clk->clk_val);
919 u3clk->clk_val);
920 } 923 }
921 924
922 if (!IS_ERR(clk)) { 925 if (!IS_ERR(hw)) {
923 of_clk_add_provider(np, of_clk_src_simple_get, clk); 926 of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
924 927
925 /* 928 /*
926 * Some few system clocks - device tree does not 929 * Some few system clocks - device tree does not
@@ -928,11 +931,11 @@ static void __init of_u300_syscon_clk_init(struct device_node *np)
928 * for now we add these three clocks here. 931 * for now we add these three clocks here.
929 */ 932 */
930 if (clk_type == U300_CLK_TYPE_REST && clk_id == 5) 933 if (clk_type == U300_CLK_TYPE_REST && clk_id == 5)
931 clk_register_clkdev(clk, NULL, "pl172"); 934 clk_hw_register_clkdev(hw, NULL, "pl172");
932 if (clk_type == U300_CLK_TYPE_REST && clk_id == 9) 935 if (clk_type == U300_CLK_TYPE_REST && clk_id == 9)
933 clk_register_clkdev(clk, NULL, "semi"); 936 clk_hw_register_clkdev(hw, NULL, "semi");
934 if (clk_type == U300_CLK_TYPE_REST && clk_id == 12) 937 if (clk_type == U300_CLK_TYPE_REST && clk_id == 12)
935 clk_register_clkdev(clk, NULL, "intcon"); 938 clk_hw_register_clkdev(hw, NULL, "intcon");
936 } 939 }
937} 940}
938 941
@@ -1111,13 +1114,14 @@ static const struct clk_ops mclk_ops = {
1111 .set_rate = mclk_clk_set_rate, 1114 .set_rate = mclk_clk_set_rate,
1112}; 1115};
1113 1116
1114static struct clk * __init 1117static struct clk_hw * __init
1115mclk_clk_register(struct device *dev, const char *name, 1118mclk_clk_register(struct device *dev, const char *name,
1116 const char *parent_name, bool is_mspro) 1119 const char *parent_name, bool is_mspro)
1117{ 1120{
1118 struct clk *clk; 1121 struct clk_hw *hw;
1119 struct clk_mclk *mclk; 1122 struct clk_mclk *mclk;
1120 struct clk_init_data init; 1123 struct clk_init_data init;
1124 int ret;
1121 1125
1122 mclk = kzalloc(sizeof(struct clk_mclk), GFP_KERNEL); 1126 mclk = kzalloc(sizeof(struct clk_mclk), GFP_KERNEL);
1123 if (!mclk) { 1127 if (!mclk) {
@@ -1133,23 +1137,26 @@ mclk_clk_register(struct device *dev, const char *name,
1133 mclk->hw.init = &init; 1137 mclk->hw.init = &init;
1134 mclk->is_mspro = is_mspro; 1138 mclk->is_mspro = is_mspro;
1135 1139
1136 clk = clk_register(dev, &mclk->hw); 1140 hw = &mclk->hw;
1137 if (IS_ERR(clk)) 1141 ret = clk_hw_register(dev, hw);
1142 if (ret) {
1138 kfree(mclk); 1143 kfree(mclk);
1144 hw = ERR_PTR(ret);
1145 }
1139 1146
1140 return clk; 1147 return hw;
1141} 1148}
1142 1149
1143static void __init of_u300_syscon_mclk_init(struct device_node *np) 1150static void __init of_u300_syscon_mclk_init(struct device_node *np)
1144{ 1151{
1145 struct clk *clk = ERR_PTR(-EINVAL); 1152 struct clk_hw *hw;
1146 const char *clk_name = np->name; 1153 const char *clk_name = np->name;
1147 const char *parent_name; 1154 const char *parent_name;
1148 1155
1149 parent_name = of_clk_get_parent_name(np, 0); 1156 parent_name = of_clk_get_parent_name(np, 0);
1150 clk = mclk_clk_register(NULL, clk_name, parent_name, false); 1157 hw = mclk_clk_register(NULL, clk_name, parent_name, false);
1151 if (!IS_ERR(clk)) 1158 if (!IS_ERR(hw))
1152 of_clk_add_provider(np, of_clk_src_simple_get, clk); 1159 of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
1153} 1160}
1154 1161
1155static const struct of_device_id u300_clk_match[] __initconst = { 1162static const struct of_device_id u300_clk_match[] __initconst = {