lkml.org 
[lkml]   [2022]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 9/9] nvme-apple: Add support for suspend/resume
Date
From: Hector Martin <marcan@marcan.st>

Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
drivers/nvme/host/apple.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index d89b4ab80169..c949a18ec690 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -1514,6 +1514,36 @@ static void apple_nvme_shutdown(struct platform_device *pdev)
apple_rtkit_shutdown(anv->rtk);
}

+#ifdef CONFIG_PM_SLEEP
+static int apple_nvme_resume(struct device *dev)
+{
+ struct apple_nvme *anv = dev_get_drvdata(dev);
+
+ return nvme_reset_ctrl(&anv->ctrl);
+}
+
+static int apple_nvme_suspend(struct device *dev)
+{
+ struct apple_nvme *anv = dev_get_drvdata(dev);
+ int ret = 0;
+
+ apple_nvme_disable(anv, true);
+
+ if (apple_rtkit_is_running(anv->rtk))
+ ret = apple_rtkit_shutdown(anv->rtk);
+
+ writel_relaxed(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
+ (void)readl_relaxed(anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
+
+ return ret;
+}
+
+static const struct dev_pm_ops apple_nvme_pm_ops = {
+ .suspend = apple_nvme_suspend,
+ .resume = apple_nvme_resume,
+};
+#endif
+
static const struct of_device_id apple_nvme_of_match[] = {
{ .compatible = "apple,nvme-ans2" },
{},
@@ -1524,6 +1554,9 @@ static struct platform_driver apple_nvme_driver = {
.driver = {
.name = "nvme-apple",
.of_match_table = apple_nvme_of_match,
+#ifdef CONFIG_PM_SLEEP
+ .pm = &apple_nvme_pm_ops,
+#endif
},
.probe = apple_nvme_probe,
.remove = apple_nvme_remove,
--
2.25.1
\
 
 \ /
  Last update: 2022-03-21 17:53    [W:0.733 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site