From patchwork Tue Jul 2 16:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13720082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56F1EC30658 for ; Tue, 2 Jul 2024 16:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=+JtiVlLkVC0hq32HXAouFb/XPrihMAJWSfHCeGySDmY=; b=S/EkohFLoLxmxCdDgY9Sql1PUQ Fbdd7twZ9b9cUZipOAIAqro/b0nuN95lm1x7BOYp1UKu2DCmZvfIWGSdGU6hL6N1uJ4FchWNU3G7p AJWu9IsnEBfSPflCvkxl58SGILH22vmfhsVjO7nDSw9hL0UPaJWJ4jTQkhsATe8GO16w9tWKYc1k3 HMwuq9bWXdN1BjBjVGW1XmaY7HxtulIWfLu3YQFdxxd0UkjZUWVRaI0rDH+1F4McxFfqMjN0PKT15 TFVVvHzF3iMHRIwA4Q0CHHHJSWcgSEfERbRMgGafzaJNoGeLq0z3ESwZqT8K5ceVi3ToVx4Mwp0Wk qFqeJKOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOge4-00000007Qpn-09CW; Tue, 02 Jul 2024 16:46:20 +0000 Received: from mail-vi1eur03on20631.outbound.protection.outlook.com ([2a01:111:f403:260c::631] helo=EUR03-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOgdo-00000007Qjc-3xJU for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2024 16:46:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hdv+lF+ngixLXDgA7+9NO7idJAge+WjEG1wVQXriT5T+Gu18k7+aAtffQa9E0BRsLz9hbVGGmMFCnSVKWeuEvzazwqGhnPu3iQ3bITQKoUMMyX9q0BshAMxWA61CYbBk0RLkIspjeY2I8FtLLXxJgjBBYyOmhv3zVRJAKUUkRu1MKSuXIgh1mk4Wvzf9Y5hEoeC4Ww7L+UOhb1+zVfp8jEb9v4c5+R72DSnSrpKdJwqPnvgk4PFTB34gNQqCBRmlOOOX7vNLXXr98AgYIt0uPEUvr4I7AzckfOxuBKCCUw9VVoTACajnrf+uPTLF2aZbArNHC6Gin5dxV5YGDsilHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=+JtiVlLkVC0hq32HXAouFb/XPrihMAJWSfHCeGySDmY=; b=H66WbUPx8wZqhj2tCs8XWQgPH/yzCU7Cy1Sd47f2LWniB7738vavBiZLYptnpq90Yrnf1MBU/ZyvlgftgAF3e7I9PTnwPaiE5i8edYgrpNl90Y10EfpWhJm2BdCD/HlKuETe4Y7tlKHCQhTQsvoSPS+eFTEFneZmfTSyEP8V9mPJx3fKP/qJEN8WJA9LTab9D++pgWYIQocPKCIyZOMrrlAc0BSTnhwPfBaZfniyTALbzEQZaHxIDUrikcaWgXt2XnBFZrih+HjMipJIVNKj70WIq613nO3p7Z0MnRsQkvOBGRWVQU4e3DikVr2cV80+0IWPgRIIdzLX6md2XhMIXg== 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=+JtiVlLkVC0hq32HXAouFb/XPrihMAJWSfHCeGySDmY=; b=EQ6cIgbDcK19XGhpmHa3qkresc3quvq/nj4ECtZMMHV49MikIwi6zn36uJzkAUOvhE/m7ebEFgMbSQDh2y1YArT0UI2aiXcOibU7Onv8zALKKaKqFodeZSO2HW5KwQF/Pkl1kT9syxOzxpFB5BtBcYSlfHVPOLstC52XtfuqH40= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) by AS8PR04MB8643.eurprd04.prod.outlook.com (2603:10a6:20b:42a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Tue, 2 Jul 2024 16:45:53 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::21bf:975e:f24d:1612]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::21bf:975e:f24d:1612%2]) with mapi id 15.20.7698.025; Tue, 2 Jul 2024 16:45:53 +0000 From: Shenwei Wang To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Shawn Guo , Sascha Hauer Cc: Pengutronix Kernel Team , Fabio Estevam , linux-pwm@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, Shenwei Wang Subject: [PATCH v2] pwm: imx-tpm: Enable pinctrl setting for sleep state Date: Tue, 2 Jul 2024 11:45:14 -0500 Message-Id: <20240702164514.11007-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR07CA0057.namprd07.prod.outlook.com (2603:10b6:a03:60::34) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|AS8PR04MB8643:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c83697b-94f1-4103-5808-08dc9ab66fba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: zS6ECyFyBzXD+Os7WQv1fwc9wEh4Sw9q4Qatj7ZI8Y9g+xRD/WUQ5hg0baKIikn70RMSybHA2j1fdfa90u/E+wogIj11ABFiptur2vNglNLd5rpPIsMcQyMIHipFoiITbmwh7VHq0yGjumrPNyiz8YZXlnaMCp5t4VcfgefvTX0cuEZNErZhuj7+oDBqm0ZpaRBdRa4mvL4tQRaaIT/uFbk5EyijpHIoTTFpwrpzRmdZo47jyaNLM0ZgpzeU2m9yzwmbLY1IH41zZEd/lGa0jMs9uxC1n8xr+kz3fsjaB/UqE53DLGY5pmViSMMLnzKPFylfn8Qf1c/FjdLVyajjMAQTmP0jwadXd6xW0/CNkQq1oLt785pg2SDss38puz41uYE9C7uLc1h6Ovio8/SZ7YyylzAQa7FexDG6A4GN0FKLfAYhyObJWMMXuh6W6kk+1Kchs30kHyZGJ8ApKaikeCzqm7tvcGpqc6D3JWHdznItBlEs3A3S5xYnSy2rgqdY0UHQl5tUGFAzbbmGjxS36bg/51+6bM1S5KUhGHqeFLPLJjeHx6nwUkHrgecUGv6BQI1bVLbFQM+nQXxFki0hKsyKArqjia2MUpMalWYCXuyWRnmmQdH5oB8RCfHT64kabOThNO2PhN3zchlhyYvtUB8CA4yRHXVj4aSTp0p7Ffr0I+hvnpzQ2kekhXop2Rlw1C4m1MdYjD5fBM2pWsGFwRkqou+G1tMokfH36nAOJgaem9A54MJ2HuRbocj6Lx1Zflti1w6yRbpAO8t4lIzX/0IGdcsvamkJmlUYMKz9MACSG3PHPjh/u7e47y6BTaKC3tRxhSfR3bw4wbU9MoCw+fSP2yReC/psk9O8OEUnIn6rkeFr8zQYsYD7WxU3z7kFTbsdjbEurHTdPkOieIY6YvrMRbrpvjS+mDRbrYBk6R6pLwihl8bY2WDhLE6v/WNgu7UG3U0+v5rfdwQs3XRanvlHZK7UEiidxMDHTGAnVpFhp3kzknI1LpY4fZ95AEOQmmzWwYDRb5nG2czaXFGzEXgbVEbyQxVBq3gbGwmMHiwoq9IR3GMgq/vyKeGmCMQuQaKXdOQbiqRqutDeejl44IIJHcNM20eAv9tXhAUqrCsrg9GoQplokaDMECarAgqJvMcxLaf8l4/e/yUqV9PH8qZpEOrn/mDMZ8NLExMOXRSB/hExdOLmtooaR0TLEaujYq01USo47shS7Shp/Ak19eNptTAbCYCyXEFhq5R8rZGgInLH9YVNhEJAV92nUWpCXHsjNYk4neJe8098eAl+HJ6mr2YIejsG4Twa1UuvVP0xwucywNwmhn4V4Uc6QrXc/4Rlyt+dbyv8EQrcCRRse/Uw+9LBqlNs5mx6HJHJQ72NFuHXYRW2YRRf22EK6ND4JUuY6bLtt5sFNCw6uKEMrA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9185.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SDohPSguG+bhnZb1ztmENVAjmPj7EUpaqi4HU1TXN2rlqGgehOo1XhriBNoU0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mDNeG2RpEEn1CmploXZlzBOMBspqlUwkTXQ3iUbZMjgs7nu365qlcW2efURVaev+hYPHC/Kxok4t+avQwUFRR5Yn1TYMjuCPwpoGXoHvNRt6j6VyD+i7qganF5Y525Syu07WDNq1X8P5A93UQOpT6Y9aofxIoxH/9shluf0ov18BmxUNUBSELzgkbPcQkPpGgg/qcrQdWH7kBQ8JNy6tkeNfHIIure9ABdfm1d5zamGn2P+02RR1fiopT/ScQTuuWCW088SJBdP2sJ2RW7Y0TIDiYucZpCLJEtqXWe6jIQSszbjHcKhJhmZb2XB/6NY+3rvEcP0y6tC9yqVmCEY4ccZgrfc9f3D7VbDY/fFxDqUDApfwLDBq1v5tauFmcoixy+Y5w4xpsmM58HBhyhDoJFDqfyGnEwef4oHzbOkkIkUZvjt4AC2gBDY3RBN+O5pLYi4zRgsw3unPV8tu0nlQ5l4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c83697b-94f1-4103-5808-08dc9ab66fba X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2024 16:45:53.2249 (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: Jj4JHHY4WxwmNzNO6zZqBugNbGQSvF0AgdN78oyQkgvfYkm+ipv/Vcta8bpyXmsv2aTHrAHa+y0hBjCHNVUdZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8643 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240702_094605_172689_8559FD1B X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Apply the pinctrl setting of sleep state when system enters suspend state. Restore to the default pinctrl setting when system resumes. Signed-off-by: Shenwei Wang --- Changes in V2: - restore the clk states in error path in .suspend function - restore the pinctrl states in error path in .resume function drivers/pwm/pwm-imx-tpm.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index c50ddbac43c8..96ea343856f0 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -380,6 +381,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev) static int pwm_imx_tpm_suspend(struct device *dev) { struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); + int ret; if (tpm->enable_count > 0) return -EBUSY; @@ -393,7 +395,11 @@ static int pwm_imx_tpm_suspend(struct device *dev) clk_disable_unprepare(tpm->clk); - return 0; + ret = pinctrl_pm_select_sleep_state(dev); + if (ret) + clk_prepare_enable(tpm->clk); + + return ret; } static int pwm_imx_tpm_resume(struct device *dev) @@ -401,9 +407,15 @@ static int pwm_imx_tpm_resume(struct device *dev) struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); int ret = 0; - ret = clk_prepare_enable(tpm->clk); + ret = pinctrl_pm_select_default_state(dev); if (ret) + return ret; + + ret = clk_prepare_enable(tpm->clk); + if (ret) { dev_err(dev, "failed to prepare or enable clock: %d\n", ret); + pinctrl_pm_select_sleep_state(dev); + } return ret; }