mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
To: Michal Simek <michal.simek@amd.com>
Cc: Ronak Jain <ronak.jain@amd.com>,
	Aravind Thokala <Aravind.Thokala@amd.com>,
	Harsh Jain <h.jain@amd.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <git@amd.com>,
	Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Subject: [PATCH 2/5] drivers: firmware: xilinx: Relocate FPGA library APIs to new file
Date: Fri, 27 Nov 2026 17:18:36 +0530	[thread overview]
Message-ID: <20261127114839.1428778-3-jay.buddhabhatti@amd.com> (raw)
In-Reply-To: <20261127114839.1428778-1-jay.buddhabhatti@amd.com>

From: Ronak Jain <ronak.jain@amd.com>

Move the FPGA library APIs into a dedicated file and header to improve
maintainability and reduce complexity in the firmware driver. Keep the
existing behavior unchanged.

List the new FPGA files in the FPGA and PDI firmware MAINTAINERS entry.

Signed-off-by: Ronak Jain <ronak.jain@amd.com>
Co-developed-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
---
 MAINTAINERS                               |  2 +
 drivers/firmware/xilinx/Makefile          |  4 +-
 drivers/firmware/xilinx/zynqmp-fpga.c     | 89 +++++++++++++++++++++++
 drivers/firmware/xilinx/zynqmp.c          | 78 --------------------
 include/linux/firmware/xlnx-zynqmp-fpga.h | 55 ++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h      | 32 +-------
 6 files changed, 149 insertions(+), 111 deletions(-)
 create mode 100644 drivers/firmware/xilinx/zynqmp-fpga.c
 create mode 100644 include/linux/firmware/xlnx-zynqmp-fpga.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 9dfdb7ade5f6..8caad731367b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -30670,7 +30670,9 @@ XILINX FPGA AND PDI FIRMWARE DRIVER
 M:	Aravind Thokala <Aravind.Thokala@amd.com>
 L:	git@amd.com
 S:	Maintained
+F:	drivers/firmware/xilinx/zynqmp-fpga.c
 F:	drivers/firmware/xilinx/zynqmp-pdi.c
+F:	include/linux/firmware/xlnx-zynqmp-fpga.h
 F:	include/linux/firmware/xlnx-zynqmp-pdi.h
 
 XILINX GPIO DRIVER
diff --git a/drivers/firmware/xilinx/Makefile b/drivers/firmware/xilinx/Makefile
index 684c3d43744e..edfba4110a7c 100644
--- a/drivers/firmware/xilinx/Makefile
+++ b/drivers/firmware/xilinx/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for Xilinx firmwares
 
-obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-crypto.o zynqmp-pdi.o \
-				 zynqmp-ufs.o zynqmp.o
+obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-crypto.o zynqmp-fpga.o \
+				 zynqmp-pdi.o zynqmp-ufs.o zynqmp.o
 obj-$(CONFIG_ZYNQMP_FIRMWARE_DEBUG) += zynqmp-debug.o
diff --git a/drivers/firmware/xilinx/zynqmp-fpga.c b/drivers/firmware/xilinx/zynqmp-fpga.c
new file mode 100644
index 000000000000..2a3ac3a50c56
--- /dev/null
+++ b/drivers/firmware/xilinx/zynqmp-fpga.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Firmware layer for XilFPGA APIs.
+ *
+ *  Copyright (C) 2014 - 2022 Xilinx, Inc.
+ *  Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/export.h>
+#include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/kernel.h>
+
+/**
+ * zynqmp_pm_fpga_load - Perform the fpga load
+ * @address:	Address to write to
+ * @size:	pl bitstream size
+ * @flags:	Bitstream type
+ *	-XILINX_ZYNQMP_PM_FPGA_FULL:  FPGA full reconfiguration
+ *	-XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
+ *
+ * This function provides access to pmufw. To transfer
+ * the required bitstream into PL.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	ret = zynqmp_pm_invoke_fn(PM_FPGA_LOAD, ret_payload, 4, lower_32_bits(address),
+				  upper_32_bits(address), size, flags);
+	if (ret_payload[0])
+		return -ret_payload[0];
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_load);
+
+/**
+ * zynqmp_pm_fpga_get_status - Read value from PCAP status register
+ * @value: Value to read
+ *
+ * This function provides access to the pmufw to get the PCAP
+ * status.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_fpga_get_status(u32 *value)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	if (!value)
+		return -EINVAL;
+
+	ret = zynqmp_pm_invoke_fn(PM_FPGA_GET_STATUS, ret_payload, 0);
+	*value = ret_payload[1];
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
+
+/**
+ * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status.
+ * @value: Buffer to store FPGA configuration status.
+ *
+ * This function provides access to the pmufw to get the FPGA configuration
+ * status.
+ *
+ * Return: 0 on success, a negative value on error
+ */
+int zynqmp_pm_fpga_get_config_status(u32 *value)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	if (!value)
+		return -EINVAL;
+
+	ret = zynqmp_pm_invoke_fn(PM_FPGA_READ, ret_payload, 4,
+				  XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET, 0, 0,
+				  XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG);
+
+	*value = ret_payload[1];
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status);
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index bebd2bfe5744..fe887d5e9354 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1087,84 +1087,6 @@ int zynqmp_pm_reset_get_status(const u32 reset, u32 *status)
 }
 EXPORT_SYMBOL_GPL(zynqmp_pm_reset_get_status);
 
