Self reception disbale bit needs to be cleared for loopback mode to work in flexcan. Signed-off-by: Pankaj Bansal <pankaj.bansal@xxxxxxx> --- Notes: V5: - New patch drivers/net/can/flexcan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 8ab77c583c32..2ffdb58c2d0b 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -933,10 +933,9 @@ static int flexcan_chip_start(struct net_device *dev) * set max mailbox number */ reg_mcr = priv->read(®s->mcr); - reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff); + reg_mcr &= ~(FLEXCAN_MCR_MAXMB(0xff) | FLEXCAN_MCR_SRX_DIS); reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV | - FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_SRX_DIS | FLEXCAN_MCR_IRMQ | - FLEXCAN_MCR_IDAM_C; + FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ | FLEXCAN_MCR_IDAM_C; if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) { reg_mcr &= ~FLEXCAN_MCR_FEN; @@ -945,6 +944,9 @@ static int flexcan_chip_start(struct net_device *dev) reg_mcr |= FLEXCAN_MCR_FEN | FLEXCAN_MCR_MAXMB(priv->tx_mb_idx); } + if (likely(!(priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK))) + reg_mcr |= FLEXCAN_MCR_SRX_DIS; + netdev_dbg(dev, "%s: writing mcr=0x%08x", __func__, reg_mcr); priv->write(reg_mcr, ®s->mcr); -- 2.17.1