Sughosh Ganu | ad3b6e9 | 2024-08-26 17:29:29 +0530 | [diff] [blame] | 1 | // 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 | |
| 18 | int 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) { |
| 39 | ulong base = bootmap_base + size; |
| 40 | |
| 41 | printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n", |
| 42 | size, (unsigned long long)bootm_size); |
| 43 | lmb_reserve(base, bootm_size - size); |
| 44 | } |
| 45 | |
| 46 | #ifdef CONFIG_MP |
| 47 | cpu_mp_lmb_reserve(); |
| 48 | #endif |
| 49 | } |
| 50 | |
| 51 | if (IS_ENABLED(CONFIG_FSL_CAAM)) { |
| 52 | struct udevice *dev; |
| 53 | int ret; |
| 54 | |
| 55 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
| 56 | DM_DRIVER_GET(caam_jr), &dev); |
| 57 | if (ret) |
| 58 | printf("Failed to initialize caam_jr: %d\n", ret); |
| 59 | } |
| 60 | |
| 61 | return 0; |
| 62 | } |