Giulio Benetti | d1203ca | 2020-02-18 20:02:55 +0100 | [diff] [blame] | 1 | // 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 Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Giulio Benetti | d1203ca | 2020-02-18 20:02:55 +0100 | [diff] [blame] | 11 | #include <ram.h> |
| 12 | #include <spl.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Giulio Benetti | d1203ca | 2020-02-18 20:02:55 +0100 | [diff] [blame] | 14 | #include <asm/io.h> |
| 15 | #include <asm/armv7m.h> |
| 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | int dram_init(void) |
| 20 | { |
| 21 | #ifndef CONFIG_SUPPORT_SPL |
| 22 | int rv; |
| 23 | struct udevice *dev; |
| 24 | |
| 25 | rv = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 26 | if (rv) { |
| 27 | debug("DRAM init failed: %d\n", rv); |
| 28 | return rv; |
| 29 | } |
| 30 | |
| 31 | #endif |
| 32 | return fdtdec_setup_mem_size_base(); |
| 33 | } |
| 34 | |
| 35 | int dram_init_banksize(void) |
| 36 | { |
| 37 | return fdtdec_setup_memory_banksize(); |
| 38 | } |
| 39 | |
| 40 | #ifdef CONFIG_SPL_BUILD |
| 41 | #ifdef CONFIG_SPL_OS_BOOT |
| 42 | int spl_start_uboot(void) |
| 43 | { |
| 44 | debug("SPL: booting kernel\n"); |
| 45 | /* break into full u-boot on 'c' */ |
| 46 | return serial_tstc() && serial_getc() == 'c'; |
| 47 | } |
| 48 | #endif |
| 49 | |
| 50 | int spl_dram_init(void) |
| 51 | { |
| 52 | struct udevice *dev; |
| 53 | int rv; |
| 54 | |
| 55 | rv = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 56 | if (rv) |
| 57 | debug("DRAM init failed: %d\n", rv); |
| 58 | return rv; |
| 59 | } |
| 60 | |
| 61 | void spl_board_init(void) |
| 62 | { |
Giulio Benetti | d1203ca | 2020-02-18 20:02:55 +0100 | [diff] [blame] | 63 | preloader_console_init(); |
Giulio Benetti | 7a24c78 | 2021-04-04 20:21:33 +0200 | [diff] [blame] | 64 | spl_dram_init(); |
Giulio Benetti | d1203ca | 2020-02-18 20:02:55 +0100 | [diff] [blame] | 65 | arch_cpu_init(); /* to configure mpu for sdram rw permissions */ |
| 66 | } |
| 67 | |
| 68 | u32 spl_boot_device(void) |
| 69 | { |
| 70 | return BOOT_DEVICE_MMC1; |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | u32 get_board_rev(void) |
| 75 | { |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | int board_init(void) |
| 80 | { |
| 81 | gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; |
| 82 | |
| 83 | return 0; |
| 84 | } |