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