GNU Linux-libre 4.19.281-gnu1
[releases.git] / arch / x86 / include / asm / cpu_device_id.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_CPU_DEVICE_ID
3 #define _ASM_X86_CPU_DEVICE_ID
4
5 /*
6  * Declare drivers belonging to specific x86 CPUs
7  * Similar in spirit to pci_device_id and related PCI functions
8  *
9  * The wildcard initializers are in mod_devicetable.h because
10  * file2alias needs them. Sigh.
11  */
12 #include <linux/mod_devicetable.h>
13 /* Get the INTEL_FAM* model defines */
14 #include <asm/intel-family.h>
15 /* And the X86_VENDOR_* ones */
16 #include <asm/processor.h>
17
18 /* Centaur FAM6 models */
19 #define X86_CENTAUR_FAM6_C7_A           0xa
20 #define X86_CENTAUR_FAM6_C7_D           0xd
21 #define X86_CENTAUR_FAM6_NANO           0xf
22
23 #define X86_STEPPINGS(mins, maxs)    GENMASK(maxs, mins)
24 /**
25  * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching
26  * @_vendor:    The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
27  *              The name is expanded to X86_VENDOR_@_vendor
28  * @_family:    The family number or X86_FAMILY_ANY
29  * @_model:     The model number, model constant or X86_MODEL_ANY
30  * @_steppings: Bitmask for steppings, stepping constant or X86_STEPPING_ANY
31  * @_feature:   A X86_FEATURE bit or X86_FEATURE_ANY
32  * @_data:      Driver specific data or NULL. The internal storage
33  *              format is unsigned long. The supplied value, pointer
34  *              etc. is casted to unsigned long internally.
35  *
36  * Use only if you need all selectors. Otherwise use one of the shorter
37  * macros of the X86_MATCH_* family. If there is no matching shorthand
38  * macro, consider to add one. If you really need to wrap one of the macros
39  * into another macro at the usage site for good reasons, then please
40  * start this local macro with X86_MATCH to allow easy grepping.
41  */
42 #define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
43                                                     _steppings, _feature, _data) { \
44         .vendor         = X86_VENDOR_##_vendor,                         \
45         .family         = _family,                                      \
46         .model          = _model,                                       \
47         .steppings      = _steppings,                                   \
48         .feature        = _feature,                                     \
49         .driver_data    = (unsigned long) _data                         \
50 }
51
52 /**
53  * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching
54  * @_vendor:    The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
55  *              The name is expanded to X86_VENDOR_@_vendor
56  * @_family:    The family number or X86_FAMILY_ANY
57  * @_model:     The model number, model constant or X86_MODEL_ANY
58  * @_feature:   A X86_FEATURE bit or X86_FEATURE_ANY
59  * @_data:      Driver specific data or NULL. The internal storage
60  *              format is unsigned long. The supplied value, pointer
61  *              etc. is casted to unsigned long internally.
62  *
63  * The steppings arguments of X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE() is
64  * set to wildcards.
65  */
66 #define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, feature, data) \
67         X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(vendor, family, model, \
68                                                 X86_STEPPING_ANY, feature, data)
69
70 /**
71  * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
72  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
73  *              The name is expanded to X86_VENDOR_@vendor
74  * @family:     The family number or X86_FAMILY_ANY
75  * @feature:    A X86_FEATURE bit
76  * @data:       Driver specific data or NULL. The internal storage
77  *              format is unsigned long. The supplied value, pointer
78  *              etc. is casted to unsigned long internally.
79  *
80  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
81  * set to wildcards.
82  */
83 #define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data)     \
84         X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family,              \
85                                            X86_MODEL_ANY, feature, data)
86
87 /**
88  * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
89  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
90  *              The name is expanded to X86_VENDOR_@vendor
91  * @feature:    A X86_FEATURE bit
92  * @data:       Driver specific data or NULL. The internal storage
93  *              format is unsigned long. The supplied value, pointer
94  *              etc. is casted to unsigned long internally.
95  *
96  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
97  * set to wildcards.
98  */
99 #define X86_MATCH_VENDOR_FEATURE(vendor, feature, data)                 \
100         X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
101
102 /**
103  * X86_MATCH_FEATURE - Macro for matching a CPU feature
104  * @feature:    A X86_FEATURE bit
105  * @data:       Driver specific data or NULL. The internal storage
106  *              format is unsigned long. The supplied value, pointer
107  *              etc. is casted to unsigned long internally.
108  *
109  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
110  * set to wildcards.
111  */
112 #define X86_MATCH_FEATURE(feature, data)                                \
113         X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
114
115 /* Transitional to keep the existing code working */
116 #define X86_FEATURE_MATCH(feature)      X86_MATCH_FEATURE(feature, NULL)
117
118 /**
119  * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
120  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
121  *              The name is expanded to X86_VENDOR_@vendor
122  * @family:     The family number or X86_FAMILY_ANY
123  * @model:      The model number, model constant or X86_MODEL_ANY
124  * @data:       Driver specific data or NULL. The internal storage
125  *              format is unsigned long. The supplied value, pointer
126  *              etc. is casted to unsigned long internally.
127  *
128  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
129  * set to wildcards.
130  */
131 #define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data)         \
132         X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model,       \
133                                            X86_FEATURE_ANY, data)
134
135 /**
136  * X86_MATCH_VENDOR_FAM - Match vendor and family
137  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
138  *              The name is expanded to X86_VENDOR_@vendor
139  * @family:     The family number or X86_FAMILY_ANY
140  * @data:       Driver specific data or NULL. The internal storage
141  *              format is unsigned long. The supplied value, pointer
142  *              etc. is casted to unsigned long internally.
143  *
144  * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
145  * set of wildcards.
146  */
147 #define X86_MATCH_VENDOR_FAM(vendor, family, data)                      \
148         X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
149
150 /**
151  * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
152  * @model:      The model name without the INTEL_FAM6_ prefix or ANY
153  *              The model name is expanded to INTEL_FAM6_@model internally
154  * @data:       Driver specific data or NULL. The internal storage
155  *              format is unsigned long. The supplied value, pointer
156  *              etc. is casted to unsigned long internally.
157  *
158  * The vendor is set to INTEL, the family to 6 and all other missing
159  * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
160  *
161  * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
162  */
163 #define X86_MATCH_INTEL_FAM6_MODEL(model, data)                         \
164         X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
165
166 /*
167  * Match specific microcode revisions.
168  *
169  * vendor/family/model/stepping must be all set.
170  *
171  * Only checks against the boot CPU.  When mixed-stepping configs are
172  * valid for a CPU model, add a quirk for every valid stepping and
173  * do the fine-tuning in the quirk handler.
174  */
175
176 struct x86_cpu_desc {
177         u8      x86_family;
178         u8      x86_vendor;
179         u8      x86_model;
180         u8      x86_stepping;
181         u32     x86_microcode_rev;
182 };
183
184 #define INTEL_CPU_DESC(model, stepping, revision) {             \
185         .x86_family             = 6,                            \
186         .x86_vendor             = X86_VENDOR_INTEL,             \
187         .x86_model              = (model),                      \
188         .x86_stepping           = (stepping),                   \
189         .x86_microcode_rev      = (revision),                   \
190 }
191
192 extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
193 extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
194
195 #endif /* _ASM_X86_CPU_DEVICE_ID */