162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASM_X86_CPU_DEVICE_ID 362306a36Sopenharmony_ci#define _ASM_X86_CPU_DEVICE_ID 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci/* 662306a36Sopenharmony_ci * Declare drivers belonging to specific x86 CPUs 762306a36Sopenharmony_ci * Similar in spirit to pci_device_id and related PCI functions 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * The wildcard initializers are in mod_devicetable.h because 1062306a36Sopenharmony_ci * file2alias needs them. Sigh. 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci#include <linux/mod_devicetable.h> 1362306a36Sopenharmony_ci/* Get the INTEL_FAM* model defines */ 1462306a36Sopenharmony_ci#include <asm/intel-family.h> 1562306a36Sopenharmony_ci/* And the X86_VENDOR_* ones */ 1662306a36Sopenharmony_ci#include <asm/processor.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* Centaur FAM6 models */ 1962306a36Sopenharmony_ci#define X86_CENTAUR_FAM6_C7_A 0xa 2062306a36Sopenharmony_ci#define X86_CENTAUR_FAM6_C7_D 0xd 2162306a36Sopenharmony_ci#define X86_CENTAUR_FAM6_NANO 0xf 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins) 2462306a36Sopenharmony_ci/** 2562306a36Sopenharmony_ci * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching 2662306a36Sopenharmony_ci * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY 2762306a36Sopenharmony_ci * The name is expanded to X86_VENDOR_@_vendor 2862306a36Sopenharmony_ci * @_family: The family number or X86_FAMILY_ANY 2962306a36Sopenharmony_ci * @_model: The model number, model constant or X86_MODEL_ANY 3062306a36Sopenharmony_ci * @_steppings: Bitmask for steppings, stepping constant or X86_STEPPING_ANY 3162306a36Sopenharmony_ci * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY 3262306a36Sopenharmony_ci * @_data: Driver specific data or NULL. The internal storage 3362306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 3462306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 3562306a36Sopenharmony_ci * 3662306a36Sopenharmony_ci * Use only if you need all selectors. Otherwise use one of the shorter 3762306a36Sopenharmony_ci * macros of the X86_MATCH_* family. If there is no matching shorthand 3862306a36Sopenharmony_ci * macro, consider to add one. If you really need to wrap one of the macros 3962306a36Sopenharmony_ci * into another macro at the usage site for good reasons, then please 4062306a36Sopenharmony_ci * start this local macro with X86_MATCH to allow easy grepping. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \ 4362306a36Sopenharmony_ci _steppings, _feature, _data) { \ 4462306a36Sopenharmony_ci .vendor = X86_VENDOR_##_vendor, \ 4562306a36Sopenharmony_ci .family = _family, \ 4662306a36Sopenharmony_ci .model = _model, \ 4762306a36Sopenharmony_ci .steppings = _steppings, \ 4862306a36Sopenharmony_ci .feature = _feature, \ 4962306a36Sopenharmony_ci .driver_data = (unsigned long) _data \ 5062306a36Sopenharmony_ci} 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci/** 5362306a36Sopenharmony_ci * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching 5462306a36Sopenharmony_ci * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY 5562306a36Sopenharmony_ci * The name is expanded to X86_VENDOR_@_vendor 5662306a36Sopenharmony_ci * @_family: The family number or X86_FAMILY_ANY 5762306a36Sopenharmony_ci * @_model: The model number, model constant or X86_MODEL_ANY 5862306a36Sopenharmony_ci * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY 5962306a36Sopenharmony_ci * @_data: Driver specific data or NULL. The internal storage 6062306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 6162306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 6262306a36Sopenharmony_ci * 6362306a36Sopenharmony_ci * The steppings arguments of X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE() is 6462306a36Sopenharmony_ci * set to wildcards. 6562306a36Sopenharmony_ci */ 6662306a36Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, feature, data) \ 6762306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(vendor, family, model, \ 6862306a36Sopenharmony_ci X86_STEPPING_ANY, feature, data) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/** 7162306a36Sopenharmony_ci * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature 7262306a36Sopenharmony_ci * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY 7362306a36Sopenharmony_ci * The name is expanded to X86_VENDOR_@vendor 7462306a36Sopenharmony_ci * @family: The family number or X86_FAMILY_ANY 7562306a36Sopenharmony_ci * @feature: A X86_FEATURE bit 7662306a36Sopenharmony_ci * @data: Driver specific data or NULL. The internal storage 7762306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 7862306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 7962306a36Sopenharmony_ci * 8062306a36Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are 8162306a36Sopenharmony_ci * set to wildcards. 8262306a36Sopenharmony_ci */ 8362306a36Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \ 8462306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, \ 8562306a36Sopenharmony_ci X86_MODEL_ANY, feature, data) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/** 8862306a36Sopenharmony_ci * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature 8962306a36Sopenharmony_ci * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY 9062306a36Sopenharmony_ci * The name is expanded to X86_VENDOR_@vendor 9162306a36Sopenharmony_ci * @feature: A X86_FEATURE bit 9262306a36Sopenharmony_ci * @data: Driver specific data or NULL. The internal storage 9362306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 9462306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 9562306a36Sopenharmony_ci * 9662306a36Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are 9762306a36Sopenharmony_ci * set to wildcards. 9862306a36Sopenharmony_ci */ 9962306a36Sopenharmony_ci#define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \ 10062306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci/** 10362306a36Sopenharmony_ci * X86_MATCH_FEATURE - Macro for matching a CPU feature 10462306a36Sopenharmony_ci * @feature: A X86_FEATURE bit 10562306a36Sopenharmony_ci * @data: Driver specific data or NULL. The internal storage 10662306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 10762306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 10862306a36Sopenharmony_ci * 10962306a36Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are 11062306a36Sopenharmony_ci * set to wildcards. 11162306a36Sopenharmony_ci */ 11262306a36Sopenharmony_ci#define X86_MATCH_FEATURE(feature, data) \ 11362306a36Sopenharmony_ci X86_MATCH_VENDOR_FEATURE(ANY, feature, data) 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci/** 11662306a36Sopenharmony_ci * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model 11762306a36Sopenharmony_ci * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY 11862306a36Sopenharmony_ci * The name is expanded to X86_VENDOR_@vendor 11962306a36Sopenharmony_ci * @family: The family number or X86_FAMILY_ANY 12062306a36Sopenharmony_ci * @model: The model number, model constant or X86_MODEL_ANY 12162306a36Sopenharmony_ci * @data: Driver specific data or NULL. The internal storage 12262306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 12362306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 12462306a36Sopenharmony_ci * 12562306a36Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are 12662306a36Sopenharmony_ci * set to wildcards. 12762306a36Sopenharmony_ci */ 12862306a36Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \ 12962306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, \ 13062306a36Sopenharmony_ci X86_FEATURE_ANY, data) 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/** 13362306a36Sopenharmony_ci * X86_MATCH_VENDOR_FAM - Match vendor and family 13462306a36Sopenharmony_ci * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY 13562306a36Sopenharmony_ci * The name is expanded to X86_VENDOR_@vendor 13662306a36Sopenharmony_ci * @family: The family number or X86_FAMILY_ANY 13762306a36Sopenharmony_ci * @data: Driver specific data or NULL. The internal storage 13862306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 13962306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 14062306a36Sopenharmony_ci * 14162306a36Sopenharmony_ci * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are 14262306a36Sopenharmony_ci * set of wildcards. 14362306a36Sopenharmony_ci */ 14462306a36Sopenharmony_ci#define X86_MATCH_VENDOR_FAM(vendor, family, data) \ 14562306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data) 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci/** 14862306a36Sopenharmony_ci * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model 14962306a36Sopenharmony_ci * @model: The model name without the INTEL_FAM6_ prefix or ANY 15062306a36Sopenharmony_ci * The model name is expanded to INTEL_FAM6_@model internally 15162306a36Sopenharmony_ci * @data: Driver specific data or NULL. The internal storage 15262306a36Sopenharmony_ci * format is unsigned long. The supplied value, pointer 15362306a36Sopenharmony_ci * etc. is casted to unsigned long internally. 15462306a36Sopenharmony_ci * 15562306a36Sopenharmony_ci * The vendor is set to INTEL, the family to 6 and all other missing 15662306a36Sopenharmony_ci * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards. 15762306a36Sopenharmony_ci * 15862306a36Sopenharmony_ci * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information. 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_ci#define X86_MATCH_INTEL_FAM6_MODEL(model, data) \ 16162306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data) 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci#define X86_MATCH_INTEL_FAM6_MODEL_STEPPINGS(model, steppings, data) \ 16462306a36Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \ 16562306a36Sopenharmony_ci steppings, X86_FEATURE_ANY, data) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci/* 16862306a36Sopenharmony_ci * Match specific microcode revisions. 16962306a36Sopenharmony_ci * 17062306a36Sopenharmony_ci * vendor/family/model/stepping must be all set. 17162306a36Sopenharmony_ci * 17262306a36Sopenharmony_ci * Only checks against the boot CPU. When mixed-stepping configs are 17362306a36Sopenharmony_ci * valid for a CPU model, add a quirk for every valid stepping and 17462306a36Sopenharmony_ci * do the fine-tuning in the quirk handler. 17562306a36Sopenharmony_ci */ 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_cistruct x86_cpu_desc { 17862306a36Sopenharmony_ci u8 x86_family; 17962306a36Sopenharmony_ci u8 x86_vendor; 18062306a36Sopenharmony_ci u8 x86_model; 18162306a36Sopenharmony_ci u8 x86_stepping; 18262306a36Sopenharmony_ci u32 x86_microcode_rev; 18362306a36Sopenharmony_ci}; 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#define INTEL_CPU_DESC(model, stepping, revision) { \ 18662306a36Sopenharmony_ci .x86_family = 6, \ 18762306a36Sopenharmony_ci .x86_vendor = X86_VENDOR_INTEL, \ 18862306a36Sopenharmony_ci .x86_model = (model), \ 18962306a36Sopenharmony_ci .x86_stepping = (stepping), \ 19062306a36Sopenharmony_ci .x86_microcode_rev = (revision), \ 19162306a36Sopenharmony_ci} 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ciextern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match); 19462306a36Sopenharmony_ciextern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table); 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci#endif /* _ASM_X86_CPU_DEVICE_ID */ 197