2018-05-23 16:17:28 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2018-05-23 16:17:28 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/u-boot.h>
|
|
|
|
#include <asm/utils.h>
|
|
|
|
#include <common.h>
|
2018-07-12 13:44:24 +00:00
|
|
|
#include <debug_uart.h>
|
2018-05-23 16:17:28 +00:00
|
|
|
#include <image.h>
|
|
|
|
#include <spl.h>
|
|
|
|
#include <asm/arch/clock_manager.h>
|
2019-11-27 07:55:15 +00:00
|
|
|
#include <asm/arch/firewall.h>
|
2018-05-23 16:17:28 +00:00
|
|
|
#include <asm/arch/mailbox_s10.h>
|
2019-11-08 02:38:19 +00:00
|
|
|
#include <asm/arch/misc.h>
|
2018-05-23 16:17:28 +00:00
|
|
|
#include <asm/arch/reset_manager.h>
|
|
|
|
#include <asm/arch/system_manager.h>
|
|
|
|
#include <watchdog.h>
|
2019-05-06 01:56:01 +00:00
|
|
|
#include <dm/uclass.h>
|
2018-05-23 16:17:28 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
u32 spl_boot_device(void)
|
|
|
|
{
|
|
|
|
/* TODO: Get from SDM or handoff */
|
|
|
|
return BOOT_DEVICE_MMC1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_MMC_SUPPORT
|
2020-04-15 09:33:30 +00:00
|
|
|
u32 spl_mmc_boot_mode(const u32 boot_device)
|
2018-05-23 16:17:28 +00:00
|
|
|
{
|
2019-01-23 06:20:05 +00:00
|
|
|
#if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
|
2018-05-23 16:17:28 +00:00
|
|
|
return MMCSD_MODE_FS;
|
|
|
|
#else
|
|
|
|
return MMCSD_MODE_RAW;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void board_init_f(ulong dummy)
|
|
|
|
{
|
|
|
|
const struct cm_config *cm_default_cfg = cm_get_default_config();
|
|
|
|
int ret;
|
|
|
|
|
2019-11-08 02:38:19 +00:00
|
|
|
ret = spl_early_init();
|
|
|
|
if (ret)
|
|
|
|
hang();
|
|
|
|
|
|
|
|
socfpga_get_managers_addr();
|
|
|
|
|
2018-05-23 16:17:28 +00:00
|
|
|
#ifdef CONFIG_HW_WATCHDOG
|
|
|
|
/* Ensure watchdog is paused when debugging is happening */
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(SYSMGR_WDDBG_PAUSE_ALL_CPU,
|
2019-11-27 07:55:18 +00:00
|
|
|
socfpga_get_sysmgr_addr() + SYSMGR_SOC64_WDDBG);
|
2018-05-23 16:17:28 +00:00
|
|
|
|
|
|
|
/* Enable watchdog before initializing the HW */
|
|
|
|
socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
|
|
|
|
socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
|
|
|
|
hw_watchdog_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ensure all processors are not released prior Linux boot */
|
|
|
|
writeq(0, CPU_RELEASE_ADDR);
|
|
|
|
|
|
|
|
socfpga_per_reset(SOCFPGA_RESET(OSC1TIMER0), 0);
|
|
|
|
timer_init();
|
|
|
|
|
2018-08-17 08:22:02 +00:00
|
|
|
sysmgr_pinmux_init();
|
2018-05-23 16:17:28 +00:00
|
|
|
|
|
|
|
/* configuring the HPS clocks */
|
|
|
|
cm_basic_init(cm_default_cfg);
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_UART
|
|
|
|
socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
|
|
|
|
debug_uart_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
preloader_console_init();
|
|
|
|
cm_print_clock_quick_summary();
|
|
|
|
|
2019-11-27 07:55:15 +00:00
|
|
|
firewall_setup();
|
2018-05-23 16:17:28 +00:00
|
|
|
|
|
|
|
/* disable ocram security at CCU for non secure access */
|
|
|
|
clrbits_le32(CCU_REG_ADDR(CCU_CPU0_MPRT_ADMASK_MEM_RAM0),
|
|
|
|
CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
|
|
|
|
clrbits_le32(CCU_REG_ADDR(CCU_IOM_MPRT_ADMASK_MEM_RAM0),
|
|
|
|
CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
|
|
|
|
|
2019-05-06 01:56:01 +00:00
|
|
|
#if CONFIG_IS_ENABLED(ALTERA_SDRAM)
|
|
|
|
struct udevice *dev;
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("DRAM init failed: %d\n", ret);
|
|
|
|
hang();
|
|
|
|
}
|
|
|
|
#endif
|
2018-05-23 16:17:28 +00:00
|
|
|
|
|
|
|
mbox_init();
|
|
|
|
|
|
|
|
#ifdef CONFIG_CADENCE_QSPI
|
|
|
|
mbox_qspi_open();
|
|
|
|
#endif
|
|
|
|
}
|