2 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/system.h>
13 #include <asm/arch/cpu.h>
14 #include <asm/arch/soc.h>
15 #include <asm/armv8/mmu.h>
17 DECLARE_GLOBAL_DATA_PTR;
20 * Not all memory is mapped in the MMU. So we need to restrict the
21 * memory size so that U-Boot does not try to access it. Also, the
22 * internal registers are located at 0xf000.0000 - 0xffff.ffff.
23 * Currently only 2GiB are mapped for system memory. This is what
24 * we pass to the U-Boot subsystem here.
26 #define USABLE_RAM_SIZE 0x80000000
28 ulong board_get_usable_ram_top(ulong total_size)
30 if (gd->ram_size > USABLE_RAM_SIZE)
31 return USABLE_RAM_SIZE;
37 * On ARMv8, MBus is not configured in U-Boot. To enable compilation
38 * of the already implemented drivers, lets add a dummy version of
39 * this function so that linking does not fail.
41 const struct mbus_dram_target_info *mvebu_mbus_dram_info(void)
46 /* DRAM init code ... */
48 static const void *get_memory_reg_prop(const void *fdt, int *lenp)
52 offset = fdt_path_offset(fdt, "/memory");
56 return fdt_getprop(fdt, offset, "reg", lenp);
61 const void *fdt = gd->fdt_blob;
65 ac = fdt_address_cells(fdt, 0);
66 sc = fdt_size_cells(fdt, 0);
67 if (ac < 0 || sc < 1 || sc > 2) {
68 printf("invalid address/size cells\n");
72 val = get_memory_reg_prop(fdt, &len);
73 if (len / sizeof(*val) < ac + sc)
78 gd->ram_size = fdtdec_get_number(val, sc);
80 debug("DRAM size = %08lx\n", (unsigned long)gd->ram_size);
85 int dram_init_banksize(void)
87 const void *fdt = gd->fdt_blob;
89 int ac, sc, cells, len, i;
91 val = get_memory_reg_prop(fdt, &len);
95 ac = fdt_address_cells(fdt, 0);
96 sc = fdt_size_cells(fdt, 0);
97 if (ac < 1 || ac > 2 || sc < 1 || sc > 2) {
98 printf("invalid address/size cells\n");
106 for (i = 0; i < CONFIG_NR_DRAM_BANKS && len >= cells;
108 gd->bd->bi_dram[i].start = fdtdec_get_number(val, ac);
110 gd->bd->bi_dram[i].size = fdtdec_get_number(val, sc);
113 debug("DRAM bank %d: start = %08lx, size = %08lx\n",
114 i, (unsigned long)gd->bd->bi_dram[i].start,
115 (unsigned long)gd->bd->bi_dram[i].size);
121 int arch_cpu_init(void)
123 /* Nothing to do (yet) */
127 int arch_early_init_r(void)
134 * Loop over all MISC uclass drivers to call the comphy code
135 * and init all CP110 devices enabled in the DT
139 /* Call the comphy code via the MISC uclass driver */
140 ret = uclass_get_device(UCLASS_MISC, i++, &dev);
142 /* We're done, once no further CP110 device is found */
147 /* Cause the SATA device to do its early init */
148 uclass_first_device(UCLASS_AHCI, &dev);