From patchwork Mon Jul 15 21:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13733917 X-Patchwork-Delegate: kuba@kernel.org Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010001.outbound.protection.outlook.com [52.101.69.1]) (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 AA17B143C72; Mon, 15 Jul 2024 21:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.1 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721078874; cv=fail; b=RmLFTZnvLYuQxiLL1uWNkF67BzQ3NgsH17kvKcBntXNsQP6a37amCIEnZipxfA8FxCHtKg9EUpyzOBzn18zGryQULSvANtQug4kvDNNQyrVVH+ijXDT/FdcIZN1Y12xdj0a8COlGbFrW3Lz9B4tzgW1zaBKHqWLRdkQKUb7L2lY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721078874; c=relaxed/simple; bh=BDMPlxeguvTdR7tbMlQo7Ms11jQeZFOQkfxYh+b8HnU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ncU2c2SnT+xnhvMv7Llymgo6jxn9mzLqxZr6qt7FgSZGgE7WdQSGW68uqWCWfYX4urpJEW6gSSvif6Rs+BXUksk2F3Zp1SBpIxbgXdinrueSdqCSBkuXXkgmr1wWdAhtZ8XJ4vfGrBmzoxp3G/LjRWckL2nOnVCA8RjNqDZfNAs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=N4OBeEaE; arc=fail smtp.client-ip=52.101.69.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="N4OBeEaE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BRcra8eLAdR/fjLvauiapmzSERp7pDFMjRZxXwUbpaN3bT5pweEDIVYw8Xskope0TOapjP40O5OC7D0NONd4V5bnQWNUle4p+2X3MMXR4lWAYDmqXUoTxp9kKD7XZovUt1GwJsYSToPLCrj/J35FTIAS8HxiHE7PIpSJEdXfEsmUHU9+119RpfUxFQLXI+QVLsp1bUGLPXX3E7+00j5mkTHhxfps4/V7e53emkmL5WPGvgj41/fPqFPtI5vKqTq2YTuO+dmZ53QZvZcniLmfxit0ttw+VXAAyVtrUeE60pIS+YarfxZwDSIILkxxUofXFPUXgKIpnOD53e6W5miXMw== 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=JcdYbiAS9ICOQCJYY0Q/Y06j0YLPixKjy3Sva3xxNe8=; b=kWb8a+ybr4kJO2T/0esC/mxDuWifCK4rq5bGM0b91lXVV6ptzBzywIDMHmG12QfcuUyerQw03p0vudQl0/hOlZkpu5FB3E9dGFTkRt2ya6kWkcrl6sYOhFE6nBNguv36tRxYEVF0IV6P1frLuDusWTWROUU8zHE6WKf4xZVFEAt/hAqWvTQPG9DYs2cntWwyaSTLnqlpdLdkRkfm1AK4lXVmQs+mQ+yBFPBnYEO163y0E9sN2JPH+uhmRsToH8KkQ+gtUenG0enBfCAIdTo18YF0ukD/QRKNRUDcqbkGITzrwR2PCDDm7HOo4oAeTeTzZIqhp2Nphy3pFKnsX530vw== 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=JcdYbiAS9ICOQCJYY0Q/Y06j0YLPixKjy3Sva3xxNe8=; b=N4OBeEaEie10mCp+UvWHadfc8sB33aSP6oOxH3fvwQH++JBtCo1+HB/BQSl+dPmVQMyUPDnYRuxk3xjhPIHcVPPYOc0QxMGCxd2vEZxyWb2FExxvLPijCUL3o+1GAxb0ECPTLb2GtOMprjiZJLbhV0Og060rU5vRZ6qd7A33/Hg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM9PR04MB8275.eurprd04.prod.outlook.com (2603:10a6:20b:3ec::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Mon, 15 Jul 2024 21:27:50 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7762.027; Mon, 15 Jul 2024 21:27:50 +0000 From: Frank Li Date: Mon, 15 Jul 2024 17:27:23 -0400 Subject: [PATCH v2 4/4] can: flexcan: add wakeup support for imx95 Message-Id: <20240715-flexcan-v2-4-2873014c595a@nxp.com> References: <20240715-flexcan-v2-0-2873014c595a@nxp.com> In-Reply-To: <20240715-flexcan-v2-0-2873014c595a@nxp.com> To: Marc Kleine-Budde , Vincent Mailhol , "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, haibo.chen@nxp.com, imx@lists.linux.dev, han.xu@nxp.com, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1721078846; l=6508; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=lqHfROCxFB43LZ85KCvKowdNhLtFntzq/RoPEWnMlnY=; b=UbNbkzmUtNEcwqcAuYQsfDgD8VSgtvfB6W8z699TLOOetJbs89DW9P8fDsVm4Aj5lZqZrDoFq klpbr91t015CJ1zMymWBSIzGY3pwVN79t47g8Ob+OW5Or/e0pL+lQ64 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0112.namprd05.prod.outlook.com (2603:10b6:a03:334::27) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8275:EE_ X-MS-Office365-Filtering-Correlation-Id: d0ee7989-af5b-41b2-073f-08dca514fa6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?m96QLS+pxjNhDs1bj4MjYm7S75InsLG?= =?utf-8?q?Vh0FfKktD20hy+VzstVkw387hJ8nNVcjH60FQH+Uz6s3l7u6SfTLXC4qTTK31qRdM?= =?utf-8?q?zyDR3KE3GSYONypW920qQAfu/0fNw7RYuCiDEB2eB+Wor80idPT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+sSCbA3uiYW?= =?utf-8?q?87Y029Xjsq9drEmsECYAm4FD/nGV9q+CnEbKoldbye3NjOXdHYQH94eJRJ7u/nHw8?= =?utf-8?q?z0CohmcKlCoKyGphnu6V+rVoHFdMA2bJkB4Dpv5zWOdhqVoxroaoopdYjDyiY5pBs?= =?utf-8?q?tBZMym/2pVlNKP75F5lTScYNRu0tAr0IYHEQqD/yczwJKXr8QbIhO+iiGPDEAFrl6?= =?utf-8?q?GX88fcrFXLCUfNdbPb64WNr7H9/Qeldz9bxSzFnpzff1+e+6V0X8gU6hF8dc9Piyy?= =?utf-8?q?aKUP1VHhigxdSidxe8bDO0I5SFs9Grk7xC6j6jZG00C3YDYQ6PvHIjpm/zR9Loon7?= =?utf-8?q?cQPiMnX3jDI2Vc7A5lW9BWCuAsOfvE6VGA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?2OvLLW0LMTrl4COn6ml6YSH3h4nj?= =?utf-8?q?DUE4Bg7JbGbs55gXtC9GVaAAI6VH9Zb/o18JNkwuZLfa07vD2eL0GXYf1MzEQVyLK?= =?utf-8?q?vr2MhiI/zYufPhZY5n4Oh2JtQGB0ALXmfwEtzAMSf08hBn7vD5KT5b2+hyUnFu3wh?= =?utf-8?q?J7NXP3i7GDHDtPqWwyxFZGLrJXYmcUvkK2SzVRlm5EciblpeWaW7BiusE7B0S6Jp4?= =?utf-8?q?CjUHSkrcvT3DthwkTLUBKe7CYXq8hRUC+L/bjMP5Zi8FHJOeKQ+Kf3R0hve6cmbgd?= =?utf-8?q?5Z8Mnc5t4Ni2Y2BW7ZIT6sbINDJ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r/sIMZNN5lXqS7Nq0OVMAW63pfdmAHyKaZuY?= =?utf-8?q?j+WkOJ2/5cDbQDnIclVWu3EeR2KDkR9VwwqQdjMZ3Vix5dysrm6OUfU61rE3VRIe6?= =?utf-8?q?fNmDB0vgcbut2X5CjK8u9bydjESbGZqOuHtHDXILtE0TVZZP+IF2UW1EjBZC/s7v2?= =?utf-8?q?yZBmisIhmUvnmKfLY6PtQiHql4q99X/TE0lg1OiAFYwMdQOIsIq+uluq9qk/UBYgL?= =?utf-8?q?PYsXC+tmuVKQPPQlMm47yr5qAVWbGMJLou1MxSQO0TUhchIV7YpVjGlsFvBnGNvVh?= =?utf-8?q?I8+LloN446U0lGEx/6PDdyxUBUx0Crse+/cikJxFfKoU+OMVquZ01g88=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0ee7989-af5b-41b2-073f-08dca514fa6f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2024 21:27:50.0146 (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: D+DsD44Xhc1KUFiHoMrIx20i/YORqZnuLW6nusXAl18hFin6fMXky84cHzCzAE+XJpQASEesLHp4s+KnzR6sgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8275 X-Patchwork-Delegate: kuba@kernel.org From: Haibo Chen iMX95 defines a bit in GPR that sets/unsets the IPG_STOP signal to the FlexCAN module, controlling its entry into STOP mode. Wakeup should work even if FlexCAN is in STOP mode. Due to iMX95 architecture design, the A-Core cannot access GPR; only the system manager (SM) can configure GPR. To support the wakeup feature, follow these steps: - For suspend: 1) During Linux suspend, when CAN suspends, do nothing for GPR and keep CAN-related clocks on. 2) In ATF, check whether CAN needs to support wakeup; if yes, send a request to SM through the SCMI protocol. 3) In SM, configure the GPR and unset IPG_STOP. 4) A-Core suspends. - For wakeup and resume: 1) A-Core wakeup event arrives. 2) In SM, deassert IPG_STOP. 3) Linux resumes. Add a new fsl_imx95_devtype_data and FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI to reflect this. Reviewed-by: Han Xu Signed-off-by: Haibo Chen Reviewed-by: Vincent Mailhol Signed-off-by: Frank Li --- drivers/net/can/flexcan/flexcan-core.c | 49 ++++++++++++++++++++++++++++++---- drivers/net/can/flexcan/flexcan.h | 2 ++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index f6e609c388d55..fe972d5b8fbe0 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -354,6 +354,14 @@ static struct flexcan_devtype_data fsl_imx93_devtype_data = { FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, }; +static const struct flexcan_devtype_data fsl_imx95_devtype_data = { + .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | + FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX | + FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI | + FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC | + FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX | + FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, +}; 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_RX_MAILBOX | @@ -548,6 +556,13 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv) } else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) { regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr, 1 << priv->stm.req_bit, 1 << priv->stm.req_bit); + } else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI) { + /* For the SCMI mode, driver do nothing, ATF will send request to + * SM(system manager, M33 core) through SCMI protocol after linux + * suspend. Once SM get this request, it will send IPG_STOP signal + * to Flex_CAN, let CAN in STOP mode. + */ + return 0; } return flexcan_low_power_enter_ack(priv); @@ -559,7 +574,11 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv) u32 reg_mcr; int ret; - /* remove stop request */ + /* Remove stop request, for FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI, + * do nothing here, because ATF already send request to SM before + * linux resume. Once SM get this request, it will deassert the + * IPG_STOP signal to Flex_CAN. + */ if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW) { ret = flexcan_stop_mode_enable_scfw(priv, false); if (ret < 0) @@ -1987,6 +2006,9 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev) ret = flexcan_setup_stop_mode_scfw(pdev); else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) ret = flexcan_setup_stop_mode_gpr(pdev); + else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI) + /* ATF will handle all STOP_IPG related work */ + ret = 0; else /* return 0 directly if doesn't support stop mode feature */ return 0; @@ -2013,6 +2035,7 @@ 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,imx93-flexcan", .data = &fsl_imx93_devtype_data, }, + { .compatible = "fsl,imx95-flexcan", .data = &fsl_imx95_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, }, @@ -2311,9 +2334,22 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device) if (netif_running(dev)) { int err; - if (device_may_wakeup(device)) + if (device_may_wakeup(device)) { flexcan_enable_wakeup_irq(priv, true); + /* For FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI, it need + * ATF to send request to SM through SCMI protocol, + * SM will assert the IPG_STOP signal. But all this + * works need the CAN clocks keep on. + * After the CAN module get the IPG_STOP mode, and + * switch to STOP mode, whether still keep the CAN + * clocks on or gate them off depend on the Hardware + * design. + */ + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI) + return 0; + } + err = pm_runtime_force_suspend(device); if (err) return err; @@ -2330,9 +2366,12 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device) if (netif_running(dev)) { int err; - err = pm_runtime_force_resume(device); - if (err) - return err; + if (!(device_may_wakeup(device) && + priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI)) { + err = pm_runtime_force_resume(device); + if (err) + return err; + } if (device_may_wakeup(device)) flexcan_enable_wakeup_irq(priv, false); diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h index 025c3417031f4..4933d8c7439e6 100644 --- a/drivers/net/can/flexcan/flexcan.h +++ b/drivers/net/can/flexcan/flexcan.h @@ -68,6 +68,8 @@ #define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15) /* Device supports RX via FIFO */ #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) struct flexcan_devtype_data { u32 quirks; /* quirks needed for different IP cores */