All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@openbsd.org>
To: u-boot@lists.denx.de
Cc: sjg@chromium.org, jh80.chung@samsung.com, trini@konsulko.com,
	sven@svenpeter.dev, marcan@marcan.st, bmeng.cn@gmail.com,
	Mark Kettenis <kettenis@openbsd.org>
Subject: [PATCH v2 6/9] nvme: Add shutdown function
Date: Sat, 22 Jan 2022 20:38:16 +0100	[thread overview]
Message-ID: <20220122193819.84907-7-kettenis@openbsd.org> (raw)
In-Reply-To: <20220122193819.84907-1-kettenis@openbsd.org>

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@openbsd.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on: Macbook Air M1
Tested-by: Simon Glass <sjg@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


  parent reply	other threads:[~2022-01-22 19:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-22 19:38 [PATCH v2 0/9] Apple M1 NVMe storage support Mark Kettenis
2022-01-22 19:38 ` [PATCH v2 1/9] nvme: Split out PCI support Mark Kettenis
2022-02-11  0:35   ` Tom Rini
2022-01-22 19:38 ` [PATCH v2 2/9] mailbox: apple: Add driver for Apple IOP mailbox Mark Kettenis
2022-02-11  0:35   ` Tom Rini
2022-01-22 19:38 ` [PATCH v2 3/9] arm: apple: Change SoC name from "m1" into "apple" Mark Kettenis
2022-01-22 22:47   ` Simon Glass
2022-02-11  0:35   ` Tom Rini
2022-01-22 19:38 ` [PATCH v2 4/9] arm: apple: Add RTKit support Mark Kettenis
2022-02-11  0:35   ` Tom Rini
2022-01-22 19:38 ` [PATCH v2 5/9] nvme: Introduce driver ops Mark Kettenis
2022-02-11  0:36   ` Tom Rini
2022-01-22 19:38 ` Mark Kettenis [this message]
2022-02-11  0:36   ` [PATCH v2 6/9] nvme: Add shutdown function Tom Rini
2022-01-22 19:38 ` [PATCH v2 7/9] power: domain: apple: Add reset support Mark Kettenis
2022-01-26 23:54   ` Jaehoon Chung
2022-01-27 11:48     ` Mark Kettenis
2022-01-27 22:29       ` Jaehoon Chung
2022-02-11  0:36   ` Tom Rini
2022-01-22 19:38 ` [PATCH v2 8/9] nvme: apple: Add driver for Apple NVMe storage controller Mark Kettenis
2022-02-11  0:36   ` Tom Rini
2022-01-22 19:38 ` [PATCH v2 9/9] configs: apple: Add NVMe boot target Mark Kettenis
2022-02-11  0:36   ` Tom Rini

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=20220122193819.84907-7-kettenis@openbsd.org \
    --to=kettenis@openbsd.org \
    --cc=bmeng.cn@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=marcan@marcan.st \
    --cc=sjg@chromium.org \
    --cc=sven@svenpeter.dev \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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: link
Be 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.