diff mbox series

[2/2] fpga: zynq-fpga: Allow ICAP enable on probe

Message ID 20250328141944.119504-2-sam.winchenbach@framepointer.org (mailing list archive)
State New
Headers show
Series [1/2] dt-bindings: fpga: zynq: Document ICAP on boot | expand

Commit Message

Sam Winchenbach March 28, 2025, 2:19 p.m. UTC
From: Sam Winchenbach <swinchenbach@arka.org>

Adds an option to enable the ICAP interface when driver is probed. This
is useful when the fabric is loaded as part of the first or second stage
of the boot process and contains an IP core that requires access to the
ICAP interface, such as Soft Error Mitigation (SEM) core.

Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
---
 drivers/fpga/zynq-fpga.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
index f7e08f7ea9ef3..4a53a429d659f 100644
--- a/drivers/fpga/zynq-fpga.c
+++ b/drivers/fpga/zynq-fpga.c
@@ -20,6 +20,7 @@ 
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/pm.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/string.h>
 #include <linux/scatterlist.h>
@@ -482,8 +483,7 @@  static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt)
 	return err;
 }
 
-static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr,
-					struct fpga_image_info *info)
+static int zynq_fpga_enable_icap(struct fpga_manager *mgr)
 {
 	struct zynq_fpga_priv *priv = mgr->priv;
 	int err;
@@ -504,6 +504,18 @@  static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr,
 
 	clk_disable(priv->clk);
 
+	return err;
+}
+
+static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr,
+					struct fpga_image_info *info)
+{
+	struct zynq_fpga_priv *priv = mgr->priv;
+	int err;
+	u32 intr_status;
+
+	err = zynq_fpga_enable_icap(mgr);
+
 	if (err)
 		return err;
 
@@ -615,6 +627,16 @@  static int zynq_fpga_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mgr);
 
+	if (device_property_read_bool(dev, "enable-icap-on-load")) {
+		err = zynq_fpga_enable_icap(mgr);
+		if (err) {
+			dev_err(dev, "unable to enable ICAP interface\n");
+			fpga_mgr_unregister(mgr);
+			clk_unprepare(priv->clk);
+			return err;
+		}
+	}
+
 	return 0;
 }