-/**
- * zynqmp_pm_fpga_load - Perform the fpga load
- * @address:	Address to write to
- * @size:	pl bitstream size
- * @flags:	Bitstream type
- *	-XILINX_ZYNQMP_PM_FPGA_FULL:  FPGA full reconfiguration
- *	-XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
- *
- * This function provides access to pmufw. To transfer
- * the required bitstream into PL.
- *
- * Return: Returns status, either success or error+reason
- */
-int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags)
-{
-	u32 ret_payload[PAYLOAD_ARG_CNT];
-	int ret;
-
-	ret = zynqmp_pm_invoke_fn(PM_FPGA_LOAD, ret_payload, 4, lower_32_bits(address),
-				  upper_32_bits(address), size, flags);
-	if (ret_payload[0])
-		return -ret_payload[0];
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_load);
-
-/**
- * zynqmp_pm_fpga_get_status - Read value from PCAP status register
- * @value: Value to read
- *
- * This function provides access to the pmufw to get the PCAP
- * status
- *
- * Return: Returns status, either success or error+reason
- */
-int zynqmp_pm_fpga_get_status(u32 *value)
-{
-	u32 ret_payload[PAYLOAD_ARG_CNT];
-	int ret;
-
-	if (!value)
-		return -EINVAL;
-
-	ret = zynqmp_pm_invoke_fn(PM_FPGA_GET_STATUS, ret_payload, 0);
-	*value = ret_payload[1];
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
-
-/**
- * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status.
- * @value: Buffer to store FPGA configuration status.
- *
- * This function provides access to the pmufw to get the FPGA configuration
- * status
- *
- * Return: 0 on success, a negative value on error
- */
-int zynqmp_pm_fpga_get_config_status(u32 *value)
-{
-	u32 ret_payload[PAYLOAD_ARG_CNT];
-	int ret;
-
-	if (!value)
-		return -EINVAL;
-
-	ret = zynqmp_pm_invoke_fn(PM_FPGA_READ, ret_payload, 4,
-				  XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET, 0, 0,
-				  XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG);
-
-	*value = ret_payload[1];
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status);
-
 /**
  * zynqmp_pm_pinctrl_request - Request Pin from firmware
  * @pin: Pin number to request
diff --git a/include/linux/firmware/xlnx-zynqmp-fpga.h b/include/linux/firmware/xlnx-zynqmp-fpga.h
new file mode 100644
index 000000000000..2e0b1dc084d1
--- /dev/null
+++ b/include/linux/firmware/xlnx-zynqmp-fpga.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Firmware layer for XilFPGA APIs.
+ *
+ *  Copyright (C) 2014 - 2021 Xilinx, Inc.
+ *  Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc.
+ */
+
+#ifndef __FIRMWARE_ZYNQMP_FPGA_H__
+#define __FIRMWARE_ZYNQMP_FPGA_H__
+
+#ifndef __FIRMWARE_ZYNQMP_H__
+# error "Do not include this file directly, use <linux/firmware/xlnx-zynqmp.h>"
+#endif
+
+#include <linux/bits.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+
+/*
+ * Firmware FPGA Manager flags
+ * XILINX_ZYNQMP_PM_FPGA_FULL:	FPGA full reconfiguration
+ * XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
+ */
+#define XILINX_ZYNQMP_PM_FPGA_FULL	0x0U
+#define XILINX_ZYNQMP_PM_FPGA_PARTIAL	BIT(0)
+
+/* FPGA Status Reg */
+#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET	7U
+#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG		0U
+
+#if IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE)
+int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags);
+int zynqmp_pm_fpga_get_status(u32 *value);
+int zynqmp_pm_fpga_get_config_status(u32 *value);
+#else
+static inline int zynqmp_pm_fpga_load(const u64 address, const u32 size,
+				      const u32 flags)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_fpga_get_status(u32 *value)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_fpga_get_config_status(u32 *value)
+{
+	return -ENODEV;
+}
+
+#endif
+
+#endif /* __FIRMWARE_ZYNQMP_FPGA_H__ */
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index cffec74a0436..5038c9051dca 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -17,6 +17,7 @@
 
 #include <linux/err.h>
 #include <linux/firmware/xlnx-zynqmp-crypto.h>
