]>
Commit | Line | Data |
---|---|---|
1965746b ME |
1 | /* |
2 | * pSeries firmware setup code. | |
3 | * | |
4 | * Portions from arch/powerpc/platforms/pseries/setup.c: | |
5 | * Copyright (C) 1995 Linus Torvalds | |
6 | * Adapted from 'alpha' version by Gary Thomas | |
7 | * Modified by Cort Dougan (cort@cs.nmt.edu) | |
8 | * Modified by PPC64 Team, IBM Corp | |
9 | * | |
10 | * Portions from arch/powerpc/kernel/firmware.c | |
11 | * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org) | |
12 | * Modifications for ppc64: | |
13 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> | |
14 | * Copyright (C) 2005 Stephen Rothwell, IBM Corporation | |
15 | * | |
16 | * Copyright 2006 IBM Corporation. | |
17 | * | |
18 | * This program is free software; you can redistribute it and/or | |
19 | * modify it under the terms of the GNU General Public License | |
20 | * as published by the Free Software Foundation; either version | |
21 | * 2 of the License, or (at your option) any later version. | |
22 | */ | |
23 | ||
1965746b | 24 | |
3808a889 | 25 | #include <linux/of_fdt.h> |
1965746b ME |
26 | #include <asm/firmware.h> |
27 | #include <asm/prom.h> | |
aa39be09 | 28 | #include <asm/udbg.h> |
1965746b | 29 | |
3ff1999b | 30 | #include "pseries.h" |
1965746b | 31 | |
f0ff7eb4 | 32 | struct hypertas_fw_feature { |
1965746b ME |
33 | unsigned long val; |
34 | char * name; | |
f0ff7eb4 | 35 | }; |
1965746b | 36 | |
2f1d4ea7 MN |
37 | /* |
38 | * The names in this table match names in rtas/ibm,hypertas-functions. If the | |
39 | * entry ends in a '*', only upto the '*' is matched. Otherwise the entire | |
40 | * string must match. | |
41 | */ | |
f0ff7eb4 NF |
42 | static __initdata struct hypertas_fw_feature |
43 | hypertas_fw_features_table[] = { | |
1965746b ME |
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"}, | |
b6dcde5c | 60 | {FW_FEATURE_BULK_REMOVE, "hcall-bulk"}, |
1965746b ME |
61 | {FW_FEATURE_XDABR, "hcall-xdabr"}, |
62 | {FW_FEATURE_MULTITCE, "hcall-multi-tce"}, | |
63 | {FW_FEATURE_SPLPAR, "hcall-splpar"}, | |
36f567b4 | 64 | {FW_FEATURE_VPHN, "hcall-vphn"}, |
d8f48ecc | 65 | {FW_FEATURE_SET_MODE, "hcall-set-mode"}, |
0388c79c | 66 | {FW_FEATURE_BEST_ENERGY, "hcall-best-energy-1*"}, |
64b40ffb | 67 | {FW_FEATURE_HPT_RESIZE, "hcall-hpt-resize"}, |
5600fbe3 | 68 | {FW_FEATURE_BLOCK_REMOVE, "hcall-block-remove"}, |
4c5d87db | 69 | {FW_FEATURE_PAPR_SCM, "hcall-scm"}, |
1965746b ME |
70 | }; |
71 | ||
72 | /* Build up the firmware features bitmask using the contents of | |
73 | * device-tree/ibm,hypertas-functions. Ultimately this functionality may | |
74 | * be moved into prom.c prom_init(). | |
75 | */ | |
3808a889 BH |
76 | static void __init fw_hypertas_feature_init(const char *hypertas, |
77 | unsigned long len) | |
1965746b | 78 | { |
ca8ffc97 MN |
79 | const char *s; |
80 | int i; | |
1965746b | 81 | |
f0ff7eb4 | 82 | pr_debug(" -> fw_hypertas_feature_init()\n"); |
1965746b | 83 | |
1965746b | 84 | for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) { |
f0ff7eb4 NF |
85 | for (i = 0; i < ARRAY_SIZE(hypertas_fw_features_table); i++) { |
86 | const char *name = hypertas_fw_features_table[i].name; | |
2f1d4ea7 | 87 | size_t size; |
43c0ea60 | 88 | |
2f1d4ea7 MN |
89 | /* |
90 | * If there is a '*' at the end of name, only check | |
91 | * upto there | |
92 | */ | |
93 | size = strlen(name); | |
94 | if (size && name[size - 1] == '*') { | |
95 | if (strncmp(name, s, size - 1)) | |
96 | continue; | |
97 | } else if (strcmp(name, s)) | |
1965746b ME |
98 | continue; |
99 | ||
100 | /* we have a match */ | |
d0160bf0 | 101 | powerpc_firmware_features |= |
f0ff7eb4 | 102 | hypertas_fw_features_table[i].val; |
1965746b ME |
103 | break; |
104 | } | |
105 | } | |
106 | ||
f0ff7eb4 NF |
107 | pr_debug(" <- fw_hypertas_feature_init()\n"); |
108 | } | |
109 | ||
110 | struct vec5_fw_feature { | |
111 | unsigned long val; | |
112 | unsigned int feature; | |
113 | }; | |
114 | ||
115 | static __initdata struct vec5_fw_feature | |
116 | vec5_fw_features_table[] = { | |
117 | {FW_FEATURE_TYPE1_AFFINITY, OV5_TYPE1_AFFINITY}, | |
5d88aa85 | 118 | {FW_FEATURE_PRRN, OV5_PRRN}, |
0c38ed6f | 119 | {FW_FEATURE_DRMEM_V2, OV5_DRMEM_V2}, |
3f38000e | 120 | {FW_FEATURE_DRC_INFO, OV5_DRC_INFO}, |
f0ff7eb4 NF |
121 | }; |
122 | ||
3808a889 | 123 | static void __init fw_vec5_feature_init(const char *vec5, unsigned long len) |
f0ff7eb4 NF |
124 | { |
125 | unsigned int index, feat; | |
126 | int i; | |
127 | ||
128 | pr_debug(" -> fw_vec5_feature_init()\n"); | |
129 | ||
130 | for (i = 0; i < ARRAY_SIZE(vec5_fw_features_table); i++) { | |
131 | index = OV5_INDX(vec5_fw_features_table[i].feature); | |
132 | feat = OV5_FEAT(vec5_fw_features_table[i].feature); | |
133 | ||
3f4ab2f8 | 134 | if (index < len && (vec5[index] & feat)) |
f0ff7eb4 NF |
135 | powerpc_firmware_features |= |
136 | vec5_fw_features_table[i].val; | |
137 | } | |
138 | ||
139 | pr_debug(" <- fw_vec5_feature_init()\n"); | |
1965746b | 140 | } |
3808a889 BH |
141 | |
142 | /* | |
143 | * Called very early, MMU is off, device-tree isn't unflattened | |
144 | */ | |
145 | static int __init probe_fw_features(unsigned long node, const char *uname, int | |
146 | depth, void *data) | |
147 | { | |
148 | const char *prop; | |
149 | int len; | |
150 | static int hypertas_found; | |
151 | static int vec5_found; | |
152 | ||
153 | if (depth != 1) | |
154 | return 0; | |
155 | ||
156 | if (!strcmp(uname, "rtas") || !strcmp(uname, "rtas@0")) { | |
157 | prop = of_get_flat_dt_prop(node, "ibm,hypertas-functions", | |
158 | &len); | |
159 | if (prop) { | |
160 | powerpc_firmware_features |= FW_FEATURE_LPAR; | |
161 | fw_hypertas_feature_init(prop, len); | |
162 | } | |
163 | ||
164 | hypertas_found = 1; | |
165 | } | |
166 | ||
167 | if (!strcmp(uname, "chosen")) { | |
168 | prop = of_get_flat_dt_prop(node, "ibm,architecture-vec-5", | |
169 | &len); | |
170 | if (prop) | |
171 | fw_vec5_feature_init(prop, len); | |
172 | ||
173 | vec5_found = 1; | |
174 | } | |
175 | ||
176 | return hypertas_found && vec5_found; | |
177 | } | |
178 | ||
179 | void __init pseries_probe_fw_features(void) | |
180 | { | |
181 | of_scan_flat_dt(probe_fw_features, NULL); | |
182 | } |