Skip to content

Commit dbb4e67

Browse files
Murali KaricheriSantosh Shilimkar
authored andcommitted
clk: keystone: use clkod register bits for postdiv
DDR3A/B, ARM and PA PLL controllers have clkod register bits for configuring postdiv values. So use it instead of using fixed post dividers for these pll controllers. Assume that if fixed-postdiv attribute is not present, use clkod register value for pistdiv. Also update the Documentation of bindings to reflect the same. Cc: Mike Turquette <mturquette@linaro.org Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
1 parent 6ce4eac commit dbb4e67

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

‎Documentation/devicetree/bindings/clock/keystone-pll.txt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ Required properties:
1717
- reg - pll control0 and pll multipler registers
1818
- reg-names : control and multiplier. The multiplier is applicable only for
1919
main pll clock
20-
- fixed-postdiv : fixed post divider value
20+
- fixed-postdiv : fixed post divider value. If absent, use clkod register bits
21+
for postdiv
2122

2223
Example:
2324
mainpllclk: mainpllclk@2310110 {
2425
#clock-cells = <0>;
2526
compatible = "ti,keystone,main-pll-clock";
26-
clocks = <&refclkmain>;
27+
clocks = <&refclksys>;
2728
reg = <0x02620350 4>, <0x02310110 4>;
2829
reg-names = "control", "multiplier";
2930
fixed-postdiv = <2>;
@@ -32,11 +33,10 @@ Example:
3233
papllclk: papllclk@2620358 {
3334
#clock-cells = <0>;
3435
compatible = "ti,keystone,pll-clock";
35-
clocks = <&refclkmain>;
36+
clocks = <&refclkpass>;
3637
clock-output-names = "pa-pll-clk";
3738
reg = <0x02620358 4>;
3839
reg-names = "control";
39-
fixed-postdiv = <6>;
4040
};
4141

4242
Required properties:

‎drivers/clk/keystone/pll.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#define MAIN_PLLM_HIGH_MASK 0x7f000
2525
#define PLLM_HIGH_SHIFT 6
2626
#define PLLD_MASK 0x3f
27+
#define CLKOD_MASK 0x780000
28+
#define CLKOD_SHIFT 19
2729

2830
/**
2931
* struct clk_pll_data - pll data structure
@@ -41,7 +43,10 @@
4143
* @pllm_upper_mask: multiplier upper mask
4244
* @pllm_upper_shift: multiplier upper shift
4345
* @plld_mask: divider mask
44-
* @postdiv: Post divider
46+
* @clkod_mask: output divider mask
47+
* @clkod_shift: output divider shift
48+
* @plld_mask: divider mask
49+
* @postdiv: Fixed post divider
4550
*/
4651
struct clk_pll_data {
4752
bool has_pllctrl;
@@ -53,6 +58,8 @@ struct clk_pll_data {
5358
u32 pllm_upper_mask;
5459
u32 pllm_upper_shift;
5560
u32 plld_mask;
61+
u32 clkod_mask;
62+
u32 clkod_shift;
5663
u32 postdiv;
5764
};
5865

@@ -90,7 +97,13 @@ static unsigned long clk_pllclk_recalc(struct clk_hw *hw,
9097
mult |= ((val & pll_data->pllm_upper_mask)
9198
>> pll_data->pllm_upper_shift);
9299
prediv = (val & pll_data->plld_mask);
93-
postdiv = pll_data->postdiv;
100+
101+
if (!pll_data->has_pllctrl)
102+
/* read post divider from od bits*/
103+
postdiv = ((val & pll_data->clkod_mask) >>
104+
pll_data->clkod_shift) + 1;
105+
else
106+
postdiv = pll_data->postdiv;
94107

95108
rate /= (prediv + 1);
96109
rate = (rate * (mult + 1));
@@ -155,8 +168,11 @@ static void __init _of_pll_clk_init(struct device_node *node, bool pllctrl)
155168
}
156169

157170
parent_name = of_clk_get_parent_name(node, 0);
158-
if (of_property_read_u32(node, "fixed-postdiv", &pll_data->postdiv))
159-
goto out;
171+
if (of_property_read_u32(node, "fixed-postdiv", &pll_data->postdiv)) {
172+
/* assume the PLL has output divider register bits */
173+
pll_data->clkod_mask = CLKOD_MASK;
174+
pll_data->clkod_shift = CLKOD_SHIFT;
175+
}
160176

161177
i = of_property_match_string(node, "reg-names", "control");
162178
pll_data->pll_ctl0 = of_iomap(node, i);

0 commit comments

Comments
 (0)