blob: 68e0310f5af53dcdf9f053b7d75dd4afe3ce148a [file] [log] [blame]
Tom Rinidec7ea02024-05-20 13:35:03 -06001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * (C) Copyright 2022 - Analog Devices, Inc.
4 *
5 * Written and/or maintained by Timesys Corporation
6 *
7 * Contact: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
8 * Contact: Greg Malysa <greg.malysa@timesys.com>
9 */
10
11#include <spl.h>
12#include <asm/arch-adi/sc5xx/sc5xx.h>
13#include <asm/arch-adi/sc5xx/spl.h>
14#include "init/clkinit.h"
15#include "init/dmcinit.h"
16
17static bool adi_start_uboot_proper;
18
19static int adi_sf_default_bus = CONFIG_SF_DEFAULT_BUS;
20static int adi_sf_default_cs = CONFIG_SF_DEFAULT_CS;
21static int adi_sf_default_speed = CONFIG_SF_DEFAULT_SPEED;
22
23u32 bmode;
24
25int spl_start_uboot(void)
26{
27 return adi_start_uboot_proper;
28}
29
30unsigned int spl_spi_get_default_speed(void)
31{
32 return adi_sf_default_speed;
33}
34
35unsigned int spl_spi_get_default_bus(void)
36{
37 return adi_sf_default_bus;
38}
39
40unsigned int spl_spi_get_default_cs(void)
41{
42 return adi_sf_default_cs;
43}
44
45void board_boot_order(u32 *spl_boot_list)
46{
47 const char *bmodestring = sc5xx_get_boot_mode(&bmode);
48
49 printf("ADI Boot Mode: 0x%x (%s)\n", bmode, bmodestring);
50
51 /*
52 * By default everything goes back to the bootrom, where we'll read table
53 * parameters and ask for another image to be loaded
54 */
55 spl_boot_list[0] = BOOT_DEVICE_BOOTROM;
56
57 if (bmode == 0) {
58 printf("SPL execution has completed. Please load U-Boot Proper via JTAG");
59 while (1)
60 ;
61 }
62}
63
64int32_t __weak adi_rom_boot_hook(struct ADI_ROM_BOOT_CONFIG *config, int32_t cause)
65{
66 return 0;
67}
68
69int board_return_to_bootrom(struct spl_image_info *spl_image,
70 struct spl_boot_device *bootdev)
71{
72#if CONFIG_ADI_SPL_FORCE_BMODE != 0
73 // see above
74 if (bmode != 0 && bmode != 3)
75 bmode = CONFIG_ADI_SPL_FORCE_BMODE;
76#endif
77
78 if (bmode >= (ARRAY_SIZE(adi_rom_boot_args)))
79 bmode = 0;
80
81 adi_rom_boot((void *)adi_rom_boot_args[bmode].addr,
82 adi_rom_boot_args[bmode].flags,
83 0, &adi_rom_boot_hook,
84 adi_rom_boot_args[bmode].cmd);
85 return 0;
86};
87
88void board_init_f(ulong dummy)
89{
90 int ret;
91
92 clks_init();
93 DMC_Config();
94 sc5xx_soc_init();
95
96 ret = spl_early_init();
97 if (ret)
98 panic("spl_early_init() failed\n");
99
100 preloader_console_init();
101}
102