18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_CPU_DEVICE_ID
38c2ecf20Sopenharmony_ci#define _ASM_X86_CPU_DEVICE_ID
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci * Declare drivers belonging to specific x86 CPUs
78c2ecf20Sopenharmony_ci * Similar in spirit to pci_device_id and related PCI functions
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * The wildcard initializers are in mod_devicetable.h because
108c2ecf20Sopenharmony_ci * file2alias needs them. Sigh.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci#include <linux/mod_devicetable.h>
138c2ecf20Sopenharmony_ci/* Get the INTEL_FAM* model defines */
148c2ecf20Sopenharmony_ci#include <asm/intel-family.h>
158c2ecf20Sopenharmony_ci/* And the X86_VENDOR_* ones */
168c2ecf20Sopenharmony_ci#include <asm/processor.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* Centaur FAM6 models */
198c2ecf20Sopenharmony_ci#define X86_CENTAUR_FAM6_C7_A		0xa
208c2ecf20Sopenharmony_ci#define X86_CENTAUR_FAM6_C7_D		0xd
218c2ecf20Sopenharmony_ci#define X86_CENTAUR_FAM6_NANO		0xf
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define X86_STEPPINGS(mins, maxs)    GENMASK(maxs, mins)
248c2ecf20Sopenharmony_ci/**
258c2ecf20Sopenharmony_ci * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching
268c2ecf20Sopenharmony_ci * @_vendor:	The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
278c2ecf20Sopenharmony_ci *		The name is expanded to X86_VENDOR_@_vendor
288c2ecf20Sopenharmony_ci * @_family:	The family number or X86_FAMILY_ANY
298c2ecf20Sopenharmony_ci * @_model:	The model number, model constant or X86_MODEL_ANY
308c2ecf20Sopenharmony_ci * @_steppings:	Bitmask for steppings, stepping constant or X86_STEPPING_ANY
318c2ecf20Sopenharmony_ci * @_feature:	A X86_FEATURE bit or X86_FEATURE_ANY
328c2ecf20Sopenharmony_ci * @_data:	Driver specific data or NULL. The internal storage
338c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
348c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci * Use only if you need all selectors. Otherwise use one of the shorter
378c2ecf20Sopenharmony_ci * macros of the X86_MATCH_* family. If there is no matching shorthand
388c2ecf20Sopenharmony_ci * macro, consider to add one. If you really need to wrap one of the macros
398c2ecf20Sopenharmony_ci * into another macro at the usage site for good reasons, then please
408c2ecf20Sopenharmony_ci * start this local macro with X86_MATCH to allow easy grepping.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
438c2ecf20Sopenharmony_ci						    _steppings, _feature, _data) { \
448c2ecf20Sopenharmony_ci	.vendor		= X86_VENDOR_##_vendor,				\
458c2ecf20Sopenharmony_ci	.family		= _family,					\
468c2ecf20Sopenharmony_ci	.model		= _model,					\
478c2ecf20Sopenharmony_ci	.steppings	= _steppings,					\
488c2ecf20Sopenharmony_ci	.feature	= _feature,					\
498c2ecf20Sopenharmony_ci	.driver_data	= (unsigned long) _data				\
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/**
538c2ecf20Sopenharmony_ci * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching
548c2ecf20Sopenharmony_ci * @_vendor:	The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
558c2ecf20Sopenharmony_ci *		The name is expanded to X86_VENDOR_@_vendor
568c2ecf20Sopenharmony_ci * @_family:	The family number or X86_FAMILY_ANY
578c2ecf20Sopenharmony_ci * @_model:	The model number, model constant or X86_MODEL_ANY
588c2ecf20Sopenharmony_ci * @_feature:	A X86_FEATURE bit or X86_FEATURE_ANY
598c2ecf20Sopenharmony_ci * @_data:	Driver specific data or NULL. The internal storage
608c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
618c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
628c2ecf20Sopenharmony_ci *
638c2ecf20Sopenharmony_ci * The steppings arguments of X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE() is
648c2ecf20Sopenharmony_ci * set to wildcards.
658c2ecf20Sopenharmony_ci */
668c2ecf20Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, feature, data) \
678c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(vendor, family, model, \
688c2ecf20Sopenharmony_ci						X86_STEPPING_ANY, feature, data)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/**
718c2ecf20Sopenharmony_ci * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
728c2ecf20Sopenharmony_ci * @vendor:	The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
738c2ecf20Sopenharmony_ci *		The name is expanded to X86_VENDOR_@vendor
748c2ecf20Sopenharmony_ci * @family:	The family number or X86_FAMILY_ANY
758c2ecf20Sopenharmony_ci * @feature:	A X86_FEATURE bit
768c2ecf20Sopenharmony_ci * @data:	Driver specific data or NULL. The internal storage
778c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
788c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
818c2ecf20Sopenharmony_ci * set to wildcards.
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data)	\
848c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family,		\
858c2ecf20Sopenharmony_ci					   X86_MODEL_ANY, feature, data)
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/**
888c2ecf20Sopenharmony_ci * X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
898c2ecf20Sopenharmony_ci * @vendor:	The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
908c2ecf20Sopenharmony_ci *		The name is expanded to X86_VENDOR_@vendor
918c2ecf20Sopenharmony_ci * @feature:	A X86_FEATURE bit
928c2ecf20Sopenharmony_ci * @data:	Driver specific data or NULL. The internal storage
938c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
948c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
958c2ecf20Sopenharmony_ci *
968c2ecf20Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
978c2ecf20Sopenharmony_ci * set to wildcards.
988c2ecf20Sopenharmony_ci */
998c2ecf20Sopenharmony_ci#define X86_MATCH_VENDOR_FEATURE(vendor, feature, data)			\
1008c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/**
1038c2ecf20Sopenharmony_ci * X86_MATCH_FEATURE - Macro for matching a CPU feature
1048c2ecf20Sopenharmony_ci * @feature:	A X86_FEATURE bit
1058c2ecf20Sopenharmony_ci * @data:	Driver specific data or NULL. The internal storage
1068c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
1078c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
1088c2ecf20Sopenharmony_ci *
1098c2ecf20Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
1108c2ecf20Sopenharmony_ci * set to wildcards.
1118c2ecf20Sopenharmony_ci */
1128c2ecf20Sopenharmony_ci#define X86_MATCH_FEATURE(feature, data)				\
1138c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/**
1168c2ecf20Sopenharmony_ci * X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
1178c2ecf20Sopenharmony_ci * @vendor:	The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
1188c2ecf20Sopenharmony_ci *		The name is expanded to X86_VENDOR_@vendor
1198c2ecf20Sopenharmony_ci * @family:	The family number or X86_FAMILY_ANY
1208c2ecf20Sopenharmony_ci * @model:	The model number, model constant or X86_MODEL_ANY
1218c2ecf20Sopenharmony_ci * @data:	Driver specific data or NULL. The internal storage
1228c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
1238c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
1248c2ecf20Sopenharmony_ci *
1258c2ecf20Sopenharmony_ci * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
1268c2ecf20Sopenharmony_ci * set to wildcards.
1278c2ecf20Sopenharmony_ci */
1288c2ecf20Sopenharmony_ci#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data)		\
1298c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model,	\
1308c2ecf20Sopenharmony_ci					   X86_FEATURE_ANY, data)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/**
1338c2ecf20Sopenharmony_ci * X86_MATCH_VENDOR_FAM - Match vendor and family
1348c2ecf20Sopenharmony_ci * @vendor:	The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
1358c2ecf20Sopenharmony_ci *		The name is expanded to X86_VENDOR_@vendor
1368c2ecf20Sopenharmony_ci * @family:	The family number or X86_FAMILY_ANY
1378c2ecf20Sopenharmony_ci * @data:	Driver specific data or NULL. The internal storage
1388c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
1398c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
1408c2ecf20Sopenharmony_ci *
1418c2ecf20Sopenharmony_ci * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
1428c2ecf20Sopenharmony_ci * set of wildcards.
1438c2ecf20Sopenharmony_ci */
1448c2ecf20Sopenharmony_ci#define X86_MATCH_VENDOR_FAM(vendor, family, data)			\
1458c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/**
1488c2ecf20Sopenharmony_ci * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
1498c2ecf20Sopenharmony_ci * @model:	The model name without the INTEL_FAM6_ prefix or ANY
1508c2ecf20Sopenharmony_ci *		The model name is expanded to INTEL_FAM6_@model internally
1518c2ecf20Sopenharmony_ci * @data:	Driver specific data or NULL. The internal storage
1528c2ecf20Sopenharmony_ci *		format is unsigned long. The supplied value, pointer
1538c2ecf20Sopenharmony_ci *		etc. is casted to unsigned long internally.
1548c2ecf20Sopenharmony_ci *
1558c2ecf20Sopenharmony_ci * The vendor is set to INTEL, the family to 6 and all other missing
1568c2ecf20Sopenharmony_ci * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
1578c2ecf20Sopenharmony_ci *
1588c2ecf20Sopenharmony_ci * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
1598c2ecf20Sopenharmony_ci */
1608c2ecf20Sopenharmony_ci#define X86_MATCH_INTEL_FAM6_MODEL(model, data)				\
1618c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci#define X86_MATCH_INTEL_FAM6_MODEL_STEPPINGS(model, steppings, data)	\
1648c2ecf20Sopenharmony_ci	X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \
1658c2ecf20Sopenharmony_ci						     steppings, X86_FEATURE_ANY, data)
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci/*
1688c2ecf20Sopenharmony_ci * Match specific microcode revisions.
1698c2ecf20Sopenharmony_ci *
1708c2ecf20Sopenharmony_ci * vendor/family/model/stepping must be all set.
1718c2ecf20Sopenharmony_ci *
1728c2ecf20Sopenharmony_ci * Only checks against the boot CPU.  When mixed-stepping configs are
1738c2ecf20Sopenharmony_ci * valid for a CPU model, add a quirk for every valid stepping and
1748c2ecf20Sopenharmony_ci * do the fine-tuning in the quirk handler.
1758c2ecf20Sopenharmony_ci */
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistruct x86_cpu_desc {
1788c2ecf20Sopenharmony_ci	u8	x86_family;
1798c2ecf20Sopenharmony_ci	u8	x86_vendor;
1808c2ecf20Sopenharmony_ci	u8	x86_model;
1818c2ecf20Sopenharmony_ci	u8	x86_stepping;
1828c2ecf20Sopenharmony_ci	u32	x86_microcode_rev;
1838c2ecf20Sopenharmony_ci};
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define INTEL_CPU_DESC(model, stepping, revision) {		\
1868c2ecf20Sopenharmony_ci	.x86_family		= 6,				\
1878c2ecf20Sopenharmony_ci	.x86_vendor		= X86_VENDOR_INTEL,		\
1888c2ecf20Sopenharmony_ci	.x86_model		= (model),			\
1898c2ecf20Sopenharmony_ci	.x86_stepping		= (stepping),			\
1908c2ecf20Sopenharmony_ci	.x86_microcode_rev	= (revision),			\
1918c2ecf20Sopenharmony_ci}
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ciextern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
1948c2ecf20Sopenharmony_ciextern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci#endif /* _ASM_X86_CPU_DEVICE_ID */
197