Skip to content

Commit fca2977

Browse files
tq-schiffermmarckleinebudde
authored andcommitted
can: m_can: set init flag earlier in probe
While an m_can controller usually already has the init flag from a hardware reset, no such reset happens on the integrated m_can_pci of the Intel Elkhart Lake. If the CAN controller is found in an active state, m_can_dev_setup() would fail because m_can_niso_supported() calls m_can_cccr_update_bits(), which refuses to modify any other configuration bits when CCCR_INIT is not set. To avoid this issue, set CCCR_INIT before attempting to modify any other configuration flags. Fixes: cd5a46c ("can: m_can: don't enable transceiver when probing") Signed-off-by: Matthias Schiffer <[email protected]> Reviewed-by: Markus Schneider-Pargmann <[email protected]> Link: https://patch.msgid.link/e247f331cb72829fcbdfda74f31a59cbad1a6006.1728288535.git.matthias.schiffer@ew.tq-group.com Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 954a2b4 commit fca2977

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,14 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
16951695
return -EINVAL;
16961696
}
16971697

1698+
/* Write the INIT bit, in case no hardware reset has happened before
1699+
* the probe (for example, it was observed that the Intel Elkhart Lake
1700+
* SoCs do not properly reset the CAN controllers on reboot)
1701+
*/
1702+
err = m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);
1703+
if (err)
1704+
return err;
1705+
16981706
if (!cdev->is_peripheral)
16991707
netif_napi_add(dev, &cdev->napi, m_can_poll);
17001708

@@ -1746,11 +1754,7 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
17461754
return -EINVAL;
17471755
}
17481756

1749-
/* Forcing standby mode should be redundant, as the chip should be in
1750-
* standby after a reset. Write the INIT bit anyways, should the chip
1751-
* be configured by previous stage.
1752-
*/
1753-
return m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);
1757+
return 0;
17541758
}
17551759

17561760
static void m_can_stop(struct net_device *dev)

0 commit comments

Comments
 (0)