[U-Boot] [PATCH] MC : Report extra reserved memory to Linux

Meenakshi Aggarwal meenakshi.aggarwal at nxp.com
Mon Mar 11 15:44:11 UTC 2019


For MC, 512 MB DDR is reserved because of MC's alignment
requirement.
But for MC binaries needing 128MB or 256MB DDR memory, rest
of the memory is a waste. So reporting this extra memory to
Linux through dtb memory fixup.

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal at nxp.com>
---
 board/freescale/lx2160a/lx2160a.c | 27 ++++++++++++++++++++++++++-
 drivers/net/fsl-mc/mc.c           | 13 +++++++++++++
 include/fsl-mc/fsl_mc.h           |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index ad72eed..3cbb7d1 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -532,8 +532,15 @@ void board_quiesce_devices(void)
 int ft_board_setup(void *blob, bd_t *bd)
 {
 	int i;
+	bool mc_memory_bank = false;
+
+#ifdef CONFIG_FSL_MC_ENET
+	u64 base[CONFIG_NR_DRAM_BANKS + 1];
+	u64 size[CONFIG_NR_DRAM_BANKS + 1];
+#else
 	u64 base[CONFIG_NR_DRAM_BANKS];
 	u64 size[CONFIG_NR_DRAM_BANKS];
+#endif
 
 	ft_cpu_setup(blob, bd);
 
@@ -556,7 +563,25 @@ int ft_board_setup(void *blob, bd_t *bd)
 		size[2] = gd->arch.resv_ram - base[2];
 #endif
 
-	fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS);
+#ifdef CONFIG_FSL_MC_ENET
+	fdt_fixup_mc_ddr(&base[3], &size[3]);
+
+	if (base[3] != 0) {
+		for (i = 0; i <= CONFIG_NR_DRAM_BANKS; i++) {
+			if (base[i] == 0 && size[i] == 0) {
+				base[i] = base[3];
+				size[i] = size[3];
+				break;
+			}
+		}
+		if (i == CONFIG_NR_DRAM_BANKS)
+			mc_memory_bank = true;
+	}
+#endif
+	if (mc_memory_bank)
+		fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS + 1);
+	else
+		fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS);
 
 #ifdef CONFIG_USB
 	fsl_fdt_fixup_dr_usb(blob, bd);
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index dddc9cc..79a38d6 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -285,6 +285,19 @@ static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id,
 				 MC_FIXUP_DPL);
 }
 
+void fdt_fixup_mc_ddr(u64* base, u64* size)
+{
+	u64 mc_size = mc_get_dram_block_size();
+
+	if (mc_size < MC_DRAM_BLOCK_DEFAULT_SIZE) {
+		*base = mc_get_dram_addr() + mc_size;
+		*size = MC_DRAM_BLOCK_DEFAULT_SIZE - mc_size;
+	} else {
+		*base = 0;
+		*size = 0;
+	}
+}
+
 void fdt_fsl_mc_fixup_iommu_map_entry(void *blob)
 {
 	u32 *prop;
diff --git a/include/fsl-mc/fsl_mc.h b/include/fsl-mc/fsl_mc.h
index aef40d3..30f961b 100644
--- a/include/fsl-mc/fsl_mc.h
+++ b/include/fsl-mc/fsl_mc.h
@@ -54,6 +54,7 @@ struct mc_ccsr_registers {
 void fdt_fsl_mc_fixup_iommu_map_entry(void *blob);
 int get_mc_boot_status(void);
 int get_dpl_apply_status(void);
+void fdt_fixup_mc_ddr(u64 *base, u64* size);
 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
 int get_aiop_apply_status(void);
 #endif
-- 
1.9.1



More information about the U-Boot mailing list