summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2021-01-29 01:18:38 +0100
committerFelix Held <felix-coreboot@felixheld.de>2021-01-30 02:15:26 +0000
commitdb185182b51b3c1651744ca2a3d6a3942f4af511 (patch)
treef03632da54316cbe85aa846ad2be2ecd29cffa59
parent230dbd6d3c194d9f839d31a0a579ef99befdd097 (diff)
soc/amd/picasso/data_fabric: factor out indirect address/index write
Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Id7bda8843a5ed0775424a056a05a6c4cb8269e49 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50097 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
-rw-r--r--src/soc/amd/picasso/data_fabric.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/soc/amd/picasso/data_fabric.c b/src/soc/amd/picasso/data_fabric.c
index f576d89857..9f83a62a8c 100644
--- a/src/soc/amd/picasso/data_fabric.c
+++ b/src/soc/amd/picasso/data_fabric.c
@@ -168,22 +168,25 @@ static const struct pci_driver data_fabric_driver __pci_driver = {
.devices = pci_device_ids,
};
-uint32_t data_fabric_read_reg32(uint8_t function, uint16_t reg, uint8_t instance_id)
+static void data_fabric_set_indirect_address(uint8_t func, uint16_t reg, uint8_t instance_id)
{
- uint32_t fabric_indirect_access_reg = 0;
-
- if (instance_id == BROADCAST_FABRIC_ID)
- /* No bit masking required. Macros will apply mask to values. */
- return pci_read_config32(_SOC_DEV(DF_DEV, function), reg);
-
- fabric_indirect_access_reg |= DF_IND_CFG_INST_ACC_EN;
+ uint32_t fabric_indirect_access_reg = DF_IND_CFG_INST_ACC_EN;
/* Register offset field [10:2] in this register corresponds to [10:2] of the
requested offset. */
fabric_indirect_access_reg |= reg & DF_IND_CFG_ACC_REG_MASK;
fabric_indirect_access_reg |=
- (function << DF_IND_CFG_ACC_FUN_SHIFT) & DF_IND_CFG_ACC_FUN_MASK;
+ (func << DF_IND_CFG_ACC_FUN_SHIFT) & DF_IND_CFG_ACC_FUN_MASK;
fabric_indirect_access_reg |= instance_id << DF_IND_CFG_INST_ID_SHIFT;
pci_write_config32(SOC_DF_F4_DEV, DF_FICAA_BIOS, fabric_indirect_access_reg);
+}
+
+uint32_t data_fabric_read_reg32(uint8_t function, uint16_t reg, uint8_t instance_id)
+{
+ if (instance_id == BROADCAST_FABRIC_ID)
+ /* No bit masking required. Macros will apply mask to values. */
+ return pci_read_config32(_SOC_DEV(DF_DEV, function), reg);
+ /* non-broadcast data fabric accesses need to be done via indirect access */
+ data_fabric_set_indirect_address(function, reg, instance_id);
return pci_read_config32(SOC_DF_F4_DEV, DF_FICAD_LO);
}