xref: /aosp_15_r20/external/coreboot/src/soc/amd/common/block/acpimmio/print_reset_status.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <amdblocks/acpimmio.h>
5 
print_num_status_bits(int num_bits,uint32_t status,const char * const bit_names[])6 static void print_num_status_bits(int num_bits, uint32_t status,
7 				  const char *const bit_names[])
8 {
9 	int i;
10 
11 	if (!status)
12 		return;
13 
14 	for (i = num_bits - 1; i >= 0; i--) {
15 		if (status & (1 << i)) {
16 			if (bit_names[i])
17 				printk(BIOS_DEBUG, "%s ", bit_names[i]);
18 			else
19 				printk(BIOS_DEBUG, "BIT%d ", i);
20 		}
21 	}
22 }
23 
fch_print_pmxc0_status(void)24 void fch_print_pmxc0_status(void)
25 {
26 	/* PMxC0 S5/Reset Status shows the source of previous reset. */
27 	uint32_t pmxc0_status = pm_read32(PM_RST_STATUS);
28 
29 	static const char *const pmxc0_status_bits[32] = {
30 		[0] = "ThermalTrip",
31 		[1] = "FourSecondPwrBtn",
32 		[2] = "Shutdown",
33 		[3] = "ThermalTripFromTemp",
34 		[4] = "RemotePowerDownFromASF",
35 		[5] = "ShutDownFan0",
36 		[9] = "InternalThermalTrip",
37 		[16] = "UserRst",
38 		[17] = "SoftPciRst",
39 		[18] = "DoInit",
40 		[19] = "DoReset",
41 		[20] = "DoFullReset",
42 		[21] = "SleepReset",
43 		[22] = "KbReset",
44 		[23] = "LtReset/ShutdownMsg",
45 		[24] = "FailBootRst",
46 		[25] = "WatchdogIssueReset",
47 		[26] = "RemoteResetFromASF",
48 		[27] = "SyncFlood",
49 		[28] = "HangReset",
50 		[29] = "EcWatchdogRst",
51 		[30] = "SdpParityErr",
52 		[31] = "SwSyncFloodFlag",
53 	};
54 
55 	printk(BIOS_DEBUG, "PMxC0 STATUS: 0x%x ", pmxc0_status);
56 	print_num_status_bits(ARRAY_SIZE(pmxc0_status_bits), pmxc0_status, pmxc0_status_bits);
57 	printk(BIOS_DEBUG, "\n");
58 }
59