From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org, Sascha Hauer <s.hauer@pengutronix.de>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH 2/5] ARM: SoCFPGA: arria10-sdram: cleanup emif_clear
Date: Mon, 03 Mar 2025 09:59:18 +0100 [thread overview]
Message-ID: <20250303-v2025-02-0-topic-socfpga-arria10-v1-2-d66021246a66@pengutronix.de> (raw)
In-Reply-To: <20250303-v2025-02-0-topic-socfpga-arria10-v1-0-d66021246a66@pengutronix.de>
Cleanup the emif_clear() function.
Use __wait_on_timeout to kick the watchdog and make the code more readable.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-socfpga/arria10-sdram.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-socfpga/arria10-sdram.c b/arch/arm/mach-socfpga/arria10-sdram.c
index 70d4edd9736c786729ba59e7ecad7eb7cfe7f77e..da7d3ea685e238c8c9abda84976a1161edfc4b03 100644
--- a/arch/arm/mach-socfpga/arria10-sdram.c
+++ b/arch/arm/mach-socfpga/arria10-sdram.c
@@ -216,20 +216,14 @@ static int ddr_calibration_es_workaround(void)
static int emif_clear(void)
{
- uint32_t s2c;
- uint32_t i = DDR_MAX_TRIES;
-
writel(0, DDR_REG_CORE2SEQ);
- do {
- ddr_delay(50);
- s2c = readl(DDR_REG_SEQ2CORE);
- } while ((s2c & SEQ2CORE_MASK) && (--i > 0));
- return !i;
+ return __wait_on_timeout(1000, readl(DDR_REG_SEQ2CORE) & SEQ2CORE_MASK);
}
static int emif_reset(void)
{
uint32_t c2s, s2c;
+ int ret;
c2s = readl(DDR_REG_CORE2SEQ);
s2c = readl(DDR_REG_SEQ2CORE);
@@ -240,9 +234,12 @@ static int emif_reset(void)
readl(IO48_MMR_NIOS2_RESERVE2),
readl(IO48_MMR_DRAMSTS));
- if ((s2c & SEQ2CORE_MASK) && emif_clear()) {
- printf("failed emif_clear()\n");
- return -1;
+ if (s2c & SEQ2CORE_MASK) {
+ ret = emif_clear();
+ if (ret) {
+ printf("failed emif_clear()\n");
+ return -1;
+ }
}
writel(CORE2SEQ_INT_REQ, DDR_REG_CORE2SEQ);
@@ -254,7 +251,8 @@ static int emif_reset(void)
printf("emif_reset interrupt acknowledged\n");
}
- if (emif_clear()) {
+ ret = emif_clear();
+ if (ret) {
printf("emif_clear() failed\n");
return -3;
}
--
2.45.2
next prev parent reply other threads:[~2025-03-03 9:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 8:59 [PATCH 0/5] SoCFPGA: Arria10: sdram: cleanup and fix DDR driver Steffen Trumtrar
2025-03-03 8:59 ` [PATCH 1/5] ARM: SoCFPGA: move wait_on_timeout to generic Steffen Trumtrar
2025-03-03 9:12 ` Ahmad Fatoum
2025-03-03 11:11 ` Steffen Trumtrar
2025-03-03 8:59 ` Steffen Trumtrar [this message]
2025-03-03 8:59 ` [PATCH 3/5] ARM: SoCFPGA: arria10-sdram: cleanup emif_reset Steffen Trumtrar
2025-03-03 8:59 ` [PATCH 4/5] ARM: SoCFPGA: arria10-sdram: remove workaround Steffen Trumtrar
2025-03-03 8:59 ` [PATCH 5/5] ARM: SoCFPGA: arria10-sdram: cleanup ddr_setup Steffen Trumtrar
2025-03-05 11:17 ` [PATCH 0/5] SoCFPGA: Arria10: sdram: cleanup and fix DDR driver Sascha Hauer
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=20250303-v2025-02-0-topic-socfpga-arria10-v1-2-d66021246a66@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.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