Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 542B5C433F5 for ; Sat, 22 Jan 2022 19:39:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AB51583881; Sat, 22 Jan 2022 20:38:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=openbsd.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=kpnmail.nl header.i=@kpnmail.nl header.b="Wi18adRM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EEE981F7E; Sat, 22 Jan 2022 20:38:42 +0100 (CET) Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.186]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9D8B4837D8 for ; Sat, 22 Jan 2022 20:38:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=openbsd.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=kettenis@openbsd.org X-KPN-MessageId: e46f3af4-7bba-11ec-983c-00505699b430 Received: from smtp.kpnmail.nl (unknown [10.31.155.8]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id e46f3af4-7bba-11ec-983c-00505699b430; Sat, 22 Jan 2022 20:38:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kpnmail.nl; s=kpnmail01; h=mime-version:message-id:date:subject:to:from; bh=7J5I9ynSF0Bgy6uzQtTyRj8vufKl7Wy3ytKlw0OAcNI=; b=Wi18adRMlanOnRJ5YAw0tKmWFPRY1yjx6WLf3uKO0jwuiC8/h0d9GNSukxUS/45/RVNJE3XODF6JV wiodDV0+PYVU5Q2fSDcikiMyZOP/sC/lFhmqRpfcMuei7/ufKHHn6RDv5CUFcNiaWf2iiDbkN+YSJ7 Jf941MGXuh3GJ6pY= X-KPN-VerifiedSender: No X-CMASSUN: 33|zoNa5cKfP6HKZgBytG9HEid/QYNrFEUqrBUileA7YiubkExaS2jt1Iao0ofN8Rr yJBVW1IAJAGgWw8IayzIKGQ== X-Originating-IP: 83.163.83.176 Received: from copland.sibelius.xs4all.nl (sibelius.xs4all.nl [83.163.83.176]) by smtp.xs4all.nl (Halon) with ESMTPSA id f60de580-7bba-11ec-a897-00505699d6e5; Sat, 22 Jan 2022 20:39:06 +0100 (CET) From: Mark Kettenis 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 Subject: [PATCH v2 6/9] nvme: Add shutdown function Date: Sat, 22 Jan 2022 20:38:16 +0100 Message-Id: <20220122193819.84907-7-kettenis@openbsd.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220122193819.84907-1-kettenis@openbsd.org> References: <20220122193819.84907-1-kettenis@openbsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Simon Glass Tested on: Macbook Air M1 Tested-by: Simon Glass --- 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