/**
 * omap2_clksel_speculate() - recalc rate from speculative parent clock rate
 * @clk: struct clk * for the clock whose rate we are recalculating
 * @parent_rate: speculative parent clock rate
 *
 * This function takes a speculative or ficticious parent clock rate and
 * recalculates the rate for the clock in question based off of it.  Useful
 * for clock rate change pre-notifiers where we don't want to actually change
 * the clksel, or even the 'rate' field of a clk struct.
 */
unsigned long omap2_clksel_speculate(struct clk *clk, unsigned long parent_rate)
{
	unsigned long rate;
	u32 div = 0;

	/* check for fixed divisor */
	if (clk->fixed_div)
		return parent_rate / clk->fixed_div;

	/* does clock follow parent rate? */
	if (!clk->clksel)
		return parent_rate;

	/* clock must use clksel */
	div = _read_divisor(clk);
	if (div == 0)
		return clk->rate;

	rate = parent_rate / div;

	pr_debug("clock: %s: recalc'd rate is %ld (div %d)\n", clk->name,
		 rate, div);

	return rate;
}
Пример #2
0
unsigned long omap2_clksel_recalc(struct clk *clk)
{
	unsigned long rate;
	u32 div = 0;

	div = _read_divisor(clk);
	if (div == 0)
		return clk->rate;

	rate = clk->parent->rate / div;

	pr_debug("clock: %s: recalc'd rate is %ld (div %d)\n", clk->name,
		 rate, div);

	return rate;
}
Пример #3
0
/**
 * omap2_clksel_recalc() - function ptr to pass via struct clk .recalc field
 * @clk: struct clk *
 *
 * This function is intended to be called only by the clock framework.
 * Each clksel clock should have its struct clk .recalc field set to this
 * function.  Returns the clock's current rate, based on its parent's rate
 * and its current divisor setting in the hardware.
 */
unsigned long omap2_clksel_recalc(struct clk *clk)
{
	unsigned long rate;
	u32 div = 0, mul = 0;

	div = _read_divisor(clk, &mul);
	if (div == 0)
		return clk->rate;

	rate = _calculate_rate(clk->parent->rate, div, mul);

	pr_debug("clock: %s: recalc'd rate is %ld (div %d) (mul %d)\n",
		 clk->name, rate, div, mul);

	return rate;
}
Пример #4
0
/**
 * omap2_clksel_recalc() - function ptr to pass via struct clk .recalc field
 * @clk: struct clk *
 *
 * This function is intended to be called only by the clock framework.
 * Each clksel clock should have its struct clk .recalc field set to this
 * function.  Returns the clock's current rate, based on its parent's rate
 * and its current divisor setting in the hardware.
 */
unsigned long omap2_clksel_recalc(struct clk *clk)
{
	unsigned long rate;
	u32 div = 0;
	struct clk *parent;

	div = _read_divisor(clk);
	if (div == 0)
		return __clk_get_rate(clk);

	parent = __clk_get_parent(clk);
	rate = __clk_get_rate(parent) / div;

	pr_debug("clock: %s: recalc'd rate is %ld (div %d)\n",
		 __clk_get_name(clk), rate, div);

	return rate;
}