Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_CPU_DEVICE_ID
0003 #define _ASM_X86_CPU_DEVICE_ID
0004 
0005 /*
0006  * Declare drivers belonging to specific x86 CPUs
0007  * Similar in spirit to pci_device_id and related PCI functions
0008  *
0009  * The wildcard initializers are in mod_devicetable.h because
0010  * file2alias needs them. Sigh.
0011  */
0012 #include <linux/mod_devicetable.h>
0013 /* Get the INTEL_FAM* model defines */
0014 #include <asm/intel-family.h>
0015 /* And the X86_VENDOR_* ones */
0016 #include <asm/processor.h>
0017 
0018 /* Centaur FAM6 models */
0019 #define X86_CENTAUR_FAM6_C7_A       0xa
0020 #define X86_CENTAUR_FAM6_C7_D       0xd
0021 #define X86_CENTAUR_FAM6_NANO       0xf
0022 
0023 #define X86_STEPPINGS(mins, maxs)    GENMASK(maxs, mins)
0024 /**
0025  * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching
0026  * @_vendor:    The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
0027  *      The name is expanded to X86_VENDOR_@_vendor
0028  * @_family:    The family number or X86_FAMILY_ANY
0029  * @_model: The model number, model constant or X86_MODEL_ANY
0030  * @_steppings: Bitmask for steppings, stepping constant or X86_STEPPING_ANY
0031  * @_feature:   A X86_FEATURE bit or X86_FEATURE_ANY
0032  * @_data:  Driver specific data or NULL. The internal storage
0033  *      format is unsigned long. The supplied value, pointer
0034  *      etc. is casted to unsigned long internally.
0035  *
0036  * Use only if you need all selectors. Otherwise use one of the shorter
0037  * macros of the X86_MATCH_* family. If there is no matching shorthand
0038  * macro, consider to add one. If you really need to wrap one of the macros
0039  * into another macro at the usage site for good reasons, then please
0040  * start this local macro with X86_MATCH to allow easy grepping.
0041  */
0042 #define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
0043                             _steppings, _feature, _data) { \
0044     .vendor     = X86_VENDOR_##_vendor,             \
0045     .family     = _family,                  \
0046     .model      = _model,                   \
0047     .steppings  = _steppings,                   \
0048     .feature    = _feature,                 \
0049     .driver_data    = (unsigned long) _data             \
0050 }
0051 
0052 /**
0053  * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching
0054  * @_vendor:    The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
0055  *      The name is expanded to X86_VENDOR_@_vendor
0056  * @_family:    The family number or X86_FAMILY_ANY
0057  * @_model: The model number, model constant or X86_MODEL_ANY
0058  * @_feature:   A X86_FEATURE bit or X86_FEATURE_ANY
0059  * @_data:  Driver specific data or NULL. The internal storage
0060  *      format is unsigned long. The supplied value, pointer
0061  *      etc. is casted to unsigned long internally.
0062  *
0063  * The steppings arguments of X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE() is
0064  * set to wildcards.
0065  */
0066 #define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, feature, data) \
0067     X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(vendor, family, model, \
0068                         X86_STEPPING_ANY, feature, data)
0069 
0070 /**
0071  * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
0072  * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
0073  *      The name is expanded to X86_VENDOR_@vendor
0074  * @family: The family number or X86_FAMILY_ANY
0075  * @feature:    A X86_FEATURE bit
0076  * @data:   Driver specific data or NULL. The internal storage
0077  *      format is unsigned long. The supplied value, pointer
0078  *      etc. is casted to unsigned long internally.
0079  *
0080  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
0081  * set to wildcards.
0082  */
0083 #define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \
0084     X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family,      \
0085                        X86_MODEL_ANY, feature, data)
0086 
0087 /**
0088  * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
0089  * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
0090  *      The name is expanded to X86_VENDOR_@vendor
0091  * @feature:    A X86_FEATURE bit
0092  * @data:   Driver specific data or NULL. The internal storage
0093  *      format is unsigned long. The supplied value, pointer
0094  *      etc. is casted to unsigned long internally.
0095  *
0096  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
0097  * set to wildcards.
0098  */
0099 #define X86_MATCH_VENDOR_FEATURE(vendor, feature, data)         \
0100     X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
0101 
0102 /**
0103  * X86_MATCH_FEATURE - Macro for matching a CPU feature
0104  * @feature:    A X86_FEATURE bit
0105  * @data:   Driver specific data or NULL. The internal storage
0106  *      format is unsigned long. The supplied value, pointer
0107  *      etc. is casted to unsigned long internally.
0108  *
0109  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
0110  * set to wildcards.
0111  */
0112 #define X86_MATCH_FEATURE(feature, data)                \
0113     X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
0114 
0115 /**
0116  * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
0117  * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
0118  *      The name is expanded to X86_VENDOR_@vendor
0119  * @family: The family number or X86_FAMILY_ANY
0120  * @model:  The model number, model constant or X86_MODEL_ANY
0121  * @data:   Driver specific data or NULL. The internal storage
0122  *      format is unsigned long. The supplied value, pointer
0123  *      etc. is casted to unsigned long internally.
0124  *
0125  * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
0126  * set to wildcards.
0127  */
0128 #define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data)     \
0129     X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model,   \
0130                        X86_FEATURE_ANY, data)
0131 
0132 /**
0133  * X86_MATCH_VENDOR_FAM - Match vendor and family
0134  * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
0135  *      The name is expanded to X86_VENDOR_@vendor
0136  * @family: The family number or X86_FAMILY_ANY
0137  * @data:   Driver specific data or NULL. The internal storage
0138  *      format is unsigned long. The supplied value, pointer
0139  *      etc. is casted to unsigned long internally.
0140  *
0141  * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
0142  * set of wildcards.
0143  */
0144 #define X86_MATCH_VENDOR_FAM(vendor, family, data)          \
0145     X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
0146 
0147 /**
0148  * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
0149  * @model:  The model name without the INTEL_FAM6_ prefix or ANY
0150  *      The model name is expanded to INTEL_FAM6_@model internally
0151  * @data:   Driver specific data or NULL. The internal storage
0152  *      format is unsigned long. The supplied value, pointer
0153  *      etc. is casted to unsigned long internally.
0154  *
0155  * The vendor is set to INTEL, the family to 6 and all other missing
0156  * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
0157  *
0158  * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
0159  */
0160 #define X86_MATCH_INTEL_FAM6_MODEL(model, data)             \
0161     X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
0162 
0163 #define X86_MATCH_INTEL_FAM6_MODEL_STEPPINGS(model, steppings, data)    \
0164     X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \
0165                              steppings, X86_FEATURE_ANY, data)
0166 
0167 /*
0168  * Match specific microcode revisions.
0169  *
0170  * vendor/family/model/stepping must be all set.
0171  *
0172  * Only checks against the boot CPU.  When mixed-stepping configs are
0173  * valid for a CPU model, add a quirk for every valid stepping and
0174  * do the fine-tuning in the quirk handler.
0175  */
0176 
0177 struct x86_cpu_desc {
0178     u8  x86_family;
0179     u8  x86_vendor;
0180     u8  x86_model;
0181     u8  x86_stepping;
0182     u32 x86_microcode_rev;
0183 };
0184 
0185 #define INTEL_CPU_DESC(model, stepping, revision) {     \
0186     .x86_family     = 6,                \
0187     .x86_vendor     = X86_VENDOR_INTEL,     \
0188     .x86_model      = (model),          \
0189     .x86_stepping       = (stepping),           \
0190     .x86_microcode_rev  = (revision),           \
0191 }
0192 
0193 extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
0194 extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
0195 
0196 #endif /* _ASM_X86_CPU_DEVICE_ID */