1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_CPU_DEVICE_ID
3 #define _ASM_X86_CPU_DEVICE_ID
6 * Can't use <linux/bitfield.h> because it generates expressions that
7 * cannot be used in structure initializers. Bitfield construction
8 * here must match the union in struct cpuinfo_86:
19 #define VFM_MODEL_BIT 0
20 #define VFM_FAMILY_BIT 8
21 #define VFM_VENDOR_BIT 16
22 #define VFM_RSVD_BIT 24
24 #define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT)
25 #define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT)
26 #define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT)
28 #define VFM_MODEL(vfm) (((vfm) & VFM_MODEL_MASK) >> VFM_MODEL_BIT)
29 #define VFM_FAMILY(vfm) (((vfm) & VFM_FAMILY_MASK) >> VFM_FAMILY_BIT)
30 #define VFM_VENDOR(vfm) (((vfm) & VFM_VENDOR_MASK) >> VFM_VENDOR_BIT)
32 #define VFM_MAKE(_vendor, _family, _model) ( \
33 ((_model) << VFM_MODEL_BIT) | \
34 ((_family) << VFM_FAMILY_BIT) | \
35 ((_vendor) << VFM_VENDOR_BIT) \
39 * Declare drivers belonging to specific x86 CPUs
40 * Similar in spirit to pci_device_id and related PCI functions
42 * The wildcard initializers are in mod_devicetable.h because
43 * file2alias needs them. Sigh.
45 #include <linux/mod_devicetable.h>
46 /* Get the INTEL_FAM* model defines */
47 #include <asm/intel-family.h>
48 /* And the X86_VENDOR_* ones */
49 #include <asm/processor.h>
51 /* Centaur FAM6 models */
52 #define X86_CENTAUR_FAM6_C7_A 0xa
53 #define X86_CENTAUR_FAM6_C7_D 0xd
54 #define X86_CENTAUR_FAM6_NANO 0xf
56 /* x86_cpu_id::flags */
57 #define X86_CPU_ID_FLAG_ENTRY_VALID BIT(0)
60 * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching
61 * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
62 * The name is expanded to X86_VENDOR_@_vendor
63 * @_family: The family number or X86_FAMILY_ANY
64 * @_model: The model number, model constant or X86_MODEL_ANY
65 * @_steppings: Bitmask for steppings, stepping constant or X86_STEPPING_ANY
66 * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY
67 * @_data: Driver specific data or NULL. The internal storage
68 * format is unsigned long. The supplied value, pointer
69 * etc. is casted to unsigned long internally.
71 * Use only if you need all selectors. Otherwise use one of the shorter
72 * macros of the X86_MATCH_* family. If there is no matching shorthand
73 * macro, consider to add one. If you really need to wrap one of the macros
74 * into another macro at the usage site for good reasons, then please
75 * start this local macro with X86_MATCH to allow easy grepping.
77 #define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
78 _steppings, _feature, _data) { \
79 .vendor = X86_VENDOR_##_vendor, \
82 .steppings = _steppings, \
83 .feature = _feature, \
84 .flags = X86_CPU_ID_FLAG_ENTRY_VALID, \
85 .driver_data = (unsigned long) _data \
88 #define X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
89 _steppings, _feature, _data) { \
93 .steppings = _steppings, \
94 .feature = _feature, \
95 .flags = X86_CPU_ID_FLAG_ENTRY_VALID, \
96 .driver_data = (unsigned long) _data \
100 * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching
101 * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
102 * The name is expanded to X86_VENDOR_@_vendor
103 * @_family: The family number or X86_FAMILY_ANY
104 * @_model: The model number, model constant or X86_MODEL_ANY
105 * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY
106 * @_data: Driver specific data or NULL. The internal storage
107 * format is unsigned long. The supplied value, pointer
108 * etc. is casted to unsigned long internally.
110 * The steppings arguments of X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE() is
113 #define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, feature, data) \
114 X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(vendor, family, model, \
115 X86_STEPPING_ANY, feature, data)
118 * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
119 * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
120 * The name is expanded to X86_VENDOR_@vendor
121 * @family: The family number or X86_FAMILY_ANY
122 * @feature: A X86_FEATURE bit
123 * @data: Driver specific data or NULL. The internal storage
124 * format is unsigned long. The supplied value, pointer
125 * etc. is casted to unsigned long internally.
127 * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
130 #define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \
131 X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, \
132 X86_MODEL_ANY, feature, data)
135 * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
136 * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
137 * The name is expanded to X86_VENDOR_@vendor
138 * @feature: A X86_FEATURE bit
139 * @data: Driver specific data or NULL. The internal storage
140 * format is unsigned long. The supplied value, pointer
141 * etc. is casted to unsigned long internally.
143 * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
146 #define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \
147 X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
150 * X86_MATCH_FEATURE - Macro for matching a CPU feature
151 * @feature: A X86_FEATURE bit
152 * @data: Driver specific data or NULL. The internal storage
153 * format is unsigned long. The supplied value, pointer
154 * etc. is casted to unsigned long internally.
156 * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
159 #define X86_MATCH_FEATURE(feature, data) \
160 X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
163 * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
164 * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
165 * The name is expanded to X86_VENDOR_@vendor
166 * @family: The family number or X86_FAMILY_ANY
167 * @model: The model number, model constant or X86_MODEL_ANY
168 * @data: Driver specific data or NULL. The internal storage
169 * format is unsigned long. The supplied value, pointer
170 * etc. is casted to unsigned long internally.
172 * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
175 #define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \
176 X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, \
177 X86_FEATURE_ANY, data)
180 * X86_MATCH_VENDOR_FAM - Match vendor and family
181 * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
182 * The name is expanded to X86_VENDOR_@vendor
183 * @family: The family number or X86_FAMILY_ANY
184 * @data: Driver specific data or NULL. The internal storage
185 * format is unsigned long. The supplied value, pointer
186 * etc. is casted to unsigned long internally.
188 * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
191 #define X86_MATCH_VENDOR_FAM(vendor, family, data) \
192 X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
195 * X86_MATCH_VFM - Match encoded vendor/family/model
196 * @vfm: Encoded 8-bits each for vendor, family, model
197 * @data: Driver specific data or NULL. The internal storage
198 * format is unsigned long. The supplied value, pointer
199 * etc. is cast to unsigned long internally.
201 * Stepping and feature are set to wildcards
203 #define X86_MATCH_VFM(vfm, data) \
204 X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
208 X86_STEPPING_ANY, X86_FEATURE_ANY, data)
210 #define __X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
212 * X86_MATCH_VFM_STEPPINGS - Match encoded vendor/family/model/stepping
213 * @vfm: Encoded 8-bits each for vendor, family, model
214 * @steppings: Bitmask of steppings to match
215 * @data: Driver specific data or NULL. The internal storage
216 * format is unsigned long. The supplied value, pointer
217 * etc. is cast to unsigned long internally.
219 * feature is set to wildcard
221 #define X86_MATCH_VFM_STEPS(vfm, min_step, max_step, data) \
222 X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
226 __X86_STEPPINGS(min_step, max_step), \
227 X86_FEATURE_ANY, data)
230 * X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature
231 * @vfm: Encoded 8-bits each for vendor, family, model
232 * @feature: A X86_FEATURE bit
233 * @data: Driver specific data or NULL. The internal storage
234 * format is unsigned long. The supplied value, pointer
235 * etc. is cast to unsigned long internally.
237 * Steppings is set to wildcard
239 #define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
240 X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
244 X86_STEPPING_ANY, feature, data)
246 extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
247 extern bool x86_match_min_microcode_rev(const struct x86_cpu_id *table);
249 #endif /* _ASM_X86_CPU_DEVICE_ID */