]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: socfpga: arria10: Enable double peripheral RBF configuration
authorTien Fong Chee <tien.fong.chee@intel.com>
Sun, 7 Nov 2021 15:08:56 +0000 (23:08 +0800)
committerTien Fong Chee <tien.fong.chee@intel.com>
Fri, 17 Dec 2021 04:58:01 +0000 (12:58 +0800)
Double peripheral RBF configuration are needed on some devices or boards
to stabilize the IO configuration system.

Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
Signed-off-by: Sin Hui Kho <sin.hui.kho@intel.com>
Reviewed-by: Tien Fong Chee <tien.fong.chee@intel.com>
arch/arm/mach-socfpga/include/mach/misc.h
arch/arm/mach-socfpga/misc_arria10.c
arch/arm/mach-socfpga/spl_a10.c
drivers/fpga/socfpga_arria10.c

index 74e8e2590fbf427f8f7f4341de0c25c12670eb1d..8460acb00d9895d9eb9b2f9aceb5858fda1bb4c1 100644 (file)
@@ -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);
index 634e63ed42bcf9335ae402f3a5f693720abf436e..0ed2adfd84a36f7a3e356dd76266b8ccfa2dadc7 100644 (file)
@@ -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
index 6450f7505831f5b548faaf4031e7c09dbb1ce009..d2f454cd24635424d409cd4f19bba91a365d650c 100644 (file)
@@ -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 */
index b992e6f08053dd455cb95aa48d1f4e4d3df186a5..798e3a3f906b72b1f02658f501f9ab6914c09a59 100644 (file)
@@ -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");