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