blob: c20e87cdbef3b69ab9384c85d5fa43c64d218049 [file] [log] [blame]
Ley Foon Tan4765ddb2018-05-24 00:17:28 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
4 *
5 */
6
Simon Glassdb41d652019-12-28 10:45:07 -07007#include <hang.h>
Simon Glass691d7192020-05-10 11:40:02 -06008#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -06009#include <log.h>
Simon Glass401d1c42020-10-30 21:38:53 -060010#include <asm/global_data.h>
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080011#include <asm/io.h>
12#include <asm/u-boot.h>
13#include <asm/utils.h>
14#include <common.h>
Ley Foon Tanaa529662018-07-12 21:44:24 +080015#include <debug_uart.h>
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080016#include <image.h>
17#include <spl.h>
18#include <asm/arch/clock_manager.h>
Ley Foon Tan8b7962a2019-11-27 15:55:15 +080019#include <asm/arch/firewall.h>
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080020#include <asm/arch/mailbox_s10.h>
Ley Foon Tanbb25aca2019-11-08 10:38:19 +080021#include <asm/arch/misc.h>
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080022#include <asm/arch/reset_manager.h>
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080023#include <asm/arch/system_manager.h>
24#include <watchdog.h>
Ley Foon Tan6bf238a2019-05-06 09:56:01 +080025#include <dm/uclass.h>
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080026
27DECLARE_GLOBAL_DATA_PTR;
28
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080029void board_init_f(ulong dummy)
30{
31 const struct cm_config *cm_default_cfg = cm_get_default_config();
32 int ret;
33
Ley Foon Tanbb25aca2019-11-08 10:38:19 +080034 ret = spl_early_init();
35 if (ret)
36 hang();
37
38 socfpga_get_managers_addr();
39
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080040 /* Ensure watchdog is paused when debugging is happening */
Ley Foon Tandb5741f2019-11-08 10:38:20 +080041 writel(SYSMGR_WDDBG_PAUSE_ALL_CPU,
Ley Foon Tan2fd1dc52019-11-27 15:55:18 +080042 socfpga_get_sysmgr_addr() + SYSMGR_SOC64_WDDBG);
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080043
Chee Hong Ang2473e132020-08-06 12:15:33 +080044#ifdef CONFIG_HW_WATCHDOG
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080045 /* Enable watchdog before initializing the HW */
46 socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
47 socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
48 hw_watchdog_init();
49#endif
50
51 /* ensure all processors are not released prior Linux boot */
52 writeq(0, CPU_RELEASE_ADDR);
53
54 socfpga_per_reset(SOCFPGA_RESET(OSC1TIMER0), 0);
55 timer_init();
56
Ley Foon Tandb3b5e92018-08-17 16:22:02 +080057 sysmgr_pinmux_init();
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080058
59 /* configuring the HPS clocks */
60 cm_basic_init(cm_default_cfg);
61
62#ifdef CONFIG_DEBUG_UART
63 socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
64 debug_uart_init();
65#endif
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080066
67 preloader_console_init();
Chee Hong Angb3e2d9f2020-08-05 21:15:57 +080068 print_reset_info();
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080069 cm_print_clock_quick_summary();
70
Ley Foon Tan8b7962a2019-11-27 15:55:15 +080071 firewall_setup();
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080072
73 /* disable ocram security at CCU for non secure access */
74 clrbits_le32(CCU_REG_ADDR(CCU_CPU0_MPRT_ADMASK_MEM_RAM0),
75 CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
76 clrbits_le32(CCU_REG_ADDR(CCU_IOM_MPRT_ADMASK_MEM_RAM0),
77 CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
78
Ley Foon Tan6bf238a2019-05-06 09:56:01 +080079#if CONFIG_IS_ENABLED(ALTERA_SDRAM)
80 struct udevice *dev;
81
82 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
83 if (ret) {
84 debug("DRAM init failed: %d\n", ret);
85 hang();
86 }
87#endif
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080088
Ley Foon Tan4765ddb2018-05-24 00:17:28 +080089 mbox_init();
90
91#ifdef CONFIG_CADENCE_QSPI
92 mbox_qspi_open();
93#endif
94}