1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
14 #include <asm/arch/reset_manager.h>
15 #include <asm/arch/system_manager.h>
16 #include <asm/arch/misc.h>
17 #include <asm/pl310.h>
18 #include <linux/libfdt.h>
20 #include <dt-bindings/reset/altr,rst-mgr-s10.h>
22 DECLARE_GLOBAL_DATA_PTR;
24 static struct socfpga_system_manager *sysmgr_regs =
25 (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
28 * DesignWare Ethernet initialization
30 #ifdef CONFIG_ETH_DESIGNWARE
32 static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode)
39 if (!strcmp(phymode, "mii") || !strcmp(phymode, "gmii") ||
40 !strcmp(phymode, "sgmii"))
41 modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
42 else if (!strcmp(phymode, "rgmii"))
43 modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
44 else if (!strcmp(phymode, "rmii"))
45 modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII;
49 clrsetbits_le32(&sysmgr_regs->emac0 + gmac_index,
50 SYSMGR_EMACGRP_CTRL_PHYSEL_MASK,
56 static int socfpga_set_phymode(void)
58 const void *fdt = gd->fdt_blob;
59 struct fdtdec_phandle_args args;
62 int nodes[3]; /* Max. 3 GMACs */
66 count = fdtdec_find_aliases_for_id(fdt, "ethernet",
67 COMPAT_ALTERA_SOCFPGA_DWMAC,
68 nodes, ARRAY_SIZE(nodes));
69 for (i = 0; i < count; i++) {
74 ret = fdtdec_parse_phandle_with_args(fdt, node, "resets",
77 if (ret || args.args_count != 1) {
78 debug("GMAC%i: Failed to parse DT 'resets'!\n", i);
82 gmac_index = args.args[0] - EMAC0_RESET;
84 phy_mode = fdt_getprop(fdt, node, "phy-mode", NULL);
85 ret = socfpga_phymode_setup(gmac_index, phy_mode);
87 debug("GMAC%i: Failed to parse DT 'phy-mode'!\n", i);
95 static int socfpga_set_phymode(void)
102 * Print CPU information
104 #if defined(CONFIG_DISPLAY_CPUINFO)
105 int print_cpuinfo(void)
107 puts("CPU: Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)\n");
113 #ifdef CONFIG_ARCH_MISC_INIT
114 int arch_misc_init(void)
116 char qspi_string[13];
118 sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
119 env_set("qspi_clock", qspi_string);
121 socfpga_set_phymode();
126 int arch_early_init_r(void)
131 void do_bridge_reset(int enable)
133 socfpga_bridges_reset(enable);