Skip to contentSkip to conversation

arm: socfpga: arria10: Setting image magic value to romcode initswstate reg

PATCH In review [email protected] 2 participants 6 messages Nov 7, 2021 – Nov 25, 2021

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

PATCH 1/3 arm: socfpga: arria10: Setting image magic value to romcode initswstate reg

From: Tien Fong Chee <[email protected]>

The romcode_initswstate register need to be set with FSBL_IMAGE_IS_VALID value if the current FSBL image is found valid, otherwise BootROM will look for next subsequent valid FSBL image when warm reset is triggered.

---
 .../mach-socfpga/include/mach/system_manager_arria10.h |  3 ++-
 arch/arm/mach-socfpga/spl_a10.c                        | 10 +++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h +2 -1
index e4fc6d2e55..75e1fcd80f 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2016-2021 Intel Corporation <www.intel.com>
  */
 
 #ifndef _SYSTEM_MANAGER_ARRIA10_H_
@@ -31,6 +31,7 @@
 #define SYSMGR_A10_NOC_IDLEACK			0xd0
 #define SYSMGR_A10_NOC_IDLESTATUS		0xd4
 #define SYSMGR_A10_FPGA2SOC_CTRL		0xd8
+#define SYSMGR_A10_ROMCODE_INITSWSTATE	0x20C
 
 #define SYSMGR_SDMMC				SYSMGR_A10_SDMMC
 
arch/arm/mach-socfpga/spl_a10.c +9 -1
index ecb656e4de..f6c4b5708d 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012-2019 Altera Corporation <www.altera.com>
+ *  Copyright (C) 2012-2021 Altera Corporation <www.altera.com>
  */
 
 #include <common.h>
@@ -32,6 +32,7 @@
 #include <memalign.h>
 
 #define FPGA_BUFSIZ	16 * 1024
+#define FSBL_IMAGE_IS_VALID	0x49535756
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -169,3 +170,10 @@ void board_init_f(ulong dummy)
 	config_dedicated_pins(gd->fdt_blob);
 	WATCHDOG_RESET();
 }
+
+/* board specific function prior loading SSBL / U-Boot proper */
+void spl_board_prepare_for_boot(void)
+{
+	writel(FSBL_IMAGE_IS_VALID, socfpga_get_sysmgr_addr() +
+	       SYSMGR_A10_ROMCODE_INITSWSTATE);
+}
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 arm: socfpga: arria10: Reset MPFE NoC after program periph / combined RBF

From: Tien Fong Chee <[email protected]>

This patch triggers warm reset to recover the MPFE NoC from corruption due to high frequency transient clock output from HPS EMIF IOPLL at VCO startup after peripheral RBF is programmed.

---
 arch/arm/mach-socfpga/include/mach/misc.h     |  5 +-
 .../include/mach/reset_manager_arria10.h      |  6 +-
 .../include/mach/system_manager_arria10.h     |  4 +
 arch/arm/mach-socfpga/misc_arria10.c          | 90 ++++++++++++++++-
 arch/arm/mach-socfpga/spl_a10.c               | 96 ++++++++++++++++++-
 5 files changed, 195 insertions(+), 6 deletions(-)
arch/arm/mach-socfpga/include/mach/misc.h +4 -1
index 649d2f6ce2..74e8e2590f 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2016-2017 Intel Corporation
+ * Copyright (C) 2016-2021 Intel Corporation
  */
 
 #ifndef _SOCFPGA_MISC_H_
@@ -45,7 +45,10 @@ int is_fpga_config_ready(void);
 #endif
 
 void do_bridge_reset(int enable, unsigned int mask);
+bool is_regular_boot_valid(void);
+void set_regular_boot(unsigned int status);
 void socfpga_pl310_clear(void);
 void socfpga_get_managers_addr(void);
+int qspi_flash_software_reset(void);
 
 #endif /* _SOCFPGA_MISC_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +5 -1
index 19507c292d..26faa628a0 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2016-2017 Intel Corporation
+ * Copyright (C) 2016-2021 Intel Corporation
  */
 
 #ifndef _RESET_MANAGER_ARRIA10_H_
