[PATCH v2 6/9] nvme: Add shutdown function

Mark Kettenis kettenis at openbsd.org
Sat Jan 22 20:38:16 CET 2022


Add a function to disable the NVMe controller. This will be used
to let the driver for the NVMe storage integrated on Apple SoCs
shutdown the NVMe controller such we can shutdown the NVMe
IOP controller in a clean way afterwards before handing control
to the OS.

Signed-off-by: Mark Kettenis <kettenis at openbsd.org>
Reviewed-by: Simon Glass <sjg at chromium.org>
Tested on: Macbook Air M1
Tested-by: Simon Glass <sjg at chromium.org>
---

ChangeLog:

v2: - Add comments


 drivers/nvme/nvme.c |  7 +++++++
 drivers/nvme/nvme.h | 12 ++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index e7cbf39c96..1d56517e99 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -896,3 +896,10 @@ free_queue:
 free_nvme:
 	return ret;
 }
+
+int nvme_shutdown(struct udevice *udev)
+{
+	struct nvme_dev *ndev = dev_get_priv(udev);
+
+	return nvme_disable_ctrl(ndev);
+}
diff --git a/drivers/nvme/nvme.h b/drivers/nvme/nvme.h
index bc6b79f8dd..bc1d612dde 100644
--- a/drivers/nvme/nvme.h
+++ b/drivers/nvme/nvme.h
@@ -691,6 +691,18 @@ struct nvme_ops {
 	void (*complete_cmd)(struct nvme_queue *nvmeq, struct nvme_command *cmd);
 };
 
+/**
+ * nvme_init() - Initialize NVM Express device
+ * @udev:	The NVM Express device
+ * Return: 0 if OK, -ve on error
+ */
 int nvme_init(struct udevice *udev);
 
+/**
+ * nvme_shutdown() - Shutdown NVM Express device
+ * @udev:	The NVM Express device
+ * Return: 0 if OK, -ve on error
+ */
+int nvme_shutdown(struct udevice *udev);
+
 #endif /* __DRIVER_NVME_H__ */
-- 
2.34.1



More information about the U-Boot mailing list