Skip to content

Commit

Permalink
clk: versatile: respect parent rate in ICST clock
Browse files Browse the repository at this point in the history
If the ICST clock has a parent, respect the rate of the parent
when calculating the clock frequency. As this involves modifying
the ICST parameter struct, make a cloned copy (the divisor
arrays should be safe) so we can update the .ref field.

Do not define the reference clock on the Integrator as we have
the reference clock from the device tree. Keep it everywhere
else.

Cc: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Linus Walleij committed Feb 13, 2014
1 parent bf6edb4 commit a183da6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 16 additions & 4 deletions drivers/clk/versatile/clk-icst.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct clk_icst {
struct clk_hw hw;
void __iomem *vcoreg;
void __iomem *lockreg;
const struct icst_params *params;
struct icst_params *params;
unsigned long rate;
};

Expand Down Expand Up @@ -84,6 +84,8 @@ static unsigned long icst_recalc_rate(struct clk_hw *hw,
struct clk_icst *icst = to_icst(hw);
struct icst_vco vco;

if (parent_rate)
icst->params->ref = parent_rate;
vco = vco_get(icst->vcoreg);
icst->rate = icst_hz(icst->params, vco);
return icst->rate;
Expand All @@ -105,6 +107,8 @@ static int icst_set_rate(struct clk_hw *hw, unsigned long rate,
struct clk_icst *icst = to_icst(hw);
struct icst_vco vco;

if (parent_rate)
icst->params->ref = parent_rate;
vco = icst_hz_to_vco(icst->params, rate);
icst->rate = icst_hz(icst->params, vco);
vco_set(icst->lockreg, icst->vcoreg, vco);
Expand All @@ -126,19 +130,27 @@ struct clk *icst_clk_register(struct device *dev,
struct clk *clk;
struct clk_icst *icst;
struct clk_init_data init;
struct icst_params *pclone;

icst = kzalloc(sizeof(struct clk_icst), GFP_KERNEL);
if (!icst) {
pr_err("could not allocate ICST clock!\n");
return ERR_PTR(-ENOMEM);
}

pclone = kmemdup(desc->params, sizeof(*pclone), GFP_KERNEL);
if (!pclone) {
pr_err("could not clone ICST params\n");
return ERR_PTR(-ENOMEM);
}

init.name = name;
init.ops = &icst_ops;
init.flags = CLK_IS_ROOT;
init.parent_names = NULL;
init.num_parents = 0;
init.parent_names = (parent_name ? &parent_name : NULL);
init.num_parents = (parent_name ? 1 : 0);
icst->hw.init = &init;
icst->params = desc->params;
icst->params = pclone;
icst->vcoreg = base + desc->vco_offset;
icst->lockreg = base + desc->lock_offset;

Expand Down
1 change: 0 additions & 1 deletion drivers/clk/versatile/clk-integrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
static void __iomem *cm_base;

static const struct icst_params cp_auxosc_params = {
.ref = 24000000,
.vco_max = ICST525_VCO_MAX_5V,
.vco_min = ICST525_VCO_MIN,
.vd_min = 8,
Expand Down

0 comments on commit a183da6

Please sign in to comment.