From: Ji Sheng Teoh <jisheng.teoh@starfivetech.com> To: Michal Simek <michal.simek@amd.com>, Andi Shyti <andi.shyti@kernel.org> Cc: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>, Ley Foon Tan <leyfoon.tan@starfivetech.com>, <linux-arm-kernel@lists.infradead.org>, <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2] i2c: cadence: Add system suspend and resume PM support Date: Sat, 9 Dec 2023 21:15:16 +0800 [thread overview] Message-ID: <20231209131516.1916550-1-jisheng.teoh@starfivetech.com> (raw) 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 <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) }; -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Ji Sheng Teoh <jisheng.teoh@starfivetech.com> To: Michal Simek <michal.simek@amd.com>, Andi Shyti <andi.shyti@kernel.org> Cc: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>, Ley Foon Tan <leyfoon.tan@starfivetech.com>, <linux-arm-kernel@lists.infradead.org>, <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2] i2c: cadence: Add system suspend and resume PM support Date: Sat, 9 Dec 2023 21:15:16 +0800 [thread overview] Message-ID: <20231209131516.1916550-1-jisheng.teoh@starfivetech.com> (raw) 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 <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) }; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-12-09 13:15 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-09 13:15 Ji Sheng Teoh [this message] 2023-12-09 13:15 ` [PATCH v2] i2c: cadence: Add system suspend and resume PM support Ji Sheng Teoh 2023-12-09 20:57 ` Andi Shyti 2023-12-09 20:57 ` Andi Shyti 2023-12-10 5:20 ` Ji Sheng Teoh 2023-12-10 5:20 ` Ji Sheng Teoh 2023-12-10 11:54 ` Andi Shyti 2023-12-10 11:54 ` Andi Shyti 2023-12-10 16:21 ` Ji Sheng Teoh 2023-12-10 16:21 ` Ji Sheng Teoh 2024-01-07 23:47 ` JiSheng Teoh 2024-01-07 23:47 ` JiSheng Teoh
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231209131516.1916550-1-jisheng.teoh@starfivetech.com \ --to=jisheng.teoh@starfivetech.com \ --cc=andi.shyti@kernel.org \ --cc=leyfoon.tan@starfivetech.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-i2c@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=michal.simek@amd.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.