+#include <linux/firmware/xlnx-zynqmp-fpga.h>
 #include <linux/firmware/xlnx-zynqmp-pdi.h>
 #include <linux/firmware/xlnx-zynqmp-ufs.h>
 
@@ -102,18 +103,6 @@
 #define	ZYNQMP_PM_CAPABILITY_WAKEUP	0x4U
 #define	ZYNQMP_PM_CAPABILITY_UNUSABLE	0x8U
 
-/*
- * Firmware FPGA Manager flags
- * XILINX_ZYNQMP_PM_FPGA_FULL:	FPGA full reconfiguration
- * XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
- */
-#define XILINX_ZYNQMP_PM_FPGA_FULL	0x0U
-#define XILINX_ZYNQMP_PM_FPGA_PARTIAL	BIT(0)
-
-/* FPGA Status Reg */
-#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET	7U
-#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG		0U
-
 /*
  * Node IDs for the Error Events.
  */
@@ -606,9 +595,6 @@ int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities,
 			      const u32 qos,
 			      const enum zynqmp_pm_request_ack ack);
 int zynqmp_pm_efuse_access(const u64 address, u32 *out);
-int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags);
-int zynqmp_pm_fpga_get_status(u32 *value);
-int zynqmp_pm_fpga_get_config_status(u32 *value);
 int zynqmp_pm_write_ggs(u32 index, u32 value);
 int zynqmp_pm_read_ggs(u32 index, u32 *value);
 int zynqmp_pm_write_pggs(u32 index, u32 value);
@@ -794,22 +780,6 @@ static inline int zynqmp_pm_efuse_access(const u64 address, u32 *out)
 	return -ENODEV;
 }
 
-static inline int zynqmp_pm_fpga_load(const u64 address, const u32 size,
-				      const u32 flags)
-{
-	return -ENODEV;
-}
-
-static inline int zynqmp_pm_fpga_get_status(u32 *value)
-{
-	return -ENODEV;
-}
-
-static inline int zynqmp_pm_fpga_get_config_status(u32 *value)
-{
-	return -ENODEV;
-}
-
 static inline int zynqmp_pm_write_ggs(u32 index, u32 value)
 {
 	return -ENODEV;
-- 
2.43.0


  parent reply	other threads:[~2026-11-27 11:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 11:48 [PATCH 0/5] drivers: firmware: xilinx: Split ZynqMP firmware driver into modular components Jay Buddhabhatti
2026-11-27 11:48 ` [PATCH 1/5] drivers: firmware: xilinx: Relocate PDI library APIs to new file Jay Buddhabhatti
2026-11-27 11:48 ` Jay Buddhabhatti [this message]
2026-11-27 11:48 ` [PATCH 3/5] drivers: firmware: xilinx: Relocate NVM " Jay Buddhabhatti
2026-11-27 11:48 ` [PATCH 4/5] drivers: firmware: xilinx: Localize firmware version caches Jay Buddhabhatti
2026-11-27 11:48 ` [PATCH 5/5] drivers: firmware: xilinx: Split PM EEMI and core APIs in firmware Jay Buddhabhatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127114839.1428778-3-jay.buddhabhatti@amd.com \
    --to=jay.buddhabhatti@amd.com \
    --cc=Aravind.Thokala@amd.com \
    --cc=git@amd.com \
    --cc=h.jain@amd.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=ronak.jain@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®