All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joakim Zhang <qiangqing.zhang@nxp.com>
To: "mkl@pengutronix.de" <mkl@pengutronix.de>,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Cc: "wg@grandegger.com" <wg@grandegger.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Joakim Zhang <qiangqing.zhang@nxp.com>
Subject: [PATCH 5/8] can: flexcan: add ISO CAN FD feature support
Date: Fri, 12 Jul 2019 08:02:51 +0000	[thread overview]
Message-ID: <20190712075926.7357-6-qiangqing.zhang@nxp.com> (raw)
In-Reply-To: <20190712075926.7357-1-qiangqing.zhang@nxp.com>

ISO CAN FD is introduced to increase the failture detection capability
than non-ISO CAN FD. The non-ISO CAN FD is still supported by FlexCAN so
that it can be used mainly during an intermediate phase, for evaluation
and development purposes.

Therefore, it is strongly recommended to configure FlexCAN to the ISO
CAN FD protocol by setting the ISOCANFDEN field in the CTRL2 register.

NOTE: If you only set "fd on", driver will use ISO FD mode by default.
You should set "fd-non-iso on" after setting "fd on" if you want to use
NON ISO FD mode.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/net/can/flexcan.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 4956ef64944a..daf4f0e88224 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -92,6 +92,7 @@
 #define FLEXCAN_CTRL2_MRP		BIT(18)
 #define FLEXCAN_CTRL2_RRS		BIT(17)
 #define FLEXCAN_CTRL2_EACEN		BIT(16)
+#define FLEXCAN_CTRL2_ISOCANFDEN	BIT(12)
 
 /* FLEXCAN memory error control register (MECR) bits */
 #define FLEXCAN_MECR_ECRWRDIS		BIT(31)
@@ -1297,6 +1298,7 @@ static int flexcan_chip_start(struct net_device *dev)
 		reg_fdctrl = priv->read(&regs->fdctrl) & ~FLEXCAN_FDCTRL_FDRATE;
 		reg_fdctrl &= ~(FLEXCAN_FDCTRL_MBDSR1(0x3) | FLEXCAN_FDCTRL_MBDSR0(0x3));
 		reg_mcr = priv->read(&regs->mcr) & ~FLEXCAN_MCR_FDEN;
+		reg_ctrl2 = priv->read(&regs->ctrl2) & ~FLEXCAN_CTRL2_ISOCANFDEN;
 
 		/* support BRS when set CAN FD mode
 		 * 64 bytes payload per MB and 7 MBs per RAM block by default
@@ -1306,10 +1308,14 @@ static int flexcan_chip_start(struct net_device *dev)
 			reg_fdctrl |= FLEXCAN_FDCTRL_FDRATE;
 			reg_fdctrl |= FLEXCAN_FDCTRL_MBDSR1(0x3) | FLEXCAN_FDCTRL_MBDSR0(0x3);
 			reg_mcr |= FLEXCAN_MCR_FDEN;
+
+			if (!(priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO))
+				reg_ctrl2 |= FLEXCAN_CTRL2_ISOCANFDEN;
 		}
 
 		priv->write(reg_fdctrl, &regs->fdctrl);
 		priv->write(reg_mcr, &regs->mcr);
+		priv->write(reg_ctrl2, &regs->ctrl2);
 	}
 
 	if ((priv->devtype_data->quirks & FLEXCAN_QUIRK_ENABLE_EACEN_RRS)) {
@@ -1799,7 +1805,7 @@ static int flexcan_probe(struct platform_device *pdev)
 
 	if (priv->devtype_data->quirks & FLEXCAN_QUIRK_TIMESTAMP_SUPPORT_FD) {
 		if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
-			priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD;
+			priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO;
 			priv->can.bittiming_const = &flexcan_fd_bittiming_const;
 			priv->can.data_bittiming_const = &flexcan_fd_data_bittiming_const;
 		} else {
-- 
2.17.1

  parent reply	other threads:[~2019-07-12  8:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12  8:02 [PATCH 0/8] can: flexcan: add CAN FD support for NXP Flexcan Joakim Zhang
2019-07-12  8:02 ` [PATCH 1/8] can: flexcan: allocate skb in flexcan_mailbox_read Joakim Zhang
2019-07-12  8:02 ` [PATCH 2/8] can: flexcan: use struct canfd_frame for CAN classic frame Joakim Zhang
2019-07-12  8:02 ` [PATCH 3/8] can: flexcan: add CAN FD mode support Joakim Zhang
2019-07-12  8:02 ` [PATCH 4/8] can: flexcan: add CANFD BRS support Joakim Zhang
2019-07-12  8:02 ` Joakim Zhang [this message]
2019-07-12  8:02 ` [PATCH 6/8] can: flexcan: add Transceiver Delay Compensation suopport Joakim Zhang
2019-07-12  8:02 ` [PATCH 7/8] can: flexcan: add imx8qm support Joakim Zhang
2019-07-12  8:03 ` [PATCH 8/8] can: flexcan: add lx2160ar1 support Joakim Zhang
2019-07-25  7:38 ` [PATCH 0/8] can: flexcan: add CAN FD support for NXP Flexcan Joakim Zhang
2019-07-25  7:53   ` Marc Kleine-Budde
2019-07-25 10:37     ` Marc Kleine-Budde
2019-07-26  1:25       ` Joakim Zhang
2020-02-13 19:20       ` Michael Walle
2020-02-14  1:55         ` Joakim Zhang
2020-02-14  8:42           ` Michael Walle
2020-02-14  9:18             ` Joakim Zhang
2020-02-14  9:33               ` Michael Walle
2020-02-14  9:56                 ` Joakim Zhang
2020-02-14 10:02                   ` Michael Walle
2020-02-17  7:13                     ` Shawn Guo
2020-02-17  8:48                       ` Michael Walle
2020-02-18  9:33                         ` Shawn Guo
2020-02-14 10:01                 ` Pankaj Bansal
2020-02-14 10:18                   ` Michael Walle
2020-02-24  9:58               ` Joakim Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190712075926.7357-6-qiangqing.zhang@nxp.com \
    --to=qiangqing.zhang@nxp.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.