diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2021-03-10 22:55:22 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-03-12 00:47:30 +0000 |
commit | e995684fa1212784bb2642ad21e4e0ce60b19130 (patch) | |
tree | c5d9f32152c33a8b5796752626b45649c362c8c0 /src/soc/amd/common/block/smu | |
parent | 5a702653cdc9562ece3c7ab5da121d42af7edb10 (diff) |
soc/amd/common: factor out SMN access function from SMU code
The SMU mailbox interface gets accessed over the SMN register space, so
factor out those access functions into a separate common code SMN access
building block.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Iabac181972c02ae641da99f47b2aa9aa28dae333
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51399
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Diffstat (limited to 'src/soc/amd/common/block/smu')
-rw-r--r-- | src/soc/amd/common/block/smu/Kconfig | 1 | ||||
-rw-r--r-- | src/soc/amd/common/block/smu/smu.c | 25 |
2 files changed, 7 insertions, 19 deletions
diff --git a/src/soc/amd/common/block/smu/Kconfig b/src/soc/amd/common/block/smu/Kconfig index fe2687ad97..40195c9db3 100644 --- a/src/soc/amd/common/block/smu/Kconfig +++ b/src/soc/amd/common/block/smu/Kconfig @@ -1,4 +1,5 @@ config SOC_AMD_COMMON_BLOCK_SMU bool + select SOC_AMD_COMMON_BLOCK_SMN help Select this option to add functions to communicate with the SMU to the build. diff --git a/src/soc/amd/common/block/smu/smu.c b/src/soc/amd/common/block/smu/smu.c index 4f9c1d1abe..5e1ad0a737 100644 --- a/src/soc/amd/common/block/smu/smu.c +++ b/src/soc/amd/common/block/smu/smu.c @@ -2,24 +2,11 @@ #include <timer.h> #include <console/console.h> -#include <device/pci_ops.h> +#include <amdblocks/smn.h> #include <amdblocks/smu.h> -#include <soc/pci_devs.h> #include <soc/smu.h> #include <types.h> -static uint32_t smu_read32(uint32_t reg) -{ - pci_write_config32(SOC_GNB_DEV, SMU_INDEX_ADDR, reg); - return pci_read_config32(SOC_GNB_DEV, SMU_DATA_ADDR); -} - -static void smu_write32(uint32_t reg, uint32_t val) -{ - pci_write_config32(SOC_GNB_DEV, SMU_INDEX_ADDR, reg); - pci_write_config32(SOC_GNB_DEV, SMU_DATA_ADDR, val); -} - #define SMU_MESG_RESP_TIMEOUT 0x00 #define SMU_MESG_RESP_OK 0x01 @@ -33,7 +20,7 @@ static int32_t smu_poll_response(bool print_command_duration) stopwatch_init_msecs_expire(&sw, timeout_ms); do { - result = smu_read32(REG_ADDR_MESG_RESP); + result = smn_read32(REG_ADDR_MESG_RESP); if (result) { if (print_command_duration) printk(BIOS_SPEW, "SMU command consumed %ld usecs\n", @@ -59,14 +46,14 @@ enum cb_err send_smu_message(enum smu_message_id message_id, struct smu_payload return CB_ERR; /* clear response register */ - smu_write32(REG_ADDR_MESG_RESP, 0); + smn_write32(REG_ADDR_MESG_RESP, 0); /* populate arguments */ for (i = 0 ; i < SMU_NUM_ARGS ; i++) - smu_write32(REG_ADDR_MESG_ARG(i), arg->msg[i]); + smn_write32(REG_ADDR_MESG_ARG(i), arg->msg[i]); /* send message to SMU */ - smu_write32(REG_ADDR_MESG_ID, message_id); + smn_write32(REG_ADDR_MESG_ID, message_id); /* wait until SMU has processed the message and check if it was successful */ if (smu_poll_response(true) != SMU_MESG_RESP_OK) @@ -74,7 +61,7 @@ enum cb_err send_smu_message(enum smu_message_id message_id, struct smu_payload /* copy returned values */ for (i = 0 ; i < SMU_NUM_ARGS ; i++) - arg->msg[i] = smu_read32(REG_ADDR_MESG_ARG(i)); + arg->msg[i] = smn_read32(REG_ADDR_MESG_ARG(i)); return CB_SUCCESS; } |