u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] imx8m: fix reading of DDR4 MR registers [again]
@ 2022-10-06 12:56 Rasmus Villemoes
  2022-10-06 13:17 ` Fabio Estevam
  2022-10-24 13:54 ` sbabic
  0 siblings, 2 replies; 3+ messages in thread
From: Rasmus Villemoes @ 2022-10-06 12:56 UTC (permalink / raw)
  To: u-boot
  Cc: Ye Li, Peng Fan, Ying-Chun Liu, Fabio Estevam, Marek Vasut,
	Rasmus Villemoes

Commit 290ffe5788 (imx8m: fix reading of DDR4 MR registers) lifted a
private definition of lpddr4_mr_read() from imx8mm-cl-iot-gate board
code to drivers/ddr/imx/imx8m/ddrphy_utils.c, because that version
actually seems to work in practice.

However, commit 99c7cc58e1 (ddr: imx: Add i.MX9 DDR controller driver)
reintroduced the broken version in drivers/ddr/imx/imx8m/ddr_init.c,
copied most of the rest of ddrphy_utils.c to
drivers/ddr/imx/phy/ddrphy_utils.c, and stopped building
drivers/ddr/imx/imx8m/ddrphy_utils.c [and that file was then finally
completely removed with 7e9bd84883 (imx8m: ddrphy_utils: Remove unused
file)].

I assume this must have broken the imx8mm-cl-iot-gate board, at least
those that have not had their eeprom programmed with the proper
information. It certainly did break our out-of-tree board which always
reads back the ID register and uses that for a sanity check.

So apply the fix from 290ffe5788 once again.

Fixes: 99c7cc58e1 (ddr: imx: Add i.MX9 DDR controller driver)
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/ddr/imx/imx8m/ddr_init.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/ddr/imx/imx8m/ddr_init.c b/drivers/ddr/imx/imx8m/ddr_init.c
index d964184ddc..52a4aa6323 100644
--- a/drivers/ddr/imx/imx8m/ddr_init.c
+++ b/drivers/ddr/imx/imx8m/ddr_init.c
@@ -134,8 +134,14 @@ unsigned int lpddr4_mr_read(unsigned int mr_rank, unsigned int mr_addr)
 		tmp = reg32_read(DRC_PERF_MON_MRR0_DAT(0));
 	} while ((tmp & 0x8) == 0);
 	tmp = reg32_read(DRC_PERF_MON_MRR1_DAT(0));
-	tmp = tmp & 0xff;
 	reg32_write(DRC_PERF_MON_MRR0_DAT(0), 0x4);
+	while (tmp) { //try to find a significant byte in the word
+		if (tmp & 0xff) {
+			tmp &= 0xff;
+			break;
+		}
+		tmp >>= 8;
+	}
 
 	return tmp;
 }
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] imx8m: fix reading of DDR4 MR registers [again]
  2022-10-06 12:56 [PATCH] imx8m: fix reading of DDR4 MR registers [again] Rasmus Villemoes
@ 2022-10-06 13:17 ` Fabio Estevam
  2022-10-24 13:54 ` sbabic
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2022-10-06 13:17 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: u-boot, Ye Li, Peng Fan, Ying-Chun Liu, Marek Vasut

Hi Rasmus,

On 06/10/2022 09:56, Rasmus Villemoes wrote:
> Commit 290ffe5788 (imx8m: fix reading of DDR4 MR registers) lifted a
> private definition of lpddr4_mr_read() from imx8mm-cl-iot-gate board
> code to drivers/ddr/imx/imx8m/ddrphy_utils.c, because that version
> actually seems to work in practice.
> 
> However, commit 99c7cc58e1 (ddr: imx: Add i.MX9 DDR controller driver)
> reintroduced the broken version in drivers/ddr/imx/imx8m/ddr_init.c,
> copied most of the rest of ddrphy_utils.c to
> drivers/ddr/imx/phy/ddrphy_utils.c, and stopped building
> drivers/ddr/imx/imx8m/ddrphy_utils.c [and that file was then finally
> completely removed with 7e9bd84883 (imx8m: ddrphy_utils: Remove unused
> file)].
> 
> I assume this must have broken the imx8mm-cl-iot-gate board, at least
> those that have not had their eeprom programmed with the proper
> information. It certainly did break our out-of-tree board which always
> reads back the ID register and uses that for a sanity check.
> 
> So apply the fix from 290ffe5788 once again.
> 
> Fixes: 99c7cc58e1 (ddr: imx: Add i.MX9 DDR controller driver)
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

Thanks for the fix:

Reviewed-by: Fabio Estevam <festevam@denx.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] imx8m: fix reading of DDR4 MR registers [again]
  2022-10-06 12:56 [PATCH] imx8m: fix reading of DDR4 MR registers [again] Rasmus Villemoes
  2022-10-06 13:17 ` Fabio Estevam
@ 2022-10-24 13:54 ` sbabic
  1 sibling, 0 replies; 3+ messages in thread
From: sbabic @ 2022-10-24 13:54 UTC (permalink / raw)
  To: Rasmus Villemoes, u-boot

> Commit 290ffe5788 (imx8m: fix reading of DDR4 MR registers) lifted a
> private definition of lpddr4_mr_read() from imx8mm-cl-iot-gate board
> code to drivers/ddr/imx/imx8m/ddrphy_utils.c, because that version
> actually seems to work in practice.
> However, commit 99c7cc58e1 (ddr: imx: Add i.MX9 DDR controller driver)
> reintroduced the broken version in drivers/ddr/imx/imx8m/ddr_init.c,
> copied most of the rest of ddrphy_utils.c to
> drivers/ddr/imx/phy/ddrphy_utils.c, and stopped building
> drivers/ddr/imx/imx8m/ddrphy_utils.c [and that file was then finally
> completely removed with 7e9bd84883 (imx8m: ddrphy_utils: Remove unused
> file)].
> I assume this must have broken the imx8mm-cl-iot-gate board, at least
> those that have not had their eeprom programmed with the proper
> information. It certainly did break our out-of-tree board which always
> reads back the ID register and uses that for a sanity check.
> So apply the fix from 290ffe5788 once again.
> Fixes: 99c7cc58e1 (ddr: imx: Add i.MX9 DDR controller driver)
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> Reviewed-by: Fabio Estevam <festevam@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-24 13:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 12:56 [PATCH] imx8m: fix reading of DDR4 MR registers [again] Rasmus Villemoes
2022-10-06 13:17 ` Fabio Estevam
2022-10-24 13:54 ` sbabic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).