1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright(c) 2020 Intel Corporation. */ 3 4 #ifndef __CXL_CORE_H__ 5 #define __CXL_CORE_H__ 6 7 extern const struct device_type cxl_nvdimm_bridge_type; 8 extern const struct device_type cxl_nvdimm_type; 9 10 extern struct attribute_group cxl_base_attribute_group; 11 12 #ifdef CONFIG_CXL_REGION 13 extern struct device_attribute dev_attr_create_pmem_region; 14 extern struct device_attribute dev_attr_create_ram_region; 15 extern struct device_attribute dev_attr_delete_region; 16 extern struct device_attribute dev_attr_region; 17 extern const struct device_type cxl_pmem_region_type; 18 extern const struct device_type cxl_region_type; 19 void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled); 20 #define CXL_REGION_ATTR(x) (&dev_attr_##x.attr) 21 #define CXL_REGION_TYPE(x) (&cxl_region_type) 22 #define SET_CXL_REGION_ATTR(x) (&dev_attr_##x.attr), 23 #define CXL_PMEM_REGION_TYPE(x) (&cxl_pmem_region_type) 24 int cxl_region_init(void); 25 void cxl_region_exit(void); 26 #else 27 static inline void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled) 28 { 29 } 30 static inline int cxl_region_init(void) 31 { 32 return 0; 33 } 34 static inline void cxl_region_exit(void) 35 { 36 } 37 #define CXL_REGION_ATTR(x) NULL 38 #define CXL_REGION_TYPE(x) NULL 39 #define SET_CXL_REGION_ATTR(x) 40 #define CXL_PMEM_REGION_TYPE(x) NULL 41 #endif 42 43 struct cxl_send_command; 44 struct cxl_mem_query_commands; 45 int cxl_query_cmd(struct cxl_memdev *cxlmd, 46 struct cxl_mem_query_commands __user *q); 47 int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s); 48 void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, 49 resource_size_t length); 50 51 struct dentry *cxl_debugfs_create_dir(const char *dir); 52 int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, 53 enum cxl_decoder_mode mode); 54 int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size); 55 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); 56 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled); 57 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled); 58 extern struct rw_semaphore cxl_dpa_rwsem; 59 60 int cxl_memdev_init(void); 61 void cxl_memdev_exit(void); 62 void cxl_mbox_init(void); 63 64 #endif /* __CXL_CORE_H__ */ 65