From patchwork Mon Jun 29 18:18:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 1319349 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=walle.cc header.i=@walle.cc header.a=rsa-sha256 header.s=mail2016061301 header.b=XIaGTyyu; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49wgv925Sjz9sVb for ; Tue, 30 Jun 2020 07:42:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403934AbgF2VmU (ORCPT ); Mon, 29 Jun 2020 17:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbgF2Sh4 (ORCPT ); Mon, 29 Jun 2020 14:37:56 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C56C031C7D; Mon, 29 Jun 2020 11:18:19 -0700 (PDT) Received: from apollo.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:6257:18ff:fec4:ca34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id B6A7622FA7; Mon, 29 Jun 2020 20:18:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1593454698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eEE2UbGu8BTGtcLgMgns43018yjd14SkF1FC8t9v/x8=; b=XIaGTyyus2oWlG5KxK6sEEDMh31kXJcp+INP/eDG3A6nTLQzla+6o1S0Fdv7D2wX8neEdV WaqZ099GB39Yx2DHEDYBDRxHwccl71glD8/skeZPZU9vUo+ryMfwmJ3N9qU4eBJ5iEpXUN 5gaOOw33ERueJDXtn3vm8ZOno0emA+8= From: Michael Walle To: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Joakim Zhang , dl-linux-imx , Michael Walle Subject: [PATCH 1/2] can: flexcan: use ctrlmode to enable CAN-FD Date: Mon, 29 Jun 2020 20:18:08 +0200 Message-Id: <20200629181809.25338-2-michael@walle.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200629181809.25338-1-michael@walle.cc> References: <20200629181809.25338-1-michael@walle.cc> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The driver will enable CAN-FD mode according to the ctrlmode_supported, which will always be true, if the controller supports it. This is wrong. Use the correct ctrlmode instead. Signed-off-by: Michael Walle --- drivers/net/can/flexcan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 12043250e398..183e094f8d66 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -1345,7 +1345,7 @@ static int flexcan_chip_start(struct net_device *dev) reg_mcr |= FLEXCAN_MCR_SRX_DIS; /* MCR - CAN-FD */ - if (priv->can.ctrlmode_supported & CAN_CTRLMODE_FD) + if (priv->can.ctrlmode & CAN_CTRLMODE_FD) reg_mcr |= FLEXCAN_MCR_FDEN; else reg_mcr &= ~FLEXCAN_MCR_FDEN; From patchwork Mon Jun 29 18:18:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 1319354 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=walle.cc header.i=@walle.cc header.a=rsa-sha256 header.s=mail2016061301 header.b=Qt5Lh88+; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49wgwX1B3Yz9sXW for ; Tue, 30 Jun 2020 07:43:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403868AbgF2Vni (ORCPT ); Mon, 29 Jun 2020 17:43:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727849AbgF2Sht (ORCPT ); Mon, 29 Jun 2020 14:37:49 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F53DC031C7E; Mon, 29 Jun 2020 11:18:20 -0700 (PDT) Received: from apollo.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:6257:18ff:fec4:ca34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 2AD6822FE5; Mon, 29 Jun 2020 20:18:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1593454698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cNOkHiPv2byQuAj2pn9ZPa3+Ddro6cPpf6otG6XMIXU=; b=Qt5Lh88+98GRoG6VG+zgAmNMRTGGa5VpEv+Ku63uodMS0RsBKLYndk4AYHhmRbWS8RtJ6w UYR3Ctbmic8zNcTFOnYMnlHam8JyvG0QERHY2zeMl3NObqvIJQpNv+AE/65FH/xg5yR9qY wSoZZ3y9pgoFrus6TXetUx3rMtdENHE= From: Michael Walle To: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Joakim Zhang , dl-linux-imx , Michael Walle Subject: [PATCH 2/2] can: flexcan: add support for ISO CAN-FD Date: Mon, 29 Jun 2020 20:18:09 +0200 Message-Id: <20200629181809.25338-3-michael@walle.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200629181809.25338-1-michael@walle.cc> References: <20200629181809.25338-1-michael@walle.cc> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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(®s->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, ®s->mcr); + priv->write(reg_ctrl2, ®s->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;