2 * Copyright (C) 2012 Altera Corporation <www.altera.com>
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/arch/reset_manager.h>
13 #include <asm/arch/system_manager.h>
14 #include <asm/arch/dwmmc.h>
15 #include <asm/arch/nic301.h>
16 #include <asm/pl310.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 static struct pl310_regs *const pl310 =
21 (struct pl310_regs *)CONFIG_SYS_PL310_BASE;
22 static struct socfpga_system_manager *sysmgr_regs =
23 (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
24 static struct nic301_registers *nic301_regs =
25 (struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
29 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
34 * DesignWare Ethernet initialization
36 #ifdef CONFIG_DESIGNWARE_ETH
37 int cpu_eth_init(bd_t *bis)
39 #if CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS
40 const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB;
41 #elif CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS
42 const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB;
44 #error "Incorrect CONFIG_EMAC_BASE value!"
47 /* Initialize EMAC. This needs to be done at least once per boot. */
50 * Putting the EMAC controller to reset when configuring the PHY
51 * interface select at System Manager
53 socfpga_emac_reset(1);
55 /* Clearing emac0 PHY interface select to 0 */
56 clrbits_le32(&sysmgr_regs->emacgrp_ctrl,
57 SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift);
59 /* configure to PHY interface select choosed */
60 setbits_le32(&sysmgr_regs->emacgrp_ctrl,
61 SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII << physhift);
63 /* Release the EMAC controller from reset */
64 socfpga_emac_reset(0);
66 /* initialize and register the emac */
67 return designware_initialize(CONFIG_EMAC_BASE,
68 CONFIG_PHY_INTERFACE_MODE);
74 * Initializes MMC controllers.
75 * to override, implement board_mmc_init()
77 int cpu_mmc_init(bd_t *bis)
79 return socfpga_dwmmc_init(SOCFPGA_SDMMC_ADDRESS,
80 CONFIG_HPS_SDMMC_BUSWIDTH, 0);
84 #if defined(CONFIG_DISPLAY_CPUINFO)
86 * Print CPU information
88 int print_cpuinfo(void)
90 puts("CPU: Altera SoCFPGA Platform\n");
95 #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \
96 defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE)
97 int overwrite_console(void)
105 * FPGA programming support for SoC FPGA Cyclone V
107 static Altera_desc altera_fpga[] = {
112 fast_passive_parallel,
113 /* No limitation as additional data will be ignored */
115 /* No device function table */
117 /* Base interface address specified in driver */
119 /* No cookie implementation */
124 /* add device descriptor to FPGA device table */
125 static void socfpga_fpga_add(void)
129 for (i = 0; i < ARRAY_SIZE(altera_fpga); i++)
130 fpga_add(fpga_altera, &altera_fpga[i]);
133 static inline void socfpga_fpga_add(void) {}
136 int arch_cpu_init(void)
139 * If the HW watchdog is NOT enabled, make sure it is not running,
140 * for example because it was enabled in the preloader. This might
141 * trigger a watchdog-triggered reboot of Linux kernel later.
143 #ifndef CONFIG_HW_WATCHDOG
144 socfpga_watchdog_reset();
149 int misc_init_r(void)
151 /* Configure the L2 controller to make SDRAM start at 0 */
152 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
153 writel(0x2, &nic301_regs->remap);
155 writel(0x1, &nic301_regs->remap); /* remap.mpuzero */
156 writel(0x1, &pl310->pl310_addr_filter_start);
159 /* Add device descriptor to FPGA device table */