@@ -22,6 +22,7 @@ int socfpga_bridges_reset(void);
 #define RSTMGR_A10_PER1MODRST	0x28
 #define RSTMGR_A10_BRGMODRST	0x2c
 #define RSTMGR_A10_SYSMODRST	0x30
+#define RSTMGR_A10_SYSWARMMASK	0x50
 
 #define RSTMGR_CTRL		RSTMGR_A10_CTRL
 
@@ -115,4 +116,7 @@ int socfpga_bridges_reset(void);
 #define ALT_RSTMGR_HDSKEN_FPGAHSEN_SET_MSK	BIT(2)
 #define ALT_RSTMGR_HDSKEN_ETRSTALLEN_SET_MSK	BIT(3)
 
+#define ALT_RSTMGR_FPGAMGRWARMMASK_S2F_SET_MSK	BIT(3)
+#define ALT_RSTMGR_SYSWARMMASK_S2F_SET_MSK	BIT(4)
+
 #endif /* _RESET_MANAGER_ARRIA10_H_ */
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h +4 -0
index 75e1fcd80f..0afe63e647 100644
@@ -31,7 +31,11 @@
 #define SYSMGR_A10_NOC_IDLEACK			0xd0
 #define SYSMGR_A10_NOC_IDLESTATUS		0xd4
 #define SYSMGR_A10_FPGA2SOC_CTRL		0xd8
+#define SYSMGR_A10_ROMCODE_CTRL			0x204
 #define SYSMGR_A10_ROMCODE_INITSWSTATE	0x20C
+#define SYSMGR_A10_ROMCODE_QSPIRESETCOMMAND	0x208
+#define SYSMGR_A10_ISW_HANDOFF_BASE		0x230
+#define SYSMGR_A10_ISW_HANDOFF_7		0x1c
 
 #define SYSMGR_SDMMC				SYSMGR_A10_SDMMC
 
arch/arm/mach-socfpga/misc_arria10.c +89 -1

116 lines not on this page · raw message

arch/arm/mach-socfpga/spl_a10.c +93 -3

125 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v1 2/3
#2 lore raw

RE: [PATCH 2/3] arm: socfpga: arria10: Reset MPFE NoC after program periph / combined RBF

Quoted 22 lines

-----Original Message-----
From: Kho, Sin Hui <[email protected]>
Sent: Sunday, 7 November, 2021 11:09 PM
To: [email protected]
Cc: Simon Goldschmidt <[email protected]>; Marek Vasut <[email protected]>; Chee, Tien Fong <[email protected]>; Hea, Kok Kiang <[email protected]>; Westergreen, Dalon <[email protected]>; Cozart, Sue <[email protected]>; Kho, Sin Hui <[email protected]>
Subject: [PATCH 2/3] arm: socfpga: arria10: Reset MPFE NoC after program periph / combined RBF

From: Tien Fong Chee <[email protected]>

This patch triggers warm reset to recover the MPFE NoC from corruption due to high frequency transient clock output from HPS EMIF IOPLL at VCO startup after peripheral RBF is programmed.

Quoted 7 lines
---
 arch/arm/mach-socfpga/include/mach/misc.h     |  5 +-
 .../include/mach/reset_manager_arria10.h      |  6 +-
 .../include/mach/system_manager_arria10.h     |  4 +
 arch/arm/mach-socfpga/misc_arria10.c          | 90 ++++++++++++++++-
 arch/arm/mach-socfpga/spl_a10.c               | 96 ++++++++++++++++++-
 5 files changed, 195 insertions(+), 6 deletions(-)
#3 lore raw

PATCH 3/3 arm: socfpga: arria10: Enable double peripheral RBF configuration

In reply to [email protected]

From: Tien Fong Chee <[email protected]>

Double peripheral RBF configuration are needed on some devices or boards to stabilize the IO configuration system.

---
 arch/arm/mach-socfpga/include/mach/misc.h |  2 ++
 arch/arm/mach-socfpga/misc_arria10.c      | 36 +++++++++++++++++++++++
 arch/arm/mach-socfpga/spl_a10.c           | 14 +++++++++
 drivers/fpga/socfpga_arria10.c            |  3 +-
 4 files changed, 54 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/misc.h +2 -0
