ARM: socfpga: Add support for selecting bridges in bridge command
authorMarek Vasut <marex@denx.de>
Tue, 16 Apr 2019 20:28:08 +0000 (22:28 +0200)
committerMarek Vasut <marex@denx.de>
Mon, 29 Apr 2019 08:08:56 +0000 (10:08 +0200)
Add optional "mask" argument to the SoCFPGA bridge command, to select
which bridges should be enabled/disabled. This allows the user to avoid
enabling bridges which are not connected into the FPGA fabric. Default
behavior is to enable/disable all bridges.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chin Liang See <chin.liang.see@intel.com>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tien Fong Chee <tien.fong.chee@intel.com>
arch/arm/mach-socfpga/include/mach/misc.h
arch/arm/mach-socfpga/misc.c
arch/arm/mach-socfpga/misc_arria10.c
arch/arm/mach-socfpga/misc_gen5.c
arch/arm/mach-socfpga/misc_s10.c

index 86d5d2b62b079aed4afafbb91d9d3c81f3154d4c..c3ca8cdf3babc4a241f14b7eec77a9d1fb3f57db 100644 (file)
@@ -39,6 +39,6 @@ void socfpga_init_security_policies(void);
 void socfpga_sdram_remap_zero(void);
 #endif
 
-void do_bridge_reset(int enable);
+void do_bridge_reset(int enable, unsigned int mask);
 
 #endif /* _MISC_H_ */
index ec8339e04574462af171b97f0f35cdb9ef74d6c0..e1ea8eb73e33ecd004f8a99adfa68b7f27cff8c8 100644 (file)
@@ -126,17 +126,22 @@ int arch_cpu_init(void)
 #ifndef CONFIG_SPL_BUILD
 static int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       if (argc != 2)
+       unsigned int mask = ~0;
+
+       if (argc < 2 || argc > 3)
                return CMD_RET_USAGE;
 
        argv++;
 
+       if (argc == 3)
+               mask = simple_strtoul(argv[1], NULL, 16);
+
        switch (*argv[0]) {
        case 'e':       /* Enable */
-               do_bridge_reset(1);
+               do_bridge_reset(1, mask);
                break;
        case 'd':       /* Disable */
-               do_bridge_reset(0);
+               do_bridge_reset(0, mask);
                break;
        default:
                return CMD_RET_USAGE;
@@ -145,10 +150,10 @@ static int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 0;
 }
 
-U_BOOT_CMD(bridge, 2, 1, do_bridge,
+U_BOOT_CMD(bridge, 3, 1, do_bridge,
           "SoCFPGA HPS FPGA bridge control",
-          "enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
-          "bridge disable - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+          "enable [mask] - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+          "bridge disable [mask] - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
           ""
 );
 
index 63b8c75d31d134053ac521c62bded724315d8485..2e2a40b65dc13dd7578150b795e630f3be9a8f16 100644 (file)
@@ -115,7 +115,7 @@ int print_cpuinfo(void)
 }
 #endif
 
-void do_bridge_reset(int enable)
+void do_bridge_reset(int enable, unsigned int mask)
 {
        if (enable)
                socfpga_reset_deassert_bridges_handoff();
index 9865f5b5b12065cf739e5669d7843ed51c6635ec..dda95e8237f128105a37f528fe624b20b11e6c42 100644 (file)
@@ -239,9 +239,19 @@ static void socfpga_sdram_apply_static_cfg(void)
        : : "r"(val), "r"(&sdr_ctrl->static_cfg) : "memory", "cc");
 }
 
-void do_bridge_reset(int enable)
+void do_bridge_reset(int enable, unsigned int mask)
 {
+       int i;
+
        if (enable) {
+               socfpga_bridges_set_handoff_regs(!(mask & BIT(0)),
+                                                !(mask & BIT(1)),
+                                                !(mask & BIT(2)));
+               for (i = 0; i < 2; i++) {       /* Reload SW setting cache */
+                       iswgrp_handoff[i] =
+                               readl(&sysmgr_regs->iswgrp_handoff[i]);
+               }
+
                writel(iswgrp_handoff[2], &sysmgr_regs->fpgaintfgrp_module);
                socfpga_sdram_apply_static_cfg();
                writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst);
index 113eace650edcfe12f3afd2566868362d11ab8ea..60c96090ce1c47ad2151e23d1986811f3006f38b 100644 (file)
@@ -150,7 +150,7 @@ int arch_early_init_r(void)
        return 0;
 }
 
-void do_bridge_reset(int enable)
+void do_bridge_reset(int enable, unsigned int mask)
 {
        socfpga_bridges_reset(enable);
 }