Skip to content

Commit 59bdb49

Browse files
talih0nashif
authored andcommitted
drivers: can_mcp251xfd: Delay initialization after reset
Mcp251xfd devices occasionally fail to initialize after board resets. It was experimentally found that adding a 5ms delay fixes the problem. Fixes #73586. Original patch by melvinvdb from #73714. Signed-off-by: Andriy Gelman <[email protected]>
1 parent 8113ff7 commit 59bdb49

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/can/can_mcp251xfd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,10 @@ static int mcp251xfd_reset(const struct device *dev)
14971497
return ret;
14981498
}
14991499

1500-
return spi_write_dt(&dev_cfg->bus, &tx);
1500+
ret = spi_write_dt(&dev_cfg->bus, &tx);
1501+
/* Adding delay after init to fix occasional init issue. Delay time found experimentally. */
1502+
k_sleep(K_USEC(MCP251XFD_RESET_DELAY_USEC));
1503+
return ret;
15011504
}
15021505

15031506
static int mcp251xfd_init(const struct device *dev)

drivers/can/can_mcp251xfd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ BUILD_ASSERT(MCP251XFD_TEF_FIFO_SIZE + MCP251XFD_TX_QUEUE_SIZE +
6969
#define MCP251XFD_MAX_INT_HANDLER_CALLS 10
7070
#define MCP251XFD_INT_HANDLER_SLEEP_USEC 10000
7171

72+
/* Delay time found experimentally to fix occasional init issue */
73+
#define MCP251XFD_RESET_DELAY_USEC 5000
7274

7375
struct mcp251xfd_mailbox {
7476
can_tx_callback_t cb;

0 commit comments

Comments
 (0)