Skip to content

Commit

Permalink
clk: fixed-rate: Add clk flags for parent accuracy
Browse files Browse the repository at this point in the history
Some clk providers want to use the accuracy of the parent clk and use
the fixed rate basic type clk to do that. This requires getting the
parent clk and extracting the accuracy before registering the fixed rate
clk. Let's add a flag for this and update the clk_ops to support this.

Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lkml.kernel.org/r/20190830150923.259497-8-sboyd@kernel.org
  • Loading branch information
Stephen Boyd committed Jan 7, 2020
1 parent 2d34f09 commit 58f0c4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/clk/clk-fixed-rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ static unsigned long clk_fixed_rate_recalc_rate(struct clk_hw *hw,
static unsigned long clk_fixed_rate_recalc_accuracy(struct clk_hw *hw,
unsigned long parent_accuracy)
{
return to_clk_fixed_rate(hw)->fixed_accuracy;
struct clk_fixed_rate *fixed = to_clk_fixed_rate(hw);

if (fixed->flags & CLK_FIXED_RATE_PARENT_ACCURACY)
return parent_accuracy;

return fixed->fixed_accuracy;
}

const struct clk_ops clk_fixed_rate_ops = {
Expand Down
6 changes: 6 additions & 0 deletions include/linux/clk-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ struct clk_hw {
* @fixed_rate: constant frequency of clock
* @fixed_accuracy: constant accuracy of clock in ppb (parts per billion)
* @flags: hardware specific flags
*
* Flags:
* * CLK_FIXED_RATE_PARENT_ACCURACY - Use the accuracy of the parent clk
* instead of what's set in @fixed_accuracy.
*/
struct clk_fixed_rate {
struct clk_hw hw;
Expand All @@ -331,6 +335,8 @@ struct clk_fixed_rate {
unsigned long flags;
};

#define CLK_FIXED_RATE_PARENT_ACCURACY BIT(0)

extern const struct clk_ops clk_fixed_rate_ops;
struct clk_hw *__clk_hw_register_fixed_rate(struct device *dev,
struct device_node *np, const char *name,
Expand Down

0 comments on commit 58f0c4b

Please sign in to comment.