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