^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #ifndef __DAX_BUS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #define __DAX_BUS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/range.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct dev_dax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct dax_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct dax_region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) void dax_region_put(struct dax_region *dax_region);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define IORESOURCE_DAX_STATIC (1UL << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct dax_region *alloc_dax_region(struct device *parent, int region_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct range *range, int target_node, unsigned int align,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) unsigned long flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) enum dev_dax_subsys {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) DEV_DAX_BUS = 0, /* zeroed dev_dax_data picks this by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) DEV_DAX_CLASS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct dev_dax_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct dax_region *dax_region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct dev_pagemap *pgmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) enum dev_dax_subsys subsys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) resource_size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* to be deleted when DEV_DAX_CLASS is removed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct dax_device_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct device_driver drv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct list_head ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int match_always;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int (*probe)(struct dev_dax *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int (*remove)(struct dev_dax *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int __dax_driver_register(struct dax_device_driver *dax_drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct module *module, const char *mod_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define dax_driver_register(driver) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void dax_driver_unregister(struct dax_device_driver *dax_drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) void kill_dev_dax(struct dev_dax *dev_dax);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int dev_dax_probe(struct dev_dax *dev_dax);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * While run_dax() is potentially a generic operation that could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * defined in include/linux/dax.h we don't want to grow any users
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * outside of drivers/dax/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void run_dax(struct dax_device *dax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define MODULE_ALIAS_DAX_DEVICE(type) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) MODULE_ALIAS("dax:t" __stringify(type) "*")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define DAX_DEVICE_MODALIAS_FMT "dax:t%d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #endif /* __DAX_BUS_H__ */