1// 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> 9#include <init.h> 10#include <log.h> 11#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} 84