xref: /openbmc/u-boot/include/nvme.h (revision 87a62bce)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2017 NXP Semiconductors
4  * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
5  */
6 
7 #ifndef __NVME_H__
8 #define __NVME_H__
9 
10 struct nvme_dev;
11 
12 /**
13  * nvme_identify - identify controller or namespace capabilities and status
14  *
15  * This issues an identify command to the NVMe controller to return a data
16  * buffer that describes the controller or namespace capabilities and status.
17  *
18  * @dev:	NVMe controller device
19  * @nsid:	0 for controller, namespace id for namespace to identify
20  * @cns:	1 for controller, 0 for namespace
21  * @dma_addr:	dma buffer address to store the identify result
22  * @return:	0 on success, -ETIMEDOUT on command execution timeout,
23  *		-EIO on command execution fails
24  */
25 int nvme_identify(struct nvme_dev *dev, unsigned nsid,
26 		  unsigned cns, dma_addr_t dma_addr);
27 
28 /**
29  * nvme_get_features - retrieve the attributes of the feature specified
30  *
31  * This retrieves the attributes of the feature specified.
32  *
33  * @dev:	NVMe controller device
34  * @fid:	feature id to provide data
35  * @nsid:	namespace id the command applies to
36  * @dma_addr:	data structure used as part of the specified feature
37  * @result:	command-specific result in the completion queue entry
38  * @return:	0 on success, -ETIMEDOUT on command execution timeout,
39  *		-EIO on command execution fails
40  */
41 int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
42 		      dma_addr_t dma_addr, u32 *result);
43 
44 /**
45  * nvme_set_features - specify the attributes of the feature indicated
46  *
47  * This specifies the attributes of the feature indicated.
48  *
49  * @dev:	NVMe controller device
50  * @fid:	feature id to provide data
51  * @dword11:	command-specific input parameter
52  * @dma_addr:	data structure used as part of the specified feature
53  * @result:	command-specific result in the completion queue entry
54  * @return:	0 on success, -ETIMEDOUT on command execution timeout,
55  *		-EIO on command execution fails
56  */
57 int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
58 		      dma_addr_t dma_addr, u32 *result);
59 
60 /**
61  * nvme_scan_namespace - scan all namespaces attached to NVMe controllers
62  *
63  * This probes all registered NVMe uclass device drivers in the system,
64  * and tries to find all namespaces attached to the NVMe controllers.
65  *
66  * @return:	0 on success, -ve on error
67  */
68 int nvme_scan_namespace(void);
69 
70 /**
71  * nvme_print_info - print detailed NVMe controller and namespace information
72  *
73  * This prints out detailed human readable NVMe controller and namespace
74  * information which is very useful for debugging.
75  *
76  * @udev:	NVMe controller device
77  * @return:	0 on success, -EIO if NVMe identify command fails
78  */
79 int nvme_print_info(struct udevice *udev);
80 
81 #endif /* __NVME_H__ */
82