blob: fbb940293d6d84384b6fa37eb412790249b4ecf7 [file] [log] [blame]
Dan Williams51cf7842017-07-12 17:58:21 -07001// 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 Williams730926c2017-07-16 13:51:53 -07005#include <linux/device.h>
Dan Williamsf5516ec2020-10-13 16:49:43 -07006#include <linux/range.h>
Dan Williams730926c2017-07-16 13:51:53 -07007
Dan Williams51cf7842017-07-12 17:58:21 -07008struct dev_dax;
9struct resource;
10struct dax_device;
11struct dax_region;
12void dax_region_put(struct dax_region *dax_region);
Dan Williamsc2f30112020-10-13 16:50:03 -070013
14#define IORESOURCE_DAX_STATIC (1UL << 0)
Dan Williams51cf7842017-07-12 17:58:21 -070015struct dax_region *alloc_dax_region(struct device *parent, int region_id,
Dan Williamsa4574f62020-10-13 16:50:29 -070016 struct range *range, int target_node, unsigned int align,
Dan Williamsc2f30112020-10-13 16:50:03 -070017 unsigned long flags);
Dan Williams730926c2017-07-16 13:51:53 -070018
Dan Williams174ebec2020-10-13 16:49:38 -070019struct dev_dax_data {
20 struct dax_region *dax_region;
21 struct dev_pagemap *pgmap;
Dan Williamsc2f30112020-10-13 16:50:03 -070022 resource_size_t size;
Dan Williams174ebec2020-10-13 16:49:38 -070023 int id;
24};
Dan Williams730926c2017-07-16 13:51:53 -070025
Dan Williams174ebec2020-10-13 16:49:38 -070026struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
Dan Williams730926c2017-07-16 13:51:53 -070027
Dan Williamsd2007812018-11-07 15:31:23 -080028struct dax_device_driver {
29 struct device_driver drv;
30 struct list_head ids;
31 int match_always;
Dan Williamsf11cf812020-10-13 16:50:08 -070032 int (*probe)(struct dev_dax *dev);
Uwe Kleine-König0d519e02021-02-05 23:28:42 +010033 void (*remove)(struct dev_dax *dev);
Dan Williamsd2007812018-11-07 15:31:23 -080034};
35
36int __dax_driver_register(struct dax_device_driver *dax_drv,
Dan Williams9567da02017-07-12 17:58:21 -070037 struct module *module, const char *mod_name);
38#define dax_driver_register(driver) \
39 __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
Dan Williamsd2007812018-11-07 15:31:23 -080040void dax_driver_unregister(struct dax_device_driver *dax_drv);
Dan Williams51cf7842017-07-12 17:58:21 -070041void kill_dev_dax(struct dev_dax *dev_dax);
Joao Martinsfc65c4e2022-01-14 14:04:33 -080042bool static_dev_dax(struct dev_dax *dev_dax);
Dan Williams9567da02017-07-12 17:58:21 -070043
44/*
45 * While run_dax() is potentially a generic operation that could be
46 * defined in include/linux/dax.h we don't want to grow any users
47 * outside of drivers/dax/
48 */
49void run_dax(struct dax_device *dax_dev);
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
Dan Williams51cf7842017-07-12 17:58:21 -070055#endif /* __DAX_BUS_H__ */