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 uapi/asm/hwcap.h for MIPS CPU features.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __ASM_CPUFEATURE_H
88c2ecf20Sopenharmony_ci#define __ASM_CPUFEATURE_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <uapi/asm/hwcap.h>
118c2ecf20Sopenharmony_ci#include <asm/elf.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap))
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define cpu_feature(x)		ilog2(HWCAP_ ## x)
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic inline bool cpu_have_feature(unsigned int num)
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci	return elf_hwcap & (1UL << num);
208c2ecf20Sopenharmony_ci}
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#endif /* __ASM_CPUFEATURE_H */
23