1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <linux/of_fdt.h>
22#include <asm/firmware.h>
23#include <asm/prom.h>
24#include <asm/udbg.h>
25#include <asm/svm.h>
26
27#include "pseries.h"
28
29struct hypertas_fw_feature {
30 unsigned long val;
31 char * name;
32};
33
34
35
36
37
38
39static __initdata struct hypertas_fw_feature
40hypertas_fw_features_table[] = {
41 {FW_FEATURE_PFT, "hcall-pft"},
42 {FW_FEATURE_TCE, "hcall-tce"},
43 {FW_FEATURE_SPRG0, "hcall-sprg0"},
44 {FW_FEATURE_DABR, "hcall-dabr"},
45 {FW_FEATURE_COPY, "hcall-copy"},
46 {FW_FEATURE_ASR, "hcall-asr"},
47 {FW_FEATURE_DEBUG, "hcall-debug"},
48 {FW_FEATURE_PERF, "hcall-perf"},
49 {FW_FEATURE_DUMP, "hcall-dump"},
50 {FW_FEATURE_INTERRUPT, "hcall-interrupt"},
51 {FW_FEATURE_MIGRATE, "hcall-migrate"},
52 {FW_FEATURE_PERFMON, "hcall-perfmon"},
53 {FW_FEATURE_CRQ, "hcall-crq"},
54 {FW_FEATURE_VIO, "hcall-vio"},
55 {FW_FEATURE_RDMA, "hcall-rdma"},
56 {FW_FEATURE_LLAN, "hcall-lLAN"},
57 {FW_FEATURE_BULK_REMOVE, "hcall-bulk"},
58 {FW_FEATURE_XDABR, "hcall-xdabr"},
59 {FW_FEATURE_PUT_TCE_IND | FW_FEATURE_STUFF_TCE,
60 "hcall-multi-tce"},
61 {FW_FEATURE_SPLPAR, "hcall-splpar"},
62 {FW_FEATURE_VPHN, "hcall-vphn"},
63 {FW_FEATURE_SET_MODE, "hcall-set-mode"},
64 {FW_FEATURE_BEST_ENERGY, "hcall-best-energy-1*"},
65 {FW_FEATURE_HPT_RESIZE, "hcall-hpt-resize"},
66 {FW_FEATURE_BLOCK_REMOVE, "hcall-block-remove"},
67 {FW_FEATURE_PAPR_SCM, "hcall-scm"},
68 {FW_FEATURE_RPT_INVALIDATE, "hcall-rpt-invalidate"},
69};
70
71
72
73
74
75static void __init fw_hypertas_feature_init(const char *hypertas,
76 unsigned long len)
77{
78 const char *s;
79 int i;
80
81 pr_debug(" -> fw_hypertas_feature_init()\n");
82
83 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
84 for (i = 0; i < ARRAY_SIZE(hypertas_fw_features_table); i++) {
85 const char *name = hypertas_fw_features_table[i].name;
86 size_t size;
87
88
89
90
91
92 size = strlen(name);
93 if (size && name[size - 1] == '*') {
94 if (strncmp(name, s, size - 1))
95 continue;
96 } else if (strcmp(name, s))
97 continue;
98
99
100 powerpc_firmware_features |=
101 hypertas_fw_features_table[i].val;
102 break;
103 }
104 }
105
106 if (is_secure_guest() &&
107 (powerpc_firmware_features & FW_FEATURE_PUT_TCE_IND)) {
108 powerpc_firmware_features &= ~FW_FEATURE_PUT_TCE_IND;
109 pr_debug("SVM: disabling PUT_TCE_IND firmware feature\n");
110 }
111
112 pr_debug(" <- fw_hypertas_feature_init()\n");
113}
114
115struct vec5_fw_feature {
116 unsigned long val;
117 unsigned int feature;
118};
119
120static __initdata struct vec5_fw_feature
121vec5_fw_features_table[] = {
122 {FW_FEATURE_FORM1_AFFINITY, OV5_FORM1_AFFINITY},
123 {FW_FEATURE_PRRN, OV5_PRRN},
124 {FW_FEATURE_DRMEM_V2, OV5_DRMEM_V2},
125 {FW_FEATURE_DRC_INFO, OV5_DRC_INFO},
126 {FW_FEATURE_FORM2_AFFINITY, OV5_FORM2_AFFINITY},
127};
128
129static void __init fw_vec5_feature_init(const char *vec5, unsigned long len)
130{
131 unsigned int index, feat;
132 int i;
133
134 pr_debug(" -> fw_vec5_feature_init()\n");
135
136 for (i = 0; i < ARRAY_SIZE(vec5_fw_features_table); i++) {
137 index = OV5_INDX(vec5_fw_features_table[i].feature);
138 feat = OV5_FEAT(vec5_fw_features_table[i].feature);
139
140 if (index < len && (vec5[index] & feat))
141 powerpc_firmware_features |=
142 vec5_fw_features_table[i].val;
143 }
144
145 pr_debug(" <- fw_vec5_feature_init()\n");
146}
147
148
149
150
151static int __init probe_fw_features(unsigned long node, const char *uname, int
152 depth, void *data)
153{
154 const char *prop;
155 int len;
156 static int hypertas_found;
157 static int vec5_found;
158
159 if (depth != 1)
160 return 0;
161
162 if (!strcmp(uname, "rtas") || !strcmp(uname, "rtas@0")) {
163 prop = of_get_flat_dt_prop(node, "ibm,hypertas-functions",
164 &len);
165 if (prop) {
166 powerpc_firmware_features |= FW_FEATURE_LPAR;
167 fw_hypertas_feature_init(prop, len);
168 }
169
170 hypertas_found = 1;
171 }
172
173 if (!strcmp(uname, "chosen")) {
174 prop = of_get_flat_dt_prop(node, "ibm,architecture-vec-5",
175 &len);
176 if (prop)
177 fw_vec5_feature_init(prop, len);
178
179 vec5_found = 1;
180 }
181
182 return hypertas_found && vec5_found;
183}
184
185void __init pseries_probe_fw_features(void)
186{
187 of_scan_flat_dt(probe_fw_features, NULL);
188}
189