blob: bc5a08e36a25049b52c22c7bbd09796816fd58d7 [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;
38 struct nd_mapping mapping[0];
39};
40
Dan Williams4d88a972015-05-31 14:41:48 -040041enum nd_async_mode {
42 ND_SYNC,
43 ND_ASYNC,
44};
45
46void nd_device_register(struct device *dev);
47void nd_device_unregister(struct device *dev, enum nd_async_mode mode);
48int __init nvdimm_init(void);
Dan Williams3d880022015-05-31 15:02:11 -040049int __init nd_region_init(void);
Dan Williams4d88a972015-05-31 14:41:48 -040050void nvdimm_exit(void);
Dan Williams3d880022015-05-31 15:02:11 -040051void nd_region_exit(void);
Dan Williams4d88a972015-05-31 14:41:48 -040052int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
53int nvdimm_init_config_data(struct nvdimm_drvdata *ndd);
Dan Williams3d880022015-05-31 15:02:11 -040054struct nd_region *to_nd_region(struct device *dev);
55int nd_region_to_nstype(struct nd_region *nd_region);
56int nd_region_register_namespaces(struct nd_region *nd_region, int *err);
57void nvdimm_bus_lock(struct device *dev);
58void nvdimm_bus_unlock(struct device *dev);
59bool is_nvdimm_bus_locked(struct device *dev);
Dan Williams4d88a972015-05-31 14:41:48 -040060#endif /* __ND_H__ */