/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_X86_CPU_DEVICE_ID2#define _ASM_X86_CPU_DEVICE_ID34/*5* Can't use <linux/bitfield.h> because it generates expressions that6* cannot be used in structure initializers. Bitfield construction7* here must match the union in struct cpuinfo_86:8* union {9* struct {10* __u8 x86_model;11* __u8 x86;12* __u8 x86_vendor;13* __u8 x86_reserved;14* };15* __u32 x86_vfm;16* };17*/18#define VFM_MODEL_BIT 019#define VFM_FAMILY_BIT 820#define VFM_VENDOR_BIT 1621#define VFM_RSVD_BIT 242223#define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT)24#define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT)25#define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT)2627#define VFM_MODEL(vfm) (((vfm) & VFM_MODEL_MASK) >> VFM_MODEL_BIT)28#define VFM_FAMILY(vfm) (((vfm) & VFM_FAMILY_MASK) >> VFM_FAMILY_BIT)29#define VFM_VENDOR(vfm) (((vfm) & VFM_VENDOR_MASK) >> VFM_VENDOR_BIT)3031#define VFM_MAKE(_vendor, _family, _model) ( \32((_model) << VFM_MODEL_BIT) | \33((_family) << VFM_FAMILY_BIT) | \34((_vendor) << VFM_VENDOR_BIT) \35)3637/*38* Declare drivers belonging to specific x86 CPUs39* Similar in spirit to pci_device_id and related PCI functions40*41* The wildcard initializers are in mod_devicetable.h because42* file2alias needs them. Sigh.43*/44#include <linux/mod_devicetable.h>45/* Get the INTEL_FAM* model defines */46#include <asm/intel-family.h>47/* And the X86_VENDOR_* ones */48#include <asm/processor.h>4950/* Centaur FAM6 models */51#define X86_CENTAUR_FAM6_C7_A 0xa52#define X86_CENTAUR_FAM6_C7_D 0xd53#define X86_CENTAUR_FAM6_NANO 0xf5455/* x86_cpu_id::flags */56#define X86_CPU_ID_FLAG_ENTRY_VALID BIT(0)5758/**59* X86_MATCH_CPU - Base macro for CPU matching60* @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY61* The name is expanded to X86_VENDOR_@_vendor62* @_family: The family number or X86_FAMILY_ANY63* @_model: The model number, model constant or X86_MODEL_ANY64* @_steppings: Bitmask for steppings, stepping constant or X86_STEPPING_ANY65* @_feature: A X86_FEATURE bit or X86_FEATURE_ANY66* @_data: Driver specific data or NULL. The internal storage67* format is unsigned long. The supplied value, pointer68* etc. is casted to unsigned long internally.69*70* Use only if you need all selectors. Otherwise use one of the shorter71* macros of the X86_MATCH_* family. If there is no matching shorthand72* macro, consider to add one. If you really need to wrap one of the macros73* into another macro at the usage site for good reasons, then please74* start this local macro with X86_MATCH to allow easy grepping.75*/76#define X86_MATCH_CPU(_vendor, _family, _model, _steppings, _feature, _type, _data) { \77.vendor = _vendor, \78.family = _family, \79.model = _model, \80.steppings = _steppings, \81.feature = _feature, \82.flags = X86_CPU_ID_FLAG_ENTRY_VALID, \83.type = _type, \84.driver_data = (unsigned long) _data \85}8687/**88* X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature89* @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY90* The name is expanded to X86_VENDOR_@vendor91* @family: The family number or X86_FAMILY_ANY92* @feature: A X86_FEATURE bit93* @data: Driver specific data or NULL. The internal storage94* format is unsigned long. The supplied value, pointer95* etc. is casted to unsigned long internally.96*/97#define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \98X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \99X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)100101/**102* X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature103* @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY104* The name is expanded to X86_VENDOR_@vendor105* @feature: A X86_FEATURE bit106* @data: Driver specific data or NULL. The internal storage107* format is unsigned long. The supplied value, pointer108* etc. is casted to unsigned long internally.109*/110#define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \111X86_MATCH_CPU(X86_VENDOR_##vendor, X86_FAMILY_ANY, X86_MODEL_ANY, \112X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)113114/**115* X86_MATCH_FEATURE - Macro for matching a CPU feature116* @feature: A X86_FEATURE bit117* @data: Driver specific data or NULL. The internal storage118* format is unsigned long. The supplied value, pointer119* etc. is casted to unsigned long internally.120*/121#define X86_MATCH_FEATURE(feature, data) \122X86_MATCH_CPU(X86_VENDOR_ANY, X86_FAMILY_ANY, X86_MODEL_ANY, \123X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)124125/**126* X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model127* @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY128* The name is expanded to X86_VENDOR_@vendor129* @family: The family number or X86_FAMILY_ANY130* @model: The model number, model constant or X86_MODEL_ANY131* @data: Driver specific data or NULL. The internal storage132* format is unsigned long. The supplied value, pointer133* etc. is casted to unsigned long internally.134*/135#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \136X86_MATCH_CPU(X86_VENDOR_##vendor, family, model, X86_STEPPING_ANY, \137X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)138139/**140* X86_MATCH_VENDOR_FAM - Match vendor and family141* @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY142* The name is expanded to X86_VENDOR_@vendor143* @family: The family number or X86_FAMILY_ANY144* @data: Driver specific data or NULL. The internal storage145* format is unsigned long. The supplied value, pointer146* etc. is casted to unsigned long internally.147*/148#define X86_MATCH_VENDOR_FAM(vendor, family, data) \149X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \150X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)151152/**153* X86_MATCH_VFM - Match encoded vendor/family/model154* @vfm: Encoded 8-bits each for vendor, family, model155* @data: Driver specific data or NULL. The internal storage156* format is unsigned long. The supplied value, pointer157* etc. is cast to unsigned long internally.158*/159#define X86_MATCH_VFM(vfm, data) \160X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \161X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)162163#define __X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)164/**165* X86_MATCH_VFM_STEPS - Match encoded vendor/family/model and steppings166* range.167* @vfm: Encoded 8-bits each for vendor, family, model168* @min_step: Lowest stepping number to match169* @max_step: Highest stepping number to match170* @data: Driver specific data or NULL. The internal storage171* format is unsigned long. The supplied value, pointer172* etc. is cast to unsigned long internally.173*/174#define X86_MATCH_VFM_STEPS(vfm, min_step, max_step, data) \175X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \176__X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, \177X86_CPU_TYPE_ANY, data)178179/**180* X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature181* @vfm: Encoded 8-bits each for vendor, family, model182* @feature: A X86_FEATURE bit183* @data: Driver specific data or NULL. The internal storage184* format is unsigned long. The supplied value, pointer185* etc. is cast to unsigned long internally.186*/187#define X86_MATCH_VFM_FEATURE(vfm, feature, data) \188X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \189X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)190191/**192* X86_MATCH_VFM_CPU_TYPE - Match encoded vendor/family/model/type193* @vfm: Encoded 8-bits each for vendor, family, model194* @type: CPU type e.g. P-core, E-core195* @data: Driver specific data or NULL. The internal storage196* format is unsigned long. The supplied value, pointer197* etc. is cast to unsigned long internally.198*/199#define X86_MATCH_VFM_CPU_TYPE(vfm, type, data) \200X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \201X86_STEPPING_ANY, X86_FEATURE_ANY, type, data)202203extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);204extern bool x86_match_min_microcode_rev(const struct x86_cpu_id *table);205206#endif /* _ASM_X86_CPU_DEVICE_ID */207208209