aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorTomasz Figa <t.figa@samsung.com>2013-08-26 13:09:04 -0400
committerMike Turquette <mturquette@linaro.org>2013-09-06 16:33:35 -0400
commit52b0601637ac41845d216c490a75e489a14c4e95 (patch)
tree2a6fd52588e76479386bbfe6e4bba6282cee5e77 /drivers/clk
parentc6415963006392cd67cb2d322c56ccc1711ac732 (diff)
clk: samsung: pll: Use new registration method for PLL45xx
This patch modifies PLL45xx support code and its users to use the recently introduced common PLL registration helper. Signed-off-by: Tomasz Figa <t.figa@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/samsung/clk-exynos4.c18
-rw-r--r--drivers/clk/samsung/clk-pll.c52
-rw-r--r--drivers/clk/samsung/clk-pll.h12
3 files changed, 20 insertions, 62 deletions
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index 41cbe6e7e182..fd0215d99c88 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -104,6 +104,7 @@
104#define DIV_DMC1 0x10504 104#define DIV_DMC1 0x10504
105#define GATE_IP_DMC 0x10900 105#define GATE_IP_DMC 0x10900
106#define APLL_LOCK 0x14000 106#define APLL_LOCK 0x14000
107#define E4210_MPLL_LOCK 0x14008
107#define APLL_CON0 0x14100 108#define APLL_CON0 0x14100
108#define E4210_MPLL_CON0 0x14108 109#define E4210_MPLL_CON0 0x14108
109#define SRC_CPU 0x14200 110#define SRC_CPU 0x14200
@@ -984,6 +985,13 @@ static struct of_device_id ext_clk_match[] __initdata = {
984 {}, 985 {},
985}; 986};
986 987
988static struct samsung_pll_clock exynos4210_plls[] __initdata = {
989 [apll] = PLL_A(pll_4508, fout_apll, "fout_apll", "fin_pll", APLL_LOCK,
990 APLL_CON0, "fout_apll", NULL),
991 [mpll] = PLL_A(pll_4508, fout_mpll, "fout_mpll", "fin_pll",
992 E4210_MPLL_LOCK, E4210_MPLL_CON0, "fout_mpll", NULL),
993};
994
987static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = { 995static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = {
988 [apll] = PLL(pll_35xx, fout_apll, "fout_apll", "fin_pll", 996 [apll] = PLL(pll_35xx, fout_apll, "fout_apll", "fin_pll",
989 APLL_LOCK, APLL_CON0, NULL), 997 APLL_LOCK, APLL_CON0, NULL),
@@ -1000,7 +1008,7 @@ static void __init exynos4_clk_init(struct device_node *np,
1000 enum exynos4_soc exynos4_soc, 1008 enum exynos4_soc exynos4_soc,
1001 void __iomem *reg_base, unsigned long xom) 1009 void __iomem *reg_base, unsigned long xom)
1002{ 1010{
1003 struct clk *apll, *mpll, *epll, *vpll; 1011 struct clk *epll, *vpll;
1004 1012
1005 reg_base = of_iomap(np, 0); 1013 reg_base = of_iomap(np, 0);
1006 if (!reg_base) 1014 if (!reg_base)
@@ -1022,17 +1030,13 @@ static void __init exynos4_clk_init(struct device_node *np,
1022 exynos4_clk_register_finpll(xom); 1030 exynos4_clk_register_finpll(xom);
1023 1031
1024 if (exynos4_soc == EXYNOS4210) { 1032 if (exynos4_soc == EXYNOS4210) {
1025 apll = samsung_clk_register_pll45xx("fout_apll", "fin_pll", 1033 samsung_clk_register_pll(exynos4210_plls,
1026 reg_base + APLL_CON0, pll_4508); 1034 ARRAY_SIZE(exynos4210_plls), reg_base);
1027 mpll = samsung_clk_register_pll45xx("fout_mpll", "fin_pll",
1028 reg_base + E4210_MPLL_CON0, pll_4508);
1029 epll = samsung_clk_register_pll46xx("fout_epll", "fin_pll", 1035 epll = samsung_clk_register_pll46xx("fout_epll", "fin_pll",
1030 reg_base + EPLL_CON0, pll_4600); 1036 reg_base + EPLL_CON0, pll_4600);
1031 vpll = samsung_clk_register_pll46xx("fout_vpll", "mout_vpllsrc", 1037 vpll = samsung_clk_register_pll46xx("fout_vpll", "mout_vpllsrc",
1032 reg_base + VPLL_CON0, pll_4650c); 1038 reg_base + VPLL_CON0, pll_4650c);
1033 1039
1034 samsung_clk_add_lookup(apll, fout_apll);
1035 samsung_clk_add_lookup(mpll, fout_mpll);
1036 samsung_clk_add_lookup(epll, fout_epll); 1040 samsung_clk_add_lookup(epll, fout_epll);
1037 samsung_clk_add_lookup(vpll, fout_vpll); 1041 samsung_clk_add_lookup(vpll, fout_vpll);
1038 } else { 1042 } else {
diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
index 7572d1d4fac1..f2e92e81173a 100644
--- a/drivers/clk/samsung/clk-pll.c
+++ b/drivers/clk/samsung/clk-pll.c
@@ -280,18 +280,10 @@ static const struct clk_ops samsung_pll36xx_clk_min_ops = {
280#define PLL45XX_PDIV_SHIFT (8) 280#define PLL45XX_PDIV_SHIFT (8)
281#define PLL45XX_SDIV_SHIFT (0) 281#define PLL45XX_SDIV_SHIFT (0)
282 282
283struct samsung_clk_pll45xx {
284 struct clk_hw hw;
285 enum pll45xx_type type;
286 const void __iomem *con_reg;
287};
288
289#define to_clk_pll45xx(_hw) container_of(_hw, struct samsung_clk_pll45xx, hw)
290
291static unsigned long samsung_pll45xx_recalc_rate(struct clk_hw *hw, 283static unsigned long samsung_pll45xx_recalc_rate(struct clk_hw *hw,
292 unsigned long parent_rate) 284 unsigned long parent_rate)
293{ 285{
294 struct samsung_clk_pll45xx *pll = to_clk_pll45xx(hw); 286 struct samsung_clk_pll *pll = to_clk_pll(hw);
295 u32 mdiv, pdiv, sdiv, pll_con; 287 u32 mdiv, pdiv, sdiv, pll_con;
296 u64 fvco = parent_rate; 288 u64 fvco = parent_rate;
297 289
@@ -313,43 +305,6 @@ static const struct clk_ops samsung_pll45xx_clk_ops = {
313 .recalc_rate = samsung_pll45xx_recalc_rate, 305 .recalc_rate = samsung_pll45xx_recalc_rate,
314}; 306};
315 307
316struct clk * __init samsung_clk_register_pll45xx(const char *name,
317 const char *pname, const void __iomem *con_reg,
318 enum pll45xx_type type)
319{
320 struct samsung_clk_pll45xx *pll;
321 struct clk *clk;
322 struct clk_init_data init;
323
324 pll = kzalloc(sizeof(*pll), GFP_KERNEL);
325 if (!pll) {
326 pr_err("%s: could not allocate pll clk %s\n", __func__, name);
327 return NULL;
328 }
329
330 init.name = name;
331 init.ops = &samsung_pll45xx_clk_ops;
332 init.flags = CLK_GET_RATE_NOCACHE;
333 init.parent_names = &pname;
334 init.num_parents = 1;
335
336 pll->hw.init = &init;
337 pll->con_reg = con_reg;
338 pll->type = type;
339
340 clk = clk_register(NULL, &pll->hw);
341 if (IS_ERR(clk)) {
342 pr_err("%s: failed to register pll clock %s\n", __func__,
343 name);
344 kfree(pll);
345 }
346
347 if (clk_register_clkdev(clk, name, NULL))
348 pr_err("%s: failed to register lookup for %s", __func__, name);
349
350 return clk;
351}
352
353/* 308/*
354 * PLL46xx Clock Type 309 * PLL46xx Clock Type
355 */ 310 */
@@ -635,6 +590,11 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
635 else 590 else
636 init.ops = &samsung_pll35xx_clk_ops; 591 init.ops = &samsung_pll35xx_clk_ops;
637 break; 592 break;
593 case pll_4500:
594 case pll_4502:
595 case pll_4508:
596 init.ops = &samsung_pll45xx_clk_ops;
597 break;
638 /* clk_ops for 36xx and 2650 are similar */ 598 /* clk_ops for 36xx and 2650 are similar */
639 case pll_36xx: 599 case pll_36xx:
640 case pll_2650: 600 case pll_2650:
diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h
index cd1103784f71..fceb2cb00f2a 100644
--- a/drivers/clk/samsung/clk-pll.h
+++ b/drivers/clk/samsung/clk-pll.h
@@ -17,6 +17,9 @@ enum samsung_pll_type {
17 pll_36xx, 17 pll_36xx,
18 pll_2550, 18 pll_2550,
19 pll_2650, 19 pll_2650,
20 pll_4500,
21 pll_4502,
22 pll_4508,
20 pll_6552, 23 pll_6552,
21 pll_6553, 24 pll_6553,
22}; 25};
@@ -48,21 +51,12 @@ struct samsung_pll_rate_table {
48 unsigned int kdiv; 51 unsigned int kdiv;
49}; 52};
50 53
51enum pll45xx_type {
52 pll_4500,
53 pll_4502,
54 pll_4508
55};
56
57enum pll46xx_type { 54enum pll46xx_type {
58 pll_4600, 55 pll_4600,
59 pll_4650, 56 pll_4650,
60 pll_4650c, 57 pll_4650c,
61}; 58};
62 59
63extern struct clk * __init samsung_clk_register_pll45xx(const char *name,
64 const char *pname, const void __iomem *con_reg,
65 enum pll45xx_type type);
66extern struct clk * __init samsung_clk_register_pll46xx(const char *name, 60extern struct clk * __init samsung_clk_register_pll46xx(const char *name,
67 const char *pname, const void __iomem *con_reg, 61 const char *pname, const void __iomem *con_reg,
68 enum pll46xx_type type); 62 enum pll46xx_type type);