clk: add clk_set_parent()

Clocks may support multiple parents: this change introduces an
optional operation on the clk-uclass to set a clock's parent.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: David Wu <david.wu@rock-chips.com>

Series-changes: 2
- Fixed David's email address.

(cherry picked from commit f7d1046da18fd03a047b5f4d290a8ab8550ebf73)

Change-Id: I92065a132988a66b7d86a936766429ea024f4d1e
Signed-off-by: David Wu <david.wu@rock-chips.com>
This commit is contained in:
Philipp Tomsich 2018-01-08 11:15:08 +01:00 committed by David Wu
parent eda90cbc2a
commit 4686bbffed
3 changed files with 31 additions and 0 deletions

View File

@ -208,6 +208,18 @@ int clk_set_phase(struct clk *clk, int degrees)
return ops->set_phase(clk, degrees);
}
int clk_set_parent(struct clk *clk, struct clk *parent)
{
const struct clk_ops *ops = clk_dev_ops(clk->dev);
debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent);
if (!ops->set_parent)
return -ENOSYS;
return ops->set_parent(clk, parent);
}
int clk_enable(struct clk *clk)
{
const struct clk_ops *ops = clk_dev_ops(clk->dev);

View File

@ -94,6 +94,14 @@ struct clk_ops {
* @return 0 on success, or -ve error code.
*/
int (*set_phase)(struct clk *clk, int degrees);
/**
* set_parent() - Set current clock parent
*
* @clk: The clock to manipulate.
* @parent: New clock parent.
* @return zero on success, or -ve error code.
*/
int (*set_parent)(struct clk *clk, struct clk *parent);
/**
* enable() - Enable a clock.
*

View File

@ -197,6 +197,17 @@ int clk_get_phase(struct clk *clk);
*/
int clk_set_phase(struct clk *clk, int degrees);
/**
* clk_set_parent() - Set current clock parent.
*
* @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
* @parent: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
* @return new rate, or -ve error code.
*/
int clk_set_parent(struct clk *clk, struct clk *parent);
/**
* clk_enable() - Enable (turn on) a clock.
*