162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _SPARC64_CHAFSR_H
362306a36Sopenharmony_ci#define _SPARC64_CHAFSR_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/* Cheetah Asynchronous Fault Status register, ASI=0x4C VA<63:0>=0x0 */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/* Comments indicate which processor variants on which the bit definition
862306a36Sopenharmony_ci * is valid.  Codes are:
962306a36Sopenharmony_ci * ch	-->	cheetah
1062306a36Sopenharmony_ci * ch+	-->	cheetah plus
1162306a36Sopenharmony_ci * jp	-->	jalapeno
1262306a36Sopenharmony_ci */
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* All bits of this register except M_SYNDROME and E_SYNDROME are
1562306a36Sopenharmony_ci * read, write 1 to clear.  M_SYNDROME and E_SYNDROME are read-only.
1662306a36Sopenharmony_ci */
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* Software bit set by linux trap handlers to indicate that the trap was
1962306a36Sopenharmony_ci * signalled at %tl >= 1.
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_ci#define CHAFSR_TL1		(1UL << 63UL) /* n/a */
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/* Unmapped error from system bus for prefetch queue or
2462306a36Sopenharmony_ci * store queue read operation
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_ci#define CHPAFSR_DTO		(1UL << 59UL) /* ch+ */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/* Bus error from system bus for prefetch queue or store queue
2962306a36Sopenharmony_ci * read operation
3062306a36Sopenharmony_ci */
3162306a36Sopenharmony_ci#define CHPAFSR_DBERR		(1UL << 58UL) /* ch+ */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* Hardware corrected E-cache Tag ECC error */
3462306a36Sopenharmony_ci#define CHPAFSR_THCE		(1UL << 57UL) /* ch+ */
3562306a36Sopenharmony_ci/* System interface protocol error, hw timeout caused */
3662306a36Sopenharmony_ci#define JPAFSR_JETO		(1UL << 57UL) /* jp */
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* SW handled correctable E-cache Tag ECC error */
3962306a36Sopenharmony_ci#define CHPAFSR_TSCE		(1UL << 56UL) /* ch+ */
4062306a36Sopenharmony_ci/* Parity error on system snoop results */
4162306a36Sopenharmony_ci#define JPAFSR_SCE		(1UL << 56UL) /* jp */
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci/* Uncorrectable E-cache Tag ECC error */
4462306a36Sopenharmony_ci#define CHPAFSR_TUE		(1UL << 55UL) /* ch+ */
4562306a36Sopenharmony_ci/* System interface protocol error, illegal command detected */
4662306a36Sopenharmony_ci#define JPAFSR_JEIC		(1UL << 55UL) /* jp */
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* Uncorrectable system bus data ECC error due to prefetch
4962306a36Sopenharmony_ci * or store fill request
5062306a36Sopenharmony_ci */
5162306a36Sopenharmony_ci#define CHPAFSR_DUE		(1UL << 54UL) /* ch+ */
5262306a36Sopenharmony_ci/* System interface protocol error, illegal ADTYPE detected */
5362306a36Sopenharmony_ci#define JPAFSR_JEIT		(1UL << 54UL) /* jp */
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci/* Multiple errors of the same type have occurred.  This bit is set when
5662306a36Sopenharmony_ci * an uncorrectable error or a SW correctable error occurs and the status
5762306a36Sopenharmony_ci * bit to report that error is already set.  When multiple errors of
5862306a36Sopenharmony_ci * different types are indicated by setting multiple status bits.
5962306a36Sopenharmony_ci *
6062306a36Sopenharmony_ci * This bit is not set if multiple HW corrected errors with the same
6162306a36Sopenharmony_ci * status bit occur, only uncorrectable and SW correctable ones have
6262306a36Sopenharmony_ci * this behavior.
6362306a36Sopenharmony_ci *
6462306a36Sopenharmony_ci * This bit is not set when multiple ECC errors happen within a single
6562306a36Sopenharmony_ci * 64-byte system bus transaction.  Only the first ECC error in a 16-byte
6662306a36Sopenharmony_ci * subunit will be logged.  All errors in subsequent 16-byte subunits
6762306a36Sopenharmony_ci * from the same 64-byte transaction are ignored.
6862306a36Sopenharmony_ci */
6962306a36Sopenharmony_ci#define CHAFSR_ME		(1UL << 53UL) /* ch,ch+,jp */
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/* Privileged state error has occurred.  This is a capture of PSTATE.PRIV
7262306a36Sopenharmony_ci * at the time the error is detected.
7362306a36Sopenharmony_ci */
7462306a36Sopenharmony_ci#define CHAFSR_PRIV		(1UL << 52UL) /* ch,ch+,jp */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* The following bits 51 (CHAFSR_PERR) to 33 (CHAFSR_CE) are sticky error
7762306a36Sopenharmony_ci * bits and record the most recently detected errors.  Bits accumulate
7862306a36Sopenharmony_ci * errors that have been detected since the last write to clear the bit.
7962306a36Sopenharmony_ci */
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci/* System interface protocol error.  The processor asserts its' ERROR
8262306a36Sopenharmony_ci * pin when this event occurs and it also logs a specific cause code
8362306a36Sopenharmony_ci * into a JTAG scannable flop.
8462306a36Sopenharmony_ci */
8562306a36Sopenharmony_ci#define CHAFSR_PERR		(1UL << 51UL) /* ch,ch+,jp */
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/* Internal processor error.  The processor asserts its' ERROR
8862306a36Sopenharmony_ci * pin when this event occurs and it also logs a specific cause code
8962306a36Sopenharmony_ci * into a JTAG scannable flop.
9062306a36Sopenharmony_ci */
9162306a36Sopenharmony_ci#define CHAFSR_IERR		(1UL << 50UL) /* ch,ch+,jp */
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* System request parity error on incoming address */
9462306a36Sopenharmony_ci#define CHAFSR_ISAP		(1UL << 49UL) /* ch,ch+,jp */
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci/* HW Corrected system bus MTAG ECC error */
9762306a36Sopenharmony_ci#define CHAFSR_EMC		(1UL << 48UL) /* ch,ch+ */
9862306a36Sopenharmony_ci/* Parity error on L2 cache tag SRAM */
9962306a36Sopenharmony_ci#define JPAFSR_ETP		(1UL << 48UL) /* jp */
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci/* Uncorrectable system bus MTAG ECC error */
10262306a36Sopenharmony_ci#define CHAFSR_EMU		(1UL << 47UL) /* ch,ch+ */
10362306a36Sopenharmony_ci/* Out of range memory error has occurred */
10462306a36Sopenharmony_ci#define JPAFSR_OM		(1UL << 47UL) /* jp */
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* HW Corrected system bus data ECC error for read of interrupt vector */
10762306a36Sopenharmony_ci#define CHAFSR_IVC		(1UL << 46UL) /* ch,ch+ */
10862306a36Sopenharmony_ci/* Error due to unsupported store */
10962306a36Sopenharmony_ci#define JPAFSR_UMS		(1UL << 46UL) /* jp */
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci/* Uncorrectable system bus data ECC error for read of interrupt vector */
11262306a36Sopenharmony_ci#define CHAFSR_IVU		(1UL << 45UL) /* ch,ch+,jp */
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* Unmapped error from system bus */
11562306a36Sopenharmony_ci#define CHAFSR_TO		(1UL << 44UL) /* ch,ch+,jp */
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci/* Bus error response from system bus */
11862306a36Sopenharmony_ci#define CHAFSR_BERR		(1UL << 43UL) /* ch,ch+,jp */
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci/* SW Correctable E-cache ECC error for instruction fetch or data access
12162306a36Sopenharmony_ci * other than block load.
12262306a36Sopenharmony_ci */
12362306a36Sopenharmony_ci#define CHAFSR_UCC		(1UL << 42UL) /* ch,ch+,jp */
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/* Uncorrectable E-cache ECC error for instruction fetch or data access
12662306a36Sopenharmony_ci * other than block load.
12762306a36Sopenharmony_ci */
12862306a36Sopenharmony_ci#define CHAFSR_UCU		(1UL << 41UL) /* ch,ch+,jp */
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci/* Copyout HW Corrected ECC error */
13162306a36Sopenharmony_ci#define CHAFSR_CPC		(1UL << 40UL) /* ch,ch+,jp */
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci/* Copyout Uncorrectable ECC error */
13462306a36Sopenharmony_ci#define CHAFSR_CPU		(1UL << 39UL) /* ch,ch+,jp */
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci/* HW Corrected ECC error from E-cache for writeback */
13762306a36Sopenharmony_ci#define CHAFSR_WDC		(1UL << 38UL) /* ch,ch+,jp */
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci/* Uncorrectable ECC error from E-cache for writeback */
14062306a36Sopenharmony_ci#define CHAFSR_WDU		(1UL << 37UL) /* ch,ch+,jp */
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci/* HW Corrected ECC error from E-cache for store merge or block load */
14362306a36Sopenharmony_ci#define CHAFSR_EDC		(1UL << 36UL) /* ch,ch+,jp */
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci/* Uncorrectable ECC error from E-cache for store merge or block load */
14662306a36Sopenharmony_ci#define CHAFSR_EDU		(1UL << 35UL) /* ch,ch+,jp */
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci/* Uncorrectable system bus data ECC error for read of memory or I/O */
14962306a36Sopenharmony_ci#define CHAFSR_UE		(1UL << 34UL) /* ch,ch+,jp */
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/* HW Corrected system bus data ECC error for read of memory or I/O */
15262306a36Sopenharmony_ci#define CHAFSR_CE		(1UL << 33UL) /* ch,ch+,jp */
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci/* Uncorrectable ECC error from remote cache/memory */
15562306a36Sopenharmony_ci#define JPAFSR_RUE		(1UL << 32UL) /* jp */
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci/* Correctable ECC error from remote cache/memory */
15862306a36Sopenharmony_ci#define JPAFSR_RCE		(1UL << 31UL) /* jp */
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/* JBUS parity error on returned read data */
16162306a36Sopenharmony_ci#define JPAFSR_BP		(1UL << 30UL) /* jp */
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/* JBUS parity error on data for writeback or block store */
16462306a36Sopenharmony_ci#define JPAFSR_WBP		(1UL << 29UL) /* jp */
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci/* Foreign read to DRAM incurring correctable ECC error */
16762306a36Sopenharmony_ci#define JPAFSR_FRC		(1UL << 28UL) /* jp */
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci/* Foreign read to DRAM incurring uncorrectable ECC error */
17062306a36Sopenharmony_ci#define JPAFSR_FRU		(1UL << 27UL) /* jp */
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci#define CHAFSR_ERRORS		(CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP | CHAFSR_EMC | \
17362306a36Sopenharmony_ci				 CHAFSR_EMU | CHAFSR_IVC | CHAFSR_IVU | CHAFSR_TO | \
17462306a36Sopenharmony_ci				 CHAFSR_BERR | CHAFSR_UCC | CHAFSR_UCU | CHAFSR_CPC | \
17562306a36Sopenharmony_ci				 CHAFSR_CPU | CHAFSR_WDC | CHAFSR_WDU | CHAFSR_EDC | \
17662306a36Sopenharmony_ci				 CHAFSR_EDU | CHAFSR_UE | CHAFSR_CE)
17762306a36Sopenharmony_ci#define CHPAFSR_ERRORS		(CHPAFSR_DTO | CHPAFSR_DBERR | CHPAFSR_THCE | \
17862306a36Sopenharmony_ci				 CHPAFSR_TSCE | CHPAFSR_TUE | CHPAFSR_DUE | \
17962306a36Sopenharmony_ci				 CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP | CHAFSR_EMC | \
18062306a36Sopenharmony_ci				 CHAFSR_EMU | CHAFSR_IVC | CHAFSR_IVU | CHAFSR_TO | \
18162306a36Sopenharmony_ci				 CHAFSR_BERR | CHAFSR_UCC | CHAFSR_UCU | CHAFSR_CPC | \
18262306a36Sopenharmony_ci				 CHAFSR_CPU | CHAFSR_WDC | CHAFSR_WDU | CHAFSR_EDC | \
18362306a36Sopenharmony_ci				 CHAFSR_EDU | CHAFSR_UE | CHAFSR_CE)
18462306a36Sopenharmony_ci#define JPAFSR_ERRORS		(JPAFSR_JETO | JPAFSR_SCE | JPAFSR_JEIC | \
18562306a36Sopenharmony_ci				 JPAFSR_JEIT | CHAFSR_PERR | CHAFSR_IERR | \
18662306a36Sopenharmony_ci				 CHAFSR_ISAP | JPAFSR_ETP | JPAFSR_OM | \
18762306a36Sopenharmony_ci				 JPAFSR_UMS | CHAFSR_IVU | CHAFSR_TO | \
18862306a36Sopenharmony_ci				 CHAFSR_BERR | CHAFSR_UCC | CHAFSR_UCU | \
18962306a36Sopenharmony_ci				 CHAFSR_CPC | CHAFSR_CPU | CHAFSR_WDC | \
19062306a36Sopenharmony_ci				 CHAFSR_WDU | CHAFSR_EDC | CHAFSR_EDU | \
19162306a36Sopenharmony_ci				 CHAFSR_UE | CHAFSR_CE | JPAFSR_RUE | \
19262306a36Sopenharmony_ci				 JPAFSR_RCE | JPAFSR_BP | JPAFSR_WBP | \
19362306a36Sopenharmony_ci				 JPAFSR_FRC | JPAFSR_FRU)
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/* Active JBUS request signal when error occurred */
19662306a36Sopenharmony_ci#define JPAFSR_JBREQ		(0x7UL << 24UL) /* jp */
19762306a36Sopenharmony_ci#define JPAFSR_JBREQ_SHIFT	24UL
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci/* L2 cache way information */
20062306a36Sopenharmony_ci#define JPAFSR_ETW		(0x3UL << 22UL) /* jp */
20162306a36Sopenharmony_ci#define JPAFSR_ETW_SHIFT	22UL
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci/* System bus MTAG ECC syndrome.  This field captures the status of the
20462306a36Sopenharmony_ci * first occurrence of the highest-priority error according to the M_SYND
20562306a36Sopenharmony_ci * overwrite policy.  After the AFSR sticky bit, corresponding to the error
20662306a36Sopenharmony_ci * for which the M_SYND is reported, is cleared, the contents of the M_SYND
20762306a36Sopenharmony_ci * field will be unchanged by will be unfrozen for further error capture.
20862306a36Sopenharmony_ci */
20962306a36Sopenharmony_ci#define CHAFSR_M_SYNDROME	(0xfUL << 16UL) /* ch,ch+,jp */
21062306a36Sopenharmony_ci#define CHAFSR_M_SYNDROME_SHIFT	16UL
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci/* Agenid Id of the foreign device causing the UE/CE errors */
21362306a36Sopenharmony_ci#define JPAFSR_AID		(0x1fUL << 9UL) /* jp */
21462306a36Sopenharmony_ci#define JPAFSR_AID_SHIFT	9UL
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci/* System bus or E-cache data ECC syndrome.  This field captures the status
21762306a36Sopenharmony_ci * of the first occurrence of the highest-priority error according to the
21862306a36Sopenharmony_ci * E_SYND overwrite policy.  After the AFSR sticky bit, corresponding to the
21962306a36Sopenharmony_ci * error for which the E_SYND is reported, is cleare, the contents of the E_SYND
22062306a36Sopenharmony_ci * field will be unchanged but will be unfrozen for further error capture.
22162306a36Sopenharmony_ci */
22262306a36Sopenharmony_ci#define CHAFSR_E_SYNDROME	(0x1ffUL << 0UL) /* ch,ch+,jp */
22362306a36Sopenharmony_ci#define CHAFSR_E_SYNDROME_SHIFT	0UL
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/* The AFSR must be explicitly cleared by software, it is not cleared automatically
22662306a36Sopenharmony_ci * by a read.  Writes to bits <51:33> with bits set will clear the corresponding
22762306a36Sopenharmony_ci * bits in the AFSR.  Bits associated with disrupting traps must be cleared before
22862306a36Sopenharmony_ci * interrupts are re-enabled to prevent multiple traps for the same error.  I.e.
22962306a36Sopenharmony_ci * PSTATE.IE and AFSR bits control delivery of disrupting traps.
23062306a36Sopenharmony_ci *
23162306a36Sopenharmony_ci * Since there is only one AFAR, when multiple events have been logged by the
23262306a36Sopenharmony_ci * bits in the AFSR, at most one of these events will have its status captured
23362306a36Sopenharmony_ci * in the AFAR.  The highest priority of those event bits will get AFAR logging.
23462306a36Sopenharmony_ci * The AFAR will be unlocked and available to capture the address of another event
23562306a36Sopenharmony_ci * as soon as the one bit in AFSR that corresponds to the event logged in AFAR is
23662306a36Sopenharmony_ci * cleared.  For example, if AFSR.CE is detected, then AFSR.UE (which overwrites
23762306a36Sopenharmony_ci * the AFAR), and AFSR.UE is cleared by not AFSR.CE, then the AFAR will be unlocked
23862306a36Sopenharmony_ci * and ready for another event, even though AFSR.CE is still set.  The same rules
23962306a36Sopenharmony_ci * also apply to the M_SYNDROME and E_SYNDROME fields of the AFSR.
24062306a36Sopenharmony_ci */
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci#endif /* _SPARC64_CHAFSR_H */
243