blob: 7bd38b7baf39e5b44687b717b05eaee05bb16c4d [file] [log] [blame]
Dan Williamsb94d5232015-05-19 22:54:31 -04001/*
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
26enum 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
40struct nfit_spa {
41 struct acpi_nfit_system_address *spa;
42 struct list_head list;
43};
44
45struct nfit_dcr {
46 struct acpi_nfit_control_region *dcr;
47 struct list_head list;
48};
49
50struct nfit_bdw {
51 struct acpi_nfit_data_region *bdw;
52 struct list_head list;
53};
54
Ross Zwisler047fc8a2015-06-25 04:21:02 -040055struct nfit_idt {
56 struct acpi_nfit_interleave *idt;
57 struct list_head list;
58};
59
Dan Williamsb94d5232015-05-19 22:54:31 -040060struct 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 */
66struct nfit_mem {
Dan Williamse6dfb2d2015-04-25 03:56:17 -040067 struct nvdimm *nvdimm;
Dan Williamsb94d5232015-05-19 22:54:31 -040068 struct acpi_nfit_memory_map *memdev_dcr;
69 struct acpi_nfit_memory_map *memdev_pmem;
Ross Zwisler047fc8a2015-06-25 04:21:02 -040070 struct acpi_nfit_memory_map *memdev_bdw;
Dan Williamsb94d5232015-05-19 22:54:31 -040071 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 Zwisler047fc8a2015-06-25 04:21:02 -040075 struct acpi_nfit_interleave *idt_dcr;
76 struct acpi_nfit_interleave *idt_bdw;
Dan Williamsb94d5232015-05-19 22:54:31 -040077 struct list_head list;
Dan Williams62232e452015-06-08 14:27:06 -040078 struct acpi_device *adev;
79 unsigned long dsm_mask;
Dan Williamsb94d5232015-05-19 22:54:31 -040080};
81
82struct acpi_nfit_desc {
83 struct nvdimm_bus_descriptor nd_desc;
84 struct acpi_table_nfit *nfit;
Ross Zwisler047fc8a2015-06-25 04:21:02 -040085 struct mutex spa_map_mutex;
86 struct list_head spa_maps;
Dan Williamsb94d5232015-05-19 22:54:31 -040087 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 Zwisler047fc8a2015-06-25 04:21:02 -040092 struct list_head idts;
Dan Williamsb94d5232015-05-19 22:54:31 -040093 struct nvdimm_bus *nvdimm_bus;
94 struct device *dev;
Dan Williams62232e452015-06-08 14:27:06 -040095 unsigned long dimm_dsm_force_en;
Dan Williamsb94d5232015-05-19 22:54:31 -040096};
97
Ross Zwisler047fc8a2015-06-25 04:21:02 -040098enum nd_blk_mmio_selector {
99 BDW,
100 DCR,
101};
102
103struct nfit_blk {
104 struct nfit_blk_mmio {
105 union {
106 void __iomem *base;
107 void *aperture;
108 };
109 u64 size;
110 u64 base_offset;
111 u32 line_size;
112 u32 num_lines;
113 u32 table_size;
114 struct acpi_nfit_interleave *idt;
115 struct acpi_nfit_system_address *spa;
116 } mmio[2];
117 struct nd_region *nd_region;
118 u64 bdw_offset; /* post interleave offset */
119 u64 stat_offset;
120 u64 cmd_offset;
121};
122
123struct nfit_spa_mapping {
124 struct acpi_nfit_desc *acpi_desc;
125 struct acpi_nfit_system_address *spa;
126 struct list_head list;
127 struct kref kref;
128 void __iomem *iomem;
129};
130
131static inline struct nfit_spa_mapping *to_spa_map(struct kref *kref)
132{
133 return container_of(kref, struct nfit_spa_mapping, kref);
134}
135
Dan Williamsb94d5232015-05-19 22:54:31 -0400136static inline struct acpi_nfit_memory_map *__to_nfit_memdev(
137 struct nfit_mem *nfit_mem)
138{
139 if (nfit_mem->memdev_dcr)
140 return nfit_mem->memdev_dcr;
141 return nfit_mem->memdev_pmem;
142}
Dan Williams45def222015-04-26 19:26:48 -0400143
144static inline struct acpi_nfit_desc *to_acpi_desc(
145 struct nvdimm_bus_descriptor *nd_desc)
146{
147 return container_of(nd_desc, struct acpi_nfit_desc, nd_desc);
148}
Dan Williamsb94d5232015-05-19 22:54:31 -0400149#endif /* __NFIT_H__ */