From patchwork Fri Jan 19 01:33:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ji Sheng Teoh X-Patchwork-Id: 13523275 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 05C3DC47DAF for ; Fri, 19 Jan 2024 01:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=Qcw5WDXKwbh8TazqtEmUcEj2RIomdcmWS7Uvg7+NZgo=; b=Y6sbAVEr2qC59k 1Ys9u3tu4GI4badmyv5Uo9U+NM795aXdDMDaHnuJws1mbus67lfgHqIG8TQDDMy827DlD1jdP1p5+ xb02R0DQZmjr+DUySaBqgRydPfhxDvzK//QeyjVcSu84jgNF9gGdnn+AOY11h4gh+/I88Z3tOQowk RPw6vwzJh4/+qGXnsjfOq4ZR2u7VBLYHwp+imIqVNPBN8HF1qnTIE8Wq0D0IJf0PYtA0W7ntgpv2A KvnqqdXwUQaRlF39FTp5O2qAAVdUSMkFkfKoenig60+ycnWsTa346cEXIA/hCUo9X3EE9Dw2YT7Gs gT6FZjFFCyBC7npgZe7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQdlr-004EYp-2f; Fri, 19 Jan 2024 01:34:11 +0000 Received: from mail-bjschn02on20608.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::608] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQdln-004EWf-2w for linux-arm-kernel@lists.infradead.org; Fri, 19 Jan 2024 01:34:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/NV0tR8sfdeADM+fRIu0FY7DFOZHod0JU0BRzqN0Yz3BbtCV01o5GiHJOpcjtUNMyJRBtx+uMZNcSn5CBM0qfe526rg+Xv0LpYCSJAzX11qbfb5jnOTtPINYJ8wFNUrEYDqbW/S8HHVIHN20Pg9LzZjthMgwi6SitiZ8eh6NhOy48crmxFrmAjJ8AYXF+d+Mkgo/G2/Aob82LP3Xzn2XR5JE8TNkpUOXsrMlDUZDCpdeHFPWghGsWHkogfEmHG9STrL87l3SVK0owjxHHYr0yXzKMApGq0ZnjcdKlvpqbd5LVYTIMSanA+zpiwgAH6VJ4bF7fYnupXVfKQKEffOYw== 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=zHN2yRlgc83yoJrdYEEwnwT3hYYCyF7Hma4hPrSLxnU=; b=A0RImxqRWeeTRrqlFC5QlqVn/uBBWOG8BZt+IsJwbzrSE0btPYfLaSt7VvCQAyVkGoX2HPfZpisPUrQ/A2KDQudSrX/otYW1QC9O7jprlSQQkbIdpH16LSGK1pxYOqjjvvgof89TuO7B68FAFq7/WS2XGG5fgmGpOKOWNtfviKCakFX3IReuLGmHaPOdkTM8bAIfyt21LzA9ki1vqgqbK05RKaLxBBv84wp6z3xmyGMcT51RZvZx1IpbYG82cYSQp+DcYYZerBkVwKglRdNQ7Z8qIAaC3OxLZLKe27bgpTvLjXpLYLm+9nbCINwx4gEeOEJ+6egfHdCYa4jAZK9cHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:19::6) by ZQ0PR01MB1272.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.32; Fri, 19 Jan 2024 01:33:49 +0000 Received: from ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn ([fe80::1dbb:b090:7d89:4e22]) by ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn ([fe80::1dbb:b090:7d89:4e22%4]) with mapi id 15.20.7181.032; Fri, 19 Jan 2024 01:33:49 +0000 From: Ji Sheng Teoh To: Michal Simek , Andi Shyti Cc: Ji Sheng Teoh , Ley Foon Tan , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 RESEND] i2c: cadence: Add system suspend and resume PM support Date: Fri, 19 Jan 2024 09:33:26 +0800 Message-ID: <20240119013326.3405484-1-jisheng.teoh@starfivetech.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: NT0PR01CA0025.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::7) To ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:19::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1160:EE_|ZQ0PR01MB1272:EE_ X-MS-Office365-Filtering-Correlation-Id: d89e61b0-d0ef-4615-f584-08dc188eafb8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wA+9CpdICGnhXRtYYppajEP7uvl4h/k5vRfuyW2MtpYttl4SefVxZFM9FIXKgyeWIeEuLxy6CVtaXoiXCzKzlOUuZs7HMVyU1hII2VSrEK0ZAF2Yx3NWxozxfcGO9WXtngo0QhFjRmO1tTn6Ynv/UJpYSel09rBMVm6mtfqLxp/szQaKsMe69aK4wUYTT+JJ/0BC/Q0ew2e8OdvHOqoHPW5vHh4eX1nEVyKYK8e2WBX4Pfkd+fJt4V52DLemU8Ma/MzvZ81QGXWRmVjbDSU73ERQvL5SRzlXOO0C+e+N9tuGS4bvEm83+vhFMDtc98H67UHnsPsCPT33OcauPIsT6s53PlXZVqOJUOOXtamJxN5jafTr57DwsmZF49D9QpdgdVVNvjjHCAW57VHA1UvNIMD/wCFNSr6AqDKigxT9jpBGH+sCsBukcBhpvoF9K6I7cLnPSCE5wVzHmRb+nh5fm4UKTPUl6e3KjTaBM/KfMEfSDare131Md2jI1CpT8I9rjyr6UB7QhSTc6IjwQJ3byFGjYrKgfQEMvkBpL9wP1wQlX34//jtKLnuJE5Is4ydl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(39830400003)(136003)(366004)(346002)(396003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(38100700002)(26005)(1076003)(2616005)(6666004)(52116002)(2906002)(5660300002)(15650500001)(83380400001)(41300700001)(508600001)(966005)(4326008)(8676002)(8936002)(66556008)(66476007)(54906003)(110136005)(66946007)(40180700001)(40160700002)(86362001)(36756003)(38350700005)(41320700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EeGM9vJ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Y55+mDQkqOvRNkizR9HJWEDvgg/ttoZa7m6z5J/MFxgzte4tzoIJG9aiVxTAgX28WRtt0NwtZ/YKMjdMSSqe7qcAlJ1rjHrw79Z6QM4MdUet82r8Oy5EiCIUH4NhnBm/gGPnId/x6tcrAq6tbjGmZXTiG2aAXDqLlWxckgGR4ZsDNG+MVtgM6J5oztrGFv3xT8cOrVgjVX9yWpHs3TyGcwTEkoDA0yznryNnQO7qBR1VHRZQyvD6DB9FdSk1zkPTEoMWmIm5wBHV8/ZOmRI7WwaFpETCYcsvzefHcEldn+TP79eF3LRfxDkHVm/0oNof9mryIOaYcfOOZV/ZVMXOASZI6yorAc83+tkT6VuIdx4tHp9rLnROGFmT1K1HRfmXVMqGWGvk0NhyHXC5aBEl+lbxddxjl3iUWaVtERGRSRdGcj9Kq6TJCjS1wHZjVUCy2HS1D7fZEqvYVqgYnMi3elaTHt9+2Qo+FqWM1315c5zX06rPpKSCFplg8N28B9PMXIzOwoJSTdJHGcBmAJVDosEQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d89e61b0-d0ef-4615-f584-08dc188eafb8 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 01:33:49.4561 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UP+mF4bJgGMVpqvG+w9rg91J08WDTvW/tAF36R366lVU/AkbXvYDopo0YCH1TtOxceWAjW5m8aSbdvfx1AwQNwr0zQLxoZACfPDy0xHTnls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1272 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_173407_975680_50403691 X-CRM114-Status: GOOD ( 10.52 ) 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 Enable device system suspend and resume PM support, and mark the device state as suspended during system suspend to reject any data transfer. Signed-off-by: Ji Sheng Teoh Reviewed-by: Andi Shyti --- Initial v2 was archived, previous discussion can be found in [1]. [1]: https://lore.kernel.org/all/20231209131516.1916550-1-jisheng.teoh@starfivetech.com/ Changes since v1: - Add missing err assignment in cdns_i2c_resume(). --- drivers/i2c/busses/i2c-cadence.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index de3f58b60dce..4bb7d6756947 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -1176,6 +1176,18 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) return 0; } +static int __maybe_unused cdns_i2c_suspend(struct device *dev) +{ + struct cdns_i2c *xi2c = dev_get_drvdata(dev); + + i2c_mark_adapter_suspended(&xi2c->adap); + + if (!pm_runtime_status_suspended(dev)) + return cdns_i2c_runtime_suspend(dev); + + return 0; +} + /** * cdns_i2c_init - Controller initialisation * @id: Device private data structure @@ -1219,7 +1231,28 @@ static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) return 0; } +static int __maybe_unused cdns_i2c_resume(struct device *dev) +{ + struct cdns_i2c *xi2c = dev_get_drvdata(dev); + int err; + + err = cdns_i2c_runtime_resume(dev); + if (err) + return err; + + if (pm_runtime_status_suspended(dev)) { + err = cdns_i2c_runtime_suspend(dev); + if (err) + return err; + } + + i2c_mark_adapter_resumed(&xi2c->adap); + + return 0; +} + static const struct dev_pm_ops cdns_i2c_dev_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cdns_i2c_suspend, cdns_i2c_resume) SET_RUNTIME_PM_OPS(cdns_i2c_runtime_suspend, cdns_i2c_runtime_resume, NULL) };