Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932464AbdCFThI (ORCPT ); Mon, 6 Mar 2017 14:37:08 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]:16780 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753621AbdCFTg5 (ORCPT ); Mon, 6 Mar 2017 14:36:57 -0500 X-RZG-AUTH: :P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrT1q0ngWNsKR9DbcDvsfbZ70J0g8MNERr4PA== X-RZG-CLASS-ID: mo00 Subject: Re: [PATCH v2] can: m_can: enable transmission of FD frame on latest version To: Marc Kleine-Budde , Wenyou Yang , Wolfgang Grandegger References: <20170306022143.7695-1-wenyou.yang@atmel.com> Cc: Alexandre Belloni , Florian Fainelli , Quentin Schulz , Wenyou Yang , Nicolas Ferre , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Oliver Hartkopp Message-ID: Date: Mon, 6 Mar 2017 20:33:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1487 Lines: 49 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 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