1 From 9f29c6c8865de6f2dc200cb4c59a447d0884a6b3 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Thu, 1 Aug 2019 08:58:48 +0100
4 Subject: [PATCH 726/806] can: mcp251x: Allow more time after a reset
6 Some boards take longer than 5ms to power up after a reset, so allow
7 a few retry attempts before giving up.
9 See: https://github.com/raspberrypi/linux/issues/2767
11 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
13 drivers/net/can/spi/mcp251x.c | 15 ++++++++++++---
14 1 file changed, 12 insertions(+), 3 deletions(-)
16 --- a/drivers/net/can/spi/mcp251x.c
17 +++ b/drivers/net/can/spi/mcp251x.c
18 @@ -628,6 +628,7 @@ static int mcp251x_hw_reset(struct spi_d
19 struct mcp251x_priv *priv = spi_get_drvdata(spi);
24 /* Wait for oscillator startup timer after power up */
25 mdelay(MCP251X_OST_DELAY_MS);
26 @@ -637,10 +638,18 @@ static int mcp251x_hw_reset(struct spi_d
30 - /* Wait for oscillator startup timer after reset */
31 - mdelay(MCP251X_OST_DELAY_MS);
33 + * Wait for oscillator startup timer after reset
35 + * Some devices can take longer than the expected 5ms to wake
36 + * up, so allow a few retries.
40 + mdelay(MCP251X_OST_DELAY_MS);
41 + reg = mcp251x_read_reg(spi, CANSTAT);
42 + } while (!reg && retries--);
44 - reg = mcp251x_read_reg(spi, CANSTAT);
45 if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)