From 7a91a10c615b50be6eb634c1f383e47c1fa2321d Mon Sep 17 00:00:00 2001 From: Tim Wawrzynczak Date: Tue, 8 Feb 2022 12:50:46 -0700 Subject: src/soc/intel/common/block/i2c: Use early BAR in ENV_PAYLOAD_LOADER There may be occasions where an I2C device was initialized during "early initialization," but when used again in ENV_PAYLOAD_LOADER before resource allocation happens, it would currently return that it has not been assigned a BAR. However, because of the early BAR assigned to it, it should still be valid to use that until proper resources have been assigned, therefore return any BAR that may have been assigned to the device during early initialization. Signed-off-by: Tim Wawrzynczak Change-Id: I8ab599199592a72ae96cd9f95accfaa0d84e66b6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/61719 Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik --- src/soc/intel/common/block/i2c/i2c.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/soc/intel') diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c index 7fdf8187ff..acfb053d6a 100644 --- a/src/soc/intel/common/block/i2c/i2c.c +++ b/src/soc/intel/common/block/i2c/i2c.c @@ -127,7 +127,12 @@ uintptr_t dw_i2c_base_address(unsigned int bus) if (res) return res->base; - return (uintptr_t)NULL; + /* No resource found yet, it's possible this is running in the + * PAYLOAD_LOADER stage before resources have been assigned yet, + * therefore, any early init BAR should still be valid. */ + + /* Read the first base address for this device */ + return (uintptr_t)ALIGN_DOWN(pci_read_config32(dev, PCI_BASE_ADDRESS_0), 16); } /* -- cgit v1.2.3