Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 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__ |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 5 | #include <linux/device.h> |
| 6 | |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 7 | struct dev_dax; |
| 8 | struct resource; |
| 9 | struct dax_device; |
| 10 | struct dax_region; |
| 11 | void dax_region_put(struct dax_region *dax_region); |
| 12 | struct dax_region *alloc_dax_region(struct device *parent, int region_id, |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 13 | struct resource *res, int target_node, unsigned int align, |
Dan Williams | 460370a | 2019-11-06 17:43:37 -0800 | [diff] [blame] | 14 | unsigned long long flags); |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 15 | |
| 16 | enum dev_dax_subsys { |
| 17 | DEV_DAX_BUS, |
| 18 | DEV_DAX_CLASS, |
| 19 | }; |
| 20 | |
| 21 | struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id, |
| 22 | struct dev_pagemap *pgmap, enum dev_dax_subsys subsys); |
| 23 | |
| 24 | static inline struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, |
| 25 | int id, struct dev_pagemap *pgmap) |
| 26 | { |
| 27 | return __devm_create_dev_dax(dax_region, id, pgmap, DEV_DAX_BUS); |
| 28 | } |
| 29 | |
| 30 | /* to be deleted when DEV_DAX_CLASS is removed */ |
| 31 | struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys); |
Dan Williams | d200781 | 2018-11-07 15:31:23 -0800 | [diff] [blame] | 32 | |
| 33 | struct dax_device_driver { |
| 34 | struct device_driver drv; |
| 35 | struct list_head ids; |
| 36 | int match_always; |
| 37 | }; |
| 38 | |
| 39 | int __dax_driver_register(struct dax_device_driver *dax_drv, |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 40 | struct module *module, const char *mod_name); |
| 41 | #define dax_driver_register(driver) \ |
| 42 | __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) |
Dan Williams | d200781 | 2018-11-07 15:31:23 -0800 | [diff] [blame] | 43 | void dax_driver_unregister(struct dax_device_driver *dax_drv); |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 44 | void kill_dev_dax(struct dev_dax *dev_dax); |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 45 | |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 46 | #if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT) |
| 47 | int dev_dax_probe(struct device *dev); |
| 48 | #endif |
| 49 | |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 50 | /* |
| 51 | * While run_dax() is potentially a generic operation that could be |
| 52 | * defined in include/linux/dax.h we don't want to grow any users |
| 53 | * outside of drivers/dax/ |
| 54 | */ |
| 55 | void run_dax(struct dax_device *dax_dev); |
| 56 | |
| 57 | #define MODULE_ALIAS_DAX_DEVICE(type) \ |
| 58 | MODULE_ALIAS("dax:t" __stringify(type) "*") |
| 59 | #define DAX_DEVICE_MODALIAS_FMT "dax:t%d" |
| 60 | |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 61 | #endif /* __DAX_BUS_H__ */ |