Re: [PATCH v2] can: m_can: enable transmission of FD frame on latest version

From: Oliver Hartkopp
Date: Mon Mar 06 2017 - 14:37:15 EST


Hi Marc,

On 03/06/2017 11:53 AM, Marc Kleine-Budde wrote:
On 03/06/2017 03:21 AM, Wenyou Yang wrote:
Enables the transmission of CAN FD frames on M_CAN IP core >= v3.1.x
and with the bit rate switching.

Tested on M_CAN IP 3.1.0 (CREL = 0x31040730) of SAMA5D2 SoC.

Does this patch work still with the old version of the silicon?

The bits that were added in the TX FIFO element are 'reserved' in the old silicon - so it should not harm.

This code enables

if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
- cccr |= CCCR_CME_CANFD_BRS << CCCR_CME_SHIFT;
+ cccr |= (CCCR_CME_CANFD_BRS | CCCR_CME_CANFD) << CCCR_CME_SHIFT;

the CAN FD support in the new silicon.

This register is set for the old silicon EVERY time a CAN frame is sent.
So this change should not harm the old silicon either.

In fact I was told that the v3.0.x IP core is rather seldom in the wild.
Although I don't have a v3.0.x to test it should work from the documentation side of view.

Reviewed-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>

If we would like to make it really better, the code in m_can_start_xmit() should only fiddle with the M_CAN_CCCR register when working with the v3.0.x silicon.

In fact I would suggest to use the

if (m_can_read_core_rev(priv) < M_CAN_COREREL_3_1_0)

method from

http://marc.info/?l=linux-can&m=148716783119090&w=2

to split the code in m_can_start_xmit() accordingly.

@Wenyou Yang: Can you please send a v3 which splits the tx function?

Regards,
Oliver