All of lore.kernel.org
 help / color / mirror / Atom feed
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] MC : Report extra reserved memory to Linux
Date: Wed, 13 Mar 2019 22:40:34 +0530	[thread overview]
Message-ID: <1552497034-14632-1-git-send-email-meenakshi.aggarwal@nxp.com> (raw)
In-Reply-To: <1552389872-6420-1-git-send-email-meenakshi.aggarwal@nxp.com>

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@nxp.com>
Reviewed-by: Ashish Kumar <Ashish.Kumar@nxp.com>
---
 board/freescale/lx2160a/lx2160a.c | 28 +++++++++++++++++++++++++++-
 drivers/net/fsl-mc/mc.c           | 13 +++++++++++++
 include/fsl-mc/fsl_mc.h           |  1 +
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index ad72eed..b763f6d 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,26 @@ 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..d7a2e8f 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..492a714 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

  reply	other threads:[~2019-03-13 17:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 15:44 [U-Boot] [PATCH] MC : Report extra reserved memory to Linux Meenakshi Aggarwal
2019-03-12 11:24 ` [U-Boot] [PATCH v2] " Meenakshi Aggarwal
2019-03-13 17:10   ` Meenakshi Aggarwal [this message]
2019-03-23  0:28     ` [U-Boot] [PATCH v3] " Prabhakar Kushwaha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1552497034-14632-1-git-send-email-meenakshi.aggarwal@nxp.com \
    --to=meenakshi.aggarwal@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.