Commit 391e3903 authored by Mike Turquette's avatar Mike Turquette

Merge branch 'for_3.14/keystone-clk' of...

Merge branch 'for_3.14/keystone-clk' of git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone into clk-next-keystone
parents 6b71e0d9 e0c223ec
...@@ -17,13 +17,14 @@ Required properties: ...@@ -17,13 +17,14 @@ Required properties:
- reg - pll control0 and pll multipler registers - reg - pll control0 and pll multipler registers
- reg-names : control and multiplier. The multiplier is applicable only for - reg-names : control and multiplier. The multiplier is applicable only for
main pll clock main pll clock
- fixed-postdiv : fixed post divider value - fixed-postdiv : fixed post divider value. If absent, use clkod register bits
for postdiv
Example: Example:
mainpllclk: mainpllclk@2310110 { mainpllclk: mainpllclk@2310110 {
#clock-cells = <0>; #clock-cells = <0>;
compatible = "ti,keystone,main-pll-clock"; compatible = "ti,keystone,main-pll-clock";
clocks = <&refclkmain>; clocks = <&refclksys>;
reg = <0x02620350 4>, <0x02310110 4>; reg = <0x02620350 4>, <0x02310110 4>;
reg-names = "control", "multiplier"; reg-names = "control", "multiplier";
fixed-postdiv = <2>; fixed-postdiv = <2>;
...@@ -32,11 +33,10 @@ Example: ...@@ -32,11 +33,10 @@ Example:
papllclk: papllclk@2620358 { papllclk: papllclk@2620358 {
#clock-cells = <0>; #clock-cells = <0>;
compatible = "ti,keystone,pll-clock"; compatible = "ti,keystone,pll-clock";
clocks = <&refclkmain>; clocks = <&refclkpass>;
clock-output-names = "pa-pll-clk"; clock-output-names = "pa-pll-clk";
reg = <0x02620358 4>; reg = <0x02620358 4>;
reg-names = "control"; reg-names = "control";
fixed-postdiv = <6>;
}; };
Required properties: Required properties:
......
...@@ -223,8 +223,7 @@ static void __init of_psc_clk_init(struct device_node *node, spinlock_t *lock) ...@@ -223,8 +223,7 @@ static void __init of_psc_clk_init(struct device_node *node, spinlock_t *lock)
data->domain_base = of_iomap(node, i); data->domain_base = of_iomap(node, i);
if (!data->domain_base) { if (!data->domain_base) {
pr_err("%s: domain ioremap failed\n", __func__); pr_err("%s: domain ioremap failed\n", __func__);
iounmap(data->control_base); goto unmap_ctrl;
goto out;
} }
of_property_read_u32(node, "domain-id", &data->domain_id); of_property_read_u32(node, "domain-id", &data->domain_id);
...@@ -237,16 +236,21 @@ static void __init of_psc_clk_init(struct device_node *node, spinlock_t *lock) ...@@ -237,16 +236,21 @@ static void __init of_psc_clk_init(struct device_node *node, spinlock_t *lock)
parent_name = of_clk_get_parent_name(node, 0); parent_name = of_clk_get_parent_name(node, 0);
if (!parent_name) { if (!parent_name) {
pr_err("%s: Parent clock not found\n", __func__); pr_err("%s: Parent clock not found\n", __func__);
goto out; goto unmap_domain;
} }
clk = clk_register_psc(NULL, clk_name, parent_name, data, lock); clk = clk_register_psc(NULL, clk_name, parent_name, data, lock);
if (clk) { if (!IS_ERR(clk)) {
of_clk_add_provider(node, of_clk_src_simple_get, clk); of_clk_add_provider(node, of_clk_src_simple_get, clk);
return; return;
} }
pr_err("%s: error registering clk %s\n", __func__, node->name); pr_err("%s: error registering clk %s\n", __func__, node->name);
unmap_domain:
iounmap(data->domain_base);
unmap_ctrl:
iounmap(data->control_base);
out: out:
kfree(data); kfree(data);
return; return;
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#define MAIN_PLLM_HIGH_MASK 0x7f000 #define MAIN_PLLM_HIGH_MASK 0x7f000
#define PLLM_HIGH_SHIFT 6 #define PLLM_HIGH_SHIFT 6
#define PLLD_MASK 0x3f #define PLLD_MASK 0x3f
#define CLKOD_MASK 0x780000
#define CLKOD_SHIFT 19
/** /**
* struct clk_pll_data - pll data structure * struct clk_pll_data - pll data structure
...@@ -41,7 +43,10 @@ ...@@ -41,7 +43,10 @@
* @pllm_upper_mask: multiplier upper mask * @pllm_upper_mask: multiplier upper mask
* @pllm_upper_shift: multiplier upper shift * @pllm_upper_shift: multiplier upper shift
* @plld_mask: divider mask * @plld_mask: divider mask
* @postdiv: Post divider * @clkod_mask: output divider mask
* @clkod_shift: output divider shift
* @plld_mask: divider mask
* @postdiv: Fixed post divider
*/ */
struct clk_pll_data { struct clk_pll_data {
bool has_pllctrl; bool has_pllctrl;
...@@ -53,6 +58,8 @@ struct clk_pll_data { ...@@ -53,6 +58,8 @@ struct clk_pll_data {
u32 pllm_upper_mask; u32 pllm_upper_mask;
u32 pllm_upper_shift; u32 pllm_upper_shift;
u32 plld_mask; u32 plld_mask;
u32 clkod_mask;
u32 clkod_shift;
u32 postdiv; u32 postdiv;
}; };
...@@ -90,7 +97,13 @@ static unsigned long clk_pllclk_recalc(struct clk_hw *hw, ...@@ -90,7 +97,13 @@ static unsigned long clk_pllclk_recalc(struct clk_hw *hw,
mult |= ((val & pll_data->pllm_upper_mask) mult |= ((val & pll_data->pllm_upper_mask)
>> pll_data->pllm_upper_shift); >> pll_data->pllm_upper_shift);
prediv = (val & pll_data->plld_mask); prediv = (val & pll_data->plld_mask);
postdiv = pll_data->postdiv;
if (!pll_data->has_pllctrl)
/* read post divider from od bits*/
postdiv = ((val & pll_data->clkod_mask) >>
pll_data->clkod_shift) + 1;
else
postdiv = pll_data->postdiv;
rate /= (prediv + 1); rate /= (prediv + 1);
rate = (rate * (mult + 1)); rate = (rate * (mult + 1));
...@@ -155,8 +168,11 @@ static void __init _of_pll_clk_init(struct device_node *node, bool pllctrl) ...@@ -155,8 +168,11 @@ static void __init _of_pll_clk_init(struct device_node *node, bool pllctrl)
} }
parent_name = of_clk_get_parent_name(node, 0); parent_name = of_clk_get_parent_name(node, 0);
if (of_property_read_u32(node, "fixed-postdiv", &pll_data->postdiv)) if (of_property_read_u32(node, "fixed-postdiv", &pll_data->postdiv)) {
goto out; /* assume the PLL has output divider register bits */
pll_data->clkod_mask = CLKOD_MASK;
pll_data->clkod_shift = CLKOD_SHIFT;
}
i = of_property_match_string(node, "reg-names", "control"); i = of_property_match_string(node, "reg-names", "control");
pll_data->pll_ctl0 = of_iomap(node, i); pll_data->pll_ctl0 = of_iomap(node, i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment