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