Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7806105 authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Isaac J. Manjarres
Browse files

arm64: Add helpers for checking CPU MIDR against a range



Add helpers for checking if the given CPU midr falls in a range
of variants/revisions for a given model.

Change-Id: Ifde0f33ededa0be56d63ed4efad21fbf5a99e6fc
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: default avatarDave Martin <dave.martin@arm.com>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
Git-commit: 1df31050
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


[isaacm@codeaurora.org: remove code that is not needed for
 having a way of expressing a list of CPUs that would
 be impacted by erratum 1024718.]
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent aa46e038
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -119,6 +119,36 @@

#define read_cpuid(reg)			read_sysreg_s(SYS_ ## reg)

/*
 * Represent a range of MIDR values for a given CPU model and a
 * range of variant/revision values.
 *
 * @model	- CPU model as defined by MIDR_CPU_MODEL
 * @rv_min	- Minimum value for the revision/variant as defined by
 *		  MIDR_CPU_VAR_REV
 * @rv_max	- Maximum value for the variant/revision for the range.
 */
struct midr_range {
	u32 model;
	u32 rv_min;
	u32 rv_max;
};

#define GENERIC_MIDR_RANGE(m, v_min, r_min, v_max, r_max)	\
	{							\
		.model = m,					\
		.rv_min = MIDR_CPU_VAR_REV(v_min, r_min),	\
		.rv_max = MIDR_CPU_VAR_REV(v_max, r_max),	\
	}

#define GENERIC_MIDR_ALL_VERSIONS(m) GENERIC_MIDR_RANGE(m, 0, 0, 0xf, 0xf)

static inline bool is_midr_in_range(u32 midr, struct midr_range const *range)
{
	return MIDR_IS_CPU_MODEL_RANGE(midr, range->model,
				 range->rv_min, range->rv_max);
}

/*
 * The CPU ID never changes at run time, so we might as well tell the
 * compiler that it's constant.  Use this function to read the CPU ID