blob: edc7fb176bbc1d11b80954356fa3d1204e4104a5 [file] [log] [blame]
Giulio Benetti6986d6b2020-01-10 15:51:48 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2019
4 * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com>
5 */
6
7#include <common.h>
8#include <dm.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
Giulio Benetti6986d6b2020-01-10 15:51:48 +010011#include <ram.h>
12#include <spl.h>
13#include <asm/io.h>
14#include <asm/armv7m.h>
15
16DECLARE_GLOBAL_DATA_PTR;
17
18int dram_init(void)
19{
20#ifndef CONFIG_SUPPORT_SPL
21 int rv;
22 struct udevice *dev;
23
24 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
25 if (rv) {
26 debug("DRAM init failed: %d\n", rv);
27 return rv;
28 }
29
30#endif
31 return fdtdec_setup_mem_size_base();
32}
33
34int dram_init_banksize(void)
35{
36 return fdtdec_setup_memory_banksize();
37}
38
39#ifdef CONFIG_SPL_BUILD
40#ifdef CONFIG_SPL_OS_BOOT
41int spl_start_uboot(void)
42{
43 debug("SPL: booting kernel\n");
44 /* break into full u-boot on 'c' */
45 return serial_tstc() && serial_getc() == 'c';
46}
47#endif
48
49int spl_dram_init(void)
50{
51 struct udevice *dev;
52 int rv;
53
54 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
55 if (rv)
56 debug("DRAM init failed: %d\n", rv);
57 return rv;
58}
59
60void spl_board_init(void)
61{
62 spl_dram_init();
63 preloader_console_init();
64 arch_cpu_init(); /* to configure mpu for sdram rw permissions */
65}
66
67u32 spl_boot_device(void)
68{
69 return BOOT_DEVICE_MMC1;
70}
71#endif
72
73u32 get_board_rev(void)
74{
75 return 0;
76}
77
78int board_init(void)
79{
80 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
81
82 return 0;
83}