diff mbox series

timer-uclass: Always use "clock-frequency" property as fallback

Message ID 20231114211127.52443-1-knaerzche@gmail.com
State Accepted
Commit d6d8078cb3604b60a579eb700ef8151d2b2b25fa
Delegated to: Tom Rini
Headers show
Series timer-uclass: Always use "clock-frequency" property as fallback | expand

Commit Message

Alex Bee Nov. 14, 2023, 9:11 p.m. UTC
Currently the "clock-frequency" DT property is only being considered as an
fallback if either there is no clock driver, the clock driver implements
the request-op correctly or there is no clock defined for the timer at all.

This patch makes "clock-frequency" also being picked as a fallback if
getting the clock-rate fails, since clk_get(_by_index) will return no
error, if a clock driver does not implement the request-op and does also
not support getting the rate of the clock in question.
timer_post_probe will take care if the property does not exist in the DT or
is defined as 0.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
---
This is currently an issue for Rockchip RK3188 and potentially also for RK3368:
The clock driver does not implement the request-op. Even if we would add it:
timer-uclass always picks the first clock and the DT bindings for Rockchip timer
requires us to place the pclk first and and the timer source clock second.

 drivers/timer/timer-uclass.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Tom Rini Nov. 29, 2023, 4:57 p.m. UTC | #1
On Tue, Nov 14, 2023 at 10:11:27PM +0100, Alex Bee wrote:

> Currently the "clock-frequency" DT property is only being considered as an
> fallback if either there is no clock driver, the clock driver implements
> the request-op correctly or there is no clock defined for the timer at all.
> 
> This patch makes "clock-frequency" also being picked as a fallback if
> getting the clock-rate fails, since clk_get(_by_index) will return no
> error, if a clock driver does not implement the request-op and does also
> not support getting the rate of the clock in question.
> timer_post_probe will take care if the property does not exist in the DT or
> is defined as 0.
> 
> Signed-off-by: Alex Bee <knaerzche@gmail.com>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 0c2018bfe3..60ff65529a 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -66,13 +66,13 @@  static int timer_pre_probe(struct udevice *dev)
 		err = clk_get_by_index(dev, 0, &timer_clk);
 		if (!err) {
 			ret = clk_get_rate(&timer_clk);
-			if (IS_ERR_VALUE(ret))
-				return ret;
-			uc_priv->clock_rate = ret;
-		} else {
-			uc_priv->clock_rate =
-				dev_read_u32_default(dev, "clock-frequency", 0);
+			if (!IS_ERR_VALUE(ret)) {
+				uc_priv->clock_rate = ret;
+				return 0;
+			}
 		}
+
+		uc_priv->clock_rate = dev_read_u32_default(dev, "clock-frequency", 0);
 	}
 
 	return 0;