From patchwork Fri Nov 29 14:25:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Costea X-Patchwork-Id: 13888729 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2079.outbound.protection.outlook.com [40.107.103.79]) (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 EEF1E3A8F7 for ; Fri, 29 Nov 2024 14:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732890358; cv=fail; b=F5+j8osgIbJDzfgxln07piF/6peE7iKk//op7ZZBvPii/OzV/55rXSG7MQRZ6/RXJ2QkwLgyM61T4a2GB5tyNjYqHX7GpVguJr1WBbyiCWLzXgBPsYYDEdOnCkLzsjPMUeacIb/UrAxn+xW+rt/mhip4TfQctD7kcSsxOLrKUvw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732890358; 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=f1e0c2Z2kM/rFTLAwvxrTdqa9VUQchvi6FlyuTdUFWq5NvS70zkdUZMFejiM9Nh/RugF6Dj/pl6SQDl31VzpEao/0sv+fArflQ6BLyS3RINXokYszpAyWJoh3m/cKTX/mYBHkul54T6F8Kse1rdCG0np+dEW6W1XH/eRouXTKMU= 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=PcYg8Owx; arc=fail smtp.client-ip=40.107.103.79 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="PcYg8Owx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NXdWa2wzZboAwkkU9P3kFbScYcKFS8UOWIKKGZafhfMWoBVNS9pWRF7O6n9mXx4iBxI3+z05qK2xrU0W2BOSOPJ6H32euLD+NdFjM/ZmljZllyAKm+sgXkFEnpLfoWnQyPDjsRVBjGxCDDeCDcaX+AIhKN06h6+H6cruthxZAV3o17aOtUjZAGCFpnIco8W4z5sns0itpBRX/zEKIsFHoiZIvqJZx6o1WD+eMD/I9XnQzZAN4JfwF1f6e8D6Up0Q+SJJK2IySln81PlpnzbQ03esF0yK8DCyjnOHbDDYDWL5M8WAyHWBBu6R8hViWSgFQmlYawMK5wJ/GGGRj05QnQ== 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=BqH9ad+b5PC1EAyBzNG6NLnzNalQpowIC1jm+J4oe0daPG/d7Hsu7lprK2MiIvUY8qLKAT4mxNAFg7oschzlGTnm6aWLbbfizcCxDdlRI9NNosRA7yVS/meGh84R184pVEI1nu0E+VvnRAUvgF3nfRwPNsMQUdwwb6n0M46EsXphYIC6CgAKE9R5SwBPrRQn0WmpnWc+W/XTEdlw7X7Gi1k5NywBsiA4sjqGCpYLlQNiZ2mobJrDtq0axxvWJC0P0e/O6kiRCOh78T8rJ0EOuAEK0xzemdGm7XzueYiPTTTV1bQ0ivyKaU9HcQYuXeXuTeFN1IrD5uYQoGYk15c2Ow== 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=PcYg8OwxOnCnvB9Hg8ObxLToawfOR5GW31Y4/jPsL2TH4His3qIn2bdzxvhxc0rVD4Grx3BHgAOktoxpW4hbLcnfPVVra6epFs8J8RLC5w4kUIVtEe3o2Fh4Y/ooocWxLLJZ/cmhL9SAVv2/Poyr6TEeWdKU20KUHb71fNF+9iw7RGkzqdm+ZZIFGwcsDwr6beOivC3KqNwqHURT/YilwILSPgTCWJ34K1sc7mo0XTqhH0SbUkrKPUD8gxSHqZBMeok9O2nx21tqH3iB0uoCt/l9v6z7WQ7v2+c4cwI/zo/6TP02pWUaPgxWUwrdapHoffFgHG8YxUZNg2jBu+SFuA== 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 AM7PR04MB6869.eurprd04.prod.outlook.com (2603:10a6:20b:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Fri, 29 Nov 2024 14:25:52 +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.010; Fri, 29 Nov 2024 14:25:52 +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 v3 2/3] can: flexcan: Add quirk to handle separate interrupt lines for mailboxes Date: Fri, 29 Nov 2024 16:25:34 +0200 Message-ID: <20241129142535.1171249-3-ciprianmarian.costea@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241129142535.1171249-1-ciprianmarian.costea@oss.nxp.com> References: <20241129142535.1171249-1-ciprianmarian.costea@oss.nxp.com> X-ClientProxiedBy: AS4P189CA0016.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::8) 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_|AM7PR04MB6869:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ee97418-e821-4ecb-1794-08dd1081ba4b 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|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?9AxeVSB4sD+M5C0oNF/e8YItVWdrc7+?= =?utf-8?q?idU9rJF5+CNWe25fLfFa5lcfw/aYFsZmFnDPiVuJ4Ha+p0RGTPalPDpxct2TuOI98?= =?utf-8?q?U1omPFZfYg1mCTgqXXOWhmKbnvOslZXI4lxxJuukyxlvJjlm3fd7/6aobUCiafw/D?=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?= =?utf-8?q?by8DLNbflwRBd7dfI5D+oZoUPrnbU5GrG7BFOE0Om9wrpQrC4uYHVhJ4LKzvm4mXO?= =?utf-8?q?9VrmbTWwtWwl7koJR8dI61zh4hfJC60d5k8dlrUu1K8xMkrlQgzo6jwhF51od3Jti?= =?utf-8?q?5gqqcqlEM6Wz+5vPx23o8/0i8WBP96LUf7X16ZLyMFAbAC5AknlOi9/RaHEPVJpK6?= =?utf-8?q?IRSTzk6BM2UUy+bwtMOtFbS1QH7tpR0ugTXpbDLAj0dVwEvmj73ykz6hJIcqQVpIz?= =?utf-8?q?6mDcqE8BTNSVDO+trKH5cXfYnxuSeJaBy3A=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)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sZV3S1+pbBEqetAChsWjplMVH7dW?= =?utf-8?q?dHRL4MVPEd6ETF5sZQ9RVnMtRHqtNJy6cxlclN2TCvnThT3Ln/MgaN+R3LcYjure7?= =?utf-8?q?/23BgKKNND2Uxxpqldu4WktpO4pBmCH4sgKMzPwqoF5EW9KS3YmAArMRT22SvrCul?= =?utf-8?q?5h1ttJ7Joiq301ekAFrmxfbKf7eNvXQnX/zM9nTS7eG98v3G7TiIFAsQ53V0xLi0/?= =?utf-8?q?ONYw0xo+B/IrEbMcpeLaqp5YikVqqkndBXYhvTNsgSwZQOg7gg8J//XKX2SVHn9vA?= =?utf-8?q?nie+yZHmvGT49NnPIds2Hnsr4j3sDFNIiT+tN1WRXRC+BK14stD+vI2hQPz9MBoBn?= =?utf-8?q?0DkQvQNf+tWhjYyltL6AUszmAWDc0jHVlqYctdhz9sixe9I3HL+tES2hhAIZ3Le21?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+jWMA0tEQFRBs?= =?utf-8?q?6Ze6AL2OkApYjlRiXSB8GmcbvmcKKCEzncZQy9XXgioYjmIGb0Rip0Ac3C++kugtk?= =?utf-8?q?IZD56rky+vvPCFH2PVvgKpqvKV+oxChJfOoGMbtcSE8Q54G5MUPEfDXJMnuAmMg8A?= =?utf-8?q?4EbiN9zF9QmEBe8SSqs+PCKL0VNsg9pNOTOxsuzzmFHQ395fe4gYMVp4pAFnUw2SN?= =?utf-8?q?YluJaXxHi9aoQs1w2QZM6Vap2PnnJsa6Wy/iaBagwHYWjfFEersaMeMnvO1OJPiTY?= =?utf-8?q?U9r7C7Jm82b/B52xihspMSP6RVHsGnp1zQ=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ee97418-e821-4ecb-1794-08dd1081ba4b X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9251.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2024 14:25:52.0153 (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: P11SOTmgBl8zTrH/C7P0VqrNyPiobrLZXUDkZUziBntwY9lxmpdYE1j4ei8ES0bUjqE13aXEzibgU/crXI+A0j6Me7M0gJegDe15AEZ62+Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6869 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;