From patchwork Mon Jan 13 12:07:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Marian Costea X-Patchwork-Id: 13937246 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2047.outbound.protection.outlook.com [40.107.21.47]) (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 0451C22A4CC for ; Mon, 13 Jan 2025 12:07:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736770043; cv=fail; b=QGGC3HfiFM61V4vw+0m69J/mCyu+C2uLp9aFtaSP2Mik/zvcvgdvVlYYdid1kKB4zYgoSxuLAKbzqrGQMM9z2y4hN3ZfV/xR7xbVoGe9aOU1kuGPz2B/qaMsL5ZF2fg2PQbsXgpX5JlQl3iybuxG3lICHrsXScGcg5H8RCTSv0A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736770043; 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=foZdTwRVfFEQx+9HqwW5MP5iTAim31XgPxOHdglPeWM2kVdH3OdD/Gm6XEBGG7IWP6Jb8iPJEpjSXbbsO6QAoJRCacMaZACM7B7S/UkM2zSlCHb146SwuD8JQT2Looui8njXOqlvGx1j6ofVoQlXsSEVlRTfXrc8dKUui7SB+zM= 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=n+JaAueo; arc=fail smtp.client-ip=40.107.21.47 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="n+JaAueo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I/xzuroo4z8axkkK7rYxkPZm34kvQmv3SEvjDVh3XuQI8r7MUEQ1yw3hRauNvJna8OzzseIdwMDPnc+Tj7C6Ihad2XR1NsnpOofKVdEZ1XN9oDWPVrZBm2b6z64JNqujecJyqerQ0sereu4SvKGEz/ROY5ZfKPqUKCjj3tQUnPXMsVFErSQI8zGgc0kSrVMgh6Te1NH3tsqaRGW8jzXnzTKmSJdZryKc75db1OSH/9B5nD/gOaKSwI43yR93M275QxRhZaIWZBIteYy0jU3VzRtvGoKzXiSL98SYd/LwgqFESgSqk0iHollkltxkhkNz5kJaZRhGi0ND3h4wEMIvjQ== 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=O+IqajhN5rAjoqIPXNu42EQ6Cv8F/WaXJAQlvXJqTDGXT7kSZAylUjyq7gUoKbHseOyxnLpyemmTfsUISngnoU12gJJrAbGiBNLsepFz5z8nez/WwL0O5HD4sVZjTPcTQRwDLjMY+0z8OjNXCZNDcNdfw+wQy/VtH6h/uqcqNOI4F4SPW+mRUclcAWHZT2PVyqUjugnE7gYcwWKu5Gj6mgTGCu7XBXFYxDzGSTmjF7miik5SkP+YL1N9w7uFAWOMGGynFvDhp+NtOFkhbq0SROPKzRM2kcJiLJXicKn2RzrMzTWw0lbvV2IFOvokSIcS33fHYBZPSEk1PpNuTROuGA== 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=n+JaAueojXijmamIAsgUUIbR7QMrcq+NQCB/f5ITRt4rSg5Rqoe9tzbXKaxOCIV//DmIvf+r/o2Ie/o/P9gjF4GNlpVyMRFygMZ4vLnAGTD8KMAWJelyBSb9ik6iXHqNTuDRggCd6Z2ewcCAz8lFAMlXeGo9zSJatPSjwoYkmE+QBo2yf65BibR5mUaaL1jYqdgXdvR57mTKcRcF6Dt0qlZ7wR9GptPZjJb62mQUcXkQwm7PfpB2Tr21orUowhQgfam5E7zdDh3PyV1yM5oGNa2TGnnOu04fniTCQ8tyzXqCnZ3DT5RWEC9F0SAjHhZH7A5w0W6ZkysoCnJ4vOSBKA== 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 DU2PR04MB9066.eurprd04.prod.outlook.com (2603:10a6:10:2f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Mon, 13 Jan 2025 12:07:15 +0000 Received: from DU0PR04MB9251.eurprd04.prod.outlook.com ([fe80::708f:69ee:15df:6ebd]) by DU0PR04MB9251.eurprd04.prod.outlook.com ([fe80::708f:69ee:15df:6ebd%5]) with mapi id 15.20.8335.017; Mon, 13 Jan 2025 12:07:15 +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 RESEND] can: flexcan: Add quirk to handle separate interrupt lines for mailboxes Date: Mon, 13 Jan 2025 14:07:03 +0200 Message-ID: <20250113120704.522307-3-ciprianmarian.costea@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250113120704.522307-1-ciprianmarian.costea@oss.nxp.com> References: <20250113120704.522307-1-ciprianmarian.costea@oss.nxp.com> X-ClientProxiedBy: AM0P190CA0007.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::17) 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_|DU2PR04MB9066:EE_ X-MS-Office365-Filtering-Correlation-Id: 29995fdc-956c-40a4-f6ca-08dd33cad1db 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|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?YQtvWCKpCwkk2MQduqEYUESqQGPrco8?= =?utf-8?q?76XcvJijjNdy5zbH77hHVXptbJ02PPgRuzZL3L3wuFkYvtm2uaqmDu0H/EoDSDeb1?= =?utf-8?q?YgTvmHPz3g/V3+yqvaMfiYfwxxPZZNLa9h000fb+MycyKrq7S/wKeR8+uG0RxhQ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-8?q?xPE12P0y9mEDSgpOe2VbMF9rBu5SSnWmA0SqsosO9tjGX5vIg4tUYYaV/SWiCPwCn?= =?utf-8?q?oxAOGocWj48334tn4pVVmgb0kRfUqIv+EbNZFsitkrTl1u5rVA2rq//XXQAkja8Bq?= =?utf-8?q?tvTavENfYxRm3mQMAorUoLvwguzJnYDvb0Nh0Haom07zyB9/KhKU+bKbHQf1m/qlw?= =?utf-8?q?JZfewtfGpB6SRs+xbxWW0ptdcPa6RImthKKw2m/6uUR3SD9fzcxDgjP7gopSf1rri?= =?utf-8?q?XiwWNAg4UFl5Lyjdoo5fE6plXebK7YWRh7P0EPKW9xXbTpRsfWt6WWTBzNTcejVJS?= =?utf-8?q?qYkUVdbZeUlW?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?DYZpbJOZjgwrg+201jadEN7dMUR+?= =?utf-8?q?JWpXBjnKyV4W0ZA2yaUSIfywPPCO3uY59xR4ORrHIq4C8e90lai5Zm7a1sIkRd0Da?= =?utf-8?q?zo8OHkEigXQBXHD2tlBU8XukQX1O/n0F/dPKGMbfeqLUagh0t6ZREReUscTFivMei?= =?utf-8?q?aWWfLcRm/u4qFfZzZc658fmNmMMko8VOXVt10usAOKbsZLEuMCz0zk6NIoQWXo4ko?= =?utf-8?q?SLvsgnUb9wzvXF1PY4W2knIVT+nHCRIqXavlc0iA9B/4pVdSgKY45CM+q0sYWR0Kk?= =?utf-8?q?ffJzDkANDgjWtL47dPgnZqHKeVXGSTSjrnvTIvKzs1SURJvu4JYs7LPlcP4eZ7y7i?= =?utf-8?q?Gab3KP3KfJWovX7ugoavhe63w5whcAzqxgD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vtu0OlogL?= =?utf-8?q?SoofsrbvY8AVpjHsmxslQgYrkEsIC3ZN0VQqglrM8FlWJSrCPIfTAEROhnpgEOLf3?= =?utf-8?q?Ko4yxU8WyHW8How/4h4nUscrDSPyq5B4XC6xT7VbxP6W0gxA7ldps9E0hdZHwkcxH?= =?utf-8?q?95y7E2ycUl3Tx/NQS9s+x8ZR0P/6MQQp5JByvCHcgIKK18atVasPdw8ze/d6yCkBf?= =?utf-8?q?EUSq6G2iMUqkebYLyahEJiS/1Ygb11mv9WIpKL0GsAy2O1KyQ+NP0gWoxfrDLVpwx?= =?utf-8?q?dQUZvXFKbiIWcTptbznC8GzAp2vI2vTBnA=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29995fdc-956c-40a4-f6ca-08dd33cad1db X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9251.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2025 12:07:15.5449 (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: 3yOHgprEwYQCq420lEMsJ5Va+4gLsNjqjmO9ER/aLvQy6AXEEEu5Q0knhsMyql+x2gA7q6X5qYWeIs7EX4fbLPsLGyK7lUkeHP3b8RrWzUE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9066 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;