Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 1 | /* |
| 2 | * NVDIMM Firmware Interface Table - NFIT |
| 3 | * |
| 4 | * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of version 2 of the GNU General Public License as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | */ |
| 15 | #ifndef __NFIT_H__ |
| 16 | #define __NFIT_H__ |
| 17 | #include <linux/libnvdimm.h> |
| 18 | #include <linux/types.h> |
| 19 | #include <linux/uuid.h> |
| 20 | #include <linux/acpi.h> |
| 21 | #include <acpi/acuuid.h> |
| 22 | |
| 23 | #define UUID_NFIT_BUS "2f10e7a4-9e91-11e4-89d3-123b93f75cba" |
| 24 | #define UUID_NFIT_DIMM "4309ac30-0d11-11e4-9191-0800200c9a66" |
| 25 | |
| 26 | enum nfit_uuids { |
| 27 | NFIT_SPA_VOLATILE, |
| 28 | NFIT_SPA_PM, |
| 29 | NFIT_SPA_DCR, |
| 30 | NFIT_SPA_BDW, |
| 31 | NFIT_SPA_VDISK, |
| 32 | NFIT_SPA_VCD, |
| 33 | NFIT_SPA_PDISK, |
| 34 | NFIT_SPA_PCD, |
| 35 | NFIT_DEV_BUS, |
| 36 | NFIT_DEV_DIMM, |
| 37 | NFIT_UUID_MAX, |
| 38 | }; |
| 39 | |
| 40 | struct nfit_spa { |
| 41 | struct acpi_nfit_system_address *spa; |
| 42 | struct list_head list; |
| 43 | }; |
| 44 | |
| 45 | struct nfit_dcr { |
| 46 | struct acpi_nfit_control_region *dcr; |
| 47 | struct list_head list; |
| 48 | }; |
| 49 | |
| 50 | struct nfit_bdw { |
| 51 | struct acpi_nfit_data_region *bdw; |
| 52 | struct list_head list; |
| 53 | }; |
| 54 | |
Ross Zwisler | 047fc8a | 2015-06-25 04:21:02 -0400 | [diff] [blame] | 55 | struct nfit_idt { |
| 56 | struct acpi_nfit_interleave *idt; |
| 57 | struct list_head list; |
| 58 | }; |
| 59 | |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 60 | struct nfit_memdev { |
| 61 | struct acpi_nfit_memory_map *memdev; |
| 62 | struct list_head list; |
| 63 | }; |
| 64 | |
| 65 | /* assembled tables for a given dimm/memory-device */ |
| 66 | struct nfit_mem { |
Dan Williams | e6dfb2d | 2015-04-25 03:56:17 -0400 | [diff] [blame] | 67 | struct nvdimm *nvdimm; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 68 | struct acpi_nfit_memory_map *memdev_dcr; |
| 69 | struct acpi_nfit_memory_map *memdev_pmem; |
Ross Zwisler | 047fc8a | 2015-06-25 04:21:02 -0400 | [diff] [blame] | 70 | struct acpi_nfit_memory_map *memdev_bdw; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 71 | struct acpi_nfit_control_region *dcr; |
| 72 | struct acpi_nfit_data_region *bdw; |
| 73 | struct acpi_nfit_system_address *spa_dcr; |
| 74 | struct acpi_nfit_system_address *spa_bdw; |
Ross Zwisler | 047fc8a | 2015-06-25 04:21:02 -0400 | [diff] [blame] | 75 | struct acpi_nfit_interleave *idt_dcr; |
| 76 | struct acpi_nfit_interleave *idt_bdw; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 77 | struct list_head list; |
Dan Williams | 62232e45 | 2015-06-08 14:27:06 -0400 | [diff] [blame] | 78 | struct acpi_device *adev; |
| 79 | unsigned long dsm_mask; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | struct acpi_nfit_desc { |
| 83 | struct nvdimm_bus_descriptor nd_desc; |
| 84 | struct acpi_table_nfit *nfit; |
Ross Zwisler | 047fc8a | 2015-06-25 04:21:02 -0400 | [diff] [blame] | 85 | struct mutex spa_map_mutex; |
| 86 | struct list_head spa_maps; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 87 | struct list_head memdevs; |
| 88 | struct list_head dimms; |
| 89 | struct list_head spas; |
| 90 | struct list_head dcrs; |
| 91 | struct list_head bdws; |
Ross Zwisler | 047fc8a | 2015-06-25 04:21:02 -0400 | [diff] [blame] | 92 | struct list_head idts; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 93 | struct nvdimm_bus *nvdimm_bus; |
| 94 | struct device *dev; |
Dan Williams | 62232e45 | 2015-06-08 14:27:06 -0400 | [diff] [blame] | 95 | unsigned long dimm_dsm_force_en; |
Dan Williams | 6bc7561 | 2015-06-17 17:23:32 -0400 | [diff] [blame^] | 96 | int (*blk_do_io)(struct nd_blk_region *ndbr, resource_size_t dpa, |
| 97 | void *iobuf, u64 len, int rw); |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 98 | }; |
| 99 | |
Ross Zwisler | 047fc8a | 2015-06-25 04:21:02 -0400 | [diff] [blame] | 100 | enum nd_blk_mmio_selector { |
| 101 | BDW, |
| 102 | DCR, |
| 103 | }; |
| 104 | |
| 105 | struct nfit_blk { |
| 106 | struct nfit_blk_mmio { |
| 107 | union { |
| 108 | void __iomem *base; |
| 109 | void *aperture; |
| 110 | }; |
| 111 | u64 size; |
| 112 | u64 base_offset; |
| 113 | u32 line_size; |
| 114 | u32 num_lines; |
| 115 | u32 table_size; |
| 116 | struct acpi_nfit_interleave *idt; |
| 117 | struct acpi_nfit_system_address *spa; |
| 118 | } mmio[2]; |
| 119 | struct nd_region *nd_region; |
| 120 | u64 bdw_offset; /* post interleave offset */ |
| 121 | u64 stat_offset; |
| 122 | u64 cmd_offset; |
| 123 | }; |
| 124 | |
| 125 | struct nfit_spa_mapping { |
| 126 | struct acpi_nfit_desc *acpi_desc; |
| 127 | struct acpi_nfit_system_address *spa; |
| 128 | struct list_head list; |
| 129 | struct kref kref; |
| 130 | void __iomem *iomem; |
| 131 | }; |
| 132 | |
| 133 | static inline struct nfit_spa_mapping *to_spa_map(struct kref *kref) |
| 134 | { |
| 135 | return container_of(kref, struct nfit_spa_mapping, kref); |
| 136 | } |
| 137 | |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 138 | static inline struct acpi_nfit_memory_map *__to_nfit_memdev( |
| 139 | struct nfit_mem *nfit_mem) |
| 140 | { |
| 141 | if (nfit_mem->memdev_dcr) |
| 142 | return nfit_mem->memdev_dcr; |
| 143 | return nfit_mem->memdev_pmem; |
| 144 | } |
Dan Williams | 45def22 | 2015-04-26 19:26:48 -0400 | [diff] [blame] | 145 | |
| 146 | static inline struct acpi_nfit_desc *to_acpi_desc( |
| 147 | struct nvdimm_bus_descriptor *nd_desc) |
| 148 | { |
| 149 | return container_of(nd_desc, struct acpi_nfit_desc, nd_desc); |
| 150 | } |
Dan Williams | 6bc7561 | 2015-06-17 17:23:32 -0400 | [diff] [blame^] | 151 | |
| 152 | const u8 *to_nfit_uuid(enum nfit_uuids id); |
| 153 | int acpi_nfit_init(struct acpi_nfit_desc *nfit, acpi_size sz); |
| 154 | extern const struct attribute_group *acpi_nfit_attribute_groups[]; |
Dan Williams | b94d523 | 2015-05-19 22:54:31 -0400 | [diff] [blame] | 155 | #endif /* __NFIT_H__ */ |