xref: /openbmc/linux/drivers/dax/bus.h (revision a0936e9e)
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 void dax_region_put(struct dax_region *dax_region);
13 
14 /* dax bus specific ioresource flags */
15 #define IORESOURCE_DAX_STATIC BIT(0)
16 #define IORESOURCE_DAX_KMEM BIT(1)
17 
18 struct dax_region *alloc_dax_region(struct device *parent, int region_id,
19 		struct range *range, int target_node, unsigned int align,
20 		unsigned long flags);
21 
22 struct dev_dax_data {
23 	struct dax_region *dax_region;
24 	struct dev_pagemap *pgmap;
25 	resource_size_t size;
26 	int id;
27 };
28 
29 struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
30 
31 enum dax_driver_type {
32 	DAXDRV_KMEM_TYPE,
33 	DAXDRV_DEVICE_TYPE,
34 };
35 
36 struct dax_device_driver {
37 	struct device_driver drv;
38 	struct list_head ids;
39 	enum dax_driver_type type;
40 	int (*probe)(struct dev_dax *dev);
41 	void (*remove)(struct dev_dax *dev);
42 };
43 
44 int __dax_driver_register(struct dax_device_driver *dax_drv,
45 		struct module *module, const char *mod_name);
46 #define dax_driver_register(driver) \
47 	__dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
48 void dax_driver_unregister(struct dax_device_driver *dax_drv);
49 void kill_dev_dax(struct dev_dax *dev_dax);
50 bool static_dev_dax(struct dev_dax *dev_dax);
51 
52 /*
53  * While run_dax() is potentially a generic operation that could be
54  * defined in include/linux/dax.h we don't want to grow any users
55  * outside of drivers/dax/
56  */
57 void run_dax(struct dax_device *dax_dev);
58 
59 #define MODULE_ALIAS_DAX_DEVICE(type) \
60 	MODULE_ALIAS("dax:t" __stringify(type) "*")
61 #define DAX_DEVICE_MODALIAS_FMT "dax:t%d"
62 
63 #endif /* __DAX_BUS_H__ */
64