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