]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
can: m_can: m_can_chip_config(): enable and configure internal timestamps
authorTorin Cooper-Bennun <torin@maxiluxsystems.com>
Mon, 8 Mar 2021 10:24:27 +0000 (10:24 +0000)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 30 Mar 2021 09:14:48 +0000 (11:14 +0200)
This is a prerequisite for transitioning the m_can driver to rx-offload,
which works best with TX and RX timestamps.

The timestamps provided by M_CAN are 16-bit, timed according to the
nominal bit timing, and may be prescaled by a multiplier up to 16. We
choose the highest prescalar so that the timestamp wraps every 2^20 bit
times, or 209 ms at a bus speed of 5 Mbit/s. Timestamps will have a
precision of 16 bit times.

Link: https://lore.kernel.org/r/20210308102427.63916-3-torin@maxiluxsystems.com
Signed-off-by: Torin Cooper-Bennun <torin@maxiluxsystems.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/m_can/m_can.c

index 9f7cfe91f7ff17b9ebdf0543c059489413d25e8e..7df81e38b043b62cced573957d81b06ecb8dc975 100644 (file)
@@ -1135,6 +1135,7 @@ static int m_can_set_bittiming(struct net_device *dev)
  *             - >= v3.1.x: TX FIFO is used
  * - configure mode
  * - setup bittiming
+ * - configure timestamp generation
  */
 static void m_can_chip_config(struct net_device *dev)
 {
@@ -1246,6 +1247,10 @@ static void m_can_chip_config(struct net_device *dev)
        /* set bittiming params */
        m_can_set_bittiming(dev);
 
+       /* enable internal timestamp generation, with a prescalar of 16. The
+        * prescalar is applied to the nominal bit timing */
+       m_can_write(cdev, M_CAN_TSCC, FIELD_PREP(TSCC_TCP_MASK, 0xf));
+
        m_can_config_endisable(cdev, false);
 
        if (cdev->ops->init)