xref: /openbmc/linux/drivers/cxl/core/core.h (revision 26a4bf80)
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_dax_region_type;
19 extern const struct device_type cxl_region_type;
20 void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled);
21 #define CXL_REGION_ATTR(x) (&dev_attr_##x.attr)
22 #define CXL_REGION_TYPE(x) (&cxl_region_type)
23 #define SET_CXL_REGION_ATTR(x) (&dev_attr_##x.attr),
24 #define CXL_PMEM_REGION_TYPE(x) (&cxl_pmem_region_type)
25 #define CXL_DAX_REGION_TYPE(x) (&cxl_dax_region_type)
26 int cxl_region_init(void);
27 void cxl_region_exit(void);
28 #else
29 static inline void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled)
30 {
31 }
32 static inline int cxl_region_init(void)
33 {
34 	return 0;
35 }
36 static inline void cxl_region_exit(void)
37 {
38 }
39 #define CXL_REGION_ATTR(x) NULL
40 #define CXL_REGION_TYPE(x) NULL
41 #define SET_CXL_REGION_ATTR(x)
42 #define CXL_PMEM_REGION_TYPE(x) NULL
43 #define CXL_DAX_REGION_TYPE(x) NULL
44 #endif
45 
46 struct cxl_send_command;
47 struct cxl_mem_query_commands;
48 int cxl_query_cmd(struct cxl_memdev *cxlmd,
49 		  struct cxl_mem_query_commands __user *q);
50 int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s);
51 void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr,
52 				   resource_size_t length);
53 
54 struct dentry *cxl_debugfs_create_dir(const char *dir);
55 int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
56 		     enum cxl_decoder_mode mode);
57 int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size);
58 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled);
59 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
60 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
61 extern struct rw_semaphore cxl_dpa_rwsem;
62 
63 int cxl_memdev_init(void);
64 void cxl_memdev_exit(void);
65 void cxl_mbox_init(void);
66 
67 #endif /* __CXL_CORE_H__ */
68