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