From d6d8078cb3604b60a579eb700ef8151d2b2b25fa Mon Sep 17 00:00:00 2001 From: Alex Bee Date: Tue, 14 Nov 2023 22:11:27 +0100 Subject: timer-uclass: Always use "clock-frequency" property as fallback 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 --- drivers/timer/timer-uclass.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/timer') diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 0c2018bfe3b..60ff65529ab 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; -- cgit v1.3.1 From 429fa3b32dbbc89793823607b4151a35dc9e7629 Mon Sep 17 00:00:00 2001 From: Kuan Lim Lee Date: Mon, 11 Dec 2023 10:22:10 +0800 Subject: timer: starfive: Add Starfive timer support Add timer driver in Starfive SoC. It is an timer that outside of CPU core and inside Starfive SoC. Signed-off-by: Kuan Lim Lee Signed-off-by: Wei Liang Lim Changes for v2: - correct driver name, comment, variable Reviewed-by: Leo Yu-Chi Liang --- drivers/timer/starfive-timer.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers/timer') diff --git a/drivers/timer/starfive-timer.c b/drivers/timer/starfive-timer.c index 816402fdbf2..6ac7d7f1d0e 100644 --- a/drivers/timer/starfive-timer.c +++ b/drivers/timer/starfive-timer.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2022 StarFive, Inc. All rights reserved. - * Author: Lee Kuan Lim + * Author: Kuan Lim Lee */ #include @@ -48,8 +48,8 @@ static int starfive_probe(struct udevice *dev) int ret; priv->base = dev_read_addr_ptr(dev); - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); + if (!priv->base) + return -EINVAL; timer_channel = dev_read_u32_default(dev, "channel", 0); priv->base = priv->base + (0x40 * timer_channel); @@ -64,14 +64,16 @@ static int starfive_probe(struct udevice *dev) return ret; uc_priv->clock_rate = clk_get_rate(&clk); - /* Initiate timer, channel 0 */ - /* Unmask Interrupt Mask */ + /* + * Initiate timer, channel 0 + * Unmask Interrupt Mask + */ writel(0, priv->base + STF_TIMER_INT_MASK); /* Single run mode Setting */ if (dev_read_bool(dev, "single-run")) writel(1, priv->base + STF_TIMER_CTL); /* Set Reload value */ - priv->timer_size = dev_read_u32_default(dev, "timer-size", 0xffffffff); + priv->timer_size = dev_read_u32_default(dev, "timer-size", -1U); writel(priv->timer_size, priv->base + STF_TIMER_LOAD); /* Enable to start timer */ writel(1, priv->base + STF_TIMER_ENABLE); @@ -85,7 +87,7 @@ static const struct udevice_id starfive_ids[] = { }; U_BOOT_DRIVER(jh8100_starfive_timer) = { - .name = "jh8100_starfive_timer", + .name = "starfive_timer", .id = UCLASS_TIMER, .of_match = starfive_ids, .probe = starfive_probe, -- cgit v1.3.1 From b106961c2e4e7f339485a401ebb06c936fc432ee Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 14 Dec 2023 07:16:54 -0500 Subject: global: Restrict use of '#include ' In general terms, we -include include/linux/kconfig.h and so normal U-Boot code does not need to also #include it. However, for code which is shared with userspace we may need to add it so that either our full config is available or so that macros such as CONFIG_IS_ENABLED() can be evaluated. In this case make sure that we guard these includes with a test for USE_HOSTCC so that it clear as to why we're doing this. Reviewed-by: Simon Glass Signed-off-by: Tom Rini --- arch/arm/include/asm/arch-fsl-layerscape/config.h | 1 - arch/arm/mach-rockchip/tpl.c | 1 - arch/arm/mach-sunxi/dram_sun50i_h6.c | 1 - arch/arm/mach-sunxi/dram_sun50i_h616.c | 1 - arch/arm/mach-sunxi/dram_sunxi_dw.c | 1 - boot/image-fit.c | 2 +- boot/image.c | 2 +- drivers/timer/dw-apb-timer.c | 1 - env/embedded.c | 2 ++ include/bootstage.h | 2 ++ include/configs/at91-sama5_common.h | 2 -- include/configs/tqma6.h | 1 - include/env_internal.h | 1 - include/u-boot/ecdsa.h | 1 - lib/rsa/rsa-verify.c | 2 +- test/dm/scmi.c | 1 - tools/mkeficapsule.c | 1 - 17 files changed, 7 insertions(+), 16 deletions(-) (limited to 'drivers/timer') diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h b/arch/arm/include/asm/arch-fsl-layerscape/config.h index 516c9eab047..faace43da71 100644 --- a/arch/arm/include/asm/arch-fsl-layerscape/config.h +++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h @@ -7,7 +7,6 @@ #ifndef _ASM_ARMV8_FSL_LAYERSCAPE_CONFIG_H_ #define _ASM_ARMV8_FSL_LAYERSCAPE_CONFIG_H_ -#include #include #ifndef __ASSEMBLY__ diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index fdd0c592b3e..2c3e9789cc8 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -16,7 +16,6 @@ #include #include #include -#include #if CONFIG_IS_ENABLED(BANNER_PRINT) #include diff --git a/arch/arm/mach-sunxi/dram_sun50i_h6.c b/arch/arm/mach-sunxi/dram_sun50i_h6.c index bff2e42513c..62bc2a0231e 100644 --- a/arch/arm/mach-sunxi/dram_sun50i_h6.c +++ b/arch/arm/mach-sunxi/dram_sun50i_h6.c @@ -15,7 +15,6 @@ #include #include #include -#include /* * The DRAM controller structure on H6 is similar to the ones on A23/A80: diff --git a/arch/arm/mach-sunxi/dram_sun50i_h616.c b/arch/arm/mach-sunxi/dram_sun50i_h616.c index c5c1331a4c3..e62d5711d0f 100644 --- a/arch/arm/mach-sunxi/dram_sun50i_h616.c +++ b/arch/arm/mach-sunxi/dram_sun50i_h616.c @@ -22,7 +22,6 @@ #include #include #include -#include enum { MBUS_QOS_LOWEST = 0, diff --git a/arch/arm/mach-sunxi/dram_sunxi_dw.c b/arch/arm/mach-sunxi/dram_sunxi_dw.c index 9382d3d0be8..daef051d0c8 100644 --- a/arch/arm/mach-sunxi/dram_sunxi_dw.c +++ b/arch/arm/mach-sunxi/dram_sunxi_dw.c @@ -16,7 +16,6 @@ #include #include #include -#include static void mctl_phy_init(u32 val) { diff --git a/boot/image-fit.c b/boot/image-fit.c index 3cc556b727f..89e377563ce 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -15,6 +15,7 @@ #include #include #include +#include #else #include #include @@ -36,7 +37,6 @@ DECLARE_GLOBAL_DATA_PTR; #include #include #include -#include #include #include #include diff --git a/boot/image.c b/boot/image.c index 675b5dd77f9..073931cd7a3 100644 --- a/boot/image.c +++ b/boot/image.c @@ -42,6 +42,7 @@ DECLARE_GLOBAL_DATA_PTR; #else /* USE_HOSTCC */ #include "mkimage.h" +#include #include #include @@ -62,7 +63,6 @@ DECLARE_GLOBAL_DATA_PTR; #include #include #include -#include #include #include #include diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c index b171232c484..6cd25251f94 100644 --- a/drivers/timer/dw-apb-timer.c +++ b/drivers/timer/dw-apb-timer.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/env/embedded.c b/env/embedded.c index 7cbe54c56e0..5b488ef818e 100644 --- a/env/embedded.c +++ b/env/embedded.c @@ -4,7 +4,9 @@ * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. */ +#ifdef USE_HOSTCC #include +#endif #ifndef __ASSEMBLY__ #define __ASSEMBLY__ /* Dirty trick to get only #defines */ diff --git a/include/bootstage.h b/include/bootstage.h index 59a76d0f0c4..f4e77b09d74 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -12,7 +12,9 @@ #define _BOOTSTAGE_H #include +#ifdef USE_HOSTCC #include +#endif /* Flags for each bootstage record */ enum bootstage_flags { diff --git a/include/configs/at91-sama5_common.h b/include/configs/at91-sama5_common.h index 4aa876a9f79..81c76ef52a7 100644 --- a/include/configs/at91-sama5_common.h +++ b/include/configs/at91-sama5_common.h @@ -9,8 +9,6 @@ #ifndef __AT91_SAMA5_COMMON_H #define __AT91_SAMA5_COMMON_H -#include - /* ARM asynchronous clock */ #define CFG_SYS_AT91_SLOW_CLOCK 32768 #define CFG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */ diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h index 8c75a75a9e5..2da76f15431 100644 --- a/include/configs/tqma6.h +++ b/include/configs/tqma6.h @@ -8,7 +8,6 @@ #ifndef __CONFIG_H #define __CONFIG_H -#include #include /* place code in last 4 MiB of RAM */ diff --git a/include/env_internal.h b/include/env_internal.h index 5c289d67f90..cbd1ef3e914 100644 --- a/include/env_internal.h +++ b/include/env_internal.h @@ -15,7 +15,6 @@ #ifndef _ENV_INTERNAL_H_ #define _ENV_INTERNAL_H_ -#include /************************************************************************** * diff --git a/include/u-boot/ecdsa.h b/include/u-boot/ecdsa.h index 6e0269e3aed..53490c6b287 100644 --- a/include/u-boot/ecdsa.h +++ b/include/u-boot/ecdsa.h @@ -8,7 +8,6 @@ #include #include -#include /** * crypto_algo API impementation for ECDSA; diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 2f3b3440391..096e7f6d178 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -17,9 +17,9 @@ #else #include "fdt_host.h" #include "mkimage.h" +#include #include #endif -#include #include #include diff --git a/test/dm/scmi.c b/test/dm/scmi.c index e80667ef72a..adf36ffaab1 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index b8fc6069b58..6a261ff549d 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include -- cgit v1.3.1