blob: 91b58ac3e5d0c13211fa1d1c3d2428dd41eb429f [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5c354b92019-04-22 14:55:16 -06002
Felix Heldf1093af2021-07-13 23:00:26 +02003#include <amdblocks/mca.h>
Martin Roth5c354b92019-04-22 14:55:16 -06004#include <cpu/x86/msr.h>
Felix Helde0d9bf72021-07-14 00:20:46 +02005#include <types.h>
Martin Roth5c354b92019-04-22 14:55:16 -06006
Martin Roth5c354b92019-04-22 14:55:16 -06007static const char *const mca_bank_name[] = {
Felix Held799742a2021-07-13 20:54:01 +02008 [0] = "Load-store unit",
9 [1] = "Instruction fetch unit",
10 [2] = "L2 cache unit",
11 [3] = "Decode unit",
12 [4] = "",
13 [5] = "Execution unit",
14 [6] = "Floating point unit",
15 [7] = "L3 cache unit",
16 [8] = "L3 cache unit",
17 [9] = "L3 cache unit",
18 [10] = "L3 cache unit",
19 [11] = "L3 cache unit",
20 [12] = "L3 cache unit",
21 [13] = "L3 cache unit",
22 [14] = "L3 cache unit",
23 [15] = "UMC",
24 [16] = "UMC",
25 [17] = "SMU",
26 [18] = "PSP",
27 [19] = "PB",
28 [20] = "CS",
29 [21] = "CS",
30 [22] = "PIE",
Martin Roth5c354b92019-04-22 14:55:16 -060031};
32
Felix Helde84c3f12021-07-14 01:16:30 +020033bool mca_has_expected_bank_count(void)
Felix Held64077de2021-07-14 01:34:59 +020034{
35 return ARRAY_SIZE(mca_bank_name) == mca_get_bank_count();
36}
37
Felix Helde84c3f12021-07-14 01:16:30 +020038bool mca_is_valid_bank(unsigned int bank)
Felix Held040d7642021-07-13 22:29:12 +020039{
40 return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL);
41}
42
Felix Helde84c3f12021-07-14 01:16:30 +020043const char *mca_get_bank_name(unsigned int bank)
Felix Heldb04148a2021-07-13 22:30:16 +020044{
45 if (mca_is_valid_bank(bank))
46 return mca_bank_name[bank];
47 else
48 return "";
49}