blob: c62fffea842327ddc6d3602ac8832ca075d7bb2a [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 Williams6bc75612015-06-17 17:23:32 -040096 int (*blk_do_io)(struct nd_blk_region *ndbr, resource_size_t dpa,
97 void *iobuf, u64 len, int rw);
Dan Williamsb94d5232015-05-19 22:54:31 -040098};
99
Ross Zwisler047fc8a2015-06-25 04:21:02 -0400100enum nd_blk_mmio_selector {
101 BDW,
102 DCR,
103};
104
105struct 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
125struct 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
133static 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 Williamsb94d5232015-05-19 22:54:31 -0400138static 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 Williams45def222015-04-26 19:26:48 -0400145
146static 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 Williams6bc75612015-06-17 17:23:32 -0400151
152const u8 *to_nfit_uuid(enum nfit_uuids id);
153int acpi_nfit_init(struct acpi_nfit_desc *nfit, acpi_size sz);
154extern const struct attribute_group *acpi_nfit_attribute_groups[];
Dan Williamsb94d5232015-05-19 22:54:31 -0400155#endif /* __NFIT_H__ */