Dan Williams | 4d88a97 | 2015-05-31 14:41:48 -0400 | [diff] [blame] | 1 | /* |
| 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 Williams | 1f7df6f | 2015-06-09 20:13:14 -0400 | [diff] [blame] | 15 | #include <linux/libnvdimm.h> |
Dan Williams | 4d88a97 | 2015-05-31 14:41:48 -0400 | [diff] [blame] | 16 | #include <linux/device.h> |
| 17 | #include <linux/mutex.h> |
| 18 | #include <linux/ndctl.h> |
| 19 | |
| 20 | struct nvdimm_drvdata { |
| 21 | struct device *dev; |
| 22 | struct nd_cmd_get_config_size nsarea; |
| 23 | void *data; |
| 24 | }; |
| 25 | |
Dan Williams | 3d88002 | 2015-05-31 15:02:11 -0400 | [diff] [blame] | 26 | struct nd_region_namespaces { |
| 27 | int count; |
| 28 | int active; |
| 29 | }; |
| 30 | |
Dan Williams | 1f7df6f | 2015-06-09 20:13:14 -0400 | [diff] [blame] | 31 | struct 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 Williams | 4d88a97 | 2015-05-31 14:41:48 -0400 | [diff] [blame] | 41 | enum nd_async_mode { |
| 42 | ND_SYNC, |
| 43 | ND_ASYNC, |
| 44 | }; |
| 45 | |
| 46 | void nd_device_register(struct device *dev); |
| 47 | void nd_device_unregister(struct device *dev, enum nd_async_mode mode); |
| 48 | int __init nvdimm_init(void); |
Dan Williams | 3d88002 | 2015-05-31 15:02:11 -0400 | [diff] [blame] | 49 | int __init nd_region_init(void); |
Dan Williams | 4d88a97 | 2015-05-31 14:41:48 -0400 | [diff] [blame] | 50 | void nvdimm_exit(void); |
Dan Williams | 3d88002 | 2015-05-31 15:02:11 -0400 | [diff] [blame] | 51 | void nd_region_exit(void); |
Dan Williams | 4d88a97 | 2015-05-31 14:41:48 -0400 | [diff] [blame] | 52 | int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd); |
| 53 | int nvdimm_init_config_data(struct nvdimm_drvdata *ndd); |
Dan Williams | 3d88002 | 2015-05-31 15:02:11 -0400 | [diff] [blame] | 54 | struct nd_region *to_nd_region(struct device *dev); |
| 55 | int nd_region_to_nstype(struct nd_region *nd_region); |
| 56 | int nd_region_register_namespaces(struct nd_region *nd_region, int *err); |
| 57 | void nvdimm_bus_lock(struct device *dev); |
| 58 | void nvdimm_bus_unlock(struct device *dev); |
| 59 | bool is_nvdimm_bus_locked(struct device *dev); |
Dan Williams | 4d88a97 | 2015-05-31 14:41:48 -0400 | [diff] [blame] | 60 | #endif /* __ND_H__ */ |