[PATCH v17 7/8] clk: en7523: generalize register clocks function

From: Christian Marangi

Date: Mon Nov 30 2026 - 13:13:22 EST


Airoha AN7583 SoC will use the same logic used by Airoha EN7581 SoC to
register clocks. Generalize it to register clocks defined in soc_data.

Add the clocks definition in EN7581 SoC to support this new implementation.

Add the .num_base_clocks value to declare the number of base clocks.

Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
drivers/clk/clk-en7523.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index 59eb41f9fa80..e91fb9c066c3 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -151,6 +151,8 @@ struct en_clk_priv {

struct en_clk_soc_data {
u32 num_clocks;
+ u32 num_base_clocks;
+ const struct en_clk_desc *base_clks;
const struct clk_ops pcie_ops;
int (*hw_init)(struct platform_device *pdev,
struct clk_hw_onecell_data *clk_data);
@@ -1117,11 +1119,14 @@ static const struct clk_ops en7581_clk_ops = {
static int en7581_register_clocks(struct device *dev, struct clk_hw_onecell_data *clk_data,
struct regmap *map, void __iomem *base)
{
+ const struct en_clk_soc_data *soc_data;
struct clk_hw *hw;
int i;

- for (i = 0; i < ARRAY_SIZE(en7581_base_clks); i++) {
- const struct en_clk_desc *desc = &en7581_base_clks[i];
+ soc_data = device_get_match_data(dev);
+
+ for (i = 0; i < soc_data->num_base_clocks; i++) {
+ const struct en_clk_desc *desc = &soc_data->base_clks[i];
struct clk_init_data init = {
.ops = &en7581_clk_ops,
};
@@ -1602,6 +1607,8 @@ static const struct en_clk_soc_data en7523_data = {
static const struct en_clk_soc_data en7581_data = {
/* We increment num_clocks by 1 to account for additional PCIe clock */
.num_clocks = ARRAY_SIZE(en7581_base_clks) + 1,
+ .base_clks = en7581_base_clks,
+ .num_base_clocks = ARRAY_SIZE(en7581_base_clks),
.pcie_ops = {
.is_enabled = en7581_pci_is_enabled,
.enable = en7581_pci_enable,
--
2.55.0