xref: /openbmc/linux/drivers/dax/bus.h (revision 2532f416)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
3 #ifndef __DAX_BUS_H__
4 #define __DAX_BUS_H__
5 #include <linux/device.h>
6 #include <linux/range.h>
7 
8 struct dev_dax;
9 struct resource;
10 struct dax_device;
11 struct dax_region;
12 
13 /* dax bus specific ioresource flags */
14 #define IORESOURCE_DAX_STATIC BIT(0)
15 #define IORESOURCE_DAX_KMEM BIT(1)
16 
17 struct dax_region *alloc_dax_region(struct device *parent, int region_id,
18 		struct range *range, int target_node, unsigned int align,
19 		unsigned long flags);
20 
21 struct dev_dax_data {
22 	struct dax_region *dax_region;
23 	struct dev_pagemap *pgmap;
24 	resource_size_t size;
25 	int id;
26 };
27 
28 struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
29 
30 enum dax_driver_type {
31 	DAXDRV_KMEM_TYPE,
32 	DAXDRV_DEVICE_TYPE,
33 };
34 
35 struct dax_device_driver {
36 	struct device_driver drv;
37 	struct list_head ids;
38 	enum dax_driver_type type;
39 	int (*probe)(struct dev_dax *dev);
40 	void (*remove)(struct dev_dax *dev);
41 };
42 
43 int __dax_driver_register(struct dax_device_driver *dax_drv,
44 		struct module *module, const char *mod_name);
45 #define dax_driver_register(driver) \
46 	__dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
47 void dax_driver_unregister(struct dax_device_driver *dax_drv);
48 void kill_dev_dax(struct dev_dax *dev_dax);
49 bool static_dev_dax(struct dev_dax *dev_dax);
50 
51 #define MODULE_ALIAS_DAX_DEVICE(type) \
52 	MODULE_ALIAS("dax:t" __stringify(type) "*")
53 #define DAX_DEVICE_MODALIAS_FMT "dax:t%d"
54 
55 #endif /* __DAX_BUS_H__ */
56