]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
timer-uclass: Always use "clock-frequency" property as fallback
authorAlex Bee <knaerzche@gmail.com>
Tue, 14 Nov 2023 21:11:27 +0000 (22:11 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 29 Nov 2023 14:32:15 +0000 (09:32 -0500)
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>
drivers/timer/timer-uclass.c

index 0c2018bfe3b0c2b7f6d0d833e8918d6e963c8709..60ff65529ab38b74d77ca6ae6c83a2254c020881 100644 (file)
@@ -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;