18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * arch/arm/mach-ixp4xx/include/mach/cpu.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * IXP4XX cpu type detection
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (C) 2007 MontaVista Software, Inc.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __ASM_ARCH_CPU_H__
118c2ecf20Sopenharmony_ci#define __ASM_ARCH_CPU_H__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/io.h>
148c2ecf20Sopenharmony_ci#include <asm/cputype.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* Processor id value in CP15 Register 0 */
178c2ecf20Sopenharmony_ci#define IXP42X_PROCESSOR_ID_VALUE	0x690541c0 /* including unused 0x690541Ex */
188c2ecf20Sopenharmony_ci#define IXP42X_PROCESSOR_ID_MASK	0xffffffc0
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define IXP43X_PROCESSOR_ID_VALUE	0x69054040
218c2ecf20Sopenharmony_ci#define IXP43X_PROCESSOR_ID_MASK	0xfffffff0
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define IXP46X_PROCESSOR_ID_VALUE	0x69054200 /* including IXP455 */
248c2ecf20Sopenharmony_ci#define IXP46X_PROCESSOR_ID_MASK	0xfffffff0
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define cpu_is_ixp42x_rev_a0() ((read_cpuid_id() & (IXP42X_PROCESSOR_ID_MASK | 0xF)) == \
278c2ecf20Sopenharmony_ci				IXP42X_PROCESSOR_ID_VALUE)
288c2ecf20Sopenharmony_ci#define cpu_is_ixp42x()	((read_cpuid_id() & IXP42X_PROCESSOR_ID_MASK) == \
298c2ecf20Sopenharmony_ci			 IXP42X_PROCESSOR_ID_VALUE)
308c2ecf20Sopenharmony_ci#define cpu_is_ixp43x()	((read_cpuid_id() & IXP43X_PROCESSOR_ID_MASK) == \
318c2ecf20Sopenharmony_ci			 IXP43X_PROCESSOR_ID_VALUE)
328c2ecf20Sopenharmony_ci#define cpu_is_ixp46x()	((read_cpuid_id() & IXP46X_PROCESSOR_ID_MASK) == \
338c2ecf20Sopenharmony_ci			 IXP46X_PROCESSOR_ID_VALUE)
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic inline u32 ixp4xx_read_feature_bits(void)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	u32 val = ~__raw_readl(IXP4XX_EXP_CFG2);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	if (cpu_is_ixp42x_rev_a0())
408c2ecf20Sopenharmony_ci		return IXP42X_FEATURE_MASK & ~(IXP4XX_FEATURE_RCOMP |
418c2ecf20Sopenharmony_ci					       IXP4XX_FEATURE_AES);
428c2ecf20Sopenharmony_ci	if (cpu_is_ixp42x())
438c2ecf20Sopenharmony_ci		return val & IXP42X_FEATURE_MASK;
448c2ecf20Sopenharmony_ci	if (cpu_is_ixp43x())
458c2ecf20Sopenharmony_ci		return val & IXP43X_FEATURE_MASK;
468c2ecf20Sopenharmony_ci	return val & IXP46X_FEATURE_MASK;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistatic inline void ixp4xx_write_feature_bits(u32 value)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	__raw_writel(~value, IXP4XX_EXP_CFG2);
528c2ecf20Sopenharmony_ci}
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#endif  /* _ASM_ARCH_CPU_H */
55