@@ -4,8 +4,9 @@
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o
+obj-$(CONFIG_CLK_FALLBACK) += clk-fallback.o
obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o
obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o
obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o clk-gate.o
obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o
new file mode 100644
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2024 Linaro Ltd.
+ *
+ * Stub clock driver for non-vital clocks.
+ */
+
+#include <clk.h>
+#include <clk-uclass.h>
+#include <dm.h>
+
+static ulong fallback_clk_set_rate(struct clk *clk, ulong rate)
+{
+ return (clk->rate = rate);
+}
+
+static ulong fallback_clk_get_rate(struct clk *clk)
+{
+ return clk->rate;
+}
+
+static int fallback_clk_nop(struct clk *clk)
+{
+ return 0;
+};
+
+static struct clk_ops fallback_clk_ops = {
+ .set_rate = fallback_clk_set_rate,
+ .get_rate = fallback_clk_get_rate,
+ .enable = fallback_clk_nop,
+ .disable = fallback_clk_nop,
+};
+
+U_BOOT_DRIVER(clk_fallback) = {
+ .name = "clk_fallback",
+ .id = UCLASS_CLK,
+ .ops = &fallback_clk_ops,
+ .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
+};
@@ -11,8 +11,9 @@
#include <common.h>
#include <clk.h>
#include <clk-uclass.h>
#include <dm.h>
+#include <dm/lists.h>
#include <dt-structs.h>
#include <errno.h>
#include <log.h>
#include <malloc.h>
@@ -801,6 +802,9 @@ int clk_uclass_post_probe(struct udevice *dev)
UCLASS_DRIVER(clk) = {
.id = UCLASS_CLK,
.name = "clk",
+#if CONFIG_IS_ENABLED(CLK_FALLBACK)
+ .fallback_drv_name = "clk_fallback",
+#endif
.post_probe = clk_uclass_post_probe,
};
@@ -476,5 +476,15 @@ menuconfig FALLBACK_DRIVERS
driver to "stub" the resource. These stubs usually do nothing and
are therefore only suitable in instances where the resource is not
required.
+config CLK_FALLBACK
+ bool "Enable the clock fallback driver"
+ depends on FALLBACK_DRIVERS && CLK
+ help
+ This provides a no-op clock driver that can be used as a fallback
+ when no other driver is available. This is useful for systems with
+ clock controllers that are not actually required for peripherals to
+ work correctly (for example the RPMh clock controller on Qualcomm
+ platforms).
+
endmenu
Add a stub_clk driver which does absolutely nothing and is configured as the fallback stub for UCLASS_CLK. If there is a dependency on a clock device which is not supported by any existing driver, and CONFIG_CLK_STUB is enabled, then the stub driver will kick in. This is intended to be useful during early bringup (e.g. if the serial port is already configured for a default rate) or for clock controllers that simply aren't vital for a platform to work. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> --- drivers/clk/Makefile | 1 + drivers/clk/clk-fallback.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/clk/clk-uclass.c | 4 ++++ drivers/core/Kconfig | 10 ++++++++++ 4 files changed, 54 insertions(+)