Skip to contentSkip to conversation

ARM: socfpga: Ensure FPGA in user mode before enabling the bridges

PATCH New [email protected] 1 participant 1 message Sep 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: socfpga: Ensure FPGA in user mode before enabling the bridges

From: Tien Fong Chee <[email protected]>

Unexpected behavior and error can occur if FPGA is accessed in unknown state.Always checking with FPGA in user mode is required to ensure system stability.

---
 arch/arm/mach-socfpga/misc_arria10.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
arch/arm/mach-socfpga/misc_arria10.c +10 -3
index 7ce888d197..89298f5d4d 100644
@@ -13,6 +13,7 @@
 #include <ns16550.h>
 #include <spi_flash.h>
 #include <watchdog.h>
+#include <asm/arch/fpga_manager.h>
 #include <asm/arch/misc.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/reset_manager.h>
@@ -126,10 +127,16 @@ int print_cpuinfo(void)
 
 void do_bridge_reset(int enable, unsigned int mask)
 {
-	if (enable)
-		socfpga_reset_deassert_bridges_handoff();
-	else
+	if (enable) {
+		if (is_fpgamgr_user_mode()) {
+			socfpga_reset_deassert_bridges_handoff();
+		} else {
+			puts("Bridges: Failed to enable because FPGA is not ");
+			puts("in user mode\n");
+		}
+	} else {
 		socfpga_bridges_reset();
+	}
 }
 
 /*
Signature · 1 line
2.25.1