Skip to contentSkip to conversation

clk: socfpga: agilex5: add clock driver for Agilex5

PATCH Superseded Khairul Anuar Romli 2 participants 2 messages Oct 6, 2025 – Oct 13, 2025 1 message not in the archive

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/1 clk: socfpga: agilex5: add clock driver for Agilex5

In reply to a message not in the archive

Add the new Clock manager driver to support new Agilex5 platform. The new driver got rid of the clk_parent_data structures as there are no 'clock-names' property in the DT bindings and use parent_names internally. This is based on the previous feedback from the maintainer.

---
Changes in v2:
- Add clk-agilex5 to Makefile
- Add Kconfig to include Agilex5 clock manager
- us of.h instead of of_device and of_address
- use devm_platform_ioremap_resource to simplify the get resource
- Fix bound-checking coverage struct clock_data
- Clean up harmless TODO comment

---
 drivers/clk/socfpga/Kconfig          |   2 +-
 drivers/clk/socfpga/Makefile         |   2 +-
 drivers/clk/socfpga/clk-agilex5.c    | 561 +++++++++++++++++++++++++++
 drivers/clk/socfpga/clk-gate-s10.c   |  53 +++
 drivers/clk/socfpga/clk-periph-s10.c |  41 ++
 drivers/clk/socfpga/clk-pll-s10.c    |  36 ++
 drivers/clk/socfpga/stratix10-clk.h  |  43 ++
 7 files changed, 736 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/socfpga/clk-agilex5.c
drivers/clk/socfpga/Kconfig +1 -1
index 0cf16b894efb..d88277e2a898 100644
@@ -13,7 +13,7 @@ config CLK_INTEL_SOCFPGA32
 	default ARM && ARCH_INTEL_SOCFPGA
 
 config CLK_INTEL_SOCFPGA64
-	bool "Intel Stratix / Agilex / N5X clock controller support" if COMPILE_TEST && (!ARM64 || !ARCH_INTEL_SOCFPGA)
+	bool "Intel Stratix / Agilex / N5X / Agilex5 clock controller support" if COMPILE_TEST && (!ARM64 || !ARCH_INTEL_SOCFPGA)
 	default ARM64 && ARCH_INTEL_SOCFPGA
 
 endif # CLK_INTEL_SOCFPGA
drivers/clk/socfpga/Makefile +1 -1
index e8dfce339c91..a1ea2b988eaf 100644
@@ -3,4 +3,4 @@ obj-$(CONFIG_CLK_INTEL_SOCFPGA32) += clk.o clk-gate.o clk-pll.o clk-periph.o \
 				     clk-pll-a10.o clk-periph-a10.o clk-gate-a10.o
 obj-$(CONFIG_CLK_INTEL_SOCFPGA64) += clk-s10.o \
 				     clk-pll-s10.o clk-periph-s10.o clk-gate-s10.o \
-				     clk-agilex.o
+				     clk-agilex.o clk-agilex5.o
drivers/clk/socfpga/clk-agilex5.c new file +561 -0

561 lines not on this page · raw message

drivers/clk/socfpga/clk-gate-s10.c +53 -0

56 lines not on this page · raw message

drivers/clk/socfpga/clk-periph-s10.c +41 -0

44 lines not on this page · raw message

drivers/clk/socfpga/clk-pll-s10.c +36 -0
index a88c212bda12..1be92827cd93 100644
@@ -304,3 +304,39 @@ struct clk_hw *n5x_register_pll(const struct stratix10_pll_clock *clks,
 	}
 	return hw_clk;
 }
+
+struct clk_hw *agilex5_register_pll(const struct agilex5_pll_clock *clks,
+				    void __iomem *reg)
+{
+	struct clk_hw *hw_clk;
+	struct socfpga_pll *pll_clk;
+	struct clk_init_data init;
+	const char *name = clks->name;
+	int ret;
+
+	pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
+	if (WARN_ON(!pll_clk))
+		return NULL;
+
+	pll_clk->hw.reg = reg + clks->offset;
+
+	if (streq(name, SOCFPGA_BOOT_CLK))
+		init.ops = &clk_boot_ops;
+	else
+		init.ops = &agilex_clk_pll_ops;
+
+	init.name = name;
+	init.flags = clks->flags;
+	init.num_parents = clks->num_parents;
+	init.parent_names = clks->parent_names;
+	pll_clk->hw.hw.init = &init;
+	pll_clk->hw.bit_idx = SOCFPGA_PLL_POWER;
+	hw_clk = &pll_clk->hw.hw;
+
+	ret = clk_hw_register(NULL, hw_clk);
+	if (ret) {
+		kfree(pll_clk);
+		return ERR_PTR(ret);
+	}
+	return hw_clk;
+}
drivers/clk/socfpga/stratix10-clk.h +43 -0

55 lines not on this page · raw message

Signature · 1 line
2.35.3
#2 lore raw
Quoted 26 lines · Khairul Anuar Romli

Add the new Clock manager driver to support new Agilex5 platform. The new driver got rid of the clk_parent_data structures as there are no 'clock-names' property in the DT bindings and use parent_names internally. This is based on the previous feedback from the maintainer.

---
Changes in v2:
- Add clk-agilex5 to Makefile
- Add Kconfig to include Agilex5 clock manager
- us of.h instead of of_device and of_address
- use devm_platform_ioremap_resource to simplify the get resource
- Fix bound-checking coverage struct clock_data
- Clean up harmless TODO comment

---
  drivers/clk/socfpga/Kconfig          |   2 +-
  drivers/clk/socfpga/Makefile         |   2 +-
  drivers/clk/socfpga/clk-agilex5.c    | 561 +++++++++++++++++++++++++++
  drivers/clk/socfpga/clk-gate-s10.c   |  53 +++
  drivers/clk/socfpga/clk-periph-s10.c |  41 ++
  drivers/clk/socfpga/clk-pll-s10.c    |  36 ++
  drivers/clk/socfpga/stratix10-clk.h  |  43 ++
  7 files changed, 736 insertions(+), 2 deletions(-)

create mode 100644 drivers/clk/socfpga/clk-agilex5.c

<snip>

Quoted 7 lines
drivers/clk/socfpga/clk-agilex5.c new file +7 -0
+
+static int agilex5_clkmgr_init(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device *dev = &pdev->dev;
+	struct stratix10_clock_data *clk_data;
+	void __iomem *base;

drivers/clk/socfpga/clk-agilex5.c line 504

Quoted 10 lines
drivers/clk/socfpga/clk-agilex5.c new file +10 -0
+	int i, num_clks;
+
+	base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	num_clks = AGILEX5_NUM_CLKS;
+
+	clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
+				num_clks), GFP_KERNEL);

Please fix these 2 warnings from checkpatch --strict:

WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) #7:
Add the new Clock manager driver to support new Agilex5 platform. The new driver

CHECK: Alignment should match open parenthesis #565: FILE: drivers/clk/socfpga/clk-agilex5.c:504:
+ clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
+ num_clks), GFP_KERNEL);

total: 0 errors, 2 warnings, 1 checks, 768 lines check

Dinh