index 74e8e2590f..8460acb00d 100644
@@ -45,7 +45,9 @@ int is_fpga_config_ready(void);
 #endif
 
 void do_bridge_reset(int enable, unsigned int mask);
+void force_periph_program(unsigned int status);
 bool is_regular_boot_valid(void);
+bool is_periph_program_force(void);
 void set_regular_boot(unsigned int status);
 void socfpga_pl310_clear(void);
 void socfpga_get_managers_addr(void);
arch/arm/mach-socfpga/misc_arria10.c +36 -0
index 634e63ed42..0ed2adfd84 100644
@@ -32,6 +32,7 @@
 #define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q4_3	0x98
 
 #define REGULAR_BOOT_MAGIC	0xd15ea5e
+#define PERIPH_RBF_PROG_FORCE	0x50455249
 
 #define QSPI_S25FL_SOFT_RESET_COMMAND	0x00f0ff82
 #define QSPI_N25_SOFT_RESET_COMMAND	0x00000001
@@ -131,6 +132,41 @@ void do_bridge_reset(int enable, unsigned int mask)
 		socfpga_bridges_reset();
 }
 
+/*
+ * This function set/unset flag with number "0x50455249" to
+ * handoff register isw_handoff[7] - 0xffd0624c
+ * This flag is used to force periph RBF program regardless FPGA status
+ * and double periph RBF config are needed on some devices or boards to
+ * stabilize the IO config system.
+ */
+void force_periph_program(unsigned int status)
+{
+	if (status)
+		writel(PERIPH_RBF_PROG_FORCE, socfpga_get_sysmgr_addr() +
+		       SYSMGR_A10_ISW_HANDOFF_BASE + SYSMGR_A10_ISW_HANDOFF_7);
+	else
+		writel(0, socfpga_get_sysmgr_addr() +
+		       SYSMGR_A10_ISW_HANDOFF_BASE + SYSMGR_A10_ISW_HANDOFF_7);
+}
+
+/*
+ * This function is used to check whether
+ * handoff register isw_handoff[7] contains
+ * flag for forcing the periph RBF program "0x50455249".
+ */
+bool is_periph_program_force(void)
+{
+	unsigned int status;
+
+	status = readl(socfpga_get_sysmgr_addr() +
+		       SYSMGR_A10_ISW_HANDOFF_BASE + SYSMGR_A10_ISW_HANDOFF_7);
+
+	if (status == PERIPH_RBF_PROG_FORCE)
+		return true;
+	else
+		return false;
+}
+
 /*
  * This function set/unset magic number "0xd15ea5e" to
  * handoff register isw_handoff[7] - 0xffd0624c
arch/arm/mach-socfpga/spl_a10.c +14 -0
index 6450f75058..d2f454cd24 100644
@@ -133,6 +133,20 @@ void spl_board_init(void)
 	} else if (!is_fpgamgr_early_user_mode()) {
 		/* Program IOSSM(early IO release) or full FPGA */
 		fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+
+		/* Skipping double program for combined RBF */
+		if (!is_fpgamgr_user_mode()) {
+			/*
+			 * Expect FPGA entered early user mode, so
+			 * the flag is set to re-program IOSSM
+			 */
+			force_periph_program(true);
+
+			/* Re-program IOSSM to stabilize IO system */
+			fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+
+			force_periph_program(false);
+		}
 	}
 
 	/* If the IOSSM/full FPGA is already loaded, start DDR */
