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