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> |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/armv7m.h> |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | int 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 | |
| 34 | int dram_init_banksize(void) |
| 35 | { |
| 36 | return fdtdec_setup_memory_banksize(); |
| 37 | } |
| 38 | |
| 39 | #ifdef CONFIG_SPL_BUILD |
| 40 | #ifdef CONFIG_SPL_OS_BOOT |
| 41 | int 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 | |
| 49 | int 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 | |
| 60 | void 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 | |
| 67 | u32 spl_boot_device(void) |
| 68 | { |
| 69 | return BOOT_DEVICE_MMC1; |
| 70 | } |
| 71 | #endif |
| 72 | |
| 73 | u32 get_board_rev(void) |
| 74 | { |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | int board_init(void) |
| 79 | { |
| 80 | gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; |
| 81 | |
| 82 | return 0; |
| 83 | } |