162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Modifications for ppc64:
662306a36Sopenharmony_ci *      Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#ifndef __ASM_POWERPC_FIRMWARE_H
962306a36Sopenharmony_ci#define __ASM_POWERPC_FIRMWARE_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifdef __KERNEL__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <asm/asm-const.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/* firmware feature bitmask values */
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define FW_FEATURE_PFT		ASM_CONST(0x0000000000000001)
1862306a36Sopenharmony_ci#define FW_FEATURE_TCE		ASM_CONST(0x0000000000000002)
1962306a36Sopenharmony_ci#define FW_FEATURE_SPRG0	ASM_CONST(0x0000000000000004)
2062306a36Sopenharmony_ci#define FW_FEATURE_DABR		ASM_CONST(0x0000000000000008)
2162306a36Sopenharmony_ci#define FW_FEATURE_COPY		ASM_CONST(0x0000000000000010)
2262306a36Sopenharmony_ci#define FW_FEATURE_ASR		ASM_CONST(0x0000000000000020)
2362306a36Sopenharmony_ci#define FW_FEATURE_DEBUG	ASM_CONST(0x0000000000000040)
2462306a36Sopenharmony_ci#define FW_FEATURE_TERM		ASM_CONST(0x0000000000000080)
2562306a36Sopenharmony_ci#define FW_FEATURE_PERF		ASM_CONST(0x0000000000000100)
2662306a36Sopenharmony_ci#define FW_FEATURE_DUMP		ASM_CONST(0x0000000000000200)
2762306a36Sopenharmony_ci#define FW_FEATURE_INTERRUPT	ASM_CONST(0x0000000000000400)
2862306a36Sopenharmony_ci#define FW_FEATURE_MIGRATE	ASM_CONST(0x0000000000000800)
2962306a36Sopenharmony_ci#define FW_FEATURE_PERFMON	ASM_CONST(0x0000000000001000)
3062306a36Sopenharmony_ci#define FW_FEATURE_CRQ		ASM_CONST(0x0000000000002000)
3162306a36Sopenharmony_ci#define FW_FEATURE_VIO		ASM_CONST(0x0000000000004000)
3262306a36Sopenharmony_ci#define FW_FEATURE_RDMA		ASM_CONST(0x0000000000008000)
3362306a36Sopenharmony_ci#define FW_FEATURE_LLAN		ASM_CONST(0x0000000000010000)
3462306a36Sopenharmony_ci#define FW_FEATURE_BULK_REMOVE	ASM_CONST(0x0000000000020000)
3562306a36Sopenharmony_ci#define FW_FEATURE_XDABR	ASM_CONST(0x0000000000040000)
3662306a36Sopenharmony_ci#define FW_FEATURE_PUT_TCE_IND	ASM_CONST(0x0000000000080000)
3762306a36Sopenharmony_ci#define FW_FEATURE_SPLPAR	ASM_CONST(0x0000000000100000)
3862306a36Sopenharmony_ci#define FW_FEATURE_LPAR		ASM_CONST(0x0000000000400000)
3962306a36Sopenharmony_ci#define FW_FEATURE_PS3_LV1	ASM_CONST(0x0000000000800000)
4062306a36Sopenharmony_ci#define FW_FEATURE_HPT_RESIZE	ASM_CONST(0x0000000001000000)
4162306a36Sopenharmony_ci#define FW_FEATURE_CMO		ASM_CONST(0x0000000002000000)
4262306a36Sopenharmony_ci#define FW_FEATURE_VPHN		ASM_CONST(0x0000000004000000)
4362306a36Sopenharmony_ci#define FW_FEATURE_XCMO		ASM_CONST(0x0000000008000000)
4462306a36Sopenharmony_ci#define FW_FEATURE_OPAL		ASM_CONST(0x0000000010000000)
4562306a36Sopenharmony_ci#define FW_FEATURE_SET_MODE	ASM_CONST(0x0000000040000000)
4662306a36Sopenharmony_ci#define FW_FEATURE_BEST_ENERGY	ASM_CONST(0x0000000080000000)
4762306a36Sopenharmony_ci#define FW_FEATURE_FORM1_AFFINITY ASM_CONST(0x0000000100000000)
4862306a36Sopenharmony_ci#define FW_FEATURE_PRRN		ASM_CONST(0x0000000200000000)
4962306a36Sopenharmony_ci#define FW_FEATURE_DRMEM_V2	ASM_CONST(0x0000000400000000)
5062306a36Sopenharmony_ci#define FW_FEATURE_DRC_INFO	ASM_CONST(0x0000000800000000)
5162306a36Sopenharmony_ci#define FW_FEATURE_BLOCK_REMOVE ASM_CONST(0x0000001000000000)
5262306a36Sopenharmony_ci#define FW_FEATURE_PAPR_SCM 	ASM_CONST(0x0000002000000000)
5362306a36Sopenharmony_ci#define FW_FEATURE_ULTRAVISOR	ASM_CONST(0x0000004000000000)
5462306a36Sopenharmony_ci#define FW_FEATURE_STUFF_TCE	ASM_CONST(0x0000008000000000)
5562306a36Sopenharmony_ci#define FW_FEATURE_RPT_INVALIDATE ASM_CONST(0x0000010000000000)
5662306a36Sopenharmony_ci#define FW_FEATURE_FORM2_AFFINITY ASM_CONST(0x0000020000000000)
5762306a36Sopenharmony_ci#define FW_FEATURE_ENERGY_SCALE_INFO ASM_CONST(0x0000040000000000)
5862306a36Sopenharmony_ci#define FW_FEATURE_WATCHDOG	ASM_CONST(0x0000080000000000)
5962306a36Sopenharmony_ci#define FW_FEATURE_PLPKS	ASM_CONST(0x0000100000000000)
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#ifndef __ASSEMBLY__
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_cienum {
6462306a36Sopenharmony_ci#ifdef CONFIG_PPC64
6562306a36Sopenharmony_ci	FW_FEATURE_PSERIES_POSSIBLE = FW_FEATURE_PFT | FW_FEATURE_TCE |
6662306a36Sopenharmony_ci		FW_FEATURE_SPRG0 | FW_FEATURE_DABR | FW_FEATURE_COPY |
6762306a36Sopenharmony_ci		FW_FEATURE_ASR | FW_FEATURE_DEBUG | FW_FEATURE_TERM |
6862306a36Sopenharmony_ci		FW_FEATURE_PERF | FW_FEATURE_DUMP | FW_FEATURE_INTERRUPT |
6962306a36Sopenharmony_ci		FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ |
7062306a36Sopenharmony_ci		FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
7162306a36Sopenharmony_ci		FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR |
7262306a36Sopenharmony_ci		FW_FEATURE_PUT_TCE_IND | FW_FEATURE_STUFF_TCE |
7362306a36Sopenharmony_ci		FW_FEATURE_SPLPAR | FW_FEATURE_LPAR |
7462306a36Sopenharmony_ci		FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO |
7562306a36Sopenharmony_ci		FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY |
7662306a36Sopenharmony_ci		FW_FEATURE_FORM1_AFFINITY | FW_FEATURE_PRRN |
7762306a36Sopenharmony_ci		FW_FEATURE_HPT_RESIZE | FW_FEATURE_DRMEM_V2 |
7862306a36Sopenharmony_ci		FW_FEATURE_DRC_INFO | FW_FEATURE_BLOCK_REMOVE |
7962306a36Sopenharmony_ci		FW_FEATURE_PAPR_SCM | FW_FEATURE_ULTRAVISOR |
8062306a36Sopenharmony_ci		FW_FEATURE_RPT_INVALIDATE | FW_FEATURE_FORM2_AFFINITY |
8162306a36Sopenharmony_ci		FW_FEATURE_ENERGY_SCALE_INFO | FW_FEATURE_WATCHDOG |
8262306a36Sopenharmony_ci		FW_FEATURE_PLPKS,
8362306a36Sopenharmony_ci	FW_FEATURE_PSERIES_ALWAYS = 0,
8462306a36Sopenharmony_ci	FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_ULTRAVISOR,
8562306a36Sopenharmony_ci	FW_FEATURE_POWERNV_ALWAYS = 0,
8662306a36Sopenharmony_ci	FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
8762306a36Sopenharmony_ci	FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
8862306a36Sopenharmony_ci	FW_FEATURE_NATIVE_POSSIBLE = 0,
8962306a36Sopenharmony_ci	FW_FEATURE_NATIVE_ALWAYS = 0,
9062306a36Sopenharmony_ci	FW_FEATURE_POSSIBLE =
9162306a36Sopenharmony_ci#ifdef CONFIG_PPC_PSERIES
9262306a36Sopenharmony_ci		FW_FEATURE_PSERIES_POSSIBLE |
9362306a36Sopenharmony_ci#endif
9462306a36Sopenharmony_ci#ifdef CONFIG_PPC_POWERNV
9562306a36Sopenharmony_ci		FW_FEATURE_POWERNV_POSSIBLE |
9662306a36Sopenharmony_ci#endif
9762306a36Sopenharmony_ci#ifdef CONFIG_PPC_PS3
9862306a36Sopenharmony_ci		FW_FEATURE_PS3_POSSIBLE |
9962306a36Sopenharmony_ci#endif
10062306a36Sopenharmony_ci#ifdef CONFIG_PPC_HASH_MMU_NATIVE
10162306a36Sopenharmony_ci		FW_FEATURE_NATIVE_ALWAYS |
10262306a36Sopenharmony_ci#endif
10362306a36Sopenharmony_ci		0,
10462306a36Sopenharmony_ci	FW_FEATURE_ALWAYS =
10562306a36Sopenharmony_ci#ifdef CONFIG_PPC_PSERIES
10662306a36Sopenharmony_ci		FW_FEATURE_PSERIES_ALWAYS &
10762306a36Sopenharmony_ci#endif
10862306a36Sopenharmony_ci#ifdef CONFIG_PPC_POWERNV
10962306a36Sopenharmony_ci		FW_FEATURE_POWERNV_ALWAYS &
11062306a36Sopenharmony_ci#endif
11162306a36Sopenharmony_ci#ifdef CONFIG_PPC_PS3
11262306a36Sopenharmony_ci		FW_FEATURE_PS3_ALWAYS &
11362306a36Sopenharmony_ci#endif
11462306a36Sopenharmony_ci#ifdef CONFIG_PPC_HASH_MMU_NATIVE
11562306a36Sopenharmony_ci		FW_FEATURE_NATIVE_ALWAYS &
11662306a36Sopenharmony_ci#endif
11762306a36Sopenharmony_ci		FW_FEATURE_POSSIBLE,
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#else /* CONFIG_PPC64 */
12062306a36Sopenharmony_ci	FW_FEATURE_POSSIBLE = 0,
12162306a36Sopenharmony_ci	FW_FEATURE_ALWAYS = 0,
12262306a36Sopenharmony_ci#endif
12362306a36Sopenharmony_ci};
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/* This is used to identify firmware features which are available
12662306a36Sopenharmony_ci * to the kernel.
12762306a36Sopenharmony_ci */
12862306a36Sopenharmony_ciextern unsigned long	powerpc_firmware_features;
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci#define firmware_has_feature(feature)					\
13162306a36Sopenharmony_ci	((FW_FEATURE_ALWAYS & (feature)) ||				\
13262306a36Sopenharmony_ci		(FW_FEATURE_POSSIBLE & powerpc_firmware_features & (feature)))
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ciextern void system_reset_fwnmi(void);
13562306a36Sopenharmony_ciextern void machine_check_fwnmi(void);
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/* This is true if we are using the firmware NMI handler (typically LPAR) */
13862306a36Sopenharmony_ciextern int fwnmi_active;
13962306a36Sopenharmony_ciextern int ibm_nmi_interlock_token;
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ciextern unsigned int __start___fw_ftr_fixup, __stop___fw_ftr_fixup;
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#ifdef CONFIG_PPC_PSERIES
14462306a36Sopenharmony_civoid pseries_probe_fw_features(void);
14562306a36Sopenharmony_ci#else
14662306a36Sopenharmony_cistatic inline void pseries_probe_fw_features(void) { }
14762306a36Sopenharmony_ci#endif
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
15062306a36Sopenharmony_ci#endif /* __KERNEL__ */
15162306a36Sopenharmony_ci#endif /* __ASM_POWERPC_FIRMWARE_H */
152