drivers: firmware: xilinx: Split ZynqMP firmware driver into modular components
cover drivers: firmware: xilinx: Split ZynqMP firmware driver into modular components
Split the ZynqMP firmware driver into focused modules to improve maintainability and clarify ownership of each firmware interface. The driver mixes platform core infrastructure, PM EEMI APIs, PDI loading, FPGA management, and NVM access in one large file.
This series applies on top of "firmware: xilinx: cleanups and debugfs fixes":
https://lore.kernel.org/all/[email protected]/
Split the driver incrementally and keep each patch reviewable:
- Move PDI library APIs into zynqmp-pdi.c with a dedicated header.
- Move FPGA library APIs into zynqmp-fpga.c with a dedicated header.
- Move NVM library APIs into zynqmp-nvm.c with a dedicated header.
- Localize the firmware version caches.
- Split core platform/SMC infrastructure (zynqmp-core.c) from PM EEMI
APIs (zynqmp-pm.c).
Jay Buddhabhatti (1):
drivers: firmware: xilinx: Localize firmware version caches
Ronak Jain (4):
drivers: firmware: xilinx: Relocate PDI library APIs to new file
drivers: firmware: xilinx: Relocate FPGA library APIs to new file
drivers: firmware: xilinx: Relocate NVM library APIs to new file
drivers: firmware: xilinx: Split PM EEMI and core APIs in firmware
MAINTAINERS | 28 +
drivers/firmware/xilinx/Makefile | 4 +-
drivers/firmware/xilinx/zynqmp-core.c | 797 +++++++++++++++
drivers/firmware/xilinx/zynqmp-debug.h | 20 +
drivers/firmware/xilinx/zynqmp-fpga.c | 89 ++
drivers/firmware/xilinx/zynqmp-nvm.c | 35 +
drivers/firmware/xilinx/zynqmp-pdi.c | 27 +
.../firmware/xilinx/{zynqmp.c => zynqmp-pm.c} | 937 +-----------------
include/linux/firmware/xlnx-zynqmp-fpga.h | 55 +
include/linux/firmware/xlnx-zynqmp-nvm.h | 28 +
include/linux/firmware/xlnx-zynqmp-pdi.h | 34 +
include/linux/firmware/xlnx-zynqmp.h | 52 +-
12 files changed, 1134 insertions(+), 972 deletions(-)
create mode 100644 drivers/firmware/xilinx/zynqmp-core.c
create mode 100644 drivers/firmware/xilinx/zynqmp-fpga.c
create mode 100644 drivers/firmware/xilinx/zynqmp-nvm.c
create mode 100644 drivers/firmware/xilinx/zynqmp-pdi.c
rename drivers/firmware/xilinx/{zynqmp.c => zynqmp-pm.c} (63%)
create mode 100644 include/linux/firmware/xlnx-zynqmp-fpga.h
create mode 100644 include/linux/firmware/xlnx-zynqmp-nvm.h
create mode 100644 include/linux/firmware/xlnx-zynqmp-pdi.hSignature · 1 line
2.43.0
PATCH 1/5 drivers: firmware: xilinx: Relocate PDI library APIs to new file
From: Ronak Jain <[email protected]>
Move the PDI library APIs into a dedicated file and header to improve maintainability and reduce complexity in the firmware driver. Keep the existing behavior unchanged.
Add a MAINTAINERS entry for the FPGA and PDI firmware files. List the new PDI files in that entry.
--- MAINTAINERS | 7 +++++ drivers/firmware/xilinx/Makefile | 3 ++- drivers/firmware/xilinx/zynqmp-pdi.c | 27 +++++++++++++++++++ drivers/firmware/xilinx/zynqmp.c | 16 ----------- include/linux/firmware/xlnx-zynqmp-pdi.h | 34 ++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 13 ++------- 6 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 drivers/firmware/xilinx/zynqmp-pdi.c create mode 100644 include/linux/firmware/xlnx-zynqmp-pdi.h
MAINTAINERS +7 -0
@@ -30666,6 +30666,13 @@ S: Maintained F: drivers/soc/xilinx/xlnx_event_manager.c F: include/linux/firmware/xlnx-event-manager.h +XILINX FPGA AND PDI FIRMWARE DRIVER +M: Aravind Thokala <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/xilinx/zynqmp-pdi.c +F: include/linux/firmware/xlnx-zynqmp-pdi.h + XILINX GPIO DRIVER M: Shubhrajyoti Datta <[email protected]> R: Srinivas Neeli <[email protected]>
drivers/firmware/xilinx/Makefile +2 -1
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Xilinx firmwares -obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp.o zynqmp-ufs.o zynqmp-crypto.o +obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-crypto.o zynqmp-pdi.o \ + zynqmp-ufs.o zynqmp.o obj-$(CONFIG_ZYNQMP_FIRMWARE_DEBUG) += zynqmp-debug.o
drivers/firmware/xilinx/zynqmp-pdi.c new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Firmware layer for XilPDI 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_load_pdi - Load and process PDI +* @src: Source device where PDI is located +* @address: PDI src address +* +* This function provides support to load PDI from Linux +* +* Return: Returns status, either success or error+reason +*/ +int zynqmp_pm_load_pdi (const u32 src,const u64 address) +{ +return zynqmp_pm_invoke_fn (PM_LOAD_PDI ,NULL ,3 , src,lower_32_bits (address), +upper_32_bits (address)); +} +EXPORT_SYMBOL_GPL (zynqmp_pm_load_pdi);
drivers/firmware/xilinx/zynqmp.c +0 -16
@@ -1675,22 +1675,6 @@ int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities, }EXPORT_SYMBOL_GPL (zynqmp_pm_set_requirement); -/** -* zynqmp_pm_load_pdi - Load and process PDI -* @src: Source device where PDI is located -* @address: PDI src address -* -* This function provides support to load PDI from linux -* -* Return: Returns status, either success or error+reason -*/ -int zynqmp_pm_load_pdi (const u32 src,const u64 address) -{ -return zynqmp_pm_invoke_fn (PM_LOAD_PDI ,NULL ,3 , src,lower_32_bits (address), -upper_32_bits (address)); -} -EXPORT_SYMBOL_GPL (zynqmp_pm_load_pdi); -/** * zynqmp_pm_efuse_access - Provides access to efuse memory. * @address: Address of the efuse params structure
include/linux/firmware/xlnx-zynqmp-pdi.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Firmware layer for XilPDI APIs. +* +* Copyright (C) 2014 - 2021 Xilinx, Inc. +* Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc. +*/ + +#ifndef __FIRMWARE_ZYNQMP_PDI_H__ +#define __FIRMWARE_ZYNQMP_PDI_H__ + +#ifndef __FIRMWARE_ZYNQMP_H__ +# error "Do not include this file directly, use <linux/firmware/xlnx-zynqmp.h>" +#endif + +#include <linux/errno.h> +#include <linux/types.h> + +/* Loader command */ +#define PM_LOAD_PDI 0x701 + +/* PDI source identifier */ +#define PDI_SRC_DDR 0xF + +#if IS_REACHABLE (CONFIG_ZYNQMP_FIRMWARE ) +int zynqmp_pm_load_pdi (const u32 src,const u64 address); +#else +static inline int zynqmp_pm_load_pdi (const u32 src,const u64 address) +{ +return -ENODEV ; +} +#endif + +#endif /* __FIRMWARE_ZYNQMP_PDI_H__ */
include/linux/firmware/xlnx-zynqmp.h +2 -11
@@ -16,8 +16,9 @@#include <linux/types.h> #include <linux/err.h> -#include <linux/firmware/xlnx-zynqmp-ufs.h> #include <linux/firmware/xlnx-zynqmp-crypto.h> +#include <linux/firmware/xlnx-zynqmp-pdi.h> +#include <linux/firmware/xlnx-zynqmp-ufs.h> #define ZYNQMP_PM_VERSION_MAJOR 1#define ZYNQMP_PM_VERSION_MINOR 0
@@ -101,10 +102,6 @@#define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U#define ZYNQMP_PM_CAPABILITY_UNUSABLE 0x8U -/* Loader commands */ -#define PM_LOAD_PDI 0x701 -#define PDI_SRC_DDR 0xF -/* * Firmware FPGA Manager flags * XILINX_ZYNQMP_PM_FPGA_FULL: FPGA full reconfiguration
@@ -626,7 +623,6 @@ int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param, u32 *value);int zynqmp_pm_pinctrl_set_config (const u32 pin,const u32 param,u32 value); -int zynqmp_pm_load_pdi (const u32 src,const u64 address);int zynqmp_pm_register_notifier (const u32 node,const u32 event,const u32 wake,const u32 enable);int zynqmp_pm_feature (const u32 api_id);
@@ -881,11 +877,6 @@ static inline int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,return -ENODEV ; } -static inline int zynqmp_pm_load_pdi (const u32 src,const u64 address) -{ -return -ENODEV ; -} -static inline int zynqmp_pm_register_notifier (const u32 node,const u32 event,const u32 wake,const u32 enable) {
Signature · 1 line
2.43.0
PATCH 2/5 drivers: firmware: xilinx: Relocate FPGA library APIs to new file
In reply to Jay BuddhabhattiFrom: Ronak Jain <[email protected]>
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.
--- 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
MAINTAINERS +2 -0
@@ -30670,7 +30670,9 @@ XILINX FPGA AND PDI FIRMWARE DRIVER M: Aravind Thokala <[email protected]> L: [email protected] 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
drivers/firmware/xilinx/Makefile +2 -2
@@ -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
drivers/firmware/xilinx/zynqmp-fpga.c new file +89 -0
89 lines not on this page · raw message
drivers/firmware/xilinx/zynqmp.c +0 -78
84 lines not on this page · raw message
include/linux/firmware/xlnx-zynqmp-fpga.h new file +55 -0
55 lines not on this page · raw message
include/linux/firmware/xlnx-zynqmp.h +1 -31
@@ -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 ;
Signature · 1 line
2.43.0
PATCH 3/5 drivers: firmware: xilinx: Relocate NVM library APIs to new file
In reply to Jay BuddhabhattiFrom: Ronak Jain <[email protected]>
Move the NVM library APIs into a dedicated file and header to improve maintainability and reduce complexity in the firmware driver. Keep the existing behavior unchanged.
Add a MAINTAINERS entry for the crypto and NVM firmware files. Include the new NVM files and the existing crypto files in that entry.
--- MAINTAINERS | 9 ++++++ drivers/firmware/xilinx/Makefile | 2 +- drivers/firmware/xilinx/zynqmp-nvm.c | 35 ++++++++++++++++++++++++ drivers/firmware/xilinx/zynqmp.c | 24 ---------------- include/linux/firmware/xlnx-zynqmp-nvm.h | 28 +++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 7 +---- 6 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 drivers/firmware/xilinx/zynqmp-nvm.c create mode 100644 include/linux/firmware/xlnx-zynqmp-nvm.h
MAINTAINERS +9 -0
@@ -30660,6 +30660,15 @@ S: Maintained F: Documentation/devicetree/bindings/net/can/xilinx,can.yaml F: drivers/net/can/xilinx_can.c +XILINX CRYPTO AND NVM FIRMWARE DRIVER +M: Harsh Jain <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/xilinx/zynqmp-crypto.c +F: drivers/firmware/xilinx/zynqmp-nvm.c +F: include/linux/firmware/xlnx-zynqmp-crypto.h +F: include/linux/firmware/xlnx-zynqmp-nvm.h + XILINX EVENT MANAGEMENT DRIVER M: Michal Simek <[email protected]> S: Maintained
drivers/firmware/xilinx/Makefile +1 -1
@@ -2,5 +2,5 @@ # Makefile for Xilinx firmwares obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-crypto.o zynqmp-fpga.o \ - zynqmp-pdi.o zynqmp-ufs.o zynqmp.o + zynqmp-nvm.o zynqmp-pdi.o zynqmp-ufs.o zynqmp.o obj-$(CONFIG_ZYNQMP_FIRMWARE_DEBUG) += zynqmp-debug.o
drivers/firmware/xilinx/zynqmp-nvm.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Firmware layer for XilNVM 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_efuse_access - Provides access to efuse memory. +* @address: Address of the efuse params structure +* @out: Returned output value +* +* Return: Returns status, either success or error code. +*/ +int zynqmp_pm_efuse_access (const u64 address,u32 *out) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; +int ret; + +if (!out) +return -EINVAL ; + + ret =zynqmp_pm_invoke_fn (PM_EFUSE_ACCESS , ret_payload,2 , +upper_32_bits (address), +lower_32_bits (address)); + *out = ret_payload[1 ]; + +return ret; +} +EXPORT_SYMBOL_GPL (zynqmp_pm_efuse_access);
drivers/firmware/xilinx/zynqmp.c +0 -24
@@ -1597,30 +1597,6 @@ int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities, }EXPORT_SYMBOL_GPL (zynqmp_pm_set_requirement); -/** -* zynqmp_pm_efuse_access - Provides access to efuse memory. -* @address: Address of the efuse params structure -* @out: Returned output value -* -* Return: Returns status, either success or error code. -*/ -int zynqmp_pm_efuse_access (const u64 address,u32 *out) -{ -u32 ret_payload[PAYLOAD_ARG_CNT ]; -int ret; - -if (!out) -return -EINVAL ; - - ret =zynqmp_pm_invoke_fn (PM_EFUSE_ACCESS , ret_payload,2 , -upper_32_bits (address), -lower_32_bits (address)); - *out = ret_payload[1 ]; - -return ret; -} -EXPORT_SYMBOL_GPL (zynqmp_pm_efuse_access); -/** * zynqmp_pm_register_notifier() - PM API for register a subsystem * to be notified about specific
include/linux/firmware/xlnx-zynqmp-nvm.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Firmware layer for XilNVM APIs. +* +* Copyright (C) 2014 - 2021 Xilinx, Inc. +* Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc. +*/ + +#ifndef __FIRMWARE_ZYNQMP_NVM_H__ +#define __FIRMWARE_ZYNQMP_NVM_H__ + +#ifndef __FIRMWARE_ZYNQMP_H__ +# error "Do not include this file directly, use <linux/firmware/xlnx-zynqmp.h>" +#endif + +#include <linux/errno.h> +#include <linux/types.h> + +#if IS_REACHABLE (CONFIG_ZYNQMP_FIRMWARE ) +int zynqmp_pm_efuse_access (const u64 address,u32 *out); +#else +static inline int zynqmp_pm_efuse_access (const u64 address,u32 *out) +{ +return -ENODEV ; +} +#endif + +#endif /* __FIRMWARE_ZYNQMP_NVM_H__ */
include/linux/firmware/xlnx-zynqmp.h +1 -6
@@ -18,6 +18,7 @@#include <linux/err.h> #include <linux/firmware/xlnx-zynqmp-crypto.h> #include <linux/firmware/xlnx-zynqmp-fpga.h> +#include <linux/firmware/xlnx-zynqmp-nvm.h> #include <linux/firmware/xlnx-zynqmp-pdi.h> #include <linux/firmware/xlnx-zynqmp-ufs.h>
@@ -594,7 +595,6 @@ int zynqmp_pm_release_node(const u32 node);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_write_ggs (u32 index,u32 value);int zynqmp_pm_read_ggs (u32 index,u32 *value);int zynqmp_pm_write_pggs (u32 index,u32 value);
@@ -775,11 +775,6 @@ static inline int zynqmp_pm_set_requirement(const u32 node,return -ENODEV ; } -static inline int zynqmp_pm_efuse_access (const u64 address,u32 *out) -{ -return -ENODEV ; -} -static inline int zynqmp_pm_write_ggs (u32 index,u32 value) {return -ENODEV ;
Signature · 1 line
2.43.0
Re: [PATCH 3/5] drivers: firmware: xilinx: Relocate NVM library APIs to new file
Quoted 6 lines · Jay Buddhabhatti
From: Ronak Jain <[email protected]>
Move the NVM library APIs into a dedicated file and header to improve maintainability and reduce complexity in the firmware driver. Keep the existing behavior unchanged.
Quoted 6 lines
Add a
MAINTAINERSentry for the crypto and NVM firmware files. Include the new NVM files and the existing crypto files in that entry.Signed-off-by Ronak Jain <[email protected]>Co-developed-by Jay Buddhabhatti <[email protected]>Signed-off-by Jay Buddhabhatti <[email protected]>
Quoted 184 lines
--- MAINTAINERS | 9 ++++++ drivers/firmware/xilinx/Makefile | 2 +- drivers/firmware/xilinx/zynqmp-nvm.c | 35 ++++++++++++++++++++++++ drivers/firmware/xilinx/zynqmp.c | 24 ---------------- include/linux/firmware/xlnx-zynqmp-nvm.h | 28 +++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 7 +---- 6 files changed, 74 insertions(+), 31 deletions(-)create mode 100644
drivers/firmware/xilinx/zynqmp-nvm.ccreate mode 100644include/linux/firmware/xlnx-zynqmp-nvm.hMAINTAINERS +9
-0@@ -30660,6 +30660,15 @@ S: Maintained F: Documentation/devicetree/bindings/net/can/xilinx,can.yaml F: drivers/net/can/xilinx_can.c +XILINX CRYPTO AND NVM FIRMWARE DRIVER +M: Harsh Jain <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/xilinx/zynqmp-crypto.c +F: drivers/firmware/xilinx/zynqmp-nvm.c +F: include/linux/firmware/xlnx-zynqmp-crypto.h +F: include/linux/firmware/xlnx-zynqmp-nvm.h + XILINX EVENT MANAGEMENT DRIVER M: Michal Simek <[email protected]> S: Maintaineddrivers/firmware/xilinx/Makefile +1
-1@@ -2,5 +2,5 @@ # Makefile for Xilinx firmwares obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-crypto.o zynqmp-fpga.o \ - zynqmp-pdi.o zynqmp-ufs.o zynqmp.o + zynqmp-nvm.o zynqmp-pdi.o zynqmp-ufs.o zynqmp.o obj-$(CONFIG_ZYNQMP_FIRMWARE_DEBUG) += zynqmp-debug.odrivers/firmware/xilinx/zynqmp-nvm.c new file +35
-0@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Firmware layer for XilNVM 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_efuse_access - Provides access to efuse memory. +* @address: Address of the efuse params structure +* @out: Returned output value +* +* Return: Returns status, either success or error code. +*/ +int zynqmp_pm_efuse_access (const u64 address,u32 *out) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; +int ret; + +if (!out) +return -EINVAL ; + + ret =zynqmp_pm_invoke_fn (PM_EFUSE_ACCESS , ret_payload,2 , +upper_32_bits (address), +lower_32_bits (address)); + *out = ret_payload[1 ]; + +return ret; +} +EXPORT_SYMBOL_GPL (zynqmp_pm_efuse_access);drivers/firmware/xilinx/zynqmp.c +0
-24@@ -1597,30 +1597,6 @@ int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities, }EXPORT_SYMBOL_GPL (zynqmp_pm_set_requirement); -/** -* zynqmp_pm_efuse_access - Provides access to efuse memory. -* @address: Address of the efuse params structure -* @out: Returned output value -* -* Return: Returns status, either success or error code. -*/ -int zynqmp_pm_efuse_access (const u64 address,u32 *out) -{ -u32 ret_payload[PAYLOAD_ARG_CNT ]; -int ret; - -if (!out) -return -EINVAL ; - - ret =zynqmp_pm_invoke_fn (PM_EFUSE_ACCESS , ret_payload,2 , -upper_32_bits (address), -lower_32_bits (address)); - *out = ret_payload[1 ]; - -return ret; -} -EXPORT_SYMBOL_GPL (zynqmp_pm_efuse_access); -/** * zynqmp_pm_register_notifier() - PM API for register a subsystem * to be notified about specific include/linux/firmware/xlnx-zynqmp-nvm.h new file +28
-0@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Firmware layer for XilNVM APIs. +* +* Copyright (C) 2014 - 2021 Xilinx, Inc. +* Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc. +*/ + +#ifndef __FIRMWARE_ZYNQMP_NVM_H__ +#define __FIRMWARE_ZYNQMP_NVM_H__ + +#ifndef __FIRMWARE_ZYNQMP_H__ +# error "Do not include this file directly, use <linux/firmware/xlnx-zynqmp.h>" +#endif + +#include <linux/errno.h> +#include <linux/types.h> + +#if IS_REACHABLE (CONFIG_ZYNQMP_FIRMWARE ) +int zynqmp_pm_efuse_access (const u64 address,u32 *out); +#else +static inline int zynqmp_pm_efuse_access (const u64 address,u32 *out) +{ +return -ENODEV ; +} +#endif + +#endif /* __FIRMWARE_ZYNQMP_NVM_H__ */ include/linux/firmware/xlnx-zynqmp.h +1
-6@@ -18,6 +18,7 @@#include <linux/err.h> #include <linux/firmware/xlnx-zynqmp-crypto.h> #include <linux/firmware/xlnx-zynqmp-fpga.h> +#include <linux/firmware/xlnx-zynqmp-nvm.h> #include <linux/firmware/xlnx-zynqmp-pdi.h> #include <linux/firmware/xlnx-zynqmp-ufs.h> @@ -594,7 +595,6 @@ int zynqmp_pm_release_node(const u32 node);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_write_ggs (u32 index,u32 value);int zynqmp_pm_read_ggs (u32 index,u32 *value);int zynqmp_pm_write_pggs (u32 index,u32 value);@@ -775,11 +775,6 @@ static inline int zynqmp_pm_set_requirement(const u32 node,return -ENODEV ; } -static inline int zynqmp_pm_efuse_access (const u64 address,u32 *out) -{ -return -ENODEV ; -} -static inline int zynqmp_pm_write_ggs (u32 index,u32 value) {return -ENODEV ;
PATCH 4/5 drivers: firmware: xilinx: Localize firmware version caches
In reply to Jay BuddhabhattiKeep the PM API version cache local to its getter and populate it after a successful query. The firmware probe now keeps the returned version in a local variable instead of passing the address of a file-wide cache.
The firmware probe is the only caller of zynqmp_pm_get_trustzone_version(). Remove the unnecessary trustzone version cache and keep the returned version local to the probe.
--- drivers/firmware/xilinx/zynqmp.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/firmware/xilinx/zynqmp.c +4 -9
@@ -488,9 +488,6 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...) smc_arg[4], smc_arg[5], smc_arg[6], smc_arg[7]); } -static u32 pm_api_version; -static u32 pm_tz_version; -int zynqmp_pm_register_sgi (u32 sgi_num,u32 reset) {int ret;
@@ -512,6 +509,7 @@ int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)int zynqmp_pm_get_api_version (u32 *version) {u32 ret_payload[PAYLOAD_ARG_CNT ]; +static u32 pm_api_version;int ret;if (!version)
@@ -524,6 +522,8 @@ int zynqmp_pm_get_api_version(u32 *version) } ret =zynqmp_pm_invoke_fn (PM_GET_API_VERSION , ret_payload,0 ); *version = ret_payload[1 ]; +if (!ret) + pm_api_version = ret_payload[1 ];return ret; }
@@ -616,11 +616,6 @@ static int zynqmp_pm_get_trustzone_version(u32 *version)if (!version)return -EINVAL ; -/* Check is PM trustzone version already verified */ -if (pm_tz_version >0 ) { - *version = pm_tz_version; -return 0 ; - } ret =zynqmp_pm_invoke_fn (PM_GET_TRUSTZONE_VERSION , ret_payload,0 ); *version = ret_payload[1 ];
@@ -2178,9 +2173,9 @@ static int zynqmp_clear_pm_state(struct device *dev)static int zynqmp_firmware_probe (struct platform_device *pdev) { +u32 pm_api_version, pm_family_code, pm_tz_version;struct device *dev = &pdev->dev;struct zynqmp_devinfo *devinfo; -u32 pm_family_code;int ret; ret =get_set_conduit_method (dev->of_node);
Signature · 1 line
2.43.0
PATCH 5/5 drivers: firmware: xilinx: Split PM EEMI and core APIs in firmware
In reply to Jay BuddhabhattiFrom: Ronak Jain <[email protected]>
Split the firmware driver into core and PM EEMI files to reduce complexity and clarify ownership of each interface.
Add a MAINTAINERS entry for the Xilinx PM firmware driver. List the core, PM EEMI, and debug files and the xlnx-zynqmp.h header.
---
MAINTAINERS | 10 +
drivers/firmware/xilinx/Makefile | 5 +-
drivers/firmware/xilinx/zynqmp-core.c | 797 +++++++++++++++++
drivers/firmware/xilinx/zynqmp-debug.h | 20 +
.../firmware/xilinx/{zynqmp.c => zynqmp-pm.c} | 808 +-----------------
5 files changed, 841 insertions(+), 799 deletions(-)
create mode 100644 drivers/firmware/xilinx/zynqmp-core.c
rename drivers/firmware/xilinx/{zynqmp.c => zynqmp-pm.c} (66%)MAINTAINERS +10 -0
@@ -30699,6 +30699,16 @@ L: [email protected] S: Orphan F: drivers/net/ethernet/xilinx/ll_temac* +XILINX PM FIRMWARE DRIVER +M: Jay Buddhabhatti <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/xilinx/zynqmp-core.c +F: drivers/firmware/xilinx/zynqmp-debug.c +F: drivers/firmware/xilinx/zynqmp-debug.h +F: drivers/firmware/xilinx/zynqmp-pm.c +F: include/linux/firmware/xlnx-zynqmp.h + XILINX PWM DRIVER M: Sean Anderson <[email protected]> S: Maintained
drivers/firmware/xilinx/Makefile +3 -2
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Xilinx firmwares -obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-crypto.o zynqmp-fpga.o \ - zynqmp-nvm.o zynqmp-pdi.o zynqmp-ufs.o zynqmp.o +obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp-core.o zynqmp-crypto.o \ + zynqmp-fpga.o zynqmp-nvm.o zynqmp-pdi.o \ + zynqmp-pm.o zynqmp-ufs.o obj-$(CONFIG_ZYNQMP_FIRMWARE_DEBUG) += zynqmp-debug.o
drivers/firmware/xilinx/zynqmp-core.c new file +797 -0
797 lines not on this page · raw message
drivers/firmware/xilinx/zynqmp-debug.h +20 -0
@@ -13,6 +13,26 @@#ifndef __FIRMWARE_ZYNQMP_DEBUG_H__#define __FIRMWARE_ZYNQMP_DEBUG_H__ +#include <linux/types.h> + +struct device ; +struct platform_device ; + +/** +* struct zynqmp_devinfo - Structure for Zynqmp device instance +* @dev: Device Pointer +* @feature_conf_id: Feature conf id +*/ +struct zynqmp_devinfo { +struct device *dev; +u32 feature_conf_id; +}; + +int zynqmp_firmware_pm_sysfs_entry (struct platform_device *pdev); +int zynqmp_pm_get_sip_svc_version (u32 *version); +int zynqmp_pm_get_trustzone_version (u32 *version); +int zynqmp_pm_init_finalize (void ); +#if IS_REACHABLE (CONFIG_ZYNQMP_FIRMWARE_DEBUG )void zynqmp_pm_api_debugfs_init (void );void zynqmp_pm_api_debugfs_exit (void );
drivers/firmware/xilinx/zynqmp-pm.c renamed from drivers/firmware/xilinx/zynqmp.c +11 -797
867 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 40 lines · Jay Buddhabhatti
Split the ZynqMP firmware driver into focused modules to improve maintainability and clarify ownership of each firmware interface. The driver mixes platform core infrastructure, PM EEMI APIs, PDI loading, FPGA management, and NVM access in one large file.
This series applies on top of "firmware: xilinx: cleanups and debugfs fixes":
https://lore.kernel.org/all/[email protected]/Split the driver incrementally and keep each patch reviewable:
- Move PDI library APIs into
zynqmp-pdi.cwith a dedicated header.
- Move FPGA library APIs intozynqmp-fpga.cwith a dedicated header.
- Move NVM library APIs intozynqmp-nvm.cwith a dedicated header.
- Localize the firmware version caches.
- Split core platform/SMC infrastructure (zynqmp-core.c) from PM EEMIAPIs (zynqmp-pm.c).Jay Buddhabhatti (1):
drivers: firmware: xilinx: Localize firmware version cachesRonak Jain (4):
drivers: firmware: xilinx: Relocate PDI library APIs to new file
drivers: firmware: xilinx: Relocate FPGA library APIs to new file
drivers: firmware: xilinx: Relocate NVM library APIs to new file
drivers: firmware: xilinx: Split PM EEMI and core APIs in firmwareMAINTAINERS | 28 + drivers/firmware/xilinx/Makefile | 4 +- drivers/firmware/xilinx/zynqmp-core.c | 797 +++++++++++++++ drivers/firmware/xilinx/zynqmp-debug.h | 20 + drivers/firmware/xilinx/zynqmp-fpga.c | 89 ++ drivers/firmware/xilinx/zynqmp-nvm.c | 35 + drivers/firmware/xilinx/zynqmp-pdi.c | 27 + .../firmware/xilinx/{zynqmp.c => zynqmp-pm.c} | 937 +----------------- include/linux/firmware/xlnx-zynqmp-fpga.h | 55 + include/linux/firmware/xlnx-zynqmp-nvm.h | 28 + include/linux/firmware/xlnx-zynqmp-pdi.h | 34 + include/linux/firmware/xlnx-zynqmp.h | 52 +- 12 files changed, 1134 insertions(+), 972 deletions(-)
Quoted 9 lines
create mode 100644
drivers/firmware/xilinx/zynqmp-core.ccreate mode 100644drivers/firmware/xilinx/zynqmp-fpga.ccreate mode 100644drivers/firmware/xilinx/zynqmp-nvm.ccreate mode 100644drivers/firmware/xilinx/zynqmp-pdi.crenamedrivers/firmware/xilinx/{zynqmp.c=>zynqmp-pm.c} (63%) create mode 100644include/linux/firmware/xlnx-zynqmp-fpga.hcreate mode 100644include/linux/firmware/xlnx-zynqmp-nvm.hcreate mode 100644include/linux/firmware/xlnx-zynqmp-pdi.h
Applied.
M