Merge tag 'dm-pull-8jan20' of git://git.denx.de/u-boot-dm
[oweals/u-boot.git] / arch / arm / mach-socfpga / spl_agilex.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2019 Intel Corporation <www.intel.com>
4  *
5  */
6
7 #include <asm/io.h>
8 #include <asm/u-boot.h>
9 #include <asm/utils.h>
10 #include <common.h>
11 #include <image.h>
12 #include <spl.h>
13 #include <asm/arch/clock_manager.h>
14 #include <asm/arch/firewall.h>
15 #include <asm/arch/mailbox_s10.h>
16 #include <asm/arch/misc.h>
17 #include <asm/arch/reset_manager.h>
18 #include <asm/arch/system_manager.h>
19 #include <watchdog.h>
20 #include <dm/uclass.h>
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 u32 spl_boot_device(void)
25 {
26         return BOOT_DEVICE_MMC1;
27 }
28
29 #ifdef CONFIG_SPL_MMC_SUPPORT
30 u32 spl_boot_mode(const u32 boot_device)
31 {
32 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
33         return MMCSD_MODE_FS;
34 #else
35         return MMCSD_MODE_RAW;
36 #endif
37 }
38 #endif
39
40 void board_init_f(ulong dummy)
41 {
42         int ret;
43         struct udevice *dev;
44
45         ret = spl_early_init();
46         if (ret)
47                 hang();
48
49         socfpga_get_managers_addr();
50
51 #ifdef CONFIG_HW_WATCHDOG
52         /* Ensure watchdog is paused when debugging is happening */
53         writel(SYSMGR_WDDBG_PAUSE_ALL_CPU,
54                socfpga_get_sysmgr_addr() + SYSMGR_SOC64_WDDBG);
55
56         /* Enable watchdog before initializing the HW */
57         socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
58         socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
59         hw_watchdog_init();
60 #endif
61
62         /* ensure all processors are not released prior Linux boot */
63         writeq(0, CPU_RELEASE_ADDR);
64
65         timer_init();
66
67         sysmgr_pinmux_init();
68
69         ret = uclass_get_device(UCLASS_CLK, 0, &dev);
70         if (ret) {
71                 debug("Clock init failed: %d\n", ret);
72                 hang();
73         }
74
75         preloader_console_init();
76         cm_print_clock_quick_summary();
77
78         firewall_setup();
79         ret = uclass_get_device(UCLASS_CACHE, 0, &dev);
80         if (ret) {
81                 debug("CCU init failed: %d\n", ret);
82                 hang();
83         }
84
85 #if CONFIG_IS_ENABLED(ALTERA_SDRAM)
86         ret = uclass_get_device(UCLASS_RAM, 0, &dev);
87         if (ret) {
88                 debug("DRAM init failed: %d\n", ret);
89                 hang();
90         }
91 #endif
92
93         mbox_init();
94
95 #ifdef CONFIG_CADENCE_QSPI
96         mbox_qspi_open();
97 #endif
98 }