162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _SPARC64_SFAFSR_H
362306a36Sopenharmony_ci#define _SPARC64_SFAFSR_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/const.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/* Spitfire Asynchronous Fault Status register, ASI=0x4C VA<63:0>=0x0 */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#define SFAFSR_ME		(_AC(1,UL) << SFAFSR_ME_SHIFT)
1062306a36Sopenharmony_ci#define SFAFSR_ME_SHIFT		32
1162306a36Sopenharmony_ci#define SFAFSR_PRIV		(_AC(1,UL) << SFAFSR_PRIV_SHIFT)
1262306a36Sopenharmony_ci#define SFAFSR_PRIV_SHIFT	31
1362306a36Sopenharmony_ci#define SFAFSR_ISAP		(_AC(1,UL) << SFAFSR_ISAP_SHIFT)
1462306a36Sopenharmony_ci#define SFAFSR_ISAP_SHIFT	30
1562306a36Sopenharmony_ci#define SFAFSR_ETP		(_AC(1,UL) << SFAFSR_ETP_SHIFT)
1662306a36Sopenharmony_ci#define SFAFSR_ETP_SHIFT	29
1762306a36Sopenharmony_ci#define SFAFSR_IVUE		(_AC(1,UL) << SFAFSR_IVUE_SHIFT)
1862306a36Sopenharmony_ci#define SFAFSR_IVUE_SHIFT	28
1962306a36Sopenharmony_ci#define SFAFSR_TO		(_AC(1,UL) << SFAFSR_TO_SHIFT)
2062306a36Sopenharmony_ci#define SFAFSR_TO_SHIFT		27
2162306a36Sopenharmony_ci#define SFAFSR_BERR		(_AC(1,UL) << SFAFSR_BERR_SHIFT)
2262306a36Sopenharmony_ci#define SFAFSR_BERR_SHIFT	26
2362306a36Sopenharmony_ci#define SFAFSR_LDP		(_AC(1,UL) << SFAFSR_LDP_SHIFT)
2462306a36Sopenharmony_ci#define SFAFSR_LDP_SHIFT	25
2562306a36Sopenharmony_ci#define SFAFSR_CP		(_AC(1,UL) << SFAFSR_CP_SHIFT)
2662306a36Sopenharmony_ci#define SFAFSR_CP_SHIFT		24
2762306a36Sopenharmony_ci#define SFAFSR_WP		(_AC(1,UL) << SFAFSR_WP_SHIFT)
2862306a36Sopenharmony_ci#define SFAFSR_WP_SHIFT		23
2962306a36Sopenharmony_ci#define SFAFSR_EDP		(_AC(1,UL) << SFAFSR_EDP_SHIFT)
3062306a36Sopenharmony_ci#define SFAFSR_EDP_SHIFT	22
3162306a36Sopenharmony_ci#define SFAFSR_UE		(_AC(1,UL) << SFAFSR_UE_SHIFT)
3262306a36Sopenharmony_ci#define SFAFSR_UE_SHIFT		21
3362306a36Sopenharmony_ci#define SFAFSR_CE		(_AC(1,UL) << SFAFSR_CE_SHIFT)
3462306a36Sopenharmony_ci#define SFAFSR_CE_SHIFT		20
3562306a36Sopenharmony_ci#define SFAFSR_ETS		(_AC(0xf,UL) << SFAFSR_ETS_SHIFT)
3662306a36Sopenharmony_ci#define SFAFSR_ETS_SHIFT	16
3762306a36Sopenharmony_ci#define SFAFSR_PSYND		(_AC(0xffff,UL) << SFAFSR_PSYND_SHIFT)
3862306a36Sopenharmony_ci#define SFAFSR_PSYND_SHIFT	0
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* UDB Error Register, ASI=0x7f VA<63:0>=0x0(High),0x18(Low) for read
4162306a36Sopenharmony_ci *                     ASI=0x77 VA<63:0>=0x0(High),0x18(Low) for write
4262306a36Sopenharmony_ci */
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define UDBE_UE			(_AC(1,UL) << 9)
4562306a36Sopenharmony_ci#define UDBE_CE			(_AC(1,UL) << 8)
4662306a36Sopenharmony_ci#define UDBE_E_SYNDR		(_AC(0xff,UL) << 0)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* The trap handlers for asynchronous errors encode the AFSR and
4962306a36Sopenharmony_ci * other pieces of information into a 64-bit argument for C code
5062306a36Sopenharmony_ci * encoded as follows:
5162306a36Sopenharmony_ci *
5262306a36Sopenharmony_ci * -----------------------------------------------
5362306a36Sopenharmony_ci * |  UDB_H  |  UDB_L  | TL>1  |  TT  |   AFSR   |
5462306a36Sopenharmony_ci * -----------------------------------------------
5562306a36Sopenharmony_ci *  63     54 53     44    42   41  33 32       0
5662306a36Sopenharmony_ci *
5762306a36Sopenharmony_ci * The AFAR is passed in unchanged.
5862306a36Sopenharmony_ci */
5962306a36Sopenharmony_ci#define SFSTAT_UDBH_MASK	(_AC(0x3ff,UL) << SFSTAT_UDBH_SHIFT)
6062306a36Sopenharmony_ci#define SFSTAT_UDBH_SHIFT	54
6162306a36Sopenharmony_ci#define SFSTAT_UDBL_MASK	(_AC(0x3ff,UL) << SFSTAT_UDBH_SHIFT)
6262306a36Sopenharmony_ci#define SFSTAT_UDBL_SHIFT	44
6362306a36Sopenharmony_ci#define SFSTAT_TL_GT_ONE	(_AC(1,UL) << SFSTAT_TL_GT_ONE_SHIFT)
6462306a36Sopenharmony_ci#define SFSTAT_TL_GT_ONE_SHIFT	42
6562306a36Sopenharmony_ci#define SFSTAT_TRAP_TYPE	(_AC(0x1FF,UL) << SFSTAT_TRAP_TYPE_SHIFT)
6662306a36Sopenharmony_ci#define SFSTAT_TRAP_TYPE_SHIFT	33
6762306a36Sopenharmony_ci#define SFSTAT_AFSR_MASK	(_AC(0x1ffffffff,UL) << SFSTAT_AFSR_SHIFT)
6862306a36Sopenharmony_ci#define SFSTAT_AFSR_SHIFT	0
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* ESTATE Error Enable Register, ASI=0x4b VA<63:0>=0x0 */
7162306a36Sopenharmony_ci#define ESTATE_ERR_CE		0x1 /* Correctable errors                    */
7262306a36Sopenharmony_ci#define ESTATE_ERR_NCE		0x2 /* TO, BERR, LDP, ETP, EDP, WP, UE, IVUE */
7362306a36Sopenharmony_ci#define ESTATE_ERR_ISAP		0x4 /* System address parity error           */
7462306a36Sopenharmony_ci#define ESTATE_ERR_ALL		(ESTATE_ERR_CE | \
7562306a36Sopenharmony_ci				 ESTATE_ERR_NCE | \
7662306a36Sopenharmony_ci				 ESTATE_ERR_ISAP)
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/* The various trap types that report using the above state. */
7962306a36Sopenharmony_ci#define TRAP_TYPE_IAE		0x09 /* Instruction Access Error             */
8062306a36Sopenharmony_ci#define TRAP_TYPE_DAE		0x32 /* Data Access Error                    */
8162306a36Sopenharmony_ci#define TRAP_TYPE_CEE		0x63 /* Correctable ECC Error                */
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#endif /* _SPARC64_SFAFSR_H */
84