From patchwork Tue Nov 19 08:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Costea X-Patchwork-Id: 13879482 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CED919D06E for ; Tue, 19 Nov 2024 08:11:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732003869; cv=fail; b=TxJK6CIyipy7yIvCzFnzxBw4YnNIdpGZSHrah89ZmDwNManonbVH0X2xLn/t60A/NzzVNM6kkkA10p1YNoq7TyNY88GAUpLj4UmWLzaGWAeVKRytltfac2NaOV2AMysWm+TYv2Pqeg5RPOT6Ljrhh1yna/Gd9aPrs0gjLB/kskc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732003869; c=relaxed/simple; bh=G0WXPIXmMq0Zlpzu9iMfPQeI0xxXc0kD7I0Hsy8XA30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=rpI4s0YWcDA+edJXivZ9DCz1lPMUOxrUKSrKKT3dpR8i8ONcx6lpOvCEzWeqhd1ilXdWxx2qILZPHM1yev8W/kRKcnAkxrG1Wmu/cR9WA2cJBdJnLi/T3X2rQy0YcenWJ4aYvtDFKmDUG8k2dkZbUoQqSaxU/YhwjOk+m0vj5v4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=djEO/WED; arc=fail smtp.client-ip=40.107.20.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="djEO/WED" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=erPxxAu5A/5CQq2wJpp2OlE5rTgujdX/BckliJSEHS+h3YWo0osU8ASQ5BxTZ+NcEi8Iup6NMUIZOKl4rjGhEtaFk6+ScGWicdOEktK9/Q4bu1jLkDa3eU4q5OwDU45zgnX5DWW0MicQmr3uq/VMQl7Zn8PXPzTfJEm5xELvog5AOz1bXcpgMX4xtbE42SUTpL1PLxOucPBIrgH2iX/J+Ck+VokGHIDnhqs7f2dkmylgRAqfloCubeegHmPPjiLIDF7t/TNJizW1xaoSkHcwnEKSqz6FtcAZZRfFEsWA4KS/bC0Rd+xMVnaKC+NJvHLRS8m56tIUc7BaGBNjgsocfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=d+MvJjMJ3N0pA8nHxioLNChTuV+Hmdtz2LxJKzYJbxY=; b=LZQU4HQvUYFa+ArSxX8oSEzccrJKmfNo+23N7fRjaTBdF0LUQT4EDWGqE28Y6OidmGrmjEw77Xjr79BVsIgqELrOmbRnBHWYpvy25UzuPywhVlwOywi+fFLJJW6b5FVUosnwfYgswrYyrE/ZGX42Yntu0dkrZTC0J4zjynwGGiLZwYQSBW9UiiCpos8PJJVC4Duccvb/E7B5TPJy+Bl081SNStjSy8S9A64TFrd0TAnFcuQt9r/uxqzG/WxSG+5UjEvW+fwHqP8Bgp0+gMnkRPKVD5/wypzu84f6YfG/9H3WOZzDjTAqw5T/IrrRZpB2QvON+u3nuIM4nnFo7hBwSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d+MvJjMJ3N0pA8nHxioLNChTuV+Hmdtz2LxJKzYJbxY=; b=djEO/WEDxg/M+oRBHEBMMuPvZYEqG5NWgDjGhpNDYen5IvNcqvExPcuMCo5T1a6P8wnPldgABIdzmToO2gUtjdtqs1h5Aa4u1Z6GF1H3VsMvx9+dqe95HBKWH/vaw29D24EWi+VT3c4HqykqQPpuDSsXDjLtOYrIOMHGsZFm9ePTCSvTLsgkVi1GyfQfx0vsPHBnd2WD3FYm1vp/a7hhROZ0Yd7YLeZ5uMnCXyKRjuZowecS3KcDjlE2zUjncMdfTYTJGCiFsHvSM00LHEK/rY/PthI88VfhABhT+DEeNan7VfOcJU3upUyRvIIhjqrffaoo0PPZwo8680b2pXLhxg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9251.eurprd04.prod.outlook.com (2603:10a6:10:352::15) by AM8PR04MB7876.eurprd04.prod.outlook.com (2603:10a6:20b:240::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 08:11:03 +0000 Received: from DU0PR04MB9251.eurprd04.prod.outlook.com ([fe80::708f:69ee:15df:6ebd]) by DU0PR04MB9251.eurprd04.prod.outlook.com ([fe80::708f:69ee:15df:6ebd%6]) with mapi id 15.20.8158.021; Tue, 19 Nov 2024 08:11:03 +0000 From: Ciprian Costea To: Marc Kleine-Budde , Vincent Mailhol , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, NXP Linux Team , Christophe Lizzi , Alberto Ruiz , Enric Balletbo , Ciprian Marian Costea Subject: [PATCH 3/3] can: flexcan: handle S32G2/S32G3 separate interrupt lines Date: Tue, 19 Nov 2024 10:10:53 +0200 Message-ID: <20241119081053.4175940-4-ciprianmarian.costea@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241119081053.4175940-1-ciprianmarian.costea@oss.nxp.com> References: <20241119081053.4175940-1-ciprianmarian.costea@oss.nxp.com> X-ClientProxiedBy: AM4PR05CA0021.eurprd05.prod.outlook.com (2603:10a6:205::34) To DU0PR04MB9251.eurprd04.prod.outlook.com (2603:10a6:10:352::15) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9251:EE_|AM8PR04MB7876:EE_ X-MS-Office365-Filtering-Correlation-Id: bc93aa2f-5cb8-4877-cfef-08dd0871b617 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?sFwlcKdPeOXHAz/Jww+0zHOBmxPkJjp?= =?utf-8?q?NCFNIWktkNmMBva6/A9iTByjCn2JApJb3D5x3fHodDq/M5yGXQuPtbGu6lpjPK24I?= =?utf-8?q?hSa6ieVFn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ZStlGu0zASDMSW7hEL46WYG982ZDww6ZG/oH+yTzYOHFZTlQIIvpPuChecaG6wgGF?= =?utf-8?q?P8W4KOZ5FHITVIyjts/6yq1zk40EKrLPDT9l3Iwwz4fsk4zlt0rXaQBYZFna7Q4tN?= =?utf-8?q?nX/KY9z666Qz3ZXc3sJxN4wn7K8nKdbekplNvsxy49fgXTcD8l1/7gIqqtznMBdHq?= =?utf-8?q?OjVkXMPHZTFH6UJozaRZzFTkgUUFP1hhe5WMfa/y+2TQDugzstJjiNhkq4kfvZlap?= =?utf-8?q?UKr4psj+guOQ9NB9eG1LfmLt3fFXl68lDLJIBxepS399hgdBdTbbxEUYcYRzan51j?= =?utf-8?q?0qX0ijcAAT0yRzhes6retgRKlWdU4BzfE1Fo0MzU0tawqVJqrqOx2zAQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9251.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eBQvtVUN0ox1steodJ247xbmivlq?= =?utf-8?q?E5QuKXgevni9CYEKGqnMltqmPYOx4r8KcXZb2R4rjG2i9x/VPXbEbVlscTPKHLy5t?= =?utf-8?q?PbgghMlxb9yssTfwaQELyO5SdPvHavnC5w5g5aquIM4q12xZoL7YmFkVPq0nSqTun?= =?utf-8?q?46BQ8qXhqbBokic14uyRMMF02TJbbkRDGpCNF24kpqvtJUanjAYnRqjESqLDVGVnZ?= =?utf-8?q?atxNDBwokz2bDi1jzbPLGQ0OiVYW+B0JBqaxU0MvtMjtHYhf0mEF6Gted9iUJclZi?= =?utf-8?q?YbcZWaedMWoGJmPP/uE5jye/bAMmEQMvW66n4F1+frQCt5i4ZKK3xCn9VTtYbkE8b?= =?utf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q?CU6yhl12ipC9O+CvHDS5Plg/QMdRphtzfOBPSmGbwhylRk8C5gwl7Xft6GQlzUcEb?= =?utf-8?q?ARV8JeB5wF35W9Jzt1asdtoqcNhdzxJp3/Zwr/OhLrKbviFR+4f7+KfhRk6dmC3ro?= =?utf-8?q?IRGpdq8GWxBGrhTb7T7RfNCwZnTQ2sCsp98uFJZ8S0JVc+GlFBWQ+jGR9XAn2xEVP?= =?utf-8?q?P+uWytG26dU6HZk16aQwkiX70IcM9RLFFb1gHxeq+vzvWNxLaST4kudOWvb+z3R5Q?= =?utf-8?q?xT9zqJu86HdOPnKegPhqJ60Rn6EtgKEQEP42LQTuaUk4y20FEjFXDd9y2w1Dd46PM?= =?utf-8?q?RWQVZeQhhQSfRIv11CBRFO01mu0MxNFwpA=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc93aa2f-5cb8-4877-cfef-08dd0871b617 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9251.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 08:11:03.7235 (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: H3X6bGugneoxgBVbFvkW2TPf3yTkSebfD4BFRZctynlcyrDmhdHx8/S+/F6wKGuWPqFEn/9Ns3wO+9bVp83MOJOyNkKG1beAeIr0+5WC+ZI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7876 From: Ciprian Marian Costea On S32G2/S32G3 SoC, there are separate interrupts for state change, bus errors, MBs 0-7 and MBs 8-127 respectively. In order to handle this FlexCAN hardware particularity, reuse the 'FLEXCAN_QUIRK_NR_IRQ_3' quirk provided by mcf5441x's irq handling support. Additionally, introduce 'FLEXCAN_QUIRK_SECONDARY_MB_IRQ' quirk, which can be used in case there are two separate mailbox ranges controlled by independent hardware interrupt lines, as it is the case on S32G2/S32G3 SoC. Signed-off-by: Ciprian Marian Costea --- drivers/net/can/flexcan/flexcan-core.c | 25 +++++++++++++++++++++++-- drivers/net/can/flexcan/flexcan.h | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index f0dee04800d3..dc56d4a7d30b 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -390,9 +390,10 @@ static const struct flexcan_devtype_data nxp_s32g2_devtype_data = { .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_USE_RX_MAILBOX | FLEXCAN_QUIRK_SUPPORT_FD | - FLEXCAN_QUIRK_SUPPORT_ECC | + FLEXCAN_QUIRK_SUPPORT_ECC | FLEXCAN_QUIRK_NR_IRQ_3 | FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX | - FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, + FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR | + FLEXCAN_QUIRK_SECONDARY_MB_IRQ, }; static const struct can_bittiming_const flexcan_bittiming_const = { @@ -1771,12 +1772,21 @@ static int flexcan_open(struct net_device *dev) goto out_free_irq_boff; } + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) { + err = request_irq(priv->irq_secondary_mb, + flexcan_irq, IRQF_SHARED, dev->name, dev); + if (err) + goto out_free_irq_err; + } + flexcan_chip_interrupts_enable(dev); netif_start_queue(dev); return 0; + out_free_irq_err: + free_irq(priv->irq_err, dev); out_free_irq_boff: free_irq(priv->irq_boff, dev); out_free_irq: @@ -1808,6 +1818,9 @@ static int flexcan_close(struct net_device *dev) free_irq(priv->irq_boff, dev); } + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) + free_irq(priv->irq_secondary_mb, dev); + free_irq(dev->irq, dev); can_rx_offload_disable(&priv->offload); flexcan_chip_stop_disable_on_error(dev); @@ -2197,6 +2210,14 @@ static int flexcan_probe(struct platform_device *pdev) } } + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) { + priv->irq_secondary_mb = platform_get_irq(pdev, 3); + if (priv->irq_secondary_mb < 0) { + err = priv->irq_secondary_mb; + goto failed_platform_get_irq; + } + } + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SUPPORT_FD) { priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO; diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h index 4933d8c7439e..d4b1a954c538 100644 --- a/drivers/net/can/flexcan/flexcan.h +++ b/drivers/net/can/flexcan/flexcan.h @@ -70,6 +70,8 @@ #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16) /* Setup stop mode with ATF SCMI protocol to support wakeup */ #define FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI BIT(17) +/* Setup secondary mailbox interrupt */ +#define FLEXCAN_QUIRK_SECONDARY_MB_IRQ BIT(18) struct flexcan_devtype_data { u32 quirks; /* quirks needed for different IP cores */ @@ -105,6 +107,7 @@ struct flexcan_priv { struct regulator *reg_xceiver; struct flexcan_stop_mode stm; + int irq_secondary_mb; int irq_boff; int irq_err;