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