diff mbox series

[v2,1/1] arm: imx8m: imx8mm-cl-iot-gate: Add support for detect memory size

Message ID 20210824094419.2199534-2-grandpaul@gmail.com
State Accepted
Commit 0f328fcc4ccfdf575794987799eee008ae4ca3bf
Delegated to: Stefano Babic
Headers show
Series arm: imx8m: imx8mm-cl-iot-gate: Add support for detect memory size | expand

Commit Message

Ying-Chun Liu Aug. 24, 2021, 9:44 a.m. UTC
From: "Ying-Chun Liu (PaulLiu)" <paulliu@debian.org>

When purchasing imx8mm-cl-iot-gate it is able to customize the
memory size. It could be 1GB, 2GB and 4GB. We implement
board_phys_sdram_size() to detect the memory size for usage.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Cc: uboot-imx <uboot-imx@nxp.com>
---
v2: use hang() instead of while(1)
---
 .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c   | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Fabio Estevam Aug. 24, 2021, 10:29 a.m. UTC | #1
Hi Paul,

On 24/08/2021 06:44, Ying-Chun Liu wrote:
> From: "Ying-Chun Liu (PaulLiu)" <paulliu@debian.org>
> 
> When purchasing imx8mm-cl-iot-gate it is able to customize the
> memory size. It could be 1GB, 2GB and 4GB. We implement
> board_phys_sdram_size() to detect the memory size for usage.
> 
> Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Cc: uboot-imx <uboot-imx@nxp.com>
> ---
> v2: use hang() instead of while(1)


Thanks for fixing this:

Reviewed-by: Fabio Estevam <festevam@denx.de>
Stefano Babic Oct. 7, 2021, 2:14 p.m. UTC | #2
> From: "Ying-Chun Liu (PaulLiu)" <paulliu@debian.org>
> When purchasing imx8mm-cl-iot-gate it is able to customize the
> memory size. It could be 1GB, 2GB and 4GB. We implement
> board_phys_sdram_size() to detect the memory size for usage.
> Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Cc: uboot-imx <uboot-imx@nxp.com>
> Reviewed-by: Fabio Estevam <festevam@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
index eabcc842a4..cd15410978 100644
--- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
+++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
@@ -6,6 +6,7 @@ 
 
 #include <common.h>
 #include <env.h>
+#include <hang.h>
 #include <init.h>
 #include <miiphy.h>
 #include <netdev.h>
@@ -14,8 +15,32 @@ 
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
 
+#include "ddr/ddr.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
+int board_phys_sdram_size(phys_size_t *size)
+{
+	struct lpddr4_tcm_desc *lpddr4_tcm_desc =
+		(struct lpddr4_tcm_desc *)TCM_DATA_CFG;
+
+	switch (lpddr4_tcm_desc->size) {
+	case 4096:
+	case 2048:
+	case 1024:
+		*size = (1L << 20) * lpddr4_tcm_desc->size;
+		break;
+	default:
+		printf("%s: DRAM size %uM is not supported\n",
+		       __func__,
+		       lpddr4_tcm_desc->size);
+		hang();
+		break;
+	};
+
+	return 0;
+}
+
 static int setup_fec(void)
 {
 	if (IS_ENABLED(CONFIG_FEC_MXC)) {