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> |
Dan Williams | f5516ec | 2020-10-13 16:49:43 -0700 | [diff] [blame] | 6 | #include <linux/range.h> |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 7 | |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 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); |
Dan Williams | c2f3011 | 2020-10-13 16:50:03 -0700 | [diff] [blame] | 13 | |
| 14 | #define IORESOURCE_DAX_STATIC (1UL << 0) |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 15 | struct dax_region *alloc_dax_region(struct device *parent, int region_id, |
Dan Williams | a4574f6 | 2020-10-13 16:50:29 -0700 | [diff] [blame^] | 16 | struct range *range, int target_node, unsigned int align, |
Dan Williams | c2f3011 | 2020-10-13 16:50:03 -0700 | [diff] [blame] | 17 | unsigned long flags); |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 18 | |
| 19 | enum dev_dax_subsys { |
Dan Williams | 174ebec | 2020-10-13 16:49:38 -0700 | [diff] [blame] | 20 | DEV_DAX_BUS = 0, /* zeroed dev_dax_data picks this by default */ |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 21 | DEV_DAX_CLASS, |
| 22 | }; |
| 23 | |
Dan Williams | 174ebec | 2020-10-13 16:49:38 -0700 | [diff] [blame] | 24 | struct dev_dax_data { |
| 25 | struct dax_region *dax_region; |
| 26 | struct dev_pagemap *pgmap; |
| 27 | enum dev_dax_subsys subsys; |
Dan Williams | c2f3011 | 2020-10-13 16:50:03 -0700 | [diff] [blame] | 28 | resource_size_t size; |
Dan Williams | 174ebec | 2020-10-13 16:49:38 -0700 | [diff] [blame] | 29 | int id; |
| 30 | }; |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 31 | |
Dan Williams | 174ebec | 2020-10-13 16:49:38 -0700 | [diff] [blame] | 32 | struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data); |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 33 | |
| 34 | /* to be deleted when DEV_DAX_CLASS is removed */ |
| 35 | 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] | 36 | |
| 37 | struct dax_device_driver { |
| 38 | struct device_driver drv; |
| 39 | struct list_head ids; |
| 40 | int match_always; |
Dan Williams | f11cf81 | 2020-10-13 16:50:08 -0700 | [diff] [blame] | 41 | int (*probe)(struct dev_dax *dev); |
| 42 | int (*remove)(struct dev_dax *dev); |
Dan Williams | d200781 | 2018-11-07 15:31:23 -0800 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | int __dax_driver_register(struct dax_device_driver *dax_drv, |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 46 | struct module *module, const char *mod_name); |
| 47 | #define dax_driver_register(driver) \ |
| 48 | __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) |
Dan Williams | d200781 | 2018-11-07 15:31:23 -0800 | [diff] [blame] | 49 | void dax_driver_unregister(struct dax_device_driver *dax_drv); |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 50 | void kill_dev_dax(struct dev_dax *dev_dax); |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 51 | |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 52 | #if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT) |
Dan Williams | f11cf81 | 2020-10-13 16:50:08 -0700 | [diff] [blame] | 53 | int dev_dax_probe(struct dev_dax *dev_dax); |
Dan Williams | 730926c | 2017-07-16 13:51:53 -0700 | [diff] [blame] | 54 | #endif |
| 55 | |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 56 | /* |
| 57 | * While run_dax() is potentially a generic operation that could be |
| 58 | * defined in include/linux/dax.h we don't want to grow any users |
| 59 | * outside of drivers/dax/ |
| 60 | */ |
| 61 | void run_dax(struct dax_device *dax_dev); |
| 62 | |
| 63 | #define MODULE_ALIAS_DAX_DEVICE(type) \ |
| 64 | MODULE_ALIAS("dax:t" __stringify(type) "*") |
| 65 | #define DAX_DEVICE_MODALIAS_FMT "dax:t%d" |
| 66 | |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 67 | #endif /* __DAX_BUS_H__ */ |