bl33: s7: reserve fdt memory will print error message [1/1]

PD#OTT-58716

Problem:
repeat set reserve memory on lmb caused fdt relocate
print error message

Solution:
1. enlarge lmb max region number and delete repeat code
2. boot 32 bit kernel if ramdisk size too big would overlap
secure memory

Verify:
s7/s1a/s7d

Change-Id: Ibe7f18a8476dac24a73e8c96bfd47528c7432b84
Signed-off-by: Bo Lv <bo.lv@amlogic.com>
diff --git a/boot/bootm.c b/boot/bootm.c
index 3c36f41..c362461 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -143,8 +143,8 @@
 		images.os.arch = image_get_arch(os_hdr);
 #ifdef CONFIG_AMLOGIC_MODIFY
 		if (images.os.arch == IH_ARCH_ARM) {
-			env_set("initrd_high", "0A000000");
-			env_set("fdt_high", "0A000000");
+			env_set("initrd_high", "0D000000");
+			env_set("fdt_high", "0D000000");
 		}
 #endif
 		break;
diff --git a/configs/amlogic/s7_bh201_defconfig b/configs/amlogic/s7_bh201_defconfig
index f41dd6b..cf0ca00 100644
--- a/configs/amlogic/s7_bh201_defconfig
+++ b/configs/amlogic/s7_bh201_defconfig
@@ -108,4 +108,5 @@
 CONFIG_SARADC_MESON_G12A=y
 CONFIG_XBC=y
 CONFIG_SHA1=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7_bh202_defconfig b/configs/amlogic/s7_bh202_defconfig
index 6e9d01c..bfd25e8 100644
--- a/configs/amlogic/s7_bh202_defconfig
+++ b/configs/amlogic/s7_bh202_defconfig
@@ -105,4 +105,5 @@
 CONFIG_SARADC_MESON_G12A=y
 CONFIG_XBC=y
 CONFIG_SHA1=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7_bh209_defconfig b/configs/amlogic/s7_bh209_defconfig
index 11588cb..55c3f6a 100644
--- a/configs/amlogic/s7_bh209_defconfig
+++ b/configs/amlogic/s7_bh209_defconfig
@@ -105,4 +105,5 @@
 CONFIG_SARADC_MESON_G12A=y
 CONFIG_XBC=y
 CONFIG_SHA1=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7_bp202_defconfig b/configs/amlogic/s7_bp202_defconfig
index 5f9094b..dbd855c 100644
--- a/configs/amlogic/s7_bp202_defconfig
+++ b/configs/amlogic/s7_bp202_defconfig
@@ -104,4 +104,5 @@
 CONFIG_SARADC_MESON_G12A=y
 CONFIG_XBC=y
 CONFIG_SHA1=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7_t223_defconfig b/configs/amlogic/s7_t223_defconfig
index 6222cd3..b32c55b 100644
--- a/configs/amlogic/s7_t223_defconfig
+++ b/configs/amlogic/s7_t223_defconfig
@@ -99,4 +99,5 @@
 CONFIG_SARADC_MESON_G12A=y
 CONFIG_XBC=y
 CONFIG_SHA1=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7d_bm201_defconfig b/configs/amlogic/s7d_bm201_defconfig
index d0594bb..94e4ff6 100644
--- a/configs/amlogic/s7d_bm201_defconfig
+++ b/configs/amlogic/s7d_bm201_defconfig
@@ -107,4 +107,5 @@
 CONFIG_XBC=y
 CONFIG_SHA1=y
 CONFIG_ZSTD=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7d_bm202_defconfig b/configs/amlogic/s7d_bm202_defconfig
index 1c8b6c7..b0bca56 100644
--- a/configs/amlogic/s7d_bm202_defconfig
+++ b/configs/amlogic/s7d_bm202_defconfig
@@ -107,4 +107,5 @@
 CONFIG_XBC=y
 CONFIG_SHA1=y
 CONFIG_ZSTD=y
+CONFIG_LMB_MAX_REGIONS=9
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/amlogic/s7d_bm209_defconfig b/configs/amlogic/s7d_bm209_defconfig
index 45e8955..eca4947 100644
--- a/configs/amlogic/s7d_bm209_defconfig
+++ b/configs/amlogic/s7d_bm209_defconfig
@@ -119,3 +119,4 @@
 CONFIG_DM_SPI=y
 CONFIG_AML_SPI_NFC=y
 CONFIG_MTD_SPI_NAND=y
+CONFIG_LMB_MAX_REGIONS=9
diff --git a/lib/lmb.c b/lib/lmb.c
index 8c0a09c..ec79076 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -17,10 +17,6 @@
 #include <asm/global_data.h>
 #include <asm/sections.h>
 
-#ifdef CONFIG_AMLOGIC_MODIFY
-#include <asm/amlogic/arch/register.h>
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #define LMB_ALLOC_ANYWHERE	0
@@ -198,25 +194,6 @@
 	if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob)
 		boot_fdt_add_mem_rsv_regions(lmb, fdt_blob);
 
-#ifdef CONFIG_AMLOGIC_MODIFY
-	/* add bl31/bl32 reserve memory */
-	uint32_t rsv_addr;
-	uint32_t reg_size;
-#if defined(P_AO_SEC_GP_CFG3)
-	rsv_addr = *((volatile uint32_t *)((uintptr_t)(P_AO_SEC_GP_CFG5)));
-	reg_size = *((volatile uint32_t *)((uintptr_t)(P_AO_SEC_GP_CFG3)));
-#elif defined(SYSCTRL_SEC_STATUS_REG15)
-	rsv_addr = *((volatile uint32_t *)((uintptr_t)(SYSCTRL_SEC_STATUS_REG17)));
-	reg_size = *((volatile uint32_t *)((uintptr_t)(SYSCTRL_SEC_STATUS_REG15)));
-#endif
-	if ((reg_size >> 16) & 0xff)
-		lmb_reserve(lmb, rsv_addr, (((reg_size & 0xffff0000) >> 16) << 16) +
-			((reg_size & 0x0000ffff) << 16));
-	else
-		lmb_reserve(lmb, rsv_addr, (((reg_size & 0xffff0000) >> 16) << 10) +
-			((reg_size & 0x0000ffff) << 10));
-#endif
-
 	if (CONFIG_IS_ENABLED(EFI_LOADER))
 		efi_lmb_reserve(lmb);
 }