Skip to content

Commit db87c00

Browse files
can: mcp251xfd: fix detection of mcp251863
In commit c6f2a61 ("can: mcp251xfd: add support for mcp251863") support for the mcp251863 was added. However it was not taken into account that the auto detection of the chip model cannot distinguish between mcp2518fd and mcp251863 and would lead to a warning message if the firmware specifies a mcp251863. Fix auto detection: If a mcp2518fd compatible chip is found, keep the mcp251863 if specified by firmware, use mcp2518fd instead. Link: https://lore.kernel.org/all/[email protected] Fixes: c6f2a61 ("can: mcp251xfd: add support for mcp251863") Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 48ea8ea commit db87c00

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,8 @@ static int mcp251xfd_register_chip_detect(struct mcp251xfd_priv *priv)
16901690
u32 osc;
16911691
int err;
16921692

1693-
/* The OSC_LPMEN is only supported on MCP2518FD, so use it to
1694-
* autodetect the model.
1693+
/* The OSC_LPMEN is only supported on MCP2518FD and MCP251863,
1694+
* so use it to autodetect the model.
16951695
*/
16961696
err = regmap_update_bits(priv->map_reg, MCP251XFD_REG_OSC,
16971697
MCP251XFD_REG_OSC_LPMEN,
@@ -1703,10 +1703,18 @@ static int mcp251xfd_register_chip_detect(struct mcp251xfd_priv *priv)
17031703
if (err)
17041704
return err;
17051705

1706-
if (osc & MCP251XFD_REG_OSC_LPMEN)
1707-
devtype_data = &mcp251xfd_devtype_data_mcp2518fd;
1708-
else
1706+
if (osc & MCP251XFD_REG_OSC_LPMEN) {
1707+
/* We cannot distinguish between MCP2518FD and
1708+
* MCP251863. If firmware specifies MCP251863, keep
1709+
* it, otherwise set to MCP2518FD.
1710+
*/
1711+
if (mcp251xfd_is_251863(priv))
1712+
devtype_data = &mcp251xfd_devtype_data_mcp251863;
1713+
else
1714+
devtype_data = &mcp251xfd_devtype_data_mcp2518fd;
1715+
} else {
17091716
devtype_data = &mcp251xfd_devtype_data_mcp2517fd;
1717+
}
17101718

17111719
if (!mcp251xfd_is_251XFD(priv) &&
17121720
priv->devtype_data.model != devtype_data->model) {

0 commit comments

Comments
 (0)