From patchwork Sun Sep 27 16:07:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 260092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B568C4346E for ; Sun, 27 Sep 2020 08:08:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BABF023976 for ; Sun, 27 Sep 2020 08:08:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="LwOe63CN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730464AbgI0IIA (ORCPT ); Sun, 27 Sep 2020 04:08:00 -0400 Received: from mail-eopbgr10049.outbound.protection.outlook.com ([40.107.1.49]:61957 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730358AbgI0IH6 (ORCPT ); Sun, 27 Sep 2020 04:07:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gryz/iAXFE2wzMrld8yM8NmAXlxtvu5KZM03iu/VmGil+HQhaGqxUjqp93MGB9KBvEItmEBIjTe+Cl+LvSDpmmSdmoZBvJ5Lnwvti5gpTKyKVyidt40BfxTljmhitjWLb+kLttC+coL+HNbn6HzofK+6PVAWUdu1lPnrPtiMP/dlvtKGQiFJ/8E7OESdm+OUGuo+37HPR+Zu0ogx445boRgAvWU0Q9nipgiJ0edx2EM/4V2HMERBw8goZL6drzCudIVtAPVRoLoAGuTRfubL7X5Ia+v5dPZoXrUB3KALrPOvmkmQcNIioo8fQVegBwtFF9l4pBc9X58LbG28h3m7Eg== 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=pTbtTu/8cQIUeSHoYbNh3Q/39S8DBuZsEbmdxyE8TNI=; b=fscy6peV7vRWmWCfYUUQSsa4Mi1pOBKRL41GTqcTW9Zis4KmuM1f2vGTJM96qrER5Qvt1TDyvi2WiNOTRZK5Ma/PSC7aNEo9gTM6HYOlC8tZCNS6HXs6y0i8yKVDi6ZtW5j2ufiQsL85NLYYSEOuMHmi4MhSUtHFNnMmg/xgF+pAkMtbQhCqM1pP5R5PCf59BftgRN6tQpjxNwC9HgrpLit/Dv/rDdAqR/eJ80Xjg2+jbQp4KuAF7Rl0uDJTjQrv0/8tlvQm2cfCWvSCUIiAjid9p4Tu6i/PxWgRrVHgnpH620k6khRIAeZUnpwRLX7OFbAzoF2m25+VaM8OcH24kg== 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=pTbtTu/8cQIUeSHoYbNh3Q/39S8DBuZsEbmdxyE8TNI=; b=LwOe63CN+uibdp3soyLd9Yo19r0e+w1CDgRG5pF+BHJzdHibtbruQUxHZvWIn4+UhGL7Uv8e+e/xhQaWrHTPE8Kw17BOnvGB9hOMtBS/C52UECRA4vdCuNxh0wXRWGaLP1wm0zbpC4Cec2igY0mdjWPCYz4k8td4FcfQmcA04TA= 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 DB7PR04MB4953.eurprd04.prod.outlook.com (2603:10a6:10:13::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Sun, 27 Sep 2020 08:07:55 +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.028; Sun, 27 Sep 2020 08:07:55 +0000 From: Joakim Zhang To: mkl@pengutronix.de, linux-can@vger.kernel.org Cc: linux-imx@nxp.com, netdev@vger.kernel.org Subject: [PATCH V2 1/3] can: flexcan: initialize all flexcan memory for ECC function Date: Mon, 28 Sep 2020 00:07:59 +0800 Message-Id: <20200927160801.28569-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200927160801.28569-1-qiangqing.zhang@nxp.com> References: <20200927160801.28569-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) 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 SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 08:07:53 +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: dfd08f06-a9e0-47d1-674d-08d862bc7032 X-MS-TrafficTypeDiagnostic: DB7PR04MB4953: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: obDGq/hzfYfNRTzUwwJoYpOqjVo/tesOxdndEupVMLkAIX1IXm3x56Y43rKhGjsPH2LC0eueAN1lnlQ4ktXAmMR+qKXF83l6OnzLLFwIHiwxUaZR1BnEF2Zdu8N80L6ttJ8Al6UajaiO8NtnTEAAMvUojxmrF0nBx00HakzrFTrafpqB7HVo3jybZrA8jBL5rE1WVsnmJPPoGFyBmgJWhwNa7zpcisw9ZgyCxchW6Aa/hDtPssOC+8GM3eH6EY+Kh/2kMKKH5to7EbLRSaZnf1FgDZ8Hh/T7IPssg2gOBrndZSVfJBpJBdP3nupvxx9F9XodMSpSnd4Li1kCffqN/54vjNydqcfflLslak5ievBCKMXX5yFTxHMRVfTMCzSQ+G2CDhNAbU90k3iwpbRXmi9J6Swi+qxpZPoRQJeKq7D+bl9++yeTn4VWG/PhOcLD 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)(136003)(346002)(376002)(39850400004)(366004)(396003)(4326008)(2616005)(2906002)(69590400008)(66556008)(66946007)(66476007)(5660300002)(16526019)(36756003)(186003)(26005)(6512007)(83380400001)(86362001)(6506007)(8676002)(6486002)(478600001)(8936002)(52116002)(1076003)(316002)(956004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: k/Bssyc14eAJRjXVvKZZItZktd9W5uK+NTL7JTGeYgCdHxhxBUtQv9Tw0a9jNAr2txMmFie7vRo4rxqV2i/31D1NO5jQwqh9cnflcoBBl/DI9/FuC0FupesQO2/InnAN1okInBKVB3fTK3tvSUYSkdgyA+rm4ks76ekKxGi38VYEATx7ilKOK76to3fo/booR/XgMhUrc0hrngI7r79hHvxilrXsNnbExQCL7zpcWY2SJ7Q6cYbDpoHRqUfRWLtkO7YNJ6jnJcmmXHeU0/TfTdkYtDe7vUlEfmx1+DvysdXv7ApiywFriF3CX03uQIOeq4W74MTYa7Ym1ES4kniXJxpR3yY49w744p8F7j4PudkvslRSLR74ZhlUxw7bl6d87zyGtq3vw+fTdrQ4ko0aPLoT3hdUpGEoi5Wy7FnwpuPDanfyuRA+0QxZtfR3WBxZaznCPQhBoJ4Nk6VJ++gfbFYCYG1eFPDx9ouL+tWixSNq+Y+JW6A6WMojzWK9HJ3bDf65x0yXPhCWV0YFVQI1tCO38uAOTj3TRj7jMEV+h02h7+xTU0JOtG/elkPqbjTVozaCDGdxatSJqEppliKoT48dT5y035Sqv3bQY8BtqRX020/aGeOF02q8SvYQ0Xrn02mDNNpjXoGIQAtiM4Hp3g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfd08f06-a9e0-47d1-674d-08d862bc7032 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 08:07:55.0233 (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: uzb9zUg8KHppV2zbB3j4c0Q7yAGR5LRGhjnBS9hUFPLYEYalOybzTNXWFOkWgl2/nCM/lkKw2UmDiCe3Zxbg/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4953 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. 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. 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. --- drivers/net/can/flexcan.c | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index e86925134009..aca0fc40ae9b 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -309,6 +309,40 @@ struct flexcan_regs { static_assert(sizeof(struct flexcan_regs) == 0x4 + 0xc08); +/* Structure of memory need be initialized for ECC feature */ +static const struct flexcan_ram_int { + u32 offset; + u16 len; +} ram_init[] = { + /* ranging from 0x0080 to 0x0ADF, ram details as below list: + * 0x0080--0x087F: 128 MBs + * 0x0880--0x0A7F: 128 RXIMRs + * 0x0A80--0x0A97: 6 RXFIRs + * 0x0A98--0x0A9F: Reserved + * 0x0AA0--0x0AA3: RXMGMASK + * 0x0AA4--0x0AA7: RXFGMASK + * 0x0AA8--0x0AAB: RX14MASK + * 0x0AAC--0x0AAF: RX15MASK + * 0x0AB0--0x0ABF: TX_SMB + * 0x0AC0--0x0ACF: RX_SMB0 + * 0x0AD0--0x0ADF: RX_SMB1 + */ + { + .offset = 0x80, + .len = (0xadf - 0x80) / sizeof(u32) + 1, + }, + /* ranging from 0x0F28 to 0x0FFF when CAN FD feature is enabled, + * ram details as below list: + * 0x0F28--0x0F6F: TX_SMB_FD + * 0x0F70--0x0FB7: RX_SMB0_FD + * 0x0FB8--0x0FFF: RX_SMB0_FD + */ + { + .offset = 0xf28, + .len = (0xfff - 0xf28) / sizeof(u32) + 1, + }, +}; + struct flexcan_devtype_data { u32 quirks; /* quirks needed for different IP cores */ }; @@ -1292,6 +1326,36 @@ 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; + int i; + + /* 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); + + for (i = 0; i < ram_init[0].len; i++) + priv->write(0, (void __iomem *)regs + ram_init[0].offset + sizeof(u32) * i); + + if (priv->can.ctrlmode & CAN_CTRLMODE_FD) + for (i = 0; i < ram_init[1].len; i++) + priv->write(0, (void __iomem *)regs + ram_init[1].offset + sizeof(u32) * i); + + reg_ctrl2 &= ~FLEXCAN_CTRL2_WRMFRZ; + priv->write(reg_ctrl2, ®s->ctrl2); +} + /* flexcan_chip_start * * this functions is entered with clocks enabled @@ -1316,6 +1380,9 @@ static int flexcan_chip_start(struct net_device *dev) if (err) goto out_chip_disable; + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_DISABLE_MECR) + flexcan_init_ram(dev); + flexcan_set_bittiming(dev); /* MCR From patchwork Sun Sep 27 16:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 289549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5DBCC4727F for ; Sun, 27 Sep 2020 08:08:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 925D523977 for ; Sun, 27 Sep 2020 08:08:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="F2kMQwE1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730482AbgI0IID (ORCPT ); Sun, 27 Sep 2020 04:08:03 -0400 Received: from mail-eopbgr10049.outbound.protection.outlook.com ([40.107.1.49]:61957 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730443AbgI0IIC (ORCPT ); Sun, 27 Sep 2020 04:08:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J62KWlkeVy7ZVO4yD9F7Y27Kn0sLOAFp62mk5fi53j915+TOtzDJAjS0MmNPjBsNhg5yUs66iMSAttSOsDL6UzmArsuZRQok1gW5X+KveUDxkJmcw26KyLUazteK4zrfCpeoMuromjDAHjOaAutklM9UDwVUa23ut9WQICGyFtSQyCyA6jAewj10YoGWQuKWbQ+lOaMn+wt7iH8L1r209Wd6boobDXAxrcTYZDZIgVRM3H6go+JO76dpuo5IS+IwHG0JiLe0Hi/smMSB2/NxA0KJrrpYAjnPlLXnVOXbsFsqTzL9sT/CL3ikGtgJN2lI1tQDO/GjazWEwxUNA2uddA== 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=ej+1gnBp+qQBj2X8daX2RaX/DdI0Ozkbv5W6apkIYJM=; b=clEOh7xZUuxyHPtSqmkX0+wOFBG7QMfEPeYSF9WCI0VVkwB3rWZpUpf+0+HfagmEkx5LtrcYGXT+Rdgi7ypm/CwQJS/rJaV1+cTTw3XlvsfGc7mVlzFQDlbfJqNMt3fUYPd4r65GWoo0hu/Y+MxXsCzvxt9Dzgi65xVbLtmPDFW4t2oHn0PffvQYEaZaUu/mZoLrC0HdyZcwhuGaoXBDgKbSebKTRKBLqyv5k64BP7dEw9+m6GowUVhOZnqu/TW7Xe7S05vz0yHoDst0sfNbQVTydCxKLxti0nc3KeYq8FaVAluvQK47cq7FBPGh3dzBe6PSjYIO8+m3ZodE4l+UBQ== 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=ej+1gnBp+qQBj2X8daX2RaX/DdI0Ozkbv5W6apkIYJM=; b=F2kMQwE1iK5yzOuxfUVFyJe+wF0bSZ59ETN/Xef67iATXPSqhqA9nEfqFVa4grkyP4pE5RLeouGsSNx9wm31cfnuu77wrixxo+8c/wFNh1qMdxAi9uAasdGtDUGAp0gezxgXG4KaICVUItYDPOphNWsBZIn8wJ67a3L2ckDzd/g= 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 DB7PR04MB4953.eurprd04.prod.outlook.com (2603:10a6:10:13::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Sun, 27 Sep 2020 08:07:57 +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.028; Sun, 27 Sep 2020 08:07:57 +0000 From: Joakim Zhang To: mkl@pengutronix.de, linux-can@vger.kernel.org Cc: linux-imx@nxp.com, netdev@vger.kernel.org Subject: [PATCH V2 2/3] can: flexcan: add flexcan driver for i.MX8MP Date: Mon, 28 Sep 2020 00:08:00 +0800 Message-Id: <20200927160801.28569-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200927160801.28569-1-qiangqing.zhang@nxp.com> References: <20200927160801.28569-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) 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 SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 08:07:55 +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: 4a7ce6ba-7610-4614-0a84-08d862bc715a X-MS-TrafficTypeDiagnostic: DB7PR04MB4953: 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: gfLTEPBkMntausi+6W2ceK0GdXYQBAl6kIddXimnmocOOpi+c6heM+t7l+LyoqIPxwYNNWsVDNDA71lR73FGXjI+39x3brBY5ugWaR6mxm2Zlg28g61UaXWCUS2bCV5Sk9aS8VTHkhCD9Ap6ESOBhi6ZV5ns3jphavcTN9g50TeeCrlYM+a0iOku1C98r6lB/qMsbVTuEC6Ru0dQSgo9EHIerSJ+sLT5yP7lX6QJr5MLFjtZ2utRzEz8JssyprSn32PtW/60+vhuTNi/wdCLiLf3n6zj5aCeRt0fHeBR688XmEMXNE7XK8DQ/WRPvq0+IjKBQ4eg5FkcNZ+/OIhnctDHyLylIAPCxz84t1NSubxshT+qgx9BrXnOt56ZC/rux+bIMhjA9onQBdmMIYPBewBHcjCrQcpNuYVqSuDhB+JHFGJPDWI1juqGbLpNngVR 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)(136003)(346002)(376002)(39850400004)(366004)(396003)(4326008)(2616005)(2906002)(69590400008)(66556008)(66946007)(66476007)(5660300002)(16526019)(36756003)(186003)(26005)(6512007)(83380400001)(86362001)(6506007)(8676002)(6486002)(478600001)(8936002)(52116002)(6666004)(1076003)(316002)(956004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YtE8do+rMHyV6DztbnD7yWGFO7Ku55OtrCwQy9GYazvieRjQeLP3/H5tAV9TDwlz9nG8kyeUoET4bMr9/mbml44zhMzTqI7Yyiuh4pma8rWDF5PoLYpTq2KKjbce+oSAxjBKEU2UtPQrpF1L0CBOjSrV0KRNAxbv45isWQvTNk/l+eiA9BZV6aLq8d8V5dgsynJLEMeGILJzg8kW2fBV/zHygN5gCjBMZe+l9YxVP15x1PC9vth7Kwbg6nldWH4Gknom2aADb6cGCHdmTnSR7E/extFVg2WVl0m0dRG/x05dGv6gX61kjhcUyXpsDPNSrmKcV1BAZxdN5twjOFfJhrgNSJbKgCYBXwItl1pwGi8D35WIa3Ye4PuZpssz1mXPpJSlRVXsmfUk+9Y1zRWhesfs4ZjhLSeqlphR0zRG9MJoBTddLjW4CFr2HuCbfE3TmrGjRJjgrPY8Y4E+YwCinu9CzCmkAJmigT8EFX+ePYKONmdjN0jups1QPBT+NQHZu1ScWOhPLVzTGjqDT1C++g8bFQ4eou6Sv+w6DRE/Nq6BfchOyVUpv8ZnM9g/RaiCAw0vFA+lN+gJzb/UwVPE5LvvP7RGwy4FcoWnRNb8OZKevKFTd8rjqhQAfyd9z1D+mvdd1z1MXObJB3iC47rlYQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a7ce6ba-7610-4614-0a84-08d862bc715a X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 08:07:56.9538 (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: 3wtlg22OnY1hP0Ovc/eoHFd/LDg79myKKyTz5cggsTgwcMLjTjQSMHmTfK2lig62XKAKFemcB1cdR3EBLabfNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4953 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. --- 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 aca0fc40ae9b..4844dbf77c9c 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 @@ -410,6 +411,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, +}; + 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 | @@ -1912,6 +1920,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 Sun Sep 27 16:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 260091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B530FC4346E for ; Sun, 27 Sep 2020 08:08:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E90923976 for ; Sun, 27 Sep 2020 08:08:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="gLKzDYwa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730493AbgI0III (ORCPT ); Sun, 27 Sep 2020 04:08:08 -0400 Received: from mail-eopbgr10049.outbound.protection.outlook.com ([40.107.1.49]:61957 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729125AbgI0IIF (ORCPT ); Sun, 27 Sep 2020 04:08:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WR1k1/GPcO/IWfP60elh5GAAoy05JbGfE11zWagvCjWazL9OXQe+bVkBbylTndAxLdyibssyCi6G1NrtvDNTrLVPN3mY/asZ9DDVNlomGAFb2BVQ8nOaxox2OH918ZUD292G6uo5OWN5ZEAEjuHi8o8abQ6bW+iDy0CVmXrrI6S8TjEE+BB7jHE1cgee90FFxxkriWjeY0MG7V9qgLLE0LC91UAklPxiuR12WlBiAKCCB/szGuuqWA11FrEzPchSWG9/yIsOTGpvAYqLcwei+UuRM6hNxJjqh3oB1y1nDU3yxXetWZnvM9gNtY0oNUyiWBcTW22yxXoRiqn/qo8cYA== 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=enP4Mok5JxOb2WmVj1GrWokgmAIuk3qI7EZPEGEfKCc=; b=fUFlUsSHP7/PIMsVEvd8zA9pcA6yKqyZHwQskBgah4OwbwbUcWA1YILVlzs6QUeiju2jQr18+0oPJb9eYT0SuZMW9DMT0RhniKPmwAdXoNu4rRCvJQ3iI/RquUcgZmcJOuaj5NFdZSckGYN+VNiSuQ9NVpc+Etrwi2ep0BT7Hy0DnxomCnj9j+gbMq5ZjBzQVDDCkrVK3mLMcpF8slH9Vwq8jl1XDVheq7ax/xKs393fs1w8GgAI8PNa+olm5ZClD9uQoddUCknvnQRUGO+2VPAdonCog29QwF4DTfLGx3LlHac1FFdeHN/ig0kjgdHrKmt5RWLk8U3waBC5ZTT6nA== 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=enP4Mok5JxOb2WmVj1GrWokgmAIuk3qI7EZPEGEfKCc=; b=gLKzDYwaqcpbOcH46Np5oBlNQAkq4o6zOicpmSjzQtXWjN4baJIvSbgOenj6H5xFrALe/tRbwmCV5AhSDCvy5ooGw5uP06hkL01A7L5wkiYb77YIm2vn+ZOJ0M+eF2rGbPsijZMj8Z6MuADpAeuMRpdHmUPzQNiNY1JQKXFDMoU= 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 DB7PR04MB4953.eurprd04.prod.outlook.com (2603:10a6:10:13::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Sun, 27 Sep 2020 08:07:59 +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.028; Sun, 27 Sep 2020 08:07:59 +0000 From: Joakim Zhang To: mkl@pengutronix.de, linux-can@vger.kernel.org Cc: linux-imx@nxp.com, netdev@vger.kernel.org Subject: [PATCH V2 3/3] can: flexcan: disable runtime PM if register flexcandev failed Date: Mon, 28 Sep 2020 00:08:01 +0800 Message-Id: <20200927160801.28569-4-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200927160801.28569-1-qiangqing.zhang@nxp.com> References: <20200927160801.28569-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) 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 SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 08:07:57 +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: 939cf9ba-abb6-4bdb-242b-08d862bc72b2 X-MS-TrafficTypeDiagnostic: DB7PR04MB4953: 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: lUjLzDNGuZA2FE5Qqk+DlcmfEZjn4i/t+ljQBIg0Gw8e8bkfF+5TiLL2Qac7JwvCBSekV4y/uMCHdxKI/RfjYtHO+5tjrYO7Kr3gGXZdRZbGZqUtW2HCa6CPsLailmKWXtAoOaGgsMHmDQ6Yp4zEi3rOGra+Mk/lr9KdrE2OEFDakZ04P9kRuNrVIsRLjGGLSOGGMR6wLqykaH2NKBgE59EbOp4a1oRsAg2UaE8aah8yHydDJ0Rddp0ah0flDcxnBGu4qcYRiSh8HbLEK1muveOt0yeICqxbo1kPL87OXJ5eFMTduFRz/3wuGWaW2ckPBus7qEQLLlnHwR4c+/YaUue/PeyV4+HlmUtAr7xHLGECiXo0CA48bC5J8VzyoN1KREeMgG69sW0hzAOs7f86OOHi1d2XPnXq/m5CwnkM7zxwOd7ZYw8IqYkfgBU3lDjK 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)(136003)(346002)(376002)(39850400004)(366004)(396003)(4326008)(2616005)(2906002)(69590400008)(66556008)(66946007)(66476007)(5660300002)(16526019)(36756003)(186003)(26005)(6512007)(4744005)(86362001)(6506007)(8676002)(6486002)(478600001)(8936002)(52116002)(6666004)(1076003)(316002)(956004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XoD6UGL/7YoUXVo1z6YpWvmHXsLhWp/vdbwQH2W2ICPByi2O491hpaLsqKWfahowI2sojQa/SaKaDUQtHgPFRWujoITV6K4H1tcCnFrwUhPNBglzG5iS3TPFUe94lOi7kiuswQKc0hk1XybUOZ0YUJ9gwhSxex0XoZnRqZ58rt654w1EnNPrXTnfPqeN/MWdL2wkLzT+Y5VIcWrg3fMxSDbR0KgiGXXPynPF31Woc61l0cwwakAesKIqZQGn4SFGAvZV9l8NUWhzurQbJpcpg5Ye+MzmugkmmLoFJmTaz1Bk+FqrYoEHOrezllxKriX1zA6F6KLon987+rG7cJmg53Oy6iSyPytxx9ukvYv7cxZpsBMeBMnb8ee/6/2C1+vKPfibyRIvBjJnv5NxUK6eIDk5gRBKcZSjE9t4v3fFGnvcNzyATtpzDrA2Eas/ItozDgN1VdUTC1G8lS0mu4h20HcNrGlGCexvYQj20MqUuhb55MQU9ygguR9+OUHmHKrRCx+oer8YZJOK6nqQcEp6Bdjq4zhbIRKtkeo0QagGUVUK3YrUnnmOLYnOka3BwPInpe3E+IJxgUVKgafROgDfsiBhTxISGw0aRNgsqptWuEjJklvEXdGBNURn7D/yHeoL+OoJW6ipYeD7sdTeau4KlA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 939cf9ba-abb6-4bdb-242b-08d862bc72b2 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 08:07:59.3353 (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: +dn81+JNbMZEAXbkm1hVPJ7ElCVOhHGR5q3+zO6KDYJyLrlFWkFo5efAVqOE0Zp1N0eFWmAT2hmGOzr5L0KAiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4953 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->V2: * 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 4844dbf77c9c..ee6d220a4b12 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -2075,6 +2075,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; }