]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ppc: lmb: move arch specific lmb reservations to arch_misc_init()
authorSughosh Ganu <sughosh.ganu@linaro.org>
Mon, 26 Aug 2024 11:59:29 +0000 (17:29 +0530)
committerTom Rini <trini@konsulko.com>
Tue, 3 Sep 2024 20:08:50 +0000 (14:08 -0600)
All the current function definitions of arch_lmb_reserve() are doing
the same thing -- reserve the U-Boot memory region. The powerpc(ppc)
architecture, in addition, is making some LMB reservations for the
bootm related image loading. Move these ppc specific reservations to
the arch_misc_init() function. This allows to move the U-Boot memory
region reservation to a different function, and remove
arch_lmb_reserve() in a subsequent commit.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/powerpc/cpu/mpc85xx/cpu_init.c
arch/powerpc/lib/Makefile
arch/powerpc/lib/bootm.c
arch/powerpc/lib/misc.c [new file with mode: 0644]
lib/Kconfig

index a7b805bc674b572fc9c68639f9b91bc2d7eff46c..739d14f8002d62070b05fba373557347e42f33ef 100644 (file)
@@ -940,22 +940,6 @@ int cpu_init_r(void)
        return 0;
 }
 
-#ifdef CONFIG_ARCH_MISC_INIT
-int arch_misc_init(void)
-{
-       if (IS_ENABLED(CONFIG_FSL_CAAM)) {
-               struct udevice *dev;
-               int ret;
-
-               ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(caam_jr), &dev);
-               if (ret)
-                       printf("Failed to initialize caam_jr: %d\n", ret);
-       }
-
-       return 0;
-}
-#endif
-
 void arch_preboot_os(void)
 {
        u32 msr;
index bb819dcbb6cc7bc5f6eb5fb261fcb19c7b148a4f..ecc2aba8f3c732d7d8fd5d4633fc8a426f066b4a 100644 (file)
@@ -39,6 +39,7 @@ obj-y += cache.o
 obj-y  += extable.o
 obj-y  += interrupts.o
 obj-$(CONFIG_CMD_KGDB) += kgdb.o
+obj-y  += misc.o
 obj-y  += stack.o
 obj-y  += time.o
 obj-y  += traps.o
index 752f72f873fc0f12c8fe51a835497838865210e4..8f21cdb0a5bcd222cd85eab8bc009ed43f237611 100644 (file)
@@ -12,7 +12,6 @@
 #include <cpu_func.h>
 #include <env.h>
 #include <init.h>
-#include <lmb.h>
 #include <log.h>
 #include <watchdog.h>
 #include <command.h>
@@ -41,10 +40,6 @@ static ulong get_sp (void);
 extern void ft_fixup_num_cores(void *blob);
 static void set_clocks_in_mhz (struct bd_info *kbd);
 
-#ifndef CFG_SYS_LINUX_LOWMEM_MAX_SIZE
-#define CFG_SYS_LINUX_LOWMEM_MAX_SIZE  (768*1024*1024)
-#endif
-
 static void boot_jump_linux(struct bootm_headers *images)
 {
        void    (*kernel)(struct bd_info *, ulong r4, ulong r5, ulong r6,
@@ -116,41 +111,6 @@ static void boot_jump_linux(struct bootm_headers *images)
        return;
 }
 
-void arch_lmb_reserve(void)
-{
-       phys_size_t bootm_size;
-       ulong size, bootmap_base;
-
-       bootmap_base = env_get_bootm_low();
-       bootm_size = env_get_bootm_size();
-
-#ifdef DEBUG
-       if (((u64)bootmap_base + bootm_size) >
-           (CFG_SYS_SDRAM_BASE + (u64)gd->ram_size))
-               puts("WARNING: bootm_low + bootm_size exceed total memory\n");
-       if ((bootmap_base + bootm_size) > get_effective_memsize())
-               puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
-#endif
-
-       size = min(bootm_size, get_effective_memsize());
-       size = min(size, (ulong)CFG_SYS_LINUX_LOWMEM_MAX_SIZE);
-
-       if (size < bootm_size) {
-               ulong base = bootmap_base + size;
-               printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n",
-                      size, (unsigned long long)bootm_size);
-               lmb_reserve(base, bootm_size - size);
-       }
-
-       arch_lmb_reserve_generic(get_sp(), gd->ram_top, 4096);
-
-#ifdef CONFIG_MP
-       cpu_mp_lmb_reserve();
-#endif
-
-       return;
-}
-
 static void boot_prep_linux(struct bootm_headers *images)
 {
 #ifdef CONFIG_MP
diff --git a/arch/powerpc/lib/misc.c b/arch/powerpc/lib/misc.c
new file mode 100644 (file)
index 0000000..4cd23b3
--- /dev/null
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2024 Linaro Ltd.
+ */
+
+#include <image.h>
+#include <init.h>
+#include <lmb.h>
+
+#include <asm/mp.h>
+#include <dm/device.h>
+#include <dm/uclass.h>
+
+#ifndef CFG_SYS_LINUX_LOWMEM_MAX_SIZE
+#define CFG_SYS_LINUX_LOWMEM_MAX_SIZE  (768 * 1024 * 1024)
+#endif
+
+int arch_misc_init(void)
+{
+       if (CONFIG_IS_ENABLED(CMD_BOOTM)) {
+               phys_size_t bootm_size;
+               ulong size, bootmap_base;
+
+               bootmap_base = env_get_bootm_low();
+               bootm_size = env_get_bootm_size();
+
+#ifdef DEBUG
+               if (((u64)bootmap_base + bootm_size) >
+                   (CFG_SYS_SDRAM_BASE + (u64)gd->ram_size))
+                       puts("WARNING: bootm_low + bootm_size exceed total memory\n");
+               if ((bootmap_base + bootm_size) > get_effective_memsize())
+                       puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
+#endif
+
+               size = min(bootm_size, get_effective_memsize());
+               size = min(size, (ulong)CFG_SYS_LINUX_LOWMEM_MAX_SIZE);
+
+               if (size < bootm_size) {
+                       ulong base = bootmap_base + size;
+
+                       printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n",
+                              size, (unsigned long long)bootm_size);
+                       lmb_reserve(base, bootm_size - size);
+               }
+
+#ifdef CONFIG_MP
+               cpu_mp_lmb_reserve();
+#endif
+       }
+
+       if (IS_ENABLED(CONFIG_FSL_CAAM)) {
+               struct udevice *dev;
+               int ret;
+
+               ret = uclass_get_device_by_driver(UCLASS_MISC,
+                                                 DM_DRIVER_GET(caam_jr), &dev);
+               if (ret)
+                       printf("Failed to initialize caam_jr: %d\n", ret);
+       }
+
+       return 0;
+}
index 6a9338390a1f5598a914ba5cf79beef8e82aa2f8..e352b5550a2104fb1d6d621a2d805b63cd1807de 100644 (file)
@@ -1102,6 +1102,7 @@ config LMB
        bool "Enable the logical memory blocks library (lmb)"
        default y if ARC || ARM || M68K || MICROBLAZE || MIPS || \
                     NIOS2 || PPC || RISCV || SANDBOX || SH || X86 || XTENSA
+       select ARCH_MISC_INIT if PPC
        help
          Support the library logical memory blocks. This will require
          a malloc() implementation for defining the data structures