aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Behera <tushar.behera@linaro.org>2013-12-26 05:18:58 -0500
committerMike Turquette <mturquette@linaro.org>2014-03-18 20:13:16 -0400
commit64d64c3573b3b6bf2d67fbb54d80bc73a1850f13 (patch)
tree5357d2b364fc1e5ae6ecffcca590aa72938c4d00
parentc7bb4fc16ead2883a9e4eece2781fa78a0837735 (diff)
clk: clk-s2mps11: Refactor for including support for other MFD clocks
The clocks in S2MPS11 and S5M8767 are managed in the same way, baring a difference in the register offset. It would be better to update existing S2MPS11 driver to support the clocks in S5M8767, rather than creating an almost duplicate driver altogether. Signed-off-by: Tushar Behera <tushar.behera@linaro.org> Reviewed-by: Tomasz Figa <t.figa@samsung.com> Reviewed-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/clk-s2mps11.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index 00a3abe103a5..43e25bb405ea 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -48,6 +48,7 @@ struct s2mps11_clk {
48 struct clk_lookup *lookup; 48 struct clk_lookup *lookup;
49 u32 mask; 49 u32 mask;
50 bool enabled; 50 bool enabled;
51 unsigned int reg;
51}; 52};
52 53
53static struct s2mps11_clk *to_s2mps11_clk(struct clk_hw *hw) 54static struct s2mps11_clk *to_s2mps11_clk(struct clk_hw *hw)
@@ -61,7 +62,7 @@ static int s2mps11_clk_prepare(struct clk_hw *hw)
61 int ret; 62 int ret;
62 63
63 ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, 64 ret = regmap_update_bits(s2mps11->iodev->regmap_pmic,
64 S2MPS11_REG_RTC_CTRL, 65 s2mps11->reg,
65 s2mps11->mask, s2mps11->mask); 66 s2mps11->mask, s2mps11->mask);
66 if (!ret) 67 if (!ret)
67 s2mps11->enabled = true; 68 s2mps11->enabled = true;
@@ -74,7 +75,7 @@ static void s2mps11_clk_unprepare(struct clk_hw *hw)
74 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); 75 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);
75 int ret; 76 int ret;
76 77
77 ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, S2MPS11_REG_RTC_CTRL, 78 ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, s2mps11->reg,
78 s2mps11->mask, ~s2mps11->mask); 79 s2mps11->mask, ~s2mps11->mask);
79 80
80 if (!ret) 81 if (!ret)
@@ -155,6 +156,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
155 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 156 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
156 struct s2mps11_clk *s2mps11_clks, *s2mps11_clk; 157 struct s2mps11_clk *s2mps11_clks, *s2mps11_clk;
157 struct device_node *clk_np = NULL; 158 struct device_node *clk_np = NULL;
159 unsigned int s2mps11_reg;
158 int i, ret = 0; 160 int i, ret = 0;
159 u32 val; 161 u32 val;
160 162
@@ -169,13 +171,23 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
169 if (IS_ERR(clk_np)) 171 if (IS_ERR(clk_np))
170 return PTR_ERR(clk_np); 172 return PTR_ERR(clk_np);
171 173
174 switch(platform_get_device_id(pdev)->driver_data) {
175 case S2MPS11X:
176 s2mps11_reg = S2MPS11_REG_RTC_CTRL;
177 break;
178 default:
179 dev_err(&pdev->dev, "Invalid device type\n");
180 return -EINVAL;
181 };
182
172 for (i = 0; i < S2MPS11_CLKS_NUM; i++, s2mps11_clk++) { 183 for (i = 0; i < S2MPS11_CLKS_NUM; i++, s2mps11_clk++) {
173 s2mps11_clk->iodev = iodev; 184 s2mps11_clk->iodev = iodev;
174 s2mps11_clk->hw.init = &s2mps11_clks_init[i]; 185 s2mps11_clk->hw.init = &s2mps11_clks_init[i];
175 s2mps11_clk->mask = 1 << i; 186 s2mps11_clk->mask = 1 << i;
187 s2mps11_clk->reg = s2mps11_reg;
176 188
177 ret = regmap_read(s2mps11_clk->iodev->regmap_pmic, 189 ret = regmap_read(s2mps11_clk->iodev->regmap_pmic,
178 S2MPS11_REG_RTC_CTRL, &val); 190 s2mps11_clk->reg, &val);
179 if (ret < 0) 191 if (ret < 0)
180 goto err_reg; 192 goto err_reg;
181 193
@@ -241,7 +253,7 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
241} 253}
242 254
243static const struct platform_device_id s2mps11_clk_id[] = { 255static const struct platform_device_id s2mps11_clk_id[] = {
244 { "s2mps11-clk", 0}, 256 { "s2mps11-clk", S2MPS11X},
245 { }, 257 { },
246}; 258};
247MODULE_DEVICE_TABLE(platform, s2mps11_clk_id); 259MODULE_DEVICE_TABLE(platform, s2mps11_clk_id);