linux/arch/x86/include/asm/cpu_device_id.h
<<
>>
Prefs
   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 - Base 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 * Use only if you need all selectors. Otherwise use one of the shorter
  64 * macros of the X86_MATCH_* family. If there is no matching shorthand
  65 * macro, consider to add one. If you really need to wrap one of the macros
  66 * into another macro at the usage site for good reasons, then please
  67 * start this local macro with X86_MATCH to allow easy grepping.
  68 */
  69#define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(_vendor, _family, _model,    \
  70                                           _feature, _data) {           \
  71        .vendor         = X86_VENDOR_##_vendor,                         \
  72        .family         = _family,                                      \
  73        .model          = _model,                                       \
  74        .feature        = _feature,                                     \
  75        .driver_data    = (unsigned long) _data                         \
  76}
  77
  78/**
  79 * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
  80 * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
  81 *              The name is expanded to X86_VENDOR_@vendor
  82 * @family:     The family number or X86_FAMILY_ANY
  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_VENDOR_FAM_FEATURE(vendor, family, feature, data)     \
  92        X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family,              \
  93                                           X86_MODEL_ANY, feature, data)
  94
  95/**
  96 * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
  97 * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
  98 *              The name is expanded to X86_VENDOR_@vendor
  99 * @feature:    A X86_FEATURE bit
 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_FEATURE(vendor, feature, data)                 \
 108        X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
 109
 110/**
 111 * X86_MATCH_FEATURE - Macro for matching a CPU feature
 112 * @feature:    A X86_FEATURE bit
 113 * @data:       Driver specific data or NULL. The internal storage
 114 *              format is unsigned long. The supplied value, pointer
 115 *              etc. is casted to unsigned long internally.
 116 *
 117 * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
 118 * set to wildcards.
 119 */
 120#define X86_MATCH_FEATURE(feature, data)                                \
 121        X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
 122
 123/* Transitional to keep the existing code working */
 124#define X86_FEATURE_MATCH(feature)      X86_MATCH_FEATURE(feature, NULL)
 125
 126/**
 127 * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
 128 * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
 129 *              The name is expanded to X86_VENDOR_@vendor
 130 * @family:     The family number or X86_FAMILY_ANY
 131 * @model:      The model number, model constant or X86_MODEL_ANY
 132 * @data:       Driver specific data or NULL. The internal storage
 133 *              format is unsigned long. The supplied value, pointer
 134 *              etc. is casted to unsigned long internally.
 135 *
 136 * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
 137 * set to wildcards.
 138 */
 139#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data)         \
 140        X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model,       \
 141                                           X86_FEATURE_ANY, data)
 142
 143/**
 144 * X86_MATCH_VENDOR_FAM - Match vendor and family
 145 * @vendor:     The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
 146 *              The name is expanded to X86_VENDOR_@vendor
 147 * @family:     The family number or X86_FAMILY_ANY
 148 * @data:       Driver specific data or NULL. The internal storage
 149 *              format is unsigned long. The supplied value, pointer
 150 *              etc. is casted to unsigned long internally.
 151 *
 152 * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
 153 * set of wildcards.
 154 */
 155#define X86_MATCH_VENDOR_FAM(vendor, family, data)                      \
 156        X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
 157
 158/**
 159 * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
 160 * @model:      The model name without the INTEL_FAM6_ prefix or ANY
 161 *              The model name is expanded to INTEL_FAM6_@model internally
 162 * @data:       Driver specific data or NULL. The internal storage
 163 *              format is unsigned long. The supplied value, pointer
 164 *              etc. is casted to unsigned long internally.
 165 *
 166 * The vendor is set to INTEL, the family to 6 and all other missing
 167 * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
 168 *
 169 * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
 170 */
 171#define X86_MATCH_INTEL_FAM6_MODEL(model, data)                         \
 172        X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
 173
 174#define X86_MATCH_INTEL_FAM6_MODEL_STEPPINGS(model, steppings, data)    \
 175        X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \
 176                                                     steppings, X86_FEATURE_ANY, data)
 177
 178/*
 179 * Match specific microcode revisions.
 180 *
 181 * vendor/family/model/stepping must be all set.
 182 *
 183 * Only checks against the boot CPU.  When mixed-stepping configs are
 184 * valid for a CPU model, add a quirk for every valid stepping and
 185 * do the fine-tuning in the quirk handler.
 186 */
 187
 188struct x86_cpu_desc {
 189        u8      x86_family;
 190        u8      x86_vendor;
 191        u8      x86_model;
 192        u8      x86_stepping;
 193        u32     x86_microcode_rev;
 194};
 195
 196#define INTEL_CPU_DESC(model, stepping, revision) {             \
 197        .x86_family             = 6,                            \
 198        .x86_vendor             = X86_VENDOR_INTEL,             \
 199        .x86_model              = (model),                      \
 200        .x86_stepping           = (stepping),                   \
 201        .x86_microcode_rev      = (revision),                   \
 202}
 203
 204extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
 205extern const struct x86_cpu_id_v2 *x86_match_cpu_v2(const struct x86_cpu_id_v2 *match);
 206extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
 207
 208#endif /* _ASM_X86_CPU_DEVICE_ID */
 209