public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: sbabic@denx.de
Cc: paul.liu@linaro.org, u-boot@lists.denx.de,
	Fabio Estevam <festevam@denx.de>
Subject: [PATCH 2/5] imx8mm-cl-iot-gate: Retrieve the DDR type from EEPROM
Date: Sat, 19 Mar 2022 09:22:46 -0300	[thread overview]
Message-ID: <20220319122249.77456-2-festevam@gmail.com> (raw)
In-Reply-To: <20220319122249.77456-1-festevam@gmail.com>

From: Fabio Estevam <festevam@denx.de>

Currently, the DDR type is retrieved by iteracting inside an array
of possible DDR types.

This may take saveral attempts, which slows the overall U-Boot process
and does not provide a good user experience:

U-Boot SPL 2021.07 (Feb 28 2022 - 06:39:32 +0000)
DDRINFO: Cfg attempt: [ 1/6 ]
DDRINFO(M): mr5-8 [ 0xff000010 ]
DDRINFO(T): mr5-8 [ 0x5000010 ]
resetting ...

U-Boot SPL 2021.07 (Feb 28 2022 - 06:39:32 +0000)
DDRINFO: Cfg attempt: [ 2/6 ]
DDRINFO(M): mr5-8 [ 0xff000010 ]
DDRINFO(T): mr5-8 [ 0x1061010 ]
resetting ...

U-Boot SPL 2021.07 (Feb 28 2022 - 06:39:32 +0000)
DDRINFO: Cfg attempt: [ 3/6 ]
DDRINFO(M): mr5-8 [ 0xff000010 ]
DDRINFO(T): mr5-8 [ 0xff000010 ]
Normal Boot
WDT:   Not starting
Trying to boot from MMC2
NOTICE:  BL31: v2.5(release):v2.5
NOTICE:  BL31: Built : 07:12:44, Jan 24 2022

Improve the boot time by retrieving the correct DDR information from
the EEPROM:

U-Boot SPL 2022.04-rc4-00045-g6d02bc40d58c (Mar 19 2022 - 08:22:29 -0300)
DDRINFO(D): Kingston 4096G
DDRINFO(M): mr5-8 [ 0xff000010 ]
DDRINFO(E): mr5-8 [ 0xff000010 ]
Normal Boot
WDT:   Started watchdog@30280000 with servicing (60s timeout)
Trying to boot from MMC2
NOTICE:  BL31: v2.5(release):v2.5
NOTICE:  BL31: Built : 22:28:11, Mar 15 2022

Based on the original code from Compulab's U-Boot.

Tested on a imx8mm-cl-iot-gate board populated with 4GB of RAM.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 board/compulab/imx8mm-cl-iot-gate/ddr/ddr.c | 24 ++++++++++++++++++---
 board/compulab/imx8mm-cl-iot-gate/ddr/ddr.h |  5 +++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.c b/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.c
index 42dd0dbf18fa..5b93491923e9 100644
--- a/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.c
+++ b/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.c
@@ -22,6 +22,8 @@
 #include <asm/mach-imx/gpio.h>
 #include "ddr.h"
 
+#include <linux/delay.h>
+
 static unsigned int lpddr4_mr_read(unsigned int mr_rank, unsigned int mr_addr)
 {
 	unsigned int tmp;
@@ -137,10 +139,11 @@ void spl_dram_init_compulab(void)
 		(struct lpddr4_tcm_desc *)SPL_TCM_DATA;
 
 	if (lpddr4_tcm_desc->sign != DEFAULT) {
-		/* if not in tcm scan mode */
+		/* get ddr type from the eeprom if not in tcm scan mode */
+		ddr_info = cl_eeprom_get_ddrinfo();
 		for (i = 0; i < ARRAY_SIZE(lpddr4_array); i++) {
 			if (lpddr4_array[i].id == ddr_info &&
-			    lpddr4_array[i].subind == 0xff) {
+			lpddr4_array[i].subind == cl_eeprom_get_subind()) {
 				ddr_found = 1;
 				break;
 			}
@@ -198,10 +201,25 @@ void spl_dram_init_compulab(void)
 
 	SPL_TCM_FINI;
 
+	if (ddr_found == 0) {
+		/* Update eeprom */
+		cl_eeprom_set_ddrinfo(ddr_info_mrr);
+		mdelay(10);
+		ddr_info = cl_eeprom_get_ddrinfo();
+		mdelay(10);
+		cl_eeprom_set_subind(lpddr4_array[i].subind);
+		/* make sure that the ddr_info has reached the eeprom */
+		printf("DDRINFO(E): mr5-8 [ 0x%x ], read back\n", ddr_info);
+		if (ddr_info_mrr != ddr_info || cl_eeprom_get_subind() != lpddr4_array[i].subind) {
+			printf("DDRINFO(EEPROM): make sure that the eeprom is accessible\n");
+			printf("DDRINFO(EEPROM): i2c dev 1; i2c md 0x51 0x40 0x50\n");
+		}
+	}
+
 	/* Pass the dram size to th U-Boot through the tcm memory */
 	{ /* To figure out what to store into the TCM buffer */
 	  /* For debug purpouse only. To override the real memsize */
-		unsigned int ddr_tcm_size = 0;
+		unsigned int ddr_tcm_size = cl_eeprom_get_osize();
 
 		if (ddr_tcm_size == 0 || ddr_tcm_size == -1)
 			ddr_tcm_size = lpddr4_array[i].size;
diff --git a/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.h b/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.h
index 59c18911592e..f7d4fdc1016a 100644
--- a/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.h
+++ b/board/compulab/imx8mm-cl-iot-gate/ddr/ddr.h
@@ -23,4 +23,9 @@ struct lpddr4_tcm_desc {
 	unsigned int count;
 };
 
+u32 cl_eeprom_get_ddrinfo(void);
+u32 cl_eeprom_set_ddrinfo(u32 ddrinfo);
+u32 cl_eeprom_get_subind(void);
+u32 cl_eeprom_set_subind(u32 subind);
+u32 cl_eeprom_get_osize(void);
 #endif
-- 
2.25.1


  reply	other threads:[~2022-03-19 12:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19 12:22 [PATCH 1/5] imx8mm-cl-iot-gate: Add SPL EEPROM support Fabio Estevam
2022-03-19 12:22 ` Fabio Estevam [this message]
2022-03-21  9:53   ` [PATCH 2/5] imx8mm-cl-iot-gate: Retrieve the DDR type from EEPROM Harald Seiler
2022-03-21 17:31   ` Tim Harvey
2022-03-21 20:11     ` Paul Liu
2022-04-12 18:44   ` sbabic
2022-03-19 12:22 ` [PATCH 3/5] imx8mm-cl-iot-gate: Retrieve the MAC address " Fabio Estevam
2022-04-12 15:33   ` Stefano Babic
2022-04-12 16:07     ` Fabio Estevam
2022-04-12 15:56   ` Sean Anderson
2022-04-12 16:08     ` Fabio Estevam
2022-04-12 18:44   ` sbabic
2022-03-19 12:22 ` [PATCH 4/5] imx8mm-cl-iot-gate: Retrieve the serial number " Fabio Estevam
2022-03-19 12:22 ` [PATCH 5/5] imx8mm-cl-iot-gate: Add redundand environment support Fabio Estevam
2022-04-12 18:43   ` sbabic
2022-04-12 18:47 ` [PATCH 1/5] imx8mm-cl-iot-gate: Add SPL EEPROM support sbabic

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=20220319122249.77456-2-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=festevam@denx.de \
    --cc=paul.liu@linaro.org \
    --cc=sbabic@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox