xref: /openbmc/u-boot/include/nvme.h (revision e8f80a5a)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2982388eaSZhikang Zhang /*
3982388eaSZhikang Zhang  * Copyright (C) 2017 NXP Semiconductors
4982388eaSZhikang Zhang  * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
5982388eaSZhikang Zhang  */
6982388eaSZhikang Zhang 
7982388eaSZhikang Zhang #ifndef __NVME_H__
8982388eaSZhikang Zhang #define __NVME_H__
9982388eaSZhikang Zhang 
10982388eaSZhikang Zhang struct nvme_dev;
11982388eaSZhikang Zhang 
12982388eaSZhikang Zhang /**
13982388eaSZhikang Zhang  * nvme_identify - identify controller or namespace capabilities and status
14982388eaSZhikang Zhang  *
15982388eaSZhikang Zhang  * This issues an identify command to the NVMe controller to return a data
16982388eaSZhikang Zhang  * buffer that describes the controller or namespace capabilities and status.
17982388eaSZhikang Zhang  *
18982388eaSZhikang Zhang  * @dev:	NVMe controller device
19982388eaSZhikang Zhang  * @nsid:	0 for controller, namespace id for namespace to identify
20982388eaSZhikang Zhang  * @cns:	1 for controller, 0 for namespace
21982388eaSZhikang Zhang  * @dma_addr:	dma buffer address to store the identify result
22982388eaSZhikang Zhang  * @return:	0 on success, -ETIMEDOUT on command execution timeout,
23982388eaSZhikang Zhang  *		-EIO on command execution fails
24982388eaSZhikang Zhang  */
25982388eaSZhikang Zhang int nvme_identify(struct nvme_dev *dev, unsigned nsid,
26982388eaSZhikang Zhang 		  unsigned cns, dma_addr_t dma_addr);
27982388eaSZhikang Zhang 
28982388eaSZhikang Zhang /**
29982388eaSZhikang Zhang  * nvme_get_features - retrieve the attributes of the feature specified
30982388eaSZhikang Zhang  *
31982388eaSZhikang Zhang  * This retrieves the attributes of the feature specified.
32982388eaSZhikang Zhang  *
33982388eaSZhikang Zhang  * @dev:	NVMe controller device
34982388eaSZhikang Zhang  * @fid:	feature id to provide data
35982388eaSZhikang Zhang  * @nsid:	namespace id the command applies to
36982388eaSZhikang Zhang  * @dma_addr:	data structure used as part of the specified feature
37982388eaSZhikang Zhang  * @result:	command-specific result in the completion queue entry
38982388eaSZhikang Zhang  * @return:	0 on success, -ETIMEDOUT on command execution timeout,
39982388eaSZhikang Zhang  *		-EIO on command execution fails
40982388eaSZhikang Zhang  */
41982388eaSZhikang Zhang int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
42982388eaSZhikang Zhang 		      dma_addr_t dma_addr, u32 *result);
43982388eaSZhikang Zhang 
44982388eaSZhikang Zhang /**
45982388eaSZhikang Zhang  * nvme_set_features - specify the attributes of the feature indicated
46982388eaSZhikang Zhang  *
47982388eaSZhikang Zhang  * This specifies the attributes of the feature indicated.
48982388eaSZhikang Zhang  *
49982388eaSZhikang Zhang  * @dev:	NVMe controller device
50982388eaSZhikang Zhang  * @fid:	feature id to provide data
51982388eaSZhikang Zhang  * @dword11:	command-specific input parameter
52982388eaSZhikang Zhang  * @dma_addr:	data structure used as part of the specified feature
53982388eaSZhikang Zhang  * @result:	command-specific result in the completion queue entry
54982388eaSZhikang Zhang  * @return:	0 on success, -ETIMEDOUT on command execution timeout,
55982388eaSZhikang Zhang  *		-EIO on command execution fails
56982388eaSZhikang Zhang  */
57982388eaSZhikang Zhang int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
58982388eaSZhikang Zhang 		      dma_addr_t dma_addr, u32 *result);
59982388eaSZhikang Zhang 
60982388eaSZhikang Zhang /**
61982388eaSZhikang Zhang  * nvme_scan_namespace - scan all namespaces attached to NVMe controllers
62982388eaSZhikang Zhang  *
63982388eaSZhikang Zhang  * This probes all registered NVMe uclass device drivers in the system,
64982388eaSZhikang Zhang  * and tries to find all namespaces attached to the NVMe controllers.
65982388eaSZhikang Zhang  *
66982388eaSZhikang Zhang  * @return:	0 on success, -ve on error
67982388eaSZhikang Zhang  */
68982388eaSZhikang Zhang int nvme_scan_namespace(void);
69982388eaSZhikang Zhang 
70f6aa61d5SZhikang Zhang /**
71f6aa61d5SZhikang Zhang  * nvme_print_info - print detailed NVMe controller and namespace information
72f6aa61d5SZhikang Zhang  *
73f6aa61d5SZhikang Zhang  * This prints out detailed human readable NVMe controller and namespace
74f6aa61d5SZhikang Zhang  * information which is very useful for debugging.
75f6aa61d5SZhikang Zhang  *
76f6aa61d5SZhikang Zhang  * @udev:	NVMe controller device
77f6aa61d5SZhikang Zhang  * @return:	0 on success, -EIO if NVMe identify command fails
78f6aa61d5SZhikang Zhang  */
79f6aa61d5SZhikang Zhang int nvme_print_info(struct udevice *udev);
80f6aa61d5SZhikang Zhang 
81982388eaSZhikang Zhang #endif /* __NVME_H__ */
82