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 71f6aa61d5SZhikang Zhang /** 72f6aa61d5SZhikang Zhang * nvme_print_info - print detailed NVMe controller and namespace information 73f6aa61d5SZhikang Zhang * 74f6aa61d5SZhikang Zhang * This prints out detailed human readable NVMe controller and namespace 75f6aa61d5SZhikang Zhang * information which is very useful for debugging. 76f6aa61d5SZhikang Zhang * 77f6aa61d5SZhikang Zhang * @udev: NVMe controller device 78f6aa61d5SZhikang Zhang * @return: 0 on success, -EIO if NVMe identify command fails 79f6aa61d5SZhikang Zhang */ 80f6aa61d5SZhikang Zhang int nvme_print_info(struct udevice *udev); 81f6aa61d5SZhikang Zhang 82*ff15e123SPatrick Wildt /** 83*ff15e123SPatrick Wildt * nvme_get_namespace_id - return namespace identifier 84*ff15e123SPatrick Wildt * 85*ff15e123SPatrick Wildt * This returns the namespace identifier. 86*ff15e123SPatrick Wildt * 87*ff15e123SPatrick Wildt * @udev: NVMe controller device 88*ff15e123SPatrick Wildt * @ns_id: Place where to put the name space identifier 89*ff15e123SPatrick Wildt * @eui64: Place where to put the IEEE Extended Unique Identifier 90*ff15e123SPatrick Wildt * @return: 0 on success, -ve on error 91*ff15e123SPatrick Wildt */ 92*ff15e123SPatrick Wildt int nvme_get_namespace_id(struct udevice *udev, u32 *ns_id, u8 *eui64); 93*ff15e123SPatrick Wildt 94982388eaSZhikang Zhang #endif /* __NVME_H__ */ 95