[U-Boot] [PATCH 2/3] arm64: zynqmp: Return pmufw version for zynqmp_pmufw_version()

Michal Simek michal.simek at xilinx.com
Thu Aug 23 10:27:41 UTC 2018


From: Siva Durga Prasad Paladugu <siva.durga.paladugu at xilinx.com>

Modify the zynqmp_pmufw_version() routine to return PMUFW version so
that it can be reused wherever required. Get PMUFW version from PMU
only once at bootup and later just return stored value.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu at xilinx.com>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

 arch/arm/cpu/armv8/zynqmp/cpu.c              | 29 ++++++++++++++--------------
 arch/arm/include/asm/arch-zynqmp/sys_proto.h |  4 +++-
 board/xilinx/zynqmp/zynqmp.c                 | 11 ++++++++++-
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/armv8/zynqmp/cpu.c b/arch/arm/cpu/armv8/zynqmp/cpu.c
index 8cdfb9317547..43ba739d2f7c 100644
--- a/arch/arm/cpu/armv8/zynqmp/cpu.c
+++ b/arch/arm/cpu/armv8/zynqmp/cpu.c
@@ -172,26 +172,27 @@ int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2,
 }
 
 #if defined(CONFIG_CLK_ZYNQMP)
-void zynqmp_pmufw_version(void)
+unsigned int zynqmp_pmufw_version(void)
 {
 	int ret;
 	u32 ret_payload[PAYLOAD_ARG_CNT];
-	u32 pm_api_version;
+	static u32 pm_api_version = ZYNQMP_PM_VERSION_INVALID;
 
-	ret = invoke_smc(ZYNQMP_SIP_SVC_GET_API_VERSION, 0, 0, 0, 0,
-			 ret_payload);
-	pm_api_version = ret_payload[1];
-
-	if (ret)
-		panic("PMUFW is not found - Please load it!\n");
+	/*
+	 * Get PMU version only once and later
+	 * just return stored values instead of
+	 * asking PMUFW again.
+	 */
+	if (pm_api_version == ZYNQMP_PM_VERSION_INVALID) {
+		ret = invoke_smc(ZYNQMP_SIP_SVC_GET_API_VERSION, 0, 0, 0, 0,
+				 ret_payload);
+		pm_api_version = ret_payload[1];
 
-	printf("PMUFW:\tv%d.%d\n",
-	       pm_api_version >> ZYNQMP_PM_VERSION_MAJOR_SHIFT,
-	       pm_api_version & ZYNQMP_PM_VERSION_MINOR_MASK);
+		if (ret)
+			panic("PMUFW is not found - Please load it!\n");
+	}
 
-	if (pm_api_version < ZYNQMP_PM_VERSION)
-		panic("PMUFW version error. Expected: v%d.%d\n",
-		      ZYNQMP_PM_VERSION_MAJOR, ZYNQMP_PM_VERSION_MINOR);
+	return pm_api_version;
 }
 #endif
 
diff --git a/arch/arm/include/asm/arch-zynqmp/sys_proto.h b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
index bc563d2b61b9..79c655a0e1a7 100644
--- a/arch/arm/include/asm/arch-zynqmp/sys_proto.h
+++ b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
@@ -32,6 +32,8 @@
 	((ZYNQMP_PM_VERSION_MAJOR << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | \
 				 ZYNQMP_PM_VERSION_MINOR)
 
+#define ZYNQMP_PM_VERSION_INVALID	~0
+
 enum {
 	IDCODE,
 	VERSION,
@@ -55,7 +57,7 @@ unsigned int zynqmp_get_silicon_version(void);
 
 void handoff_setup(void);
 
-void zynqmp_pmufw_version(void);
+unsigned int zynqmp_pmufw_version(void);
 int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value);
 int zynqmp_mmio_read(const u32 address, u32 *value);
 int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 02f5a41e81ab..3800d2da4dc1 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -281,7 +281,16 @@ int board_early_init_f(void)
 {
 	int ret = 0;
 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_CLK_ZYNQMP)
-	zynqmp_pmufw_version();
+	u32 pm_api_version;
+
+	pm_api_version = zynqmp_pmufw_version();
+	printf("PMUFW:\tv%d.%d\n",
+	       pm_api_version >> ZYNQMP_PM_VERSION_MAJOR_SHIFT,
+	       pm_api_version & ZYNQMP_PM_VERSION_MINOR_MASK);
+
+	if (pm_api_version < ZYNQMP_PM_VERSION)
+		panic("PMUFW version error. Expected: v%d.%d\n",
+		      ZYNQMP_PM_VERSION_MAJOR, ZYNQMP_PM_VERSION_MINOR);
 #endif
 
 #if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED)
-- 
1.9.1



More information about the U-Boot mailing list