drivers/fpga/socfpga_arria10.c +2 -1
index b992e6f080..798e3a3f90 100644
@@ -604,7 +604,8 @@ static int first_loading_rbf_to_buffer(struct udevice *dev,
 
 			if (strstr(uname, "fpga-periph") &&
 				(!is_fpgamgr_early_user_mode() ||
-				is_fpgamgr_user_mode())) {
+				is_fpgamgr_user_mode() ||
+				is_periph_program_force())) {
 				fpga_node_name = uname;
 				printf("FPGA: Start to program ");
 				printf("peripheral/full bitstream ...\n");
Signature · 1 line
2.25.1
Reviewed-by on v1 3/3
#4 lore raw

RE: [PATCH 3/3] arm: socfpga: arria10: Enable double peripheral RBF configuration

Quoted 21 lines

-----Original Message-----
From: Kho, Sin Hui <[email protected]>
Sent: Sunday, 7 November, 2021 11:09 PM
To: [email protected]
Cc: Simon Goldschmidt <[email protected]>; Marek Vasut <[email protected]>; Chee, Tien Fong <[email protected]>; Hea, Kok Kiang <[email protected]>; Westergreen, Dalon <[email protected]>; Cozart, Sue <[email protected]>; Kho, Sin Hui <[email protected]>
Subject: [PATCH 3/3] arm: socfpga: arria10: Enable double peripheral RBF configuration

From: Tien Fong Chee <[email protected]>

Double peripheral RBF configuration are needed on some devices or boards to stabilize the IO configuration system.

Quoted 8 lines
---
 arch/arm/mach-socfpga/include/mach/misc.h |  2 ++
 arch/arm/mach-socfpga/misc_arria10.c      | 36
+++++++++++++++++++++++
 arch/arm/mach-socfpga/spl_a10.c           | 14 +++++++++
 drivers/fpga/socfpga_arria10.c            |  3 +-
 4 files changed, 54 insertions(+), 1 deletion(-)
Reviewed-by on v1 1/3
#5 lore raw
In reply to [email protected]
Quoted 78 lines

-----Original Message-----
From: Kho, Sin Hui <[email protected]>
Sent: Sunday, 7 November, 2021 11:09 PM
To: [email protected]
Cc: Simon Goldschmidt <[email protected]>; Marek Vasut <[email protected]>; Chee, Tien Fong <[email protected]>; Hea, Kok Kiang <[email protected]>; Westergreen, Dalon <[email protected]>; Cozart, Sue <[email protected]>; Kho, Sin Hui <[email protected]>
Subject: [PATCH 1/3] arm: socfpga: arria10: Setting image magic value to romcode initswstate reg

From: Tien Fong Chee <[email protected]>

The romcode_initswstate register need to be set with FSBL_IMAGE_IS_VALID value if the current FSBL image is found valid, otherwise BootROM will look for next subsequent valid FSBL image when warm reset is triggered.

---
 .../mach-socfpga/include/mach/system_manager_arria10.h |  3 ++-
 arch/arm/mach-socfpga/spl_a10.c                        | 10 +++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h +2 -1
index e4fc6d2e55..75e1fcd80f 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2016-2021 Intel Corporation <www.intel.com>
  */
 
 #ifndef _SYSTEM_MANAGER_ARRIA10_H_
@@ -31,6 +31,7 @@
 #define SYSMGR_A10_NOC_IDLEACK			0xd0
 #define SYSMGR_A10_NOC_IDLESTATUS		0xd4
 #define SYSMGR_A10_FPGA2SOC_CTRL		0xd8
+#define SYSMGR_A10_ROMCODE_INITSWSTATE	0x20C
 
 #define SYSMGR_SDMMC				SYSMGR_A10_SDMMC
 
arch/arm/mach- renamed from arch/arm/mach-socfpga/spl_a10.c +0 -0

socfpga/spl_a10.c index ecb656e4de..f6c4b5708d 100644

arch/arm/mach-socfpga/spl_a10.c +7 -2
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012-2019 Altera Corporation <www.altera.com>
+ *  Copyright (C) 2012-2021 Altera Corporation <www.altera.com>
  */
 
 #include <common.h>
@@ -32,6 +32,7 @@
 #include <memalign.h>
 
 #define FPGA_BUFSIZ	16 * 1024
+#define FSBL_IMAGE_IS_VALID	0x49535756
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -169,3 +170,10 @@ void board_init_f(ulong dummy)
 	config_dedicated_pins(gd->fdt_blob);
 	WATCHDOG_RESET();
 }
+
+/* board specific function prior loading SSBL / U-Boot proper */ void
+spl_board_prepare_for_boot(void) {
+	writel(FSBL_IMAGE_IS_VALID, socfpga_get_sysmgr_addr() +
+	       SYSMGR_A10_ROMCODE_INITSWSTATE); }
--
Quoted 1 line

2.25.1