diff options
author | Tang Yuantian <Yuantian.Tang@freescale.com> | 2015-01-15 01:03:40 -0500 |
---|---|---|
committer | Michael Turquette <mturquette@linaro.org> | 2015-01-20 13:09:10 -0500 |
commit | 57bfd7ee6fa9811481e6d67ff18aa90951dd974e (patch) | |
tree | 94f029d7ed9a6c76fad7e48ed05db98702115715 | |
parent | 11144283123355d232e3565b224730315b8c3c72 (diff) |
clock: redefine variable clocks_per_pll as a struct member
redefine variable clocks_per_pll as a struct member
If there are multiple PLL clock nodes, this variable will
get overwritten. Redefining it as a struct member can avoid that.
Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
-rw-r--r-- | drivers/clk/clk-ppc-corenet.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/clk/clk-ppc-corenet.c b/drivers/clk/clk-ppc-corenet.c index 57a2de47d2cb..5e9bb18a5249 100644 --- a/drivers/clk/clk-ppc-corenet.c +++ b/drivers/clk/clk-ppc-corenet.c | |||
@@ -19,6 +19,7 @@ | |||
19 | struct cmux_clk { | 19 | struct cmux_clk { |
20 | struct clk_hw hw; | 20 | struct clk_hw hw; |
21 | void __iomem *reg; | 21 | void __iomem *reg; |
22 | unsigned int clk_per_pll; | ||
22 | u32 flags; | 23 | u32 flags; |
23 | }; | 24 | }; |
24 | 25 | ||
@@ -27,14 +28,12 @@ struct cmux_clk { | |||
27 | #define CLKSEL_ADJUST BIT(0) | 28 | #define CLKSEL_ADJUST BIT(0) |
28 | #define to_cmux_clk(p) container_of(p, struct cmux_clk, hw) | 29 | #define to_cmux_clk(p) container_of(p, struct cmux_clk, hw) |
29 | 30 | ||
30 | static unsigned int clocks_per_pll; | ||
31 | |||
32 | static int cmux_set_parent(struct clk_hw *hw, u8 idx) | 31 | static int cmux_set_parent(struct clk_hw *hw, u8 idx) |
33 | { | 32 | { |
34 | struct cmux_clk *clk = to_cmux_clk(hw); | 33 | struct cmux_clk *clk = to_cmux_clk(hw); |
35 | u32 clksel; | 34 | u32 clksel; |
36 | 35 | ||
37 | clksel = ((idx / clocks_per_pll) << 2) + idx % clocks_per_pll; | 36 | clksel = ((idx / clk->clk_per_pll) << 2) + idx % clk->clk_per_pll; |
38 | if (clk->flags & CLKSEL_ADJUST) | 37 | if (clk->flags & CLKSEL_ADJUST) |
39 | clksel += 8; | 38 | clksel += 8; |
40 | clksel = (clksel & 0xf) << CLKSEL_SHIFT; | 39 | clksel = (clksel & 0xf) << CLKSEL_SHIFT; |
@@ -52,7 +51,7 @@ static u8 cmux_get_parent(struct clk_hw *hw) | |||
52 | clksel = (clksel >> CLKSEL_SHIFT) & 0xf; | 51 | clksel = (clksel >> CLKSEL_SHIFT) & 0xf; |
53 | if (clk->flags & CLKSEL_ADJUST) | 52 | if (clk->flags & CLKSEL_ADJUST) |
54 | clksel -= 8; | 53 | clksel -= 8; |
55 | clksel = (clksel >> 2) * clocks_per_pll + clksel % 4; | 54 | clksel = (clksel >> 2) * clk->clk_per_pll + clksel % 4; |
56 | 55 | ||
57 | return clksel; | 56 | return clksel; |
58 | } | 57 | } |
@@ -72,6 +71,7 @@ static void __init core_mux_init(struct device_node *np) | |||
72 | u32 offset; | 71 | u32 offset; |
73 | const char *clk_name; | 72 | const char *clk_name; |
74 | const char **parent_names; | 73 | const char **parent_names; |
74 | struct of_phandle_args clkspec; | ||
75 | 75 | ||
76 | rc = of_property_read_u32(np, "reg", &offset); | 76 | rc = of_property_read_u32(np, "reg", &offset); |
77 | if (rc) { | 77 | if (rc) { |
@@ -105,6 +105,17 @@ static void __init core_mux_init(struct device_node *np) | |||
105 | goto err_clk; | 105 | goto err_clk; |
106 | } | 106 | } |
107 | 107 | ||
108 | rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", 0, | ||
109 | &clkspec); | ||
110 | if (rc) { | ||
111 | pr_err("%s: parse clock node error\n", __func__); | ||
112 | goto err_clk; | ||
113 | } | ||
114 | |||
115 | cmux_clk->clk_per_pll = of_property_count_strings(clkspec.np, | ||
116 | "clock-output-names"); | ||
117 | of_node_put(clkspec.np); | ||
118 | |||
108 | node = of_find_compatible_node(NULL, NULL, "fsl,p4080-clockgen"); | 119 | node = of_find_compatible_node(NULL, NULL, "fsl,p4080-clockgen"); |
109 | if (node && (offset >= 0x80)) | 120 | if (node && (offset >= 0x80)) |
110 | cmux_clk->flags = CLKSEL_ADJUST; | 121 | cmux_clk->flags = CLKSEL_ADJUST; |
@@ -181,9 +192,6 @@ static void __init core_pll_init(struct device_node *np) | |||
181 | goto err_map; | 192 | goto err_map; |
182 | } | 193 | } |
183 | 194 | ||
184 | /* output clock number per PLL */ | ||
185 | clocks_per_pll = count; | ||
186 | |||
187 | subclks = kzalloc(sizeof(struct clk *) * count, GFP_KERNEL); | 195 | subclks = kzalloc(sizeof(struct clk *) * count, GFP_KERNEL); |
188 | if (!subclks) { | 196 | if (!subclks) { |
189 | pr_err("%s: could not allocate subclks\n", __func__); | 197 | pr_err("%s: could not allocate subclks\n", __func__); |