From patchwork Tue Sep 29 21:15:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 1373406 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=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=VuJYVyRF; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4C10JG3Z6Cz9ryj for ; Tue, 29 Sep 2020 23:15:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729925AbgI2NP4 (ORCPT ); Tue, 29 Sep 2020 09:15:56 -0400 Received: from mail-eopbgr70071.outbound.protection.outlook.com ([40.107.7.71]:52705 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729532AbgI2NPw (ORCPT ); Tue, 29 Sep 2020 09:15:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k54g+0+7YsXO1Fwh9h9YYM6tX53rcvkaDbguRLQO4SWZtzgJ9xbusg+979kdr4wvRvTwP9VoFPscM8pgbdcsmBQGYOfl6kQNEkK/KB8P0yfoXi5ZnRoc6/bWMUYEtK3zFio4c/elpIkbndEcgDCBRO6ujg9XMGmM8TffATuJmL1KGjP0ggXxfjnMDCYmpkCJ1MKItd83enSE/a3flQQ3iS607lCa676EGeFjZkwi/wk/9aNAIxFgm57T8SFsx7L5AaJ7NyoGDQMKJjsuv2wce41t5fhgBsanw9+0ZD++NpCAXQlLjYtzqF9mIKBB4farHKGxFT3oLn3aVRw701gCXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5DYWCvDiEz8KOFy9XGfuRH5656gDSbnLgj3VR4w0Pnw=; b=TWuxgOHraOEAztRerMQtYjqU8cctNx/OuYJIAaEbFgVogWVlH2ZPYxMuGzzpneBTcjeMQ5bPmiKb31M8W8QtXkA/nf9ZTfoTRrsgT/ow5ZRC3kPnZpuOQ9D+bUqVYyfQ47e3pd9ii/omTdStL8/X1lIpBNOTWgwjl3SrNYkMfL4gOMe58MTCwgST54pFS4GwRc+MqhkoV/3jvEolRqovdZxtkth1PlMQnqNp/28PugtoVSqjlnFgAcM0cwVBD+BHJENh1LctMA+606u8kYg0hqwk9exXVvaPuxP7rLaU9jJ5+shWP8q1j/cG6RZf3zuARv79I061hFNqUR10w/32mQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5DYWCvDiEz8KOFy9XGfuRH5656gDSbnLgj3VR4w0Pnw=; b=VuJYVyRFcVdusB6U9Eb/xrn1Qk9mRgYRjgXpUt0EfCKJ1Ggkv78xM9giq2EHjYhqqD0cVunhvzv7MjGmHdmFlcoQUW5+5XSGMauEfzOL10muBwiMfMkiwRyjh11XK8eV9d/SJIqBpCcT/0njQgjhzdpl12fvyFr2jDQv6UWeyko= Authentication-Results: pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB6PR04MB2967.eurprd04.prod.outlook.com (2603:10a6:6:a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.28; Tue, 29 Sep 2020 13:15:48 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::d12e:689a:169:fd68]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::d12e:689a:169:fd68%8]) with mapi id 15.20.3412.029; Tue, 29 Sep 2020 13:15:48 +0000 From: Joakim Zhang To: mkl@pengutronix.de, linux-can@vger.kernel.org Cc: netdev@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V5 1/3] can: flexcan: initialize all flexcan memory for ECC function Date: Wed, 30 Sep 2020 05:15:55 +0800 Message-Id: <20200929211557.14153-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929211557.14153-1-qiangqing.zhang@nxp.com> References: <20200929211557.14153-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.25 via Frontend Transport; Tue, 29 Sep 2020 13:15:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c1babf27-555b-4250-0c20-08d86479c798 X-MS-TrafficTypeDiagnostic: DB6PR04MB2967: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s6AsR9qFGtGUPpX47tgfeqSa7TjTHVGM3LBCWXNw2kJ6p/jxX3OBgAZ+l87Kd1ZJ4mMhE4xf53kB8DoiwzN0cyQDmI+RgZVsO2YKok70mCqoC1iGQQcjBjY0c3qWD6ZHDJBeAQvYXLQJgjvPoz34G3Aj3n8teH9w2ETPU1S+FOFp4YzH1PH3/HSrdrj6RUUafnHXd++NjVzoIznmcqES7ceuwanNZ8fLIsJe8RbamDt6veWYgJnX0d13Uwx4qpurdqZkV7L4WLUv7JG8VoH70w6U4+/pTElisuUgLBqcMUl9op7fDnxBxX1QMVHmXzHU7ltHgcjS6FvMLZDFwPsGz70y+1LTEmm81T3zITSVAwFKHMTIMKh3WYY6S0cSUYGGL7jAm9tfsiCfvPsQV9iwbuI12pK1ZXufaIg5gch/jY3qzQLXUo1CMZ0Lb7dvukPo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6795.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(396003)(136003)(376002)(39850400004)(8936002)(4326008)(6486002)(26005)(6666004)(66476007)(2616005)(956004)(66946007)(36756003)(5660300002)(6512007)(66556008)(2906002)(1076003)(16526019)(186003)(86362001)(83380400001)(478600001)(8676002)(316002)(69590400008)(52116002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /SE+LbrkmveeUrJUiqAhCZmjRPc5UAaXleSlwOEyCZrB1X51szKaQuV3AKwccOtXgHCarkAQvQSv+OoIBAfHV00ZO30OdjNgmv5RwaFD2Jt7X4hpQpMX6ss6s/rRgWCUV/1MV2jZVdIsxuqIy8wPCOpU810Olc5dQDjoH88pVpx4ik7opJGVCayYAsruQxEzj90kdqXXJBo+7nzMsTjuE84p50G53b6E2NY+kluh9Xu7DSFmckI/TdhNGtHfZsNiAD2rmkOUafO0Zo+e5gY2Yd8zlIyaex16RjZGt5qYKc/ZiIKzooCuLnFFVsibRMRse8mN2bHQhCH/eOFKlO9WBF2zW8P6T7UTJKDcttzy89qUK+lue+PnCBfuYDc7vaq1rYe3EyjMqQmNPX9OgNYvZer8pbSk8e3X9NH8VNq1xcjvzS97na89j0sfDtQ0XiJHgrDXv9bvPsp6u5irkADaN3YeiO1wxDaXeA3pPjSHE9z0rifjJ5xwiqBadMrLnCX9E18zyRYn0KvXuVvMdGc41fJDXyaQYZmhgNCkmRyPvIlFyjxFEvp52l0pwxb6vi9N4yRQXjJiJmElD98xUOIT0iZTOFMAqNBKI0jYuZ1yIvxVNAyf5TXM4i/0pzlL8pPWG4d/+sLKnGKqwTS66r03CQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1babf27-555b-4250-0c20-08d86479c798 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2020 13:15:47.8840 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZWG+0AL3wpdZ/5XkYIT/ezcwHUFaj3d3h7yU6z8kpEolxy0GY2WLA1YUluq7OiQUolcbyoq3/J8CcBxDjQ6tsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB2967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org One issue was reported at a baremetal environment, which is used for FPGA verification. "The first transfer will fail for extended ID format(for both 2.0B and FD format), following frames can be transmitted and received successfully for extended format, and standard format don't have this issue. This issue occurred randomly with high possiblity, when it occurs, the transmitter will detect a BIT1 error, the receiver a CRC error. According to the spec, a non-correctable error may cause this transfer failure." With FLEXCAN_QUIRK_DISABLE_MECR quirk, it supports correctable errors, disable non-correctable errors interrupt and freeze mode. Platform has ECC hardware support, but select this quirk, this issue may not come to light. Initialize all FlexCAN memory before accessing them, at least it can avoid non-correctable errors detected due to memory uninitialized. The internal region can't be initialized when the hardware doesn't support ECC. According to IMX8MPRM, Rev.C, 04/2020. There is a NOTE at the section 11.8.3.13 Detection and correction of memory errors: "All FlexCAN memory must be initialized before starting its operation in order to have the parity bits in memory properly updated. CTRL2[WRMFRZ] grants write access to all memory positions that require initialization, ranging from 0x080 to 0xADF and from 0xF28 to 0xFFF when the CAN FD feature is enabled. The RXMGMASK, RX14MASK, RX15MASK, and RXFGMASK registers need to be initialized as well. MCR[RFEN] must not be set during memory initialization." Memory range from 0x080 to 0xADF, there are reserved memory (unimplemented by hardware, e.g. only configure 64 MBs), these memory can be initialized or not. In this patch, initialize all flexcan memory which includes reserved memory. In this patch, create FLEXCAN_QUIRK_SUPPORT_ECC for platforms which has ECC feature. If you have a ECC platform in your hand, please select this qurik to initialize all flexcan memory firstly, then you can select FLEXCAN_QUIRK_DISABLE_MECR to only enable correctable errors. Signed-off-by: Joakim Zhang --- ChangeLogs: V1->V2: * update commit messages, add a datasheet reference. * initialize block memory instead of trivial memory. * inilialize reserved memory. V2->V3: * add FLEXCAN_QUIRK_SUPPORT_ECC quirk. * remove init_ram struct. V3->V4: * move register definition into flexcan_reg. V4->V5: * use offsetof instead of cast --- drivers/net/can/flexcan.c | 51 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index e86925134009..8e4c27d9e1b7 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -239,6 +239,8 @@ #define FLEXCAN_QUIRK_SETUP_STOP_MODE BIT(8) /* Support CAN-FD mode */ #define FLEXCAN_QUIRK_SUPPORT_FD BIT(9) +/* support memory detection and correction */ +#define FLEXCAN_QUIRK_SUPPORT_ECC BIT(10) /* Structure of the message buffer */ struct flexcan_mb { @@ -292,7 +294,16 @@ struct flexcan_regs { u32 rximr[64]; /* 0x880 - Not affected by Soft Reset */ u32 _reserved5[24]; /* 0x980 */ u32 gfwr_mx6; /* 0x9e0 - MX6 */ - u32 _reserved6[63]; /* 0x9e4 */ + u32 _reserved6[39]; /* 0x9e4 */ + u32 _rxfir[6]; /* 0xa80 */ + u32 _reserved8[2]; /* 0xa98 */ + u32 _rxmgmask; /* 0xaa0 */ + u32 _rxfgmask; /* 0xaa4 */ + u32 _rx14mask; /* 0xaa8 */ + u32 _rx15mask; /* 0xaac */ + u32 tx_smb[4]; /* 0xab0 */ + u32 rx_smb0[4]; /* 0xac0 */ + u32 rx_smb1[4]; /* 0xad0 */ u32 mecr; /* 0xae0 */ u32 erriar; /* 0xae4 */ u32 erridpr; /* 0xae8 */ @@ -305,9 +316,13 @@ struct flexcan_regs { u32 fdctrl; /* 0xc00 - Not affected by Soft Reset */ u32 fdcbt; /* 0xc04 - Not affected by Soft Reset */ u32 fdcrc; /* 0xc08 */ + u32 _reserved9[199]; /* 0xc0c */ + u32 tx_smb_fd[18]; /* 0xf28 */ + u32 rx_smb0_fd[18]; /* 0xf70 */ + u32 rx_smb1_fd[18]; /* 0xfb8 */ }; -static_assert(sizeof(struct flexcan_regs) == 0x4 + 0xc08); +static_assert(sizeof(struct flexcan_regs) == 0x4 * 18 + 0xfb8); struct flexcan_devtype_data { u32 quirks; /* quirks needed for different IP cores */ @@ -1292,6 +1307,35 @@ static void flexcan_set_bittiming(struct net_device *dev) return flexcan_set_bittiming_ctrl(dev); } +static void flexcan_init_ram(struct net_device *dev) +{ + struct flexcan_priv *priv = netdev_priv(dev); + struct flexcan_regs __iomem *regs = priv->regs; + u32 reg_ctrl2; + + /* 11.8.3.13 Detection and correction of memory errors: + * CTRL2[WRMFRZ] grants write access to all memory positions that + * require initialization, ranging from 0x080 to 0xADF and + * from 0xF28 to 0xFFF when the CAN FD feature is enabled. + * The RXMGMASK, RX14MASK, RX15MASK, and RXFGMASK registers need to + * be initialized as well. MCR[RFEN] must not be set during memory + * initialization. + */ + reg_ctrl2 = priv->read(®s->ctrl2); + reg_ctrl2 |= FLEXCAN_CTRL2_WRMFRZ; + priv->write(reg_ctrl2, ®s->ctrl2); + + memset_io(®s->mb[0][0], 0, + offsetof(struct flexcan_regs, rx_smb1[3]) - offsetof(struct flexcan_regs, mb[0][0]) + 0x4); + + if (priv->can.ctrlmode & CAN_CTRLMODE_FD) + memset_io(®s->tx_smb_fd[0], 0, + offsetof(struct flexcan_regs, rx_smb1_fd[17]) - offsetof(struct flexcan_regs, tx_smb_fd[0]) + 0x4); + + reg_ctrl2 &= ~FLEXCAN_CTRL2_WRMFRZ; + priv->write(reg_ctrl2, ®s->ctrl2); +} + /* flexcan_chip_start * * this functions is entered with clocks enabled @@ -1316,6 +1360,9 @@ static int flexcan_chip_start(struct net_device *dev) if (err) goto out_chip_disable; + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_ECC) + flexcan_init_ram(dev); + flexcan_set_bittiming(dev); /* MCR From patchwork Tue Sep 29 21:15:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 1373407 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=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=gdIYxWeL; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4C10JK3q7Yz9ryj for ; Tue, 29 Sep 2020 23:16:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729935AbgI2NQA (ORCPT ); Tue, 29 Sep 2020 09:16:00 -0400 Received: from mail-eopbgr70071.outbound.protection.outlook.com ([40.107.7.71]:52705 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725554AbgI2NP7 (ORCPT ); Tue, 29 Sep 2020 09:15:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DpX4TNyh+594rRS0+ASzYvbH2da1O9dIxdBGMa6LMrOe/7sLSKGK4+enbjDEotzSzNlJ8OxD4RpG2/YAJxAN32B8rvLxNZAi4YTi/tDgr+h3ORKkL7rjw+JKpFqxJp7gt5qpW2AHcC32TDavBE0xkdxyiLSeo54go669BIjAe2SMsjW7M0r4r/Aw4oYDdRwCn/AGmNxfKESW4Qv/yDtbHpQfR9kMvxEWVyqgovM9WTlj3dNBsj0kk1Jf258YDnM6/xwDLtonOX1bD1X9FLx6c+j5LrQQauGk/C2RSD6iUxXT4Pxx8ve5VKrpdq04bl1mwhAmMkBDgNNIv0XNVPtHog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t7vltm/bJ+9JZXr4ZPK+P+mx4pvyG4E07xLm/hjBAug=; b=Wx7o+f6MH5QLxpPa9fYr4C332Akn4OJ6Hd42WqUzscuSv1GKjn33dkjjlYVZwdrb6/lAV7yTX8mXpxKnZRQ4g3bwcoisArLCYjfdzcJZDl2dKfd38Lvpdhq+L1K1+2rD9ltYPznk10LJ4EI3bh2vfuIkqtW6U3pG0S2SFKWTM4fhK7vWm56kx+7XH6VhVXtFlBkOcaAmjoVGYZ4dynt3Euapk0QV8UqSSs9iiD1modFHYTRBQLq3yt6ap5V5561IV5Wsl50R19k+LclT3Y/uMsu2N8A7b4y0BSNcjwTk6c1U6T9LU/NUTF/xDz/R+CiW2AQur9sYip0TOT15LYxbwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t7vltm/bJ+9JZXr4ZPK+P+mx4pvyG4E07xLm/hjBAug=; b=gdIYxWeLD3qM/fdh45/k2oPVaA7YrTubtVMRBrkdLUpuLDmODqOOvBgwGZDNHNDNV5TD4nmd7Befq2c939Prs6BLMkg5hrcg1C1RC5jidt+gtYxyQYi/CL5EOEgRtES77/o/VuAAJOk1mHU1eRE96WZsRZGoLSHuLw1Cbmnd6Fc= Authentication-Results: pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB6PR04MB2967.eurprd04.prod.outlook.com (2603:10a6:6:a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.28; Tue, 29 Sep 2020 13:15:50 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::d12e:689a:169:fd68]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::d12e:689a:169:fd68%8]) with mapi id 15.20.3412.029; Tue, 29 Sep 2020 13:15:50 +0000 From: Joakim Zhang To: mkl@pengutronix.de, linux-can@vger.kernel.org Cc: netdev@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V5 2/3] can: flexcan: add flexcan driver for i.MX8MP Date: Wed, 30 Sep 2020 05:15:56 +0800 Message-Id: <20200929211557.14153-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929211557.14153-1-qiangqing.zhang@nxp.com> References: <20200929211557.14153-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.25 via Frontend Transport; Tue, 29 Sep 2020 13:15:48 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7b1bab17-3ed9-4a34-2412-08d86479c8d8 X-MS-TrafficTypeDiagnostic: DB6PR04MB2967: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1122; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uFpr0HBHer9q7E/1RrNiGuaclSW9YJ9ho9CqTDs21weGfQpZ6YaeROOGagRSrvtJR3Zm7wlb2I9E7sZvCeY224LuXzJslbm3ty7q5ZUg2ZjAVxEfTL+FFGbUhlQiSnhdEX2hsvomuSdIDs49dy9oNb7a0/c3I56DNm0bLSrvj0qm/Jp6Xo9LgUsW/wtBtsO9+A+y63MoMl2KgUC9ncehucnM8f70gSCaiw0VUmqRtCS8A4T8fYQHKCPhR/5R9rrp79+dg/smwirubGq0dMIlNCmCa/I8qj+TBnP1nMOSJ74syityZMt7Jt+Vrp+tJ5Dh+7kZGGYReJW0h7+wk2IRlVFB5BOxNBaOIHRMvx19TBN8pd0j8kC/P+/kUm7tAbXIoximKKJyKZxABch7MJ2P2csmNhJ3Q7ukJXpVfrmKUsChYIgHWXs0KdokxCohyeAR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6795.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(396003)(136003)(376002)(39850400004)(8936002)(4326008)(6486002)(26005)(6666004)(66476007)(2616005)(956004)(66946007)(36756003)(5660300002)(6512007)(66556008)(2906002)(1076003)(16526019)(186003)(86362001)(83380400001)(478600001)(8676002)(316002)(69590400008)(52116002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: S6UgFmt8g3jLPrEhO6JbyaeYCLkjaAEeSRpmA3KF4wCyuIzVK48n1pNRTtV2qhPl0jbdYqKXaoqIwH/dl0tAR3CGUftKMc/ZZe0eAXt+2DonpenQ932BhqkRL0PIdx1Idvel6B9f3nlljdV4wIGnbV6M8UoHqvIq4y+zOTrJ1LzHFNkM6OndmS95dXUWiTowMbnuo8jtCAks5M6oZxO6jYE8Kr8P9vREBG6s0LLt7QuCtuAMJsBE21gZbiznYIFeUssPpx6tD2xS5jJbbFEzwiBp8ipl+Ho3vBkZx2iTQ/twXeWpwC/xw/CcArufOnLJowxTJaozXOvXqNGyK7xi693ruyMiJCQwInhm9l3oJ2Uk7/YgTfmU7zsotM0qdG5JCVz+lvgwlx4yqPivlZZqF/R76bnngfOAzdkSIr5qLpw18A6IQy1CnbvR5zlG69PDN9Gt/mHF9BvaG7zwSF6WNh4LqTK5z2FNaIPAbf9CmdFWXyOSCLTAvVR91h6WuKbWTzY59wrYPZh+OEfKcr2eCY5hBbXmT8KCvhu8/+xa6Re14r3o9bLOFBWWc7NR1h1lK/B1SamGcGgjPFuNZqiGSTBPVbesgoWe0O3mZP8LFEvSXsq8TiGUw5h8CcNshlQbeW1OZUbjLZMCQUGVydxJ+w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b1bab17-3ed9-4a34-2412-08d86479c8d8 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2020 13:15:49.8842 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Di2FNMVkajO1PQUAivqI9uXhhuiUTkSjRx9BkuFkUA5VMsxdqEiJW3XfSrXXk/XCh1X2M8O7TbmsvMxhuFsQOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB2967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add flexcan driver for i.MX8MP, which supports CAN FD and ECC. Signed-off-by: Joakim Zhang --- ChangeLogs: V1->V2: * sort the order of the quirks by their value. V2->V3: * add FLEXCAN_QUIRK_SUPPORT_ECC for i.MX8MP. V3->V5: * no changes. --- drivers/net/can/flexcan.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 8e4c27d9e1b7..1ab12774cbbb 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -214,6 +214,7 @@ * MX53 FlexCAN2 03.00.00.00 yes no no no no no * MX6s FlexCAN3 10.00.12.00 yes yes no no yes no * MX8QM FlexCAN3 03.00.23.00 yes yes no no yes yes + * MX8MP FlexCAN3 03.00.17.01 yes yes no yes yes yes * VF610 FlexCAN3 ? no yes no yes yes? no * LS1021A FlexCAN2 03.00.04.00 no yes no no yes no * LX2160A FlexCAN3 03.00.23.00 no yes no no yes yes @@ -391,6 +392,13 @@ static const struct flexcan_devtype_data fsl_imx8qm_devtype_data = { FLEXCAN_QUIRK_SUPPORT_FD, }; +static struct flexcan_devtype_data fsl_imx8mp_devtype_data = { + .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | + FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | + FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SETUP_STOP_MODE | + FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC, +}; + static const struct flexcan_devtype_data fsl_vf610_devtype_data = { .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | @@ -1892,6 +1900,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev) static const struct of_device_id flexcan_of_match[] = { { .compatible = "fsl,imx8qm-flexcan", .data = &fsl_imx8qm_devtype_data, }, + { .compatible = "fsl,imx8mp-flexcan", .data = &fsl_imx8mp_devtype_data, }, { .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, }, { .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, }, { .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, }, From patchwork Tue Sep 29 21:15:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 1373408 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=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=OreiYIdX; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4C10JP2NbMz9ryj for ; Tue, 29 Sep 2020 23:16:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729873AbgI2NQE (ORCPT ); Tue, 29 Sep 2020 09:16:04 -0400 Received: from mail-eopbgr70071.outbound.protection.outlook.com ([40.107.7.71]:52705 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729294AbgI2NQC (ORCPT ); Tue, 29 Sep 2020 09:16:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNz6BDMulP0tLxTuj5N+uFn2i/g2YLzfKIiTdImEEfby11NDJrLZoJdKC/CrhhH2A9G24KrBjagkASkpEkkQv9WVV13Q+Ag5PvAdYMDXeFvLuz1ydDCMPezANwmwwOHpy2WLTeBarGlZcd6cQuMDWKQsfbhOndgOQ3e6I5FB8a42bzEvNHHCVMmTNgnwP+H4/S8nOMFrtMhyL68UYwZRsDzKeLjGu8DyHHyR9HPMTPnSpAlh1rmaPdvJkd/V6dSJNGwpISvYAMwuG356U9g88L14gy/iV0i3rJWyNswRqz1+nhg0VEZ2o558kKoNYmXDNghEJ6SaRO4tIXR8W9YnxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EZ7YUelM7F0lAjcqYwYnDrx3azGBgOP8EC+g+CU14eY=; b=lRxf13HHAxTMqgr9X5rzjz5SnDrRoGjzSy1ghK60ivZEo1wif/WsTcnfZufF1nPSANs9HJBduVF5mWWMFysxOZdTpcuUsa5ZM8HYZI2gdSW3KEIzI55hOA4lNZg0XqYGv1rWqWvbn3wgkYJ2DxM6unv4Atj7wiMdZsFb5rPMWl7JTGdS1P3PSUJdcw3F7+1l/09fCO8vQe8YTBRJL5sDMPe9l7ap05fm6AxbmM8rzgBhUl9ANXZSv1N2kXHsocZffjZDadcEL+2BUFmlG1Sd/GJRjZXUFbOIlZrkYRTEC18Xh1RnskbP1EgAqJNUF4l4fRbYnXaryUmsCxSsnefNSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EZ7YUelM7F0lAjcqYwYnDrx3azGBgOP8EC+g+CU14eY=; b=OreiYIdXwuvXV8gRpNr9j0FK6vB72zMyZXqJB7kESNqLnVj281/1gpST0DAXYHwMbAzc+TdhKaCjHTCRHaXMr97V/MLoN5iY9krWbiBHL+tGdOHCdTKNH7SeF5C5JoaIo11Ap03DCeqE/2mjWjA0Cu7MAqX7vL4kzAI7XryWWfI= Authentication-Results: pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB6PR04MB2967.eurprd04.prod.outlook.com (2603:10a6:6:a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.28; Tue, 29 Sep 2020 13:15:52 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::d12e:689a:169:fd68]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::d12e:689a:169:fd68%8]) with mapi id 15.20.3412.029; Tue, 29 Sep 2020 13:15:52 +0000 From: Joakim Zhang To: mkl@pengutronix.de, linux-can@vger.kernel.org Cc: netdev@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V5 3/3] can: flexcan: disable runtime PM if register flexcandev failed Date: Wed, 30 Sep 2020 05:15:57 +0800 Message-Id: <20200929211557.14153-4-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929211557.14153-1-qiangqing.zhang@nxp.com> References: <20200929211557.14153-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.25 via Frontend Transport; Tue, 29 Sep 2020 13:15:50 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 02a8f2ed-1da1-4123-8604-08d86479ca07 X-MS-TrafficTypeDiagnostic: DB6PR04MB2967: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:421; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XzhOW69m2LfmgAEqPilEVIbnFpt3UdvR85eB5IE2GaaIuMECn7mrL6ubPakM2Bqatk9ED27h4Cl91te7bSMq2sK4yr1fdwLsTa+dyhfb8XrucBm0d4ZJaSekmYvgv4wW4b4ZJNvzeyHKKHQjXLOJ7BfZ559la5ofzH7znejZ1JtkoN/tnII6PIyrEbPjcUSiyWUMpZqpudM6ILRISOXS88KdI6wgqo/QVRGllc/73b18pLqmlS1P9wa2o0LgPwiNW5HX71Cd26/oeASZ3e5CBqfWEkiU6aoBqC8to4DcUSsNTDvGMTXUDodTlCBu/0lQbsF9RbnrtjC/yV2I2ryGaxPJuUAg65BVA85T8lCLysO0/gkYsPqZM4qs3yfys7sgwvyftyjPmDycwWcyQy+srpvaavEymxOBhEp6OIauz9y9r1D7Rb276y3T8UnVdZ9m X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6795.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(396003)(136003)(376002)(39850400004)(8936002)(4326008)(6486002)(26005)(66476007)(2616005)(956004)(66946007)(4744005)(36756003)(5660300002)(6512007)(66556008)(2906002)(1076003)(16526019)(186003)(86362001)(478600001)(8676002)(316002)(69590400008)(52116002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9YxfvEGZPuhb3LUTg84InR4rtkxKg4sOyQ3kIDiC8p1xMO16RgP3VNPWiMtXFfDczU+ax6nIk/cAU8PSu0A6u1SVeMXhziYOAG3tZu0gdfPpWJa3NSp712sKPlmAwsTvm9He4gD1LVMgeBZaxb9/vn3xwU5EuXbB54EKuH6hbGDePw30tr/mXP+7kE6vmG4PZvbQCSEIygRvEz6YsrXLmu2qPCI89/cOv/0f+6Bu+zVVibq/FJxyF2yJq+Q5HqAWa+IqRKwsuiJVSBggb8DflzWUKYGh5wYa2jCmOaKhLNDvhcm9Wc2LKd58GKGhQZUl5sWvEqv7nO0Ni/gPfdeTtKvJhErSnDnWkX+7Px7h3G9J2vawB6F9U3eJiOXOe9vv1eCI1GRp5whbBJv0UWDn1aSwxHUNXiDHDMQLMSlzr+UkCgpHBvo9op96MXOS9hMRI/84XbUziU51TX80vQny60bdXvOZc/7z1QzJfdc/I7xOAWyXy1Ac4YlKfTgxacJDmnW0dh3/an38A3ATDNaFytZDDkG/lNQ09RVA7t3nXXsR2gLHP8QZd2/W/V/spajbwKKeuZNXUrbQrlUp9N6088h9XxBXGc/hloC1XThN84tzauOU4L9J7rl8+ar8VzsQkrvFy1xEDcg+2fP+/h66nA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02a8f2ed-1da1-4123-8604-08d86479ca07 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2020 13:15:51.9581 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AnYvC+dunAvETaAD268MD9iidPLYgz7dkxMF4ZlbH0ztyOXdoZh1eK4zp8G6cBU+fV4fiZOkqUeeVXyxIvYr2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB2967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Disable runtime PM if register flexcandev failed, and balance reference of usage_count. Signed-off-by: Joakim Zhang --- ChangeLogs: V1->V5: * no changes. --- drivers/net/can/flexcan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 1ab12774cbbb..f32660fee92c 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -2055,6 +2055,8 @@ static int flexcan_probe(struct platform_device *pdev) return 0; failed_register: + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); free_candev(dev); return err; }