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

Alex Elder
2025-04-09T21:17:52Z

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@riscstar.com>
---
drivers/clk/spacemit/ccu-k1.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
index 7715cd38434f7..201ffefa5fa9f 100644
--- a/drivers/clk/spacemit/ccu-k1.c
+++ b/drivers/clk/spacemit/ccu-k1.c
@@ -1369,12 +1369,17 @@ static const struct reset_control_ops spacemit_reset_control_ops = {
};

static int spacemit_ccu_register(struct device *dev,
- struct regmap *regmap, struct regmap *lock_regmap,
+ struct regmap *regmap,
+ struct regmap *lock_regmap,
const struct spacemit_ccu_data *data)
{
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)
@@ -1486,6 +1491,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