From patchwork Wed Sep 4 08:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 13789954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 451BACA0ED3 for ; Wed, 4 Sep 2024 08:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cb7vXQlVS7y6oyz41Qf4m+a5sPR0+1fSp1mhhOadb2g=; b=m8wbDiefWhIJkO WNP0WH0EVrc7bjyCfBEkfEc10rtT5g6ms0CclPd6Qq4so3fVoscPwehV64kCVoHP7izp5J3hZHlXz PkI/DUIx4o9XZu+Ln4jP/qW5SdH5SYj1pZbnzyv/LLucL+LrkclBfVVve7ZrePw280AjWr7SSmxje sk4JwDkRc8MFM/Q97QGJomE/5EvH+RiMriemAum5+swhyXLyEuTW49inzElOY3yeDUzEFfAchOfo5 T3DcXCLKGmWoH6tZb6rcZMnitlpOOWLLGuwdp00V8AdiHoxmW4X0qWtcdFc/YoRoYGvICV+6qEFPt WhWHiFHDP0s9udy8C5WA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sllDd-00000003MIM-0ZPc; Wed, 04 Sep 2024 08:18:25 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sll92-00000003KhH-0fEV for linux-rockchip@lists.infradead.org; Wed, 04 Sep 2024 08:13:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sll8x-0007dB-US for linux-rockchip@lists.infradead.org; Wed, 04 Sep 2024 10:13:35 +0200 Received: from [2a0a:edc0:0:b01:1d::7b] (helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sll8s-005Orw-EV for linux-rockchip@lists.infradead.org; Wed, 04 Sep 2024 10:13:30 +0200 Received: from dspam.blackshift.org (localhost [127.0.0.1]) by bjornoya.blackshift.org (Postfix) with SMTP id D474D332026 for ; Wed, 04 Sep 2024 08:13:29 +0000 (UTC) Received: from hardanger.blackshift.org (unknown [172.20.34.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by bjornoya.blackshift.org (Postfix) with ESMTPS id 20FD9331F54; Wed, 04 Sep 2024 08:13:22 +0000 (UTC) Received: from [172.20.34.65] (localhost [::1]) by hardanger.blackshift.org (OpenSMTPD) with ESMTP id a71031cc; Wed, 4 Sep 2024 08:13:20 +0000 (UTC) From: Marc Kleine-Budde Date: Wed, 04 Sep 2024 10:12:49 +0200 Subject: [PATCH can-next v5 05/20] can: rockchip_canfd: add quirks for errata workarounds MIME-Version: 1.0 Message-Id: <20240904-rockchip-canfd-v5-5-8ae22bcb27cc@pengutronix.de> References: <20240904-rockchip-canfd-v5-0-8ae22bcb27cc@pengutronix.de> In-Reply-To: <20240904-rockchip-canfd-v5-0-8ae22bcb27cc@pengutronix.de> To: kernel@pengutronix.de, Alibek Omarov , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Philipp Zabel , Elaine Zhang , David Jander Cc: Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Kleine-Budde X-Mailer: b4 0.15-dev-99b12 X-Developer-Signature: v=1; a=openpgp-sha256; l=4251; i=mkl@pengutronix.de; h=from:subject:message-id; bh=0XfIvBSHxbvsi8q2NBqn07n4EZRg55BSI/J7mfb49+c=; b=owEBbQGS/pANAwAKASg4oj56LbxvAcsmYgBm2BaJKjBKk2hxuLHF8VZFCrysyRuLWb+c0m8+E ElQ02LG+OSJATMEAAEKAB0WIQRQQLqG4LYE3Sm8Pl8oOKI+ei28bwUCZtgWiQAKCRAoOKI+ei28 b7OTB/0TldvmgaL0BvryPFUY0gXuZfsBbDfm//OBa6hhePDOXOBqlnsFEBd0lrEEmfyfDbh5jho kpSb7uv7/cwWdhYB+29eCgPATxblj1V/vPuyR9lpCC1jKAK0q87k1V2zexC1ApvpxMBtTiStDMy 3TakFx608jxg8/0zIgW6MJN7JjHSP32Lnd4uWJnYuoxEPAGOCt4nLB1+Od5WWMnAdO6aQQ5uQaD Z5gnjXLj1JXn4ZpLgoUdnEKeHxD2xVJ25WySaV4mVIrZYUzAwQGRZrJm/42erEthppaAKL07aEz hbwBqqBkaF4v9Q9Pb6yVkzkCHSz8qvLWq0adf2IYWx3Fua4w X-Developer-Key: i=mkl@pengutronix.de; a=openpgp; fpr=C1400BA0B3989E6FBC7D5B5C2B5EE211C58AEA54 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-rockchip@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_011340_206352_DC130F9E X-CRM114-Status: GOOD ( 16.88 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Add a basic infrastructure for quirks for the 12 documented errata. Tested-by: Alibek Omarov Signed-off-by: Marc Kleine-Budde --- drivers/net/can/rockchip/rockchip_canfd-core.c | 11 +++++- drivers/net/can/rockchip/rockchip_canfd.h | 55 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rockchip/rockchip_canfd-core.c b/drivers/net/can/rockchip/rockchip_canfd-core.c index f1b2bad04bf4..18957769b3d3 100644 --- a/drivers/net/can/rockchip/rockchip_canfd-core.c +++ b/drivers/net/can/rockchip/rockchip_canfd-core.c @@ -26,6 +26,12 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v2 = { .model = RKCANFD_MODEL_RK3568V2, + .quirks = RKCANFD_QUIRK_RK3568_ERRATUM_1 | RKCANFD_QUIRK_RK3568_ERRATUM_2 | + RKCANFD_QUIRK_RK3568_ERRATUM_3 | RKCANFD_QUIRK_RK3568_ERRATUM_4 | + RKCANFD_QUIRK_RK3568_ERRATUM_5 | RKCANFD_QUIRK_RK3568_ERRATUM_6 | + RKCANFD_QUIRK_RK3568_ERRATUM_7 | RKCANFD_QUIRK_RK3568_ERRATUM_8 | + RKCANFD_QUIRK_RK3568_ERRATUM_9 | RKCANFD_QUIRK_RK3568_ERRATUM_10 | + RKCANFD_QUIRK_RK3568_ERRATUM_11 | RKCANFD_QUIRK_RK3568_ERRATUM_12, }; static const char *__rkcanfd_get_model_str(enum rkcanfd_model model) @@ -709,10 +715,11 @@ static void rkcanfd_register_done(const struct rkcanfd_priv *priv) dev_id = rkcanfd_read(priv, RKCANFD_REG_RTL_VERSION); netdev_info(priv->ndev, - "Rockchip-CANFD %s rev%lu.%lu found\n", + "Rockchip-CANFD %s rev%lu.%lu (errata 0x%04x) found\n", rkcanfd_get_model_str(priv), FIELD_GET(RKCANFD_REG_RTL_VERSION_MAJOR, dev_id), - FIELD_GET(RKCANFD_REG_RTL_VERSION_MINOR, dev_id)); + FIELD_GET(RKCANFD_REG_RTL_VERSION_MINOR, dev_id), + priv->devtype_data.quirks); } static int rkcanfd_register(struct rkcanfd_priv *priv) diff --git a/drivers/net/can/rockchip/rockchip_canfd.h b/drivers/net/can/rockchip/rockchip_canfd.h index 0848b1900baa..09626ca174a8 100644 --- a/drivers/net/can/rockchip/rockchip_canfd.h +++ b/drivers/net/can/rockchip/rockchip_canfd.h @@ -295,12 +295,67 @@ #define RKCANFD_TIMESTAMP_WORK_MAX_DELAY_SEC 60 #define RKCANFD_ERRATUM_5_SYSCLOCK_HZ_MIN (300 * MEGA) +/* rk3568 CAN-FD Errata, as of Tue 07 Nov 2023 11:25:31 +08:00 */ + +/* Erratum 1: The error frame sent by the CAN controller has an + * abnormal format. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_1 BIT(0) + +/* Erratum 2: The error frame sent after detecting a CRC error has an + * abnormal position. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_2 BIT(1) + +/* Erratum 3: Intermittent CRC calculation errors. */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_3 BIT(2) + +/* Erratum 4: Intermittent occurrence of stuffing errors. */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_4 BIT(3) + +/* Erratum 5: Counters related to the TXFIFO and RXFIFO exhibit + * abnormal counting behavior. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_5 BIT(4) + +/* Erratum 6: The CAN controller's transmission of extended frames may + * intermittently change into standard frames + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_6 BIT(5) + +/* Erratum 7: In the passive error state, the CAN controller's + * interframe space segment counting is inaccurate. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_7 BIT(6) + +/* Erratum 8: The Format-Error error flag is transmitted one bit + * later. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_8 BIT(7) + +/* Erratum 9: In the arbitration segment, the CAN controller will + * identify stuffing errors as arbitration failures. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_9 BIT(8) + +/* Erratum 10: Does not support the BUSOFF slow recovery mechanism. */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_10 BIT(9) + +/* Erratum 11: Arbitration error. */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_11 BIT(10) + +/* Erratum 12: A dominant bit at the third bit of the intermission may + * cause a transmission error. + */ +#define RKCANFD_QUIRK_RK3568_ERRATUM_12 BIT(11) + enum rkcanfd_model { RKCANFD_MODEL_RK3568V2 = 0x35682, }; struct rkcanfd_devtype_data { enum rkcanfd_model model; + u32 quirks; }; struct rkcanfd_fifo_header {