mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-02-15 04:42:02 +00:00
52 lines
1.5 KiB
Diff
52 lines
1.5 KiB
Diff
From 9543c9ffe07dcfd7b7a93e9009bd004c3c1cfdec Mon Sep 17 00:00:00 2001
|
|
From: Phil Elwell <phil@raspberrypi.org>
|
|
Date: Thu, 1 Aug 2019 08:58:48 +0100
|
|
Subject: [PATCH 737/826] can: mcp251x: Allow more time after a reset
|
|
|
|
Some boards take longer than 5ms to power up after a reset, so allow
|
|
a few retry attempts before giving up.
|
|
|
|
See: https://github.com/raspberrypi/linux/issues/2767
|
|
|
|
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
|
---
|
|
drivers/net/can/spi/mcp251x.c | 15 ++++++++++++---
|
|
1 file changed, 12 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
|
|
index cae0f5b633d0..c5c2ac423fc9 100644
|
|
--- a/drivers/net/can/spi/mcp251x.c
|
|
+++ b/drivers/net/can/spi/mcp251x.c
|
|
@@ -628,6 +628,7 @@ static int mcp251x_hw_reset(struct spi_device *spi)
|
|
struct mcp251x_priv *priv = spi_get_drvdata(spi);
|
|
u8 reg;
|
|
int ret;
|
|
+ int retries = 10;
|
|
|
|
/* Wait for oscillator startup timer after power up */
|
|
mdelay(MCP251X_OST_DELAY_MS);
|
|
@@ -637,10 +638,18 @@ static int mcp251x_hw_reset(struct spi_device *spi)
|
|
if (ret)
|
|
return ret;
|
|
|
|
- /* Wait for oscillator startup timer after reset */
|
|
- mdelay(MCP251X_OST_DELAY_MS);
|
|
+ /*
|
|
+ * Wait for oscillator startup timer after reset
|
|
+ *
|
|
+ * Some devices can take longer than the expected 5ms to wake
|
|
+ * up, so allow a few retries.
|
|
+ */
|
|
+
|
|
+ do {
|
|
+ mdelay(MCP251X_OST_DELAY_MS);
|
|
+ reg = mcp251x_read_reg(spi, CANSTAT);
|
|
+ } while (!reg && retries--);
|
|
|
|
- reg = mcp251x_read_reg(spi, CANSTAT);
|
|
if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)
|
|
return -ENODEV;
|
|
|
|
--
|
|
2.22.0
|
|
|