Re: can, tcan4x5x: look to merge rpi support into rpi kernel tree

Marc Kleine-Budde
2021-02-26T16:02:27Z

[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]

On 26.02.2021 15:26:33, Torin Cooper-Bennun wrote:
> On Fri, Feb 26, 2021 at 03:00:54PM +0100, Marc Kleine-Budde wrote:
> > https://github.com/hartkopp/M_CAN-User-Manual-History
>
> Great, thanks. I can see this also sits in the linux-can repo which is
> handy.
>
> > > Note: With CAN FD an external counter is required for timestamp
> > > generation (TSS = “10”)
> >
> > I suggest to check on the tcan hardware, what's really in the register.
>
> I've just verified that internal timestamping works on the TCAN4550 (in
> both RX FIFO and TX event FIFO), with FD and BRS both enabled. The
> 16-bit timestamps are generated specifically from the nomimal bit times,
> and you can prescale up to 16x. \o/

NICE! \o/

> Is timestamp-wrapping a concern for rx-offloading?

No, as long as you provide a proper u32 timestamp, which means wrap
around at 0xffffffff to 0x0. As the tcan4x5x has only a 16 bit
timestamp, shift it to full 32 bit, like this:

https://elixir.bootlin.com/linux/v5.11/source/drivers/net/can/flexcan.c#L805

On the mcp with true 32 bit timestamp there's a wraparound every 107
seconds at 40 MHz external clock (0xffffffff / 40000000).

The tcan has the TSS.TCP as a prescaler and increments in bit time,
which is 5MHz max. This results in a wrap around every 13ms (0xffff /
5000000) with a prescaler of 1. With a prescaler of 16, you can increase
this to 209ms (0xffff / 5000000 * 16), which gives an accuracy of 2
bytes.

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]