diff --git a/src/soc/amd/cezanne/cpu.c b/src/soc/amd/cezanne/cpu.c index 4f39aefc75..52d2e2b704 100644 --- a/src/soc/amd/cezanne/cpu.c +++ b/src/soc/amd/cezanne/cpu.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include -#include #include #include #include @@ -10,16 +8,8 @@ _Static_assert(CONFIG_MAX_CPUS == 16, "Do not override MAX_CPUS. To reduce the number of " "available cores, use the downcore_mode and disable_smt devicetree settings instead."); -static void zen_2_3_init(struct device *dev) -{ - check_mca(); - set_cstate_io_addr(); - - amd_apply_microcode_patch(); -} - static struct device_operations cpu_dev_ops = { - .init = zen_2_3_init, + .init = amd_cpu_init, }; static struct cpu_device_id cpu_table[] = { diff --git a/src/soc/amd/common/block/cpu/noncar/cpu.c b/src/soc/amd/common/block/cpu/noncar/cpu.c index e67d669bb6..c97e2f4f44 100644 --- a/src/soc/amd/common/block/cpu/noncar/cpu.c +++ b/src/soc/amd/common/block/cpu/noncar/cpu.c @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include #include +#include #include #include #include @@ -100,3 +102,14 @@ unsigned int get_reserved_phys_addr_bits(void) return (cpuid_ebx(CPUID_EBX_MEM_ENCRYPT) & CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_MASK) >> CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_SHIFT; } + +void amd_cpu_init(struct device *dev) +{ + if (CONFIG(SOC_AMD_COMMON_BLOCK_MCA_COMMON)) + check_mca(); + + set_cstate_io_addr(); + + if (CONFIG(SOC_AMD_COMMON_BLOCK_UCODE)) + amd_apply_microcode_patch(); +} diff --git a/src/soc/amd/common/block/include/amdblocks/cpu.h b/src/soc/amd/common/block/include/amdblocks/cpu.h index 4aa225bda3..ce0b2da816 100644 --- a/src/soc/amd/common/block/include/amdblocks/cpu.h +++ b/src/soc/amd/common/block/include/amdblocks/cpu.h @@ -22,5 +22,6 @@ uint32_t get_pstate_latency(void); uint32_t get_pstate_core_freq(union pstate_msr pstate_reg); uint32_t get_pstate_core_uvolts(union pstate_msr pstate_reg); const acpi_cstate_t *get_cstate_config_data(size_t *size); +void amd_cpu_init(struct device *dev); #endif /* AMD_BLOCK_CPU_H */ diff --git a/src/soc/amd/genoa_poc/cpu.c b/src/soc/amd/genoa_poc/cpu.c index 241bec21fd..a91720a842 100644 --- a/src/soc/amd/genoa_poc/cpu.c +++ b/src/soc/amd/genoa_poc/cpu.c @@ -1,22 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include -#include #include #include #include -static void model_19_init(struct device *dev) -{ - check_mca(); - set_cstate_io_addr(); - - amd_apply_microcode_patch(); -} - static struct device_operations cpu_dev_ops = { - .init = model_19_init, + .init = amd_cpu_init, }; static struct cpu_device_id cpu_table[] = { diff --git a/src/soc/amd/glinda/cpu.c b/src/soc/amd/glinda/cpu.c index a7161270d2..2dcc3c5d21 100644 --- a/src/soc/amd/glinda/cpu.c +++ b/src/soc/amd/glinda/cpu.c @@ -3,8 +3,6 @@ /* TODO: Update for Glinda */ #include -#include -#include #include #include #include @@ -12,16 +10,8 @@ _Static_assert(CONFIG_MAX_CPUS == 24, "Do not override MAX_CPUS. To reduce the number of " "available cores, use the downcore_mode and disable_smt devicetree settings instead."); -static void zen_2_3_init(struct device *dev) -{ - check_mca(); - set_cstate_io_addr(); - - amd_apply_microcode_patch(); -} - static struct device_operations cpu_dev_ops = { - .init = zen_2_3_init, + .init = amd_cpu_init, }; static struct cpu_device_id cpu_table[] = { diff --git a/src/soc/amd/mendocino/cpu.c b/src/soc/amd/mendocino/cpu.c index 842b04fb25..e2e1f53773 100644 --- a/src/soc/amd/mendocino/cpu.c +++ b/src/soc/amd/mendocino/cpu.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include -#include #include #include #include @@ -10,16 +8,8 @@ _Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of " "available cores, use the downcore_mode and disable_smt devicetree settings instead."); -static void zen_2_3_init(struct device *dev) -{ - check_mca(); - set_cstate_io_addr(); - - amd_apply_microcode_patch(); -} - static struct device_operations cpu_dev_ops = { - .init = zen_2_3_init, + .init = amd_cpu_init, }; static struct cpu_device_id cpu_table[] = { diff --git a/src/soc/amd/phoenix/cpu.c b/src/soc/amd/phoenix/cpu.c index 05dac9a032..5d15b1dd83 100644 --- a/src/soc/amd/phoenix/cpu.c +++ b/src/soc/amd/phoenix/cpu.c @@ -3,8 +3,6 @@ /* TODO: Update for Phoenix */ #include -#include -#include #include #include #include @@ -12,16 +10,8 @@ _Static_assert(CONFIG_MAX_CPUS == 16, "Do not override MAX_CPUS. To reduce the number of " "available cores, use the downcore_mode and disable_smt devicetree settings instead."); -static void zen_2_3_init(struct device *dev) -{ - check_mca(); - set_cstate_io_addr(); - - amd_apply_microcode_patch(); -} - static struct device_operations cpu_dev_ops = { - .init = zen_2_3_init, + .init = amd_cpu_init, }; static struct cpu_device_id cpu_table[] = { diff --git a/src/soc/amd/picasso/cpu.c b/src/soc/amd/picasso/cpu.c index 4f846293a8..702f626e0a 100644 --- a/src/soc/amd/picasso/cpu.c +++ b/src/soc/amd/picasso/cpu.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include -#include #include #include #include @@ -10,16 +8,8 @@ _Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of " "available cores, use the downcore_mode and disable_smt devicetree settings instead."); -static void model_17_init(struct device *dev) -{ - check_mca(); - set_cstate_io_addr(); - - amd_apply_microcode_patch(); -} - static struct device_operations cpu_dev_ops = { - .init = model_17_init, + .init = amd_cpu_init, }; static struct cpu_device_id cpu_table[] = {