mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
clk: introduce clk_set_phase function & callback
A common operation for a clock signal generator is to shift the phase of that signal. This patch introduces a new function to the clk.h API to dynamically adjust the phase of a clock signal. Additionally this patch introduces support for the new function in the common clock framework via the .set_phase call back in struct clk_ops. Signed-off-by: Mike Turquette <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Acked-by: Hans de Goede <[email protected]>
This commit is contained in:
parent
cfe4c93b58
commit
e59c5371fb
4 changed files with 116 additions and 4 deletions
|
|
@ -117,11 +117,11 @@ static void clk_summary_show_one(struct seq_file *s, struct clk *c, int level)
|
|||
if (!c)
|
||||
return;
|
||||
|
||||
seq_printf(s, "%*s%-*s %11d %12d %11lu %10lu\n",
|
||||
seq_printf(s, "%*s%-*s %11d %12d %11lu %10lu %-3d\n",
|
||||
level * 3 + 1, "",
|
||||
30 - level * 3, c->name,
|
||||
c->enable_count, c->prepare_count, clk_get_rate(c),
|
||||
clk_get_accuracy(c));
|
||||
clk_get_accuracy(c), clk_get_phase(c));
|
||||
}
|
||||
|
||||
static void clk_summary_show_subtree(struct seq_file *s, struct clk *c,
|
||||
|
|
@ -143,8 +143,8 @@ static int clk_summary_show(struct seq_file *s, void *data)
|
|||
struct clk *c;
|
||||
struct hlist_head **lists = (struct hlist_head **)s->private;
|
||||
|
||||
seq_puts(s, " clock enable_cnt prepare_cnt rate accuracy\n");
|
||||
seq_puts(s, "--------------------------------------------------------------------------------\n");
|
||||
seq_puts(s, " clock enable_cnt prepare_cnt rate accuracy phase\n");
|
||||
seq_puts(s, "----------------------------------------------------------------------------------------\n");
|
||||
|
||||
clk_prepare_lock();
|
||||
|
||||
|
|
@ -180,6 +180,7 @@ static void clk_dump_one(struct seq_file *s, struct clk *c, int level)
|
|||
seq_printf(s, "\"prepare_count\": %d,", c->prepare_count);
|
||||
seq_printf(s, "\"rate\": %lu", clk_get_rate(c));
|
||||
seq_printf(s, "\"accuracy\": %lu", clk_get_accuracy(c));
|
||||
seq_printf(s, "\"phase\": %d", clk_get_phase(c));
|
||||
}
|
||||
|
||||
static void clk_dump_subtree(struct seq_file *s, struct clk *c, int level)
|
||||
|
|
@ -264,6 +265,11 @@ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry)
|
|||
if (!d)
|
||||
goto err_out;
|
||||
|
||||
d = debugfs_create_u32("clk_phase", S_IRUGO, clk->dentry,
|
||||
(u32 *)&clk->phase);
|
||||
if (!d)
|
||||
goto err_out;
|
||||
|
||||
d = debugfs_create_x32("clk_flags", S_IRUGO, clk->dentry,
|
||||
(u32 *)&clk->flags);
|
||||
if (!d)
|
||||
|
|
@ -1738,6 +1744,77 @@ out:
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(clk_set_parent);
|
||||
|
||||
/**
|
||||
* clk_set_phase - adjust the phase shift of a clock signal
|
||||
* @clk: clock signal source
|
||||
* @degrees: number of degrees the signal is shifted
|
||||
*
|
||||
* Shifts the phase of a clock signal by the specified
|
||||
* degrees. Returns 0 on success, -EERROR otherwise.
|
||||
*
|
||||
* This function makes no distinction about the input or reference
|
||||
* signal that we adjust the clock signal phase against. For example
|
||||
* phase locked-loop clock signal generators we may shift phase with
|
||||
* respect to feedback clock signal input, but for other cases the
|
||||
* clock phase may be shifted with respect to some other, unspecified
|
||||
* signal.
|
||||
*
|
||||
* Additionally the concept of phase shift does not propagate through
|
||||
* the clock tree hierarchy, which sets it apart from clock rates and
|
||||
* clock accuracy. A parent clock phase attribute does not have an
|
||||
* impact on the phase attribute of a child clock.
|
||||
*/
|
||||
int clk_set_phase(struct clk *clk, int degrees)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!clk)
|
||||
goto out;
|
||||
|
||||
/* sanity check degrees */
|
||||
degrees %= 360;
|
||||
if (degrees < 0)
|
||||
degrees += 360;
|
||||
|
||||
clk_prepare_lock();
|
||||
|
||||
if (!clk->ops->set_phase)
|
||||
goto out_unlock;
|
||||
|
||||
ret = clk->ops->set_phase(clk->hw, degrees);
|
||||
|
||||
if (!ret)
|
||||
clk->phase = degrees;
|
||||
|
||||
out_unlock:
|
||||
clk_prepare_unlock();
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* clk_get_phase - return the phase shift of a clock signal
|
||||
* @clk: clock signal source
|
||||
*
|
||||
* Returns the phase shift of a clock node in degrees, otherwise returns
|
||||
* -EERROR.
|
||||
*/
|
||||
int clk_get_phase(struct clk *clk)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!clk)
|
||||
goto out;
|
||||
|
||||
clk_prepare_lock();
|
||||
ret = clk->phase;
|
||||
clk_prepare_unlock();
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* __clk_init - initialize the data structures in a struct clk
|
||||
* @dev: device initializing this clk, placeholder for now
|
||||
|
|
|
|||
Loading…
Reference in a new issue