xref: /OK3568_Linux_fs/u-boot/arch/arm/mach-socfpga/misc_gen5.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *  Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #include <common.h>
8*4882a593Smuzhiyun #include <asm/io.h>
9*4882a593Smuzhiyun #include <errno.h>
10*4882a593Smuzhiyun #include <fdtdec.h>
11*4882a593Smuzhiyun #include <linux/libfdt.h>
12*4882a593Smuzhiyun #include <altera.h>
13*4882a593Smuzhiyun #include <miiphy.h>
14*4882a593Smuzhiyun #include <netdev.h>
15*4882a593Smuzhiyun #include <watchdog.h>
16*4882a593Smuzhiyun #include <asm/arch/misc.h>
17*4882a593Smuzhiyun #include <asm/arch/reset_manager.h>
18*4882a593Smuzhiyun #include <asm/arch/scan_manager.h>
19*4882a593Smuzhiyun #include <asm/arch/sdram.h>
20*4882a593Smuzhiyun #include <asm/arch/system_manager.h>
21*4882a593Smuzhiyun #include <asm/arch/nic301.h>
22*4882a593Smuzhiyun #include <asm/arch/scu.h>
23*4882a593Smuzhiyun #include <asm/pl310.h>
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #include <dt-bindings/reset/altr,rst-mgr.h>
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun DECLARE_GLOBAL_DATA_PTR;
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun static struct pl310_regs *const pl310 =
30*4882a593Smuzhiyun 	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
31*4882a593Smuzhiyun static struct socfpga_system_manager *sysmgr_regs =
32*4882a593Smuzhiyun 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
33*4882a593Smuzhiyun static struct socfpga_reset_manager *reset_manager_base =
34*4882a593Smuzhiyun 	(struct socfpga_reset_manager *)SOCFPGA_RSTMGR_ADDRESS;
35*4882a593Smuzhiyun static struct nic301_registers *nic301_regs =
36*4882a593Smuzhiyun 	(struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
37*4882a593Smuzhiyun static struct scu_registers *scu_regs =
38*4882a593Smuzhiyun 	(struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
39*4882a593Smuzhiyun static struct socfpga_sdr_ctrl *sdr_ctrl =
40*4882a593Smuzhiyun 	(struct socfpga_sdr_ctrl *)SDR_CTRLGRP_ADDRESS;
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /*
43*4882a593Smuzhiyun  * DesignWare Ethernet initialization
44*4882a593Smuzhiyun  */
45*4882a593Smuzhiyun #ifdef CONFIG_ETH_DESIGNWARE
dwmac_deassert_reset(const unsigned int of_reset_id,const u32 phymode)46*4882a593Smuzhiyun void dwmac_deassert_reset(const unsigned int of_reset_id,
47*4882a593Smuzhiyun 				 const u32 phymode)
48*4882a593Smuzhiyun {
49*4882a593Smuzhiyun 	u32 physhift, reset;
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun 	if (of_reset_id == EMAC0_RESET) {
52*4882a593Smuzhiyun 		physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB;
53*4882a593Smuzhiyun 		reset = SOCFPGA_RESET(EMAC0);
54*4882a593Smuzhiyun 	} else if (of_reset_id == EMAC1_RESET) {
55*4882a593Smuzhiyun 		physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB;
56*4882a593Smuzhiyun 		reset = SOCFPGA_RESET(EMAC1);
57*4882a593Smuzhiyun 	} else {
58*4882a593Smuzhiyun 		printf("GMAC: Invalid reset ID (%i)!\n", of_reset_id);
59*4882a593Smuzhiyun 		return;
60*4882a593Smuzhiyun 	}
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun 	/* configure to PHY interface select choosed */
63*4882a593Smuzhiyun 	clrsetbits_le32(&sysmgr_regs->emacgrp_ctrl,
64*4882a593Smuzhiyun 			SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift,
65*4882a593Smuzhiyun 			phymode << physhift);
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	/* Release the EMAC controller from reset */
68*4882a593Smuzhiyun 	socfpga_per_reset(reset, 0);
69*4882a593Smuzhiyun }
70*4882a593Smuzhiyun 
dwmac_phymode_to_modereg(const char * phymode,u32 * modereg)71*4882a593Smuzhiyun static u32 dwmac_phymode_to_modereg(const char *phymode, u32 *modereg)
72*4882a593Smuzhiyun {
73*4882a593Smuzhiyun 	if (!phymode)
74*4882a593Smuzhiyun 		return -EINVAL;
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	if (!strcmp(phymode, "mii") || !strcmp(phymode, "gmii")) {
77*4882a593Smuzhiyun 		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
78*4882a593Smuzhiyun 		return 0;
79*4882a593Smuzhiyun 	}
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun 	if (!strcmp(phymode, "rgmii")) {
82*4882a593Smuzhiyun 		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
83*4882a593Smuzhiyun 		return 0;
84*4882a593Smuzhiyun 	}
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun 	if (!strcmp(phymode, "rmii")) {
87*4882a593Smuzhiyun 		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII;
88*4882a593Smuzhiyun 		return 0;
89*4882a593Smuzhiyun 	}
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 	return -EINVAL;
92*4882a593Smuzhiyun }
93*4882a593Smuzhiyun 
socfpga_eth_reset(void)94*4882a593Smuzhiyun static int socfpga_eth_reset(void)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun 	const void *fdt = gd->fdt_blob;
97*4882a593Smuzhiyun 	struct fdtdec_phandle_args args;
98*4882a593Smuzhiyun 	const char *phy_mode;
99*4882a593Smuzhiyun 	u32 phy_modereg;
100*4882a593Smuzhiyun 	int nodes[2];	/* Max. two GMACs */
101*4882a593Smuzhiyun 	int ret, count;
102*4882a593Smuzhiyun 	int i, node;
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	/* Put both GMACs into RESET state. */
105*4882a593Smuzhiyun 	socfpga_per_reset(SOCFPGA_RESET(EMAC0), 1);
106*4882a593Smuzhiyun 	socfpga_per_reset(SOCFPGA_RESET(EMAC1), 1);
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun 	count = fdtdec_find_aliases_for_id(fdt, "ethernet",
109*4882a593Smuzhiyun 					   COMPAT_ALTERA_SOCFPGA_DWMAC,
110*4882a593Smuzhiyun 					   nodes, ARRAY_SIZE(nodes));
111*4882a593Smuzhiyun 	for (i = 0; i < count; i++) {
112*4882a593Smuzhiyun 		node = nodes[i];
113*4882a593Smuzhiyun 		if (node <= 0)
114*4882a593Smuzhiyun 			continue;
115*4882a593Smuzhiyun 
116*4882a593Smuzhiyun 		ret = fdtdec_parse_phandle_with_args(fdt, node, "resets",
117*4882a593Smuzhiyun 						     "#reset-cells", 1, 0,
118*4882a593Smuzhiyun 						     &args);
119*4882a593Smuzhiyun 		if (ret || (args.args_count != 1)) {
120*4882a593Smuzhiyun 			debug("GMAC%i: Failed to parse DT 'resets'!\n", i);
121*4882a593Smuzhiyun 			continue;
122*4882a593Smuzhiyun 		}
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun 		phy_mode = fdt_getprop(fdt, node, "phy-mode", NULL);
125*4882a593Smuzhiyun 		ret = dwmac_phymode_to_modereg(phy_mode, &phy_modereg);
126*4882a593Smuzhiyun 		if (ret) {
127*4882a593Smuzhiyun 			debug("GMAC%i: Failed to parse DT 'phy-mode'!\n", i);
128*4882a593Smuzhiyun 			continue;
129*4882a593Smuzhiyun 		}
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun 		dwmac_deassert_reset(args.args[0], phy_modereg);
132*4882a593Smuzhiyun 	}
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun 	return 0;
135*4882a593Smuzhiyun }
136*4882a593Smuzhiyun #else
socfpga_eth_reset(void)137*4882a593Smuzhiyun static int socfpga_eth_reset(void)
138*4882a593Smuzhiyun {
139*4882a593Smuzhiyun 	return 0;
140*4882a593Smuzhiyun };
141*4882a593Smuzhiyun #endif
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun static const struct {
144*4882a593Smuzhiyun 	const u16	pn;
145*4882a593Smuzhiyun 	const char	*name;
146*4882a593Smuzhiyun 	const char	*var;
147*4882a593Smuzhiyun } const socfpga_fpga_model[] = {
148*4882a593Smuzhiyun 	/* Cyclone V E */
149*4882a593Smuzhiyun 	{ 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
150*4882a593Smuzhiyun 	{ 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
151*4882a593Smuzhiyun 	{ 0x2b22, "Cyclone V, E/A5", "cv_e_a5" },
152*4882a593Smuzhiyun 	{ 0x2b13, "Cyclone V, E/A7", "cv_e_a7" },
153*4882a593Smuzhiyun 	{ 0x2b14, "Cyclone V, E/A9", "cv_e_a9" },
154*4882a593Smuzhiyun 	/* Cyclone V GX/GT */
155*4882a593Smuzhiyun 	{ 0x2b01, "Cyclone V, GX/C3", "cv_gx_c3" },
156*4882a593Smuzhiyun 	{ 0x2b12, "Cyclone V, GX/C4", "cv_gx_c4" },
157*4882a593Smuzhiyun 	{ 0x2b02, "Cyclone V, GX/C5 or GT/D5", "cv_gx_c5" },
158*4882a593Smuzhiyun 	{ 0x2b03, "Cyclone V, GX/C7 or GT/D7", "cv_gx_c7" },
159*4882a593Smuzhiyun 	{ 0x2b04, "Cyclone V, GX/C9 or GT/D9", "cv_gx_c9" },
160*4882a593Smuzhiyun 	/* Cyclone V SE/SX/ST */
161*4882a593Smuzhiyun 	{ 0x2d11, "Cyclone V, SE/A2 or SX/C2", "cv_se_a2" },
162*4882a593Smuzhiyun 	{ 0x2d01, "Cyclone V, SE/A4 or SX/C4", "cv_se_a4" },
163*4882a593Smuzhiyun 	{ 0x2d12, "Cyclone V, SE/A5 or SX/C5 or ST/D5", "cv_se_a5" },
164*4882a593Smuzhiyun 	{ 0x2d02, "Cyclone V, SE/A6 or SX/C6 or ST/D6", "cv_se_a6" },
165*4882a593Smuzhiyun 	/* Arria V */
166*4882a593Smuzhiyun 	{ 0x2d03, "Arria V, D5", "av_d5" },
167*4882a593Smuzhiyun };
168*4882a593Smuzhiyun 
socfpga_fpga_id(const bool print_id)169*4882a593Smuzhiyun static int socfpga_fpga_id(const bool print_id)
170*4882a593Smuzhiyun {
171*4882a593Smuzhiyun 	const u32 altera_mi = 0x6e;
172*4882a593Smuzhiyun 	const u32 id = scan_mgr_get_fpga_id();
173*4882a593Smuzhiyun 
174*4882a593Smuzhiyun 	const u32 lsb = id & 0x00000001;
175*4882a593Smuzhiyun 	const u32 mi = (id >> 1) & 0x000007ff;
176*4882a593Smuzhiyun 	const u32 pn = (id >> 12) & 0x0000ffff;
177*4882a593Smuzhiyun 	const u32 version = (id >> 28) & 0x0000000f;
178*4882a593Smuzhiyun 	int i;
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun 	if ((mi != altera_mi) || (lsb != 1)) {
181*4882a593Smuzhiyun 		printf("FPGA:  Not Altera chip ID\n");
182*4882a593Smuzhiyun 		return -EINVAL;
183*4882a593Smuzhiyun 	}
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun 	for (i = 0; i < ARRAY_SIZE(socfpga_fpga_model); i++)
186*4882a593Smuzhiyun 		if (pn == socfpga_fpga_model[i].pn)
187*4882a593Smuzhiyun 			break;
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun 	if (i == ARRAY_SIZE(socfpga_fpga_model)) {
190*4882a593Smuzhiyun 		printf("FPGA:  Unknown Altera chip, ID 0x%08x\n", id);
191*4882a593Smuzhiyun 		return -EINVAL;
192*4882a593Smuzhiyun 	}
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun 	if (print_id)
195*4882a593Smuzhiyun 		printf("FPGA:  Altera %s, version 0x%01x\n",
196*4882a593Smuzhiyun 		       socfpga_fpga_model[i].name, version);
197*4882a593Smuzhiyun 	return i;
198*4882a593Smuzhiyun }
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun /*
201*4882a593Smuzhiyun  * Print CPU information
202*4882a593Smuzhiyun  */
203*4882a593Smuzhiyun #if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo(void)204*4882a593Smuzhiyun int print_cpuinfo(void)
205*4882a593Smuzhiyun {
206*4882a593Smuzhiyun 	const u32 bsel =
207*4882a593Smuzhiyun 		SYSMGR_GET_BOOTINFO_BSEL(readl(&sysmgr_regs->bootinfo));
208*4882a593Smuzhiyun 
209*4882a593Smuzhiyun 	puts("CPU:   Altera SoCFPGA Platform\n");
210*4882a593Smuzhiyun 	socfpga_fpga_id(1);
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun 	printf("BOOT:  %s\n", bsel_str[bsel].name);
213*4882a593Smuzhiyun 	return 0;
214*4882a593Smuzhiyun }
215*4882a593Smuzhiyun #endif
216*4882a593Smuzhiyun 
217*4882a593Smuzhiyun #ifdef CONFIG_ARCH_MISC_INIT
arch_misc_init(void)218*4882a593Smuzhiyun int arch_misc_init(void)
219*4882a593Smuzhiyun {
220*4882a593Smuzhiyun 	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
221*4882a593Smuzhiyun 	const int fpga_id = socfpga_fpga_id(0);
222*4882a593Smuzhiyun 	env_set("bootmode", bsel_str[bsel].mode);
223*4882a593Smuzhiyun 	if (fpga_id >= 0)
224*4882a593Smuzhiyun 		env_set("fpgatype", socfpga_fpga_model[fpga_id].var);
225*4882a593Smuzhiyun 	return socfpga_eth_reset();
226*4882a593Smuzhiyun }
227*4882a593Smuzhiyun #endif
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun /*
230*4882a593Smuzhiyun  * Convert all NIC-301 AMBA slaves from secure to non-secure
231*4882a593Smuzhiyun  */
socfpga_nic301_slave_ns(void)232*4882a593Smuzhiyun static void socfpga_nic301_slave_ns(void)
233*4882a593Smuzhiyun {
234*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->lwhps2fpgaregs);
235*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->hps2fpgaregs);
236*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->acp);
237*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->rom);
238*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->ocram);
239*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->sdrdata);
240*4882a593Smuzhiyun }
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun static u32 iswgrp_handoff[8];
243*4882a593Smuzhiyun 
arch_early_init_r(void)244*4882a593Smuzhiyun int arch_early_init_r(void)
245*4882a593Smuzhiyun {
246*4882a593Smuzhiyun 	int i;
247*4882a593Smuzhiyun 
248*4882a593Smuzhiyun 	/*
249*4882a593Smuzhiyun 	 * Write magic value into magic register to unlock support for
250*4882a593Smuzhiyun 	 * issuing warm reset. The ancient kernel code expects this
251*4882a593Smuzhiyun 	 * value to be written into the register by the bootloader, so
252*4882a593Smuzhiyun 	 * to support that old code, we write it here instead of in the
253*4882a593Smuzhiyun 	 * reset_cpu() function just before resetting the CPU.
254*4882a593Smuzhiyun 	 */
255*4882a593Smuzhiyun 	writel(0xae9efebc, &sysmgr_regs->romcodegrp_warmramgrp_enable);
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun 	for (i = 0; i < 8; i++)	/* Cache initial SW setting regs */
258*4882a593Smuzhiyun 		iswgrp_handoff[i] = readl(&sysmgr_regs->iswgrp_handoff[i]);
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun 	socfpga_bridges_reset(1);
261*4882a593Smuzhiyun 
262*4882a593Smuzhiyun 	socfpga_nic301_slave_ns();
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun 	/*
265*4882a593Smuzhiyun 	 * Private components security:
266*4882a593Smuzhiyun 	 * U-Boot : configure private timer, global timer and cpu component
267*4882a593Smuzhiyun 	 * access as non secure for kernel stage (as required by Linux)
268*4882a593Smuzhiyun 	 */
269*4882a593Smuzhiyun 	setbits_le32(&scu_regs->sacr, 0xfff);
270*4882a593Smuzhiyun 
271*4882a593Smuzhiyun 	/* Configure the L2 controller to make SDRAM start at 0 */
272*4882a593Smuzhiyun #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
273*4882a593Smuzhiyun 	writel(0x2, &nic301_regs->remap);
274*4882a593Smuzhiyun #else
275*4882a593Smuzhiyun 	writel(0x1, &nic301_regs->remap);	/* remap.mpuzero */
276*4882a593Smuzhiyun 	writel(0x1, &pl310->pl310_addr_filter_start);
277*4882a593Smuzhiyun #endif
278*4882a593Smuzhiyun 
279*4882a593Smuzhiyun 	/* Add device descriptor to FPGA device table */
280*4882a593Smuzhiyun 	socfpga_fpga_add();
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun #ifdef CONFIG_DESIGNWARE_SPI
283*4882a593Smuzhiyun 	/* Get Designware SPI controller out of reset */
284*4882a593Smuzhiyun 	socfpga_per_reset(SOCFPGA_RESET(SPIM0), 0);
285*4882a593Smuzhiyun 	socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);
286*4882a593Smuzhiyun #endif
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun #ifdef CONFIG_NAND_DENALI
289*4882a593Smuzhiyun 	socfpga_per_reset(SOCFPGA_RESET(NAND), 0);
290*4882a593Smuzhiyun #endif
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun 	return 0;
293*4882a593Smuzhiyun }
294*4882a593Smuzhiyun 
socfpga_sdram_apply_static_cfg(void)295*4882a593Smuzhiyun static void socfpga_sdram_apply_static_cfg(void)
296*4882a593Smuzhiyun {
297*4882a593Smuzhiyun 	const u32 applymask = 0x8;
298*4882a593Smuzhiyun 	u32 val = readl(&sdr_ctrl->static_cfg) | applymask;
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun 	/*
301*4882a593Smuzhiyun 	 * SDRAM staticcfg register specific:
302*4882a593Smuzhiyun 	 * When applying the register setting, the CPU must not access
303*4882a593Smuzhiyun 	 * SDRAM. Luckily for us, we can abuse i-cache here to help us
304*4882a593Smuzhiyun 	 * circumvent the SDRAM access issue. The idea is to make sure
305*4882a593Smuzhiyun 	 * that the code is in one full i-cache line by branching past
306*4882a593Smuzhiyun 	 * it and back. Once it is in the i-cache, we execute the core
307*4882a593Smuzhiyun 	 * of the code and apply the register settings.
308*4882a593Smuzhiyun 	 *
309*4882a593Smuzhiyun 	 * The code below uses 7 instructions, while the Cortex-A9 has
310*4882a593Smuzhiyun 	 * 32-byte cachelines, thus the limit is 8 instructions total.
311*4882a593Smuzhiyun 	 */
312*4882a593Smuzhiyun 	asm volatile(
313*4882a593Smuzhiyun 		".align	5			\n"
314*4882a593Smuzhiyun 		"	b	2f		\n"
315*4882a593Smuzhiyun 		"1:	str	%0,	[%1]	\n"
316*4882a593Smuzhiyun 		"	dsb			\n"
317*4882a593Smuzhiyun 		"	isb			\n"
318*4882a593Smuzhiyun 		"	b	3f		\n"
319*4882a593Smuzhiyun 		"2:	b	1b		\n"
320*4882a593Smuzhiyun 		"3:	nop			\n"
321*4882a593Smuzhiyun 	: : "r"(val), "r"(&sdr_ctrl->static_cfg) : "memory", "cc");
322*4882a593Smuzhiyun }
323*4882a593Smuzhiyun 
do_bridge(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])324*4882a593Smuzhiyun int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun 	if (argc != 2)
327*4882a593Smuzhiyun 		return CMD_RET_USAGE;
328*4882a593Smuzhiyun 
329*4882a593Smuzhiyun 	argv++;
330*4882a593Smuzhiyun 
331*4882a593Smuzhiyun 	switch (*argv[0]) {
332*4882a593Smuzhiyun 	case 'e':	/* Enable */
333*4882a593Smuzhiyun 		writel(iswgrp_handoff[2], &sysmgr_regs->fpgaintfgrp_module);
334*4882a593Smuzhiyun 		socfpga_sdram_apply_static_cfg();
335*4882a593Smuzhiyun 		writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst);
336*4882a593Smuzhiyun 		writel(iswgrp_handoff[0], &reset_manager_base->brg_mod_reset);
337*4882a593Smuzhiyun 		writel(iswgrp_handoff[1], &nic301_regs->remap);
338*4882a593Smuzhiyun 		break;
339*4882a593Smuzhiyun 	case 'd':	/* Disable */
340*4882a593Smuzhiyun 		writel(0, &sysmgr_regs->fpgaintfgrp_module);
341*4882a593Smuzhiyun 		writel(0, &sdr_ctrl->fpgaport_rst);
342*4882a593Smuzhiyun 		socfpga_sdram_apply_static_cfg();
343*4882a593Smuzhiyun 		writel(0, &reset_manager_base->brg_mod_reset);
344*4882a593Smuzhiyun 		writel(1, &nic301_regs->remap);
345*4882a593Smuzhiyun 		break;
346*4882a593Smuzhiyun 	default:
347*4882a593Smuzhiyun 		return CMD_RET_USAGE;
348*4882a593Smuzhiyun 	}
349*4882a593Smuzhiyun 
350*4882a593Smuzhiyun 	return 0;
351*4882a593Smuzhiyun }
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun U_BOOT_CMD(
354*4882a593Smuzhiyun 	bridge, 2, 1, do_bridge,
355*4882a593Smuzhiyun 	"SoCFPGA HPS FPGA bridge control",
356*4882a593Smuzhiyun 	"enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
357*4882a593Smuzhiyun 	"bridge disable - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
358*4882a593Smuzhiyun 	""
359*4882a593Smuzhiyun );
360