blob: 0285e4588b0350c8e50ba1a4462f84f50789c969 [file] [log] [blame]
Dan Williams4d88a972015-05-31 14:41:48 -04001/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13#ifndef __ND_H__
14#define __ND_H__
Dan Williams1f7df6f2015-06-09 20:13:14 -040015#include <linux/libnvdimm.h>
Dan Williams4d88a972015-05-31 14:41:48 -040016#include <linux/device.h>
17#include <linux/mutex.h>
18#include <linux/ndctl.h>
19
20struct nvdimm_drvdata {
21 struct device *dev;
22 struct nd_cmd_get_config_size nsarea;
23 void *data;
24};
25
Dan Williams3d880022015-05-31 15:02:11 -040026struct nd_region_namespaces {
27 int count;
28 int active;
29};
30
Dan Williams1f7df6f2015-06-09 20:13:14 -040031struct nd_region {
32 struct device dev;
33 u16 ndr_mappings;
34 u64 ndr_size;
35 u64 ndr_start;
36 int id;
37 void *provider_data;
Dan Williamseaf96152015-05-01 13:11:27 -040038 struct nd_interleave_set *nd_set;
Dan Williams1f7df6f2015-06-09 20:13:14 -040039 struct nd_mapping mapping[0];
40};
41
Dan Williams4d88a972015-05-31 14:41:48 -040042enum nd_async_mode {
43 ND_SYNC,
44 ND_ASYNC,
45};
46
47void nd_device_register(struct device *dev);
48void nd_device_unregister(struct device *dev, enum nd_async_mode mode);
49int __init nvdimm_init(void);
Dan Williams3d880022015-05-31 15:02:11 -040050int __init nd_region_init(void);
Dan Williams4d88a972015-05-31 14:41:48 -040051void nvdimm_exit(void);
Dan Williams3d880022015-05-31 15:02:11 -040052void nd_region_exit(void);
Dan Williams4d88a972015-05-31 14:41:48 -040053int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
54int nvdimm_init_config_data(struct nvdimm_drvdata *ndd);
Dan Williams3d880022015-05-31 15:02:11 -040055struct nd_region *to_nd_region(struct device *dev);
56int nd_region_to_nstype(struct nd_region *nd_region);
57int nd_region_register_namespaces(struct nd_region *nd_region, int *err);
58void nvdimm_bus_lock(struct device *dev);
59void nvdimm_bus_unlock(struct device *dev);
60bool is_nvdimm_bus_locked(struct device *dev);
Dan Williams4d88a972015-05-31 14:41:48 -040061#endif /* __ND_H__ */