From patchwork Tue Jul 23 20:48:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13740377 X-Patchwork-Delegate: kuba@kernel.org Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010011.outbound.protection.outlook.com [52.101.69.11]) (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 0CBAB1465A3; Tue, 23 Jul 2024 20:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721767753; cv=fail; b=t6tR3KUTI57do/PH1/6IU+q7qgpiwS+g+5vAeIaKyNaOO91gNXSHIxEaE4/7avPgA4s2b+Hhmc8oUQ5Da2EBTOjnvETipfaBMhiLk4NailNRFSGrLy7EySZGMw+L2qWnDz0lYGtyjMpLD7Fr9XpAgojKUOrdCF+OPW4mhHdsdCA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721767753; c=relaxed/simple; bh=IVSQUSfBDeaesbJm52M4rmlYN3OmCbE5ouiCrdgSVOk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=n9GhK/WlyKn3/xWcYbP5xx1F2lpKl++u2py67WogUBOJrUVZlOlIw1B8MfMTIVbvkvsntJ0jj1H5XbcuRNO3RZ5SYzJRYe3ytQsvpaPZzVNqv5xSxwuFTt7iDG6/pYB9Qzc44ycdoku3v4709UrGRke6ZOzm2kxAyRrxcBec4ps= 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=iD5dHPXn; arc=fail smtp.client-ip=52.101.69.11 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="iD5dHPXn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bTK5OiN41Lfwb2ZcjU0UPuwnrzCYADqB8lpdQr50UhCoisnr/nnFnXyXXST3donzN9CejJPRDt0Pi/S78lgGTc3IUPGYEkBFmVPo5aFwgZ4qK8zrPZwb1R2tjlm9v98A/hWEGj7flqw/Ap901t2Egp69WadSePxUF/DPoMzyVSei+C9ZiEOTBREoKWvJNQlDJsCtwgWinZbC7qkc39KP6kr4Z73CtIHoLVZQtw5YGAt/dljnCAbcYmlfhHU553jwCJ1qCDRNy8LNTZvEN1Dn4xRHZEt+82TJNR942mlPv6FIkkHdsX3uPle3YqFrzd64hdZ8Q/hhDzmlr5DWOuIsBg== 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=St4NJuio65wQSfmzYa86IyNljHrNbq7WpnUr3BaOoQo=; b=DCYaO/RXNSncpeV/H2xYjLFkr6I0scx7l6siJu9qWBNJRq+k0pUA36K9tEQwTfZ6ksQS6klyN+0VtT4kXBCTcmOJPR4ek9yBjKGvPMbjCHQnVc59L48xV2a5V/MBgQtAyk/MteWQyzd4o0eow20Fixul5GPX1mn1YdbGXdlfHqCah2aV5960BzSTLfZij6raFeqZs5fJlPmBlYIIMWkpHcf8TZutvlLEERnosXsxr83w8mZda7ow5pNpROgfjVsf2+9FRvvk84zH+rNtNHR464UR0spyWHDenm0MqVavbXz/TWY9FpoJKBKeFKIGQH5sp+DskYK/B6sEUhMzohbEMg== 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=St4NJuio65wQSfmzYa86IyNljHrNbq7WpnUr3BaOoQo=; b=iD5dHPXnKFn67aXoEI/AfbXpebJLbdT6U8+N8wONj7CjltvhqWjWtl4Mz2Sf4JCNcaw7H33xfcxIdN4etBkMBR3hmBgRc4Y4ygrzx6oghe+N3sRqWhvFpNo2AVd98FAQWHV7wOmCphpEZPzsPy6PrKrsWRb+KOYA8Z7ZRqijA8M= 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 VE1PR04MB7470.eurprd04.prod.outlook.com (2603:10a6:800:1a3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Tue, 23 Jul 2024 20:49:07 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.7784.017; Tue, 23 Jul 2024 20:49:07 +0000 From: Frank Li Date: Tue, 23 Jul 2024 16:48:36 -0400 Subject: [PATCH v3 2/2] can: flexcan: add wakeup support for imx95 Message-Id: <20240723-flexcan-v3-2-084056119ac8@nxp.com> References: <20240723-flexcan-v3-0-084056119ac8@nxp.com> In-Reply-To: <20240723-flexcan-v3-0-084056119ac8@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=1721767734; l=6676; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DZF8lRBk1z5gCbtmnlwiLvTEP638d+rt+ccnMOssc7U=; b=2PGjp3nrhOHz+pKOhG0BHZXpfi4xP2i/PEJAEjEA0C+QGF/GRQt9gfcx6ztozxWeebCtUOTAS lGb9oz0pxP3AVhvLBuLExicikHCdFuFQuVBh9+HZ3Bx2egOt4R3AmNg X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0115.namprd05.prod.outlook.com (2603:10b6:a03:334::30) 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_|VE1PR04MB7470:EE_ X-MS-Office365-Filtering-Correlation-Id: 740d3e29-d6ef-41af-8d74-08dcab58e52f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?jOau15MW1jAG19rUpduotCz0tuogwe2?= =?utf-8?q?eOPV7IE/N/rHNizOMWZgHOEYcthwZKln68rCfi6kI4NPXuLqm+r5rckvQ+fmYjFWQ?= =?utf-8?q?c8Wzz3qwZ+QQJ6efA8Mb0hUe1tzeQb5YnbbLp8f5I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A3vzi3iPfR7VZVCR/WhXga?= =?utf-8?q?RFeWDTy64BZKyfgW/V0nxkAcPIDXJGKUBmmpT5vsCXw2ZEPJsB1775RX/H+0p6nPq?= =?utf-8?q?TA6AKN2YOQyEm+v84+TA4gavbWQQy9TbKxmyNIJpkqjU9cgWLZqoeMArFc7xtwIJk?= =?utf-8?q?f+ujAUj1vfM7i/iqo8w0u10EIxqJzWqAm7pMAcmWgMAJ3ZlbFbQCUlrF0eYHlznhe?= =?utf-8?q?llhezbObWYrir9lAKJurKR5Sv0rYq85uWRg4rXgtr+mwEZzWz4kZIvUerbxIyhIcn?= =?utf-8?q?FXYnZBlfkfPU6aKe4SAL/bZa8z1D/LenppxG/RQdp+nJ+xh/oZXL4w4WOFkiGQICH?= =?utf-8?q?MNazQ089A8j5gMkP8Lw4I+K68gyv2WONRw=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)(7416014)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?aSWMGzPfHkAkF5yQYeLog/v8Vh/V?= =?utf-8?q?wO3uRPXbBhiqTmYP72RNTilWxwdPJmOk/Pw76xTXOx6jY55+f17Pdh24B+wWEPvQT?= =?utf-8?q?hYlIRBOCLLZBb8JXQzT5ig9vMFcMhUsCGF3ZbdxO6alQlZe00LqlKSROWseXtxc/r?= =?utf-8?q?NQmnWqUh24VNpXK273D20zWBYtc5kw6QftTdYT+CldgoiBucSLohGfU7Blc4B+Q9S?= =?utf-8?q?9V5o9idSQt4BUPrWXRKRIahIvhxIZvVB3j5OaOdkc8VMuiQJdsgQ8s/i+JlpbWnnz?= =?utf-8?q?8luT836W37mOZyLoLf05pOUsiTL45zhd8VHwN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wGBS8zG++3b?= =?utf-8?q?+episL3edcS8OilZreSVN5GzvjGtPTdsQgxKvqK4R6cbh8fymyLTIDWZkAvP7syVq?= =?utf-8?q?MgtgQJo1XCEMcvAybgWfJf0Knx2D9eqIaqADINBe8gEvzlJeh2WtepTW+UX0ChN40?= =?utf-8?q?nqDlueFlGy6yeCkEf6QdH3rLg/Q4yBXeoMuvxQ1rdelD0T5OGtkwJw2iDYmw9hzSH?= =?utf-8?q?5O3/4OpUWXdDKnTdimxi5QbxjE/z2oZR4TADTArfoWtjBzFuFJgpbbGlQTt33GOOg?= =?utf-8?q?9AKYqHTSGoQjlHSGIfM6t1aejlvfGv7HfD5DmaS1lmkvpu1BfqjtmcOl1uI8NFXaC?= =?utf-8?q?3cQn12a3xrEe?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 740d3e29-d6ef-41af-8d74-08dcab58e52f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2024 20:49:07.1229 (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: vkLRdZwe7wZUzEhEyvoxgKfBDcZjE41obLw+01Bl8W0DybARAK4jS76qo0/bJ8fc30v80O6lzppFczhEt6bOgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7470 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 --- Change from v1 to v2 - fsl_imx95_devtype_data keep order by value - Add empty line after fsl_imx95_devtype_data - suspend/resume code look symmetrical --- drivers/net/can/flexcan/flexcan-core.c | 50 +++++++++++++++++++++++++++++----- drivers/net/can/flexcan/flexcan.h | 2 ++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index f6e609c388d55..3c98231e25898 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_SUPPORT_FD | + FLEXCAN_QUIRK_SUPPORT_ECC | FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX | + FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR | FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI, +}; + 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, }, @@ -2314,9 +2337,19 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device) if (device_may_wakeup(device)) flexcan_enable_wakeup_irq(priv, true); - err = pm_runtime_force_suspend(device); - if (err) - return err; + /* For FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI, it need ATF to send + * 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 (!(device_may_wakeup(device) && + priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI)) { + err = pm_runtime_force_suspend(device); + if (err) + return err; + } } return 0; @@ -2330,9 +2363,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 */