@@ -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,