18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * CPU feature definitions for module loading, used by
48c2ecf20Sopenharmony_ci * module_cpu_feature_match(), see asm/cputable.h for powerpc CPU features.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright 2016 Alastair D'Silva, IBM Corporation.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __ASM_POWERPC_CPUFEATURE_H
108c2ecf20Sopenharmony_ci#define __ASM_POWERPC_CPUFEATURE_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <asm/cputable.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* Keep these in step with powerpc/include/asm/cputable.h */
158c2ecf20Sopenharmony_ci#define MAX_CPU_FEATURES (2 * 32)
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * Currently we don't have a need for any of the feature bits defined in
198c2ecf20Sopenharmony_ci * cpu_user_features. When we do, they should be defined such as:
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * #define PPC_MODULE_FEATURE_32 (ilog2(PPC_FEATURE_32))
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define PPC_MODULE_FEATURE_VEC_CRYPTO			(32 + ilog2(PPC_FEATURE2_VEC_CRYPTO))
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define cpu_feature(x)		(x)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cistatic inline bool cpu_have_feature(unsigned int num)
298c2ecf20Sopenharmony_ci{
308c2ecf20Sopenharmony_ci	if (num < 32)
318c2ecf20Sopenharmony_ci		return !!(cur_cpu_spec->cpu_user_features & 1UL << num);
328c2ecf20Sopenharmony_ci	else
338c2ecf20Sopenharmony_ci		return !!(cur_cpu_spec->cpu_user_features2 & 1UL << (num - 32));
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#endif /* __ASM_POWERPC_CPUFEATURE_H */
37