[PATCH v4 5/7] clk: spacemit: make clocks optional

From: Alex Elder
Date: Mon Apr 14 2025 - 15:18:44 EST


There are some syscon devices that support both clocks and resets,
but for now only their reset functionality is required. Make
defining clocks optional for a SpacemiT CCU, though at least one
clock or at least one reset controller must be defined.

Signed-off-by: Alex Elder <elder@xxxxxxxxxxxx>
---
drivers/clk/spacemit/ccu-k1.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
index 09f101a52b1af..7494c97c3c7ec 100644
--- a/drivers/clk/spacemit/ccu-k1.c
+++ b/drivers/clk/spacemit/ccu-k1.c
@@ -1218,6 +1218,10 @@ static int spacemit_ccu_register(struct device *dev,
struct clk_hw_onecell_data *clk_data;
int i, ret;

+ /* Clocks are optional */
+ if (!data->clk_hws)
+ return 0;
+
clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, data->clk_num),
GFP_KERNEL);
if (!clk_data)
@@ -1329,6 +1333,7 @@ static int k1_ccu_probe(struct platform_device *pdev)
return 0;
}

+/* Match data is required; its clk_hws or reset_data field must be non-null */
static const struct of_device_id of_k1_ccu_match[] = {
{
.compatible = "spacemit,k1-pll",
--
2.45.2