blob: fc10ae50cf8a0e428c43babd2c2bb7fb37da22b9 [file] [log] [blame]
Sughosh Ganuad3b6e92024-08-26 17:29:29 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2024 Linaro Ltd.
4 */
5
6#include <image.h>
7#include <init.h>
8#include <lmb.h>
9
10#include <asm/mp.h>
11#include <dm/device.h>
12#include <dm/uclass.h>
13
14#ifndef CFG_SYS_LINUX_LOWMEM_MAX_SIZE
15#define CFG_SYS_LINUX_LOWMEM_MAX_SIZE (768 * 1024 * 1024)
16#endif
17
18int arch_misc_init(void)
19{
20 if (CONFIG_IS_ENABLED(CMD_BOOTM)) {
21 phys_size_t bootm_size;
22 ulong size, bootmap_base;
23
24 bootmap_base = env_get_bootm_low();
25 bootm_size = env_get_bootm_size();
26
27#ifdef DEBUG
28 if (((u64)bootmap_base + bootm_size) >
29 (CFG_SYS_SDRAM_BASE + (u64)gd->ram_size))
30 puts("WARNING: bootm_low + bootm_size exceed total memory\n");
31 if ((bootmap_base + bootm_size) > get_effective_memsize())
32 puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
33#endif
34
35 size = min(bootm_size, get_effective_memsize());
36 size = min(size, (ulong)CFG_SYS_LINUX_LOWMEM_MAX_SIZE);
37
38 if (size < bootm_size) {
Sughosh Ganu9b0765a2025-06-17 16:13:40 +053039 phys_addr_t base = bootmap_base + size;
Sughosh Ganuad3b6e92024-08-26 17:29:29 +053040
41 printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n",
42 size, (unsigned long long)bootm_size);
Sughosh Ganu9b0765a2025-06-17 16:13:40 +053043 lmb_alloc_mem(LMB_MEM_ALLOC_ADDR, 0, &base,
44 bootm_size - size, LMB_NONE);
Sughosh Ganuad3b6e92024-08-26 17:29:29 +053045 }
46
47#ifdef CONFIG_MP
48 cpu_mp_lmb_reserve();
49#endif
50 }
51
52 if (IS_ENABLED(CONFIG_FSL_CAAM)) {
53 struct udevice *dev;
54 int ret;
55
56 ret = uclass_get_device_by_driver(UCLASS_MISC,
57 DM_DRIVER_GET(caam_jr), &dev);
58 if (ret)
59 printf("Failed to initialize caam_jr: %d\n", ret);
60 }
61
62 return 0;
63}