From ac41f582351dc2c6aaaf0c1ef662e6d99b67b4ce Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Sun, 14 Jun 2020 17:24:12 -0600 Subject: soc/amd/picasso: Allow modification of i2c base addresses in PSP BUG=b:158124527 TEST=Build & boot psp_verstage on trembyle Signed-off-by: Martin Roth Change-Id: I45380e0c61e1bb7a94a96630e5867b7ffca0909c Reviewed-on: https://review.coreboot.org/c/coreboot/+/42064 Reviewed-by: Raul Rangel Tested-by: build bot (Jenkins) --- src/soc/amd/picasso/i2c.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/soc/amd/picasso/i2c.c') diff --git a/src/soc/amd/picasso/i2c.c b/src/soc/amd/picasso/i2c.c index 881278f254..1eb0720dc9 100644 --- a/src/soc/amd/picasso/i2c.c +++ b/src/soc/amd/picasso/i2c.c @@ -13,9 +13,7 @@ #include #include "chip.h" -/* - * We don't have addresses for I2C0-1. - */ +#if ENV_X86 static const uintptr_t i2c_bus_address[I2C_MASTER_DEV_COUNT + I2C_SLAVE_DEV_COUNT] = { 0, 0, @@ -23,6 +21,9 @@ static const uintptr_t i2c_bus_address[I2C_MASTER_DEV_COUNT + I2C_SLAVE_DEV_COUN APU_I2C3_BASE, APU_I2C4_BASE, /* Can only be used in slave mode */ }; +#else +static uintptr_t i2c_bus_address[I2C_MASTER_DEV_COUNT + I2C_SLAVE_DEV_COUNT]; +#endif uintptr_t dw_i2c_base_address(unsigned int bus) { @@ -32,6 +33,18 @@ uintptr_t dw_i2c_base_address(unsigned int bus) return i2c_bus_address[bus]; } +#if !ENV_X86 +void i2c_set_bar(unsigned int bus, uintptr_t bar) +{ + if (bus >= ARRAY_SIZE(i2c_bus_address)) { + printk(BIOS_ERR, "Error: i2c index out of bounds: %u.", bus); + return; + } + + i2c_bus_address[bus] = bar; +} +#endif + const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus) { const struct soc_amd_picasso_config *config; @@ -47,28 +60,23 @@ const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus) static const char *i2c_acpi_name(const struct device *dev) { - switch (dev->path.mmio.addr) { - case APU_I2C2_BASE: + if ((uintptr_t)dev->path.mmio.addr == i2c_bus_address[2]) return "I2C2"; - case APU_I2C3_BASE: + else if ((uintptr_t)dev->path.mmio.addr == i2c_bus_address[3]) return "I2C3"; - case APU_I2C4_BASE: + else if ((uintptr_t)dev->path.mmio.addr == i2c_bus_address[4]) return "I2C4"; - default: - return NULL; - } + return NULL; } int dw_i2c_soc_dev_to_bus(const struct device *dev) { - switch (dev->path.mmio.addr) { - case APU_I2C2_BASE: + if ((uintptr_t)dev->path.mmio.addr == i2c_bus_address[2]) return 2; - case APU_I2C3_BASE: + else if ((uintptr_t)dev->path.mmio.addr == i2c_bus_address[3]) return 3; - case APU_I2C4_BASE: + else if ((uintptr_t)dev->path.mmio.addr == i2c_bus_address[4]) return 4; - } return -1; } -- cgit v1.2.3