Merge branch 'next' into for-linus
[linux-2.6-microblaze.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 /**
24  * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Base macro for CPU matching
25  * @_vendor:    The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
26  *              The name is expanded to X86_VENDOR_@_vendor
27  * @_family:    The family number or X86_FAMILY_ANY
28  * @_model:     The model number, model constant or X86_MODEL_ANY
29  * @_feature:   A X86_FEATURE bit or X86_FEATURE_ANY
30  * @_data:      Driver specific data or NULL. The internal storage
31  *              format is unsigned long. The supplied value, pointer
32  *              etc. is casted to unsigned long internally.
33  *
34  * Use only if you need all selectors. Otherwise use one of the shorter
35  * macros of the X86_MATCH_* family. If there is no matching shorthand
36  * macro, consider to add one. If you really need to wrap one of the macros
37  * into another macro at the usage site for good reasons, then please
38  * start this local macro with X86_MATCH to allow easy grepping.
39  */
40 #define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(_vendor, _family, _model,    \
41                                            _feature, _data) {           \
42         .vendor         = X86_VENDOR_##_vendor,                         \
43         .family         = _family,                                      \
44         .model          = _model,                                       \
45         .feature        = _feature,                                     \
46         .driver_data    = (unsigned long) _data                         \
47 }
48
49 /**
50  * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
51  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
52  *              The name is expanded to X86_VENDOR_@vendor
53  * @family:     The family number or X86_FAMILY_ANY
54  * @feature:    A X86_FEATURE bit
55  * @data:       Driver specific data or NULL. The internal storage
56  *              format is unsigned long. The supplied value, pointer
57  *              etc. is casted to unsigned long internally.
58  *
59  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
60  * set to wildcards.
61  */
62 #define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data)     \
63         X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family,              \
64                                            X86_MODEL_ANY, feature, data)
65
66 /**
67  * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
68  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
69  *              The name is expanded to X86_VENDOR_@vendor
70  * @feature:    A X86_FEATURE bit
71  * @data:       Driver specific data or NULL. The internal storage
72  *              format is unsigned long. The supplied value, pointer
73  *              etc. is casted to unsigned long internally.
74  *
75  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
76  * set to wildcards.
77  */
78 #define X86_MATCH_VENDOR_FEATURE(vendor, feature, data)                 \
79         X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
80
81 /**
82  * X86_MATCH_FEATURE - Macro for matching a CPU feature
83  * @feature:    A X86_FEATURE bit
84  * @data:       Driver specific data or NULL. The internal storage
85  *              format is unsigned long. The supplied value, pointer
86  *              etc. is casted to unsigned long internally.
87  *
88  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
89  * set to wildcards.
90  */
91 #define X86_MATCH_FEATURE(feature, data)                                \
92         X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
93
94 /**
95  * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
96  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
97  *              The name is expanded to X86_VENDOR_@vendor
98  * @family:     The family number or X86_FAMILY_ANY
99  * @model:      The model number, model constant or X86_MODEL_ANY
100  * @data:       Driver specific data or NULL. The internal storage
101  *              format is unsigned long. The supplied value, pointer
102  *              etc. is casted to unsigned long internally.
103  *
104  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
105  * set to wildcards.
106  */
107 #define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data)         \
108         X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model,       \
109                                            X86_FEATURE_ANY, data)
110
111 /**
112  * X86_MATCH_VENDOR_FAM - Match vendor and family
113  * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
114  *              The name is expanded to X86_VENDOR_@vendor
115  * @family:     The family number or X86_FAMILY_ANY
116  * @data:       Driver specific data or NULL. The internal storage
117  *              format is unsigned long. The supplied value, pointer
118  *              etc. is casted to unsigned long internally.
119  *
120  * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
121  * set of wildcards.
122  */
123 #define X86_MATCH_VENDOR_FAM(vendor, family, data)                      \
124         X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
125
126 /**
127  * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
128  * @model:      The model name without the INTEL_FAM6_ prefix or ANY
129  *              The model name is expanded to INTEL_FAM6_@model internally
130  * @data:       Driver specific data or NULL. The internal storage
131  *              format is unsigned long. The supplied value, pointer
132  *              etc. is casted to unsigned long internally.
133  *
134  * The vendor is set to INTEL, the family to 6 and all other missing
135  * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
136  *
137  * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
138  */
139 #define X86_MATCH_INTEL_FAM6_MODEL(model, data)                         \
140         X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
141
142 /*
143  * Match specific microcode revisions.
144  *
145  * vendor/family/model/stepping must be all set.
146  *
147  * Only checks against the boot CPU.  When mixed-stepping configs are
148  * valid for a CPU model, add a quirk for every valid stepping and
149  * do the fine-tuning in the quirk handler.
150  */
151
152 struct x86_cpu_desc {
153         u8      x86_family;
154         u8      x86_vendor;
155         u8      x86_model;
156         u8      x86_stepping;
157         u32     x86_microcode_rev;
158 };
159
160 #define INTEL_CPU_DESC(model, stepping, revision) {             \
161         .x86_family             = 6,                            \
162         .x86_vendor             = X86_VENDOR_INTEL,             \
163         .x86_model              = (model),                      \
164         .x86_stepping           = (stepping),                   \
165         .x86_microcode_rev      = (revision),                   \
166 }
167
168 extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
169 extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
170
171 #endif /* _ASM_X86_CPU_DEVICE_ID */