From patchwork Wed Dec 4 07:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Costea X-Patchwork-Id: 13893361 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2067.outbound.protection.outlook.com [40.107.105.67]) (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 B8E111F4283 for ; Wed, 4 Dec 2024 07:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733298573; cv=fail; b=plND2tUlHgm3dloRM2m5BnU651j6u4hXezS6wa+JZVaYWt2MR9B8ccxsf6S9zi/ec0XVHWLkHwuq12vtAujPwp4cvLJXe4v4WIuK3415hRwF0UCIaLjJ0Mo9sLO3Zz+HS/0DJVr9YoyNg/Dup52YeAtM1RTSZYoFjbn4u3bo6vI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733298573; c=relaxed/simple; bh=D/27Msja/lJBWRfcJFy3VjNENyNFL2o0U4+oVCpi7ps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=neSsbWCjwHXml8ATQegZY9r4uu61TzRlxB8eygpzfZfjPGE/9aekCXxAPQJ2McI0nTp5IFuPAzaEClYKvl0SZ+emUQ6DMVR1L0Tp3+zPf9+b5g/dw7vmg47IYd2VP1XwGXrR2XZiBRPiNdbhE7C2lT2ttprS4iVgYkEke+DXcus= 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=GPZtHaF8; arc=fail smtp.client-ip=40.107.105.67 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="GPZtHaF8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S7t2hP9hCZgat0Md8h4QVirH8umd8dr0YXwRhHIQNWdT4ogX+dt1JJ12nkIe0wl6+shy/AnrUVjgTU+X0hR+nfT7X4cnBn6iPThSUmdA9kGY4O0sTdrizTDImt/F8sU5VGg7bMBAqVTojBpOhvqZRhnssQuPT3jHRO7qFvPHeGs5bKkQREuquLAd2hnEKiaqF6JeW+RxiuvjQKvo4ZJdTKw9QcgqAUgwwdGv1Fz6yRq/Secd/Qd0vmiDrmX75ozF/MsOa2FseiVq8cuWKJaYVSmYB40/BaroKPmlvY1iLA4HMoVWb+TvLeXrLX/5kfriv+z+TXytNtA/7L2Q2RYwDA== 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=tpZ3L6RcAnRf0eDx7wa22XwJ34ledo9Aicworoq88jQ=; b=wdDeIX/nSPjneg2WA5SAwaOe0dMjWzl/oVHIVTOxfQAN2z4oMW/t8QsgF0QrB10TGYXN4MXFQ/ugj4r9MAffGAKIyZAwnN6E9ldi+UKopSREUCf60z3QaGDfU5KpO4Zuv/b4T0Nkg9GikfBYCR5hZ8nBykugKq2wm/NutMN1++tUjbY2vqcvuXyIJmc3Ssiw1bjyEiqez4G+mZUQ2m7lP9IjgwHyVxUO3AzXUZ5tI8DpSkdY5YO8Evw7I7HstinwkH5uz+xxE1S1+R3vl82bUekL1FaTa3BHrb6Ezuikutrvj2JyM7XjTnF1Gdk9SBhHtLGdoTF6Lg+7/UlasDHl8A== 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=tpZ3L6RcAnRf0eDx7wa22XwJ34ledo9Aicworoq88jQ=; b=GPZtHaF8BHsiEWnInX98bsuRT+IldufzvFk6uQPAmOYQYx8+6b/53YCuTESDtq+rNadAwBsefx42zG6nan7G7zZe4xm5Zd4yQ6y4rBc3x/AkcFKfRJCowy4Lb9t35QcA+PU3oomxVmi7AoCoscsboxNzdTiKkRZlGJ3poMiGNA93bPlkbSWbMgruotQLY1FG9O0K7wu7B+CUnmL2XyBc+l0SuOM+p57b1oAnxpzXFwSiLKaVdJ46IGmGlHxuiCUOUIhpaK6W2jD5saO1bvIpN7HZqGKEqMoArb3yiNIED4mN7s4/P27udUAuE4zuwFbF3aK7vOX0CS+XmW5aV+9cfg== 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 PA1PR04MB10769.eurprd04.prod.outlook.com (2603:10a6:102:488::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Wed, 4 Dec 2024 07:49:23 +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.8207.017; Wed, 4 Dec 2024 07:49:23 +0000 From: Ciprian Costea To: Marc Kleine-Budde , Vincent Mailhol , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-can@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, NXP S32 Linux , imx@lists.linux.dev, Christophe Lizzi , Alberto Ruiz , Enric Balletbo , Ciprian Marian Costea Subject: [PATCH v4 2/3] can: flexcan: Add quirk to handle separate interrupt lines for mailboxes Date: Wed, 4 Dec 2024 09:49:14 +0200 Message-ID: <20241204074916.880466-3-ciprianmarian.costea@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241204074916.880466-1-ciprianmarian.costea@oss.nxp.com> References: <20241204074916.880466-1-ciprianmarian.costea@oss.nxp.com> X-ClientProxiedBy: AS4P191CA0003.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d5::18) 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_|PA1PR04MB10769:EE_ X-MS-Office365-Filtering-Correlation-Id: f4a610a8-6bae-4b4d-1b23-08dd14382b57 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|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xR0rt34r3lyKzutaUXd59omSIwskD7X?= =?utf-8?q?SdSYDq4dgvfNgXcYMI0UX7iG23CV/IAeK1RdmyxGHqONB004f7LB9eKCR3RckwY4Z?= =?utf-8?q?HLeNyAiZ0poA91JbDFKND7XHk8wHeYxCJ5VAPIbnCb35hM25mRDxbpCgc5mbs3RYu?= =?ut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B7cCyYRR7hygQ/k4A5YIE+spJvw7G78VWF+lBJRz4OYoUjuf8QC1sw4l+8e5w8HM?= =?utf-8?q?V8AIlgMB9pPWbSd2U7sYwzsU2ayscFVeYbcRIAQutWCKpULHdnPYWL0ywxAxPW/j1?= =?utf-8?q?KmgYAKmTnHQGIg8fvOUQacqDHhpL5lrQrtSTr36uTQ9xUSot7icHSk/FYDvBdJevT?= =?utf-8?q?S/PccS4G2lK0A73pORn9iquSOStxbWpyOrLQT+lpL2JdGKDIksi3rGeJfRq0+B3ui?= =?utf-8?q?9L2VZNGKS8QfGfUoqJtd3ZMa6xLE+rH0/7w=3D=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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?C52OUhkh3mZYQML5ATz9uly1vu7j?= =?utf-8?q?l9v2ADW4TFkCOnZrbTaj3HhKi+RHKrUGzBjfzFpcUQUbu4FRhKOJAVXd/Ilt768wq?= =?utf-8?q?65+6djt5uM7gvAI29+GSPZkp9o3cAE2WqEfuWkn9TzecaOxYonQCEacuS2pR389wl?= =?utf-8?q?l+tM/5DmR8t5/eVYr23S7dX7z5Dnqi/SH22zT5btSci3EhumeN5gk8KFmnxhXs9c5?= =?utf-8?q?hHmzSHQHf+v9lU6L8/qLSw4xTx8DFdzNLB7Frb5LjlDPzBSNaoAa9KOiFUvvS0Prt?= =?utf-8?q?6JwdKjBiqR9xS9EuXLLlohotZvL/dpTTdVTKGgy6ob63qxpafXtZ8jXxPq3o0+/IW?= =?utf-8?q?V/tU0DJgKjFzzV23HUbvJACOJSyIdvTRYaWVtc7dSsCSHLL//ZdMbUfM8UYPRrpZr?= =?utf-8?q?H0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6llUb4fVWE3doj6CQrv5OIB/zL68bKiGmjhRgtdZAAGTp?= =?utf-8?q?VuS+i//SUirCnLKMtAe7AgzX9YrwpbguWocsmJtTbAltk3TBThXffzb77Y9Jh3kER?= =?utf-8?q?TqOzIB681KpvLWmrVAE6kJfcVcJg7lB3t0N0/uepciPkXR/b0rTVPiUPUmjjMKzqI?= =?utf-8?q?AFd/WObxJUZXdlr7iFr8T8zwvNlcGpbwLMuqGrRPa6d93EqGGjjDN7qWMT6k8LFjx?= =?utf-8?q?vTayxN9NPGOxZztzh0u+eR/MisKODPavEg=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4a610a8-6bae-4b4d-1b23-08dd14382b57 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9251.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2024 07:49:23.5660 (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: wxOpABf5eZsqpik5w+jVQIXslgXfCwYEW4z2ORcANxXc6+eioEuxRXa3B/wsK/Xn06yNdDfvGrJghy6kToR6k8r3tt37CtwkrHQ7GktkkYU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10769 From: Ciprian Marian Costea Introduce 'FLEXCAN_QUIRK_SECONDARY_MB_IRQ' quirk to handle a FlexCAN hardware module integration particularity where two ranges of mailboxes are controlled by separate hardware interrupt lines. The same 'flexcan_irq' handler is used for both separate mailbox interrupt lines, with no other changes. Signed-off-by: Ciprian Marian Costea Reviewed-by: Vincent Mailhol --- drivers/net/can/flexcan/flexcan-core.c | 24 +++++++++++++++++++++++- drivers/net/can/flexcan/flexcan.h | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index ac1a860986df..3ae54305bf33 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -1762,14 +1762,25 @@ 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: + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) + free_irq(priv->irq_err, dev); out_free_irq_boff: - free_irq(priv->irq_boff, dev); + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) + free_irq(priv->irq_boff, dev); out_free_irq: free_irq(dev->irq, dev); out_can_rx_offload_disable: @@ -1799,6 +1810,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); @@ -2187,6 +2201,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_byname(pdev, "mb-1"); + 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..2cf886618c96 100644 --- a/drivers/net/can/flexcan/flexcan.h +++ b/drivers/net/can/flexcan/flexcan.h @@ -70,6 +70,10 @@ #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) +/* Device has two separate interrupt lines for two mailbox ranges, which + * both need to have an interrupt handler registered. + */ +#define FLEXCAN_QUIRK_SECONDARY_MB_IRQ BIT(18) struct flexcan_devtype_data { u32 quirks; /* quirks needed for different IP cores */ @@ -107,6 +111,7 @@ struct flexcan_priv { int irq_boff; int irq_err; + int irq_secondary_mb; /* IPC handle when setup stop mode by System Controller firmware(scfw) */ struct imx_sc_ipc *sc_ipc_handle;