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 <andriy.gelman@gmail.com>
This commit is contained in:
Andriy Gelman 2024-06-04 11:12:32 +02:00 committed by Anas Nashif
parent 8113ff7e9c
commit 59bdb49901
2 changed files with 6 additions and 1 deletions

View file

@ -1497,7 +1497,10 @@ static int mcp251xfd_reset(const struct device *dev)
return ret;
}
return spi_write_dt(&dev_cfg->bus, &tx);
ret = spi_write_dt(&dev_cfg->bus, &tx);
/* Adding delay after init to fix occasional init issue. Delay time found experimentally. */
k_sleep(K_USEC(MCP251XFD_RESET_DELAY_USEC));
return ret;
}
static int mcp251xfd_init(const struct device *dev)

View file

@ -69,6 +69,8 @@ BUILD_ASSERT(MCP251XFD_TEF_FIFO_SIZE + MCP251XFD_TX_QUEUE_SIZE +
#define MCP251XFD_MAX_INT_HANDLER_CALLS 10
#define MCP251XFD_INT_HANDLER_SLEEP_USEC 10000
/* Delay time found experimentally to fix occasional init issue */
#define MCP251XFD_RESET_DELAY_USEC 5000
struct mcp251xfd_mailbox {
can_tx_callback_t cb;