Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2938697rdb; Sat, 9 Dec 2023 05:15:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhikkr5KUpdrGfsvR9ibHHZG1wJTID0nBbECNBHEXiotnje6d2WnChXlK8xzg7Sq77Ws8O X-Received: by 2002:a6b:a0b:0:b0:7b7:338:cae4 with SMTP id z11-20020a6b0a0b000000b007b70338cae4mr2310024ioi.17.1702127757220; Sat, 09 Dec 2023 05:15:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702127757; cv=none; d=google.com; s=arc-20160816; b=bWDk0/tHajeqgiHl6fUlva0DjND7cS+sAISYqk31dIUHas7c8eBTXkJNyX7cpQcSMC q3RDWwXLpbKyEZiPOd6xamkhsbLftH6p2uRaD1JmVRd0oia6Vf9RmW21jauh8Z5KYZLq zeaHVmOmwyXy/5b5SZ/jv+j4UBO+R2Kt/0nF99ypfKtJlDLZkBHAi4h7KnDdG6jT2Dmd xViQ0yR/E8gQxBjJALim7xh56RGJx4mxoO5Mssn+s+IuN8vnT1HBWtdr+LQRN8zewQQD dWQ8Ovo2dwDOFFOqG8LHXDBMd8CnY9uo6h+8ZH/Qs4tQUfSIcls7uIPjOrz5tY9/n9Ba f5zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9pLiGp0uNtStNEByhVxs9gZBhq7wY8OiFxt1R4yqKlY=; fh=tln9a9p6X0VsgY3bwYYvR7QJr/+FoE5BVrGA/Nv1AVI=; b=Smbpm+QDgGfVHz1BgoSIaj4yeq0GcDWxsom6JtKjkzY9o8kUhMl18lTu5Egy2DV3Or 60NtG/UgZRbLMKqGmqUY1JuQH9viqul92pQaH7709d1gJRpPA7iU1xBA6scn7Ypq7ylU dOUL+aTzquH1bFN7aTfNC2F+T0axJowy6uYWYi2BDANDMizWexf8w8wt6+e1q9xeziox DErq7PVGoPA1BqZ5Yh5uvBehczi40vfceouoR+DZ+RuUe7U5Di6cXhc6lau3x19pTNM4 mOR7IrumJ0E9wm168edWbf8ZfmRzcDH3oYH9JFR94CtdF3PZ1LdhcqUc6/ztjTjh1w67 Ivlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h18-20020a056a00231200b006cdfbccebc5si3062428pfh.316.2023.12.09.05.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 05:15:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4D6FD8068E1E; Sat, 9 Dec 2023 05:15:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjLINP0 convert rfc822-to-8bit (ORCPT + 99 others); Sat, 9 Dec 2023 08:15:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjLINPZ (ORCPT ); Sat, 9 Dec 2023 08:15:25 -0500 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7BA1AC; Sat, 9 Dec 2023 05:15:30 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 9DCE024DB83; Sat, 9 Dec 2023 21:15:29 +0800 (CST) Received: from EXMBX072.cuchost.com (172.16.6.82) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 9 Dec 2023 21:15:29 +0800 Received: from localhost.localdomain (202.188.176.82) by EXMBX072.cuchost.com (172.16.6.82) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 9 Dec 2023 21:15:26 +0800 From: Ji Sheng Teoh To: Michal Simek , Andi Shyti CC: Ji Sheng Teoh , Ley Foon Tan , , , Subject: [PATCH v2] i2c: cadence: Add system suspend and resume PM support Date: Sat, 9 Dec 2023 21:15:16 +0800 Message-ID: <20231209131516.1916550-1-jisheng.teoh@starfivetech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [202.188.176.82] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX072.cuchost.com (172.16.6.82) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 09 Dec 2023 05:15:42 -0800 (PST) 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 --- 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) }; -- 2.25.1