All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: divider: fix clk_round_rate() when CLK_DIVIDER_READ_ONLY && CLK_RATE_SET_PARENT
@ 2018-01-06 18:19 David Lechner
  2018-01-10 22:03 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: David Lechner @ 2018-01-06 18:19 UTC (permalink / raw)
  To: linux-clk; +Cc: David Lechner, Michael Turquette, Stephen Boyd, linux-kernel

clk_round_rate() 'answers the question "if I were to pass @rate to
clk_set_rate(), what clock rate would I end up with?" without changing
the hardware'.

Currently, clk_divider_round_rate() returns the "current value" when
divider->flags & CLK_DIVIDER_READ_ONLY. But, if CLK_SET_RATE_PARENT is
set, then clk_set_rate() is supposed to propagate the rate change to the
parent clock. So, we need to do check for CLK_SET_RATE_PARENT and if it
is set, ask the parent clock what rate it can provide given the current
divider value.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/clk/clk-divider.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 4ed516c..cffe9ef 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -357,6 +357,13 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
 		bestdiv &= div_mask(divider->width);
 		bestdiv = _get_div(divider->table, bestdiv, divider->flags,
 			divider->width);
+
+		if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
+			struct clk_hw *parent = clk_hw_get_parent(hw);
+
+			*prate = clk_hw_round_rate(parent, rate * bestdiv);
+		}
+
 		return DIV_ROUND_UP_ULL((u64)*prate, bestdiv);
 	}
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: divider: fix clk_round_rate() when CLK_DIVIDER_READ_ONLY && CLK_RATE_SET_PARENT
  2018-01-06 18:19 [PATCH] clk: divider: fix clk_round_rate() when CLK_DIVIDER_READ_ONLY && CLK_RATE_SET_PARENT David Lechner
@ 2018-01-10 22:03 ` Stephen Boyd
  2018-01-11 23:10   ` David Lechner
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2018-01-10 22:03 UTC (permalink / raw)
  To: David Lechner; +Cc: linux-clk, Michael Turquette, linux-kernel

On 01/06, David Lechner wrote:
> clk_round_rate() 'answers the question "if I were to pass @rate to
> clk_set_rate(), what clock rate would I end up with?" without changing
> the hardware'.
> 
> Currently, clk_divider_round_rate() returns the "current value" when
> divider->flags & CLK_DIVIDER_READ_ONLY. But, if CLK_SET_RATE_PARENT is
> set, then clk_set_rate() is supposed to propagate the rate change to the
> parent clock. So, we need to do check for CLK_SET_RATE_PARENT and if it
> is set, ask the parent clock what rate it can provide given the current
> divider value.
> 
> Signed-off-by: David Lechner <david@lechnology.com>

Jerome sent a patch the day before that probably addresses the
same thing. See the message-id of 20180105170959.17266-2-jbrunet@baylibre.com
for more info.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: divider: fix clk_round_rate() when CLK_DIVIDER_READ_ONLY && CLK_RATE_SET_PARENT
  2018-01-10 22:03 ` Stephen Boyd
@ 2018-01-11 23:10   ` David Lechner
  0 siblings, 0 replies; 3+ messages in thread
From: David Lechner @ 2018-01-11 23:10 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: linux-clk, Michael Turquette, linux-kernel

On 01/10/2018 04:03 PM, Stephen Boyd wrote:
> On 01/06, David Lechner wrote:
>> clk_round_rate() 'answers the question "if I were to pass @rate to
>> clk_set_rate(), what clock rate would I end up with?" without changing
>> the hardware'.
>>
>> Currently, clk_divider_round_rate() returns the "current value" when
>> divider->flags & CLK_DIVIDER_READ_ONLY. But, if CLK_SET_RATE_PARENT is
>> set, then clk_set_rate() is supposed to propagate the rate change to the
>> parent clock. So, we need to do check for CLK_SET_RATE_PARENT and if it
>> is set, ask the parent clock what rate it can provide given the current
>> divider value.
>>
>> Signed-off-by: David Lechner <david@lechnology.com>
> 
> Jerome sent a patch the day before that probably addresses the
> same thing. See the message-id of 20180105170959.17266-2-jbrunet@baylibre.com
> for more info.
> 

Indeed, thank you. We can drop this patch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-11 23:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-06 18:19 [PATCH] clk: divider: fix clk_round_rate() when CLK_DIVIDER_READ_ONLY && CLK_RATE_SET_PARENT David Lechner
2018-01-10 22:03 ` Stephen Boyd
2018-01-11 23:10   ` David Lechner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.