Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Stefan Roese <sr@denx.de> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <fdtdec.h> |
| 10 | #include <libfdt.h> |
Konstantin Porotchkin | f4f194e | 2017-04-05 17:42:33 +0300 | [diff] [blame] | 11 | #include <pci.h> |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <asm/system.h> |
| 14 | #include <asm/arch/cpu.h> |
| 15 | #include <asm/arch/soc.h> |
| 16 | #include <asm/armv8/mmu.h> |
| 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | /* |
Stefan Roese | 059f75d | 2016-11-11 08:18:44 +0100 | [diff] [blame] | 21 | * Not all memory is mapped in the MMU. So we need to restrict the |
| 22 | * memory size so that U-Boot does not try to access it. Also, the |
| 23 | * internal registers are located at 0xf000.0000 - 0xffff.ffff. |
| 24 | * Currently only 2GiB are mapped for system memory. This is what |
| 25 | * we pass to the U-Boot subsystem here. |
| 26 | */ |
| 27 | #define USABLE_RAM_SIZE 0x80000000 |
| 28 | |
| 29 | ulong board_get_usable_ram_top(ulong total_size) |
| 30 | { |
| 31 | if (gd->ram_size > USABLE_RAM_SIZE) |
| 32 | return USABLE_RAM_SIZE; |
| 33 | |
| 34 | return gd->ram_size; |
| 35 | } |
| 36 | |
| 37 | /* |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 38 | * On ARMv8, MBus is not configured in U-Boot. To enable compilation |
| 39 | * of the already implemented drivers, lets add a dummy version of |
| 40 | * this function so that linking does not fail. |
| 41 | */ |
| 42 | const struct mbus_dram_target_info *mvebu_mbus_dram_info(void) |
| 43 | { |
| 44 | return NULL; |
| 45 | } |
| 46 | |
| 47 | /* DRAM init code ... */ |
| 48 | |
Stefan Roese | 780f80c | 2017-05-08 08:31:30 +0200 | [diff] [blame] | 49 | int dram_init_banksize(void) |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 50 | { |
Stefan Roese | 780f80c | 2017-05-08 08:31:30 +0200 | [diff] [blame] | 51 | fdtdec_setup_memory_banksize(); |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
Stefan Roese | 780f80c | 2017-05-08 08:31:30 +0200 | [diff] [blame] | 56 | int dram_init(void) |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 57 | { |
Stefan Roese | 780f80c | 2017-05-08 08:31:30 +0200 | [diff] [blame] | 58 | if (fdtdec_setup_memory_size() != 0) |
| 59 | return -EINVAL; |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 60 | |
| 61 | return 0; |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | int arch_cpu_init(void) |
| 65 | { |
| 66 | /* Nothing to do (yet) */ |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | int arch_early_init_r(void) |
| 71 | { |
| 72 | struct udevice *dev; |
| 73 | int ret; |
Stefan Roese | d7dd358 | 2016-10-25 18:12:40 +0200 | [diff] [blame] | 74 | int i; |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 75 | |
Stefan Roese | d7dd358 | 2016-10-25 18:12:40 +0200 | [diff] [blame] | 76 | /* |
| 77 | * Loop over all MISC uclass drivers to call the comphy code |
| 78 | * and init all CP110 devices enabled in the DT |
| 79 | */ |
| 80 | i = 0; |
| 81 | while (1) { |
| 82 | /* Call the comphy code via the MISC uclass driver */ |
| 83 | ret = uclass_get_device(UCLASS_MISC, i++, &dev); |
| 84 | |
| 85 | /* We're done, once no further CP110 device is found */ |
| 86 | if (ret) |
| 87 | break; |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /* Cause the SATA device to do its early init */ |
| 91 | uclass_first_device(UCLASS_AHCI, &dev); |
| 92 | |
Konstantin Porotchkin | f4f194e | 2017-04-05 17:42:33 +0300 | [diff] [blame] | 93 | #ifdef CONFIG_DM_PCI |
| 94 | /* Trigger PCIe devices detection */ |
| 95 | pci_init(); |
| 96 | #endif |
| 97 | |
Stefan Roese | 21b29fc | 2016-05-25 08:13:45 +0200 | [diff] [blame] | 98 | return 0; |
| 99 | } |