Skip to contentSkip to conversation

clk: at91: utmi: add timeout for utmi lock

PATCH In review Eugen Hristev 2 participants 2 messages Aug 3, 2018 – Aug 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: at91: utmi: add timeout for utmi lock

In case the slow clock is not properly configured, the UTMI clock cannot lock the PLL, because UPLLCOUNT will "wait X slow clock cycles". In this case U-boot will loop indefinitely.
Added a timeout in this case, to start U-boot even if UTMI clock is not enabled, so the user can use different media if needed, or investigate.

---
 drivers/clk/at91/clk-utmi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clk/at91/clk-utmi.c +6 -1
index 0b56261..e850609 100644
@@ -28,6 +28,7 @@ static int utmi_clk_enable(struct clk *clk)
 	u32 utmi_ref_clk_freq;
 	u32 tmp;
 	int err;
+	int timeout = 2000000;
 
 	if (readl(&pmc->sr) & AT91_PMC_LOCKU)
 		return 0;
@@ -85,8 +86,12 @@ static int utmi_clk_enable(struct clk *clk)
 	       AT91_PMC_BIASEN;
 	writel(tmp, &pmc->uckr);
 
-	while (!(readl(&pmc->sr) & AT91_PMC_LOCKU))
+	while ((--timeout) && !(readl(&pmc->sr) & AT91_PMC_LOCKU))
 		;
+	if (!timeout) {
+		printf("UTMICK: timeout waiting for UPLL lock\n");
+		return -ETIMEDOUT;
+	}
 
 	return 0;
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · Eugen Hristev

In case the slow clock is not properly configured, the UTMI clock cannot lock the PLL, because UPLLCOUNT will "wait X slow clock cycles". In this case U-boot will loop indefinitely.
Added a timeout in this case, to start U-boot even if UTMI clock is not enabled, so the user can use different media if needed, or investigate.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180813/1258e1e6/attachment.sig>