netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Joakim Zhang <qiangqing.zhang@nxp.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	Michael Walle <michael@walle.cc>
Subject: [PATCH 2/2] can: flexcan: add support for ISO CAN-FD
Date: Mon, 29 Jun 2020 20:18:09 +0200	[thread overview]
Message-ID: <20200629181809.25338-3-michael@walle.cc> (raw)
In-Reply-To: <20200629181809.25338-1-michael@walle.cc>

Up until now, the controller used non-ISO CAN-FD mode, although it
supports it. Add support for ISO mode, too. By default the hardware
is in non-ISO mode and an enable bit has to be explicitly set.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/net/can/flexcan.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 183e094f8d66..a92d3cdf4195 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -94,6 +94,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)
@@ -1344,14 +1345,25 @@ static int flexcan_chip_start(struct net_device *dev)
 	else
 		reg_mcr |= FLEXCAN_MCR_SRX_DIS;
 
-	/* MCR - CAN-FD */
-	if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
+	/* MCR, CTRL2
+	 *
+	 * CAN-FD mode
+	 * ISO CAN-FD mode
+	 */
+	reg_ctrl2 = priv->read(&regs->ctrl2);
+	if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
 		reg_mcr |= FLEXCAN_MCR_FDEN;
-	else
+		reg_ctrl2 |= FLEXCAN_CTRL2_ISOCANFDEN;
+	} else {
 		reg_mcr &= ~FLEXCAN_MCR_FDEN;
+	}
+
+	if (priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO)
+		reg_ctrl2 &= ~FLEXCAN_CTRL2_ISOCANFDEN;
 
 	netdev_dbg(dev, "%s: writing mcr=0x%08x", __func__, reg_mcr);
 	priv->write(reg_mcr, &regs->mcr);
+	priv->write(reg_ctrl2, &regs->ctrl2);
 
 	/* CTRL
 	 *
@@ -1952,6 +1964,7 @@ static int flexcan_probe(struct platform_device *pdev)
 
 	if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) {
 		priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD;
+		priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD_NON_ISO;
 		priv->can.bittiming_const = &flexcan_fd_bittiming_const;
 		priv->can.data_bittiming_const =
 			&flexcan_fd_data_bittiming_const;
-- 
2.20.1


  parent reply	other threads:[~2020-06-29 21:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 18:18 [PATCH 0/2] can: flexcan: small fix and ISO CAN-FD support Michael Walle
2020-06-29 18:18 ` [PATCH 1/2] can: flexcan: use ctrlmode to enable CAN-FD Michael Walle
2020-06-29 18:18 ` Michael Walle [this message]
2020-06-30  2:42   ` [PATCH 2/2] can: flexcan: add support for ISO CAN-FD Joakim Zhang
2020-06-30  5:53     ` Michael Walle
2020-06-30 16:15       ` Oliver Hartkopp
2020-06-30 17:00         ` Michael Walle

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=20200629181809.25338-3-michael@walle.cc \
    --to=michael@walle.cc \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=qiangqing.zhang@nxp.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).