Hello Joe,
On 3/31/22 06:32, Joe Komlodi wrote:
The Aspeed I2C controller is used across other SKUs that have different
reserved bits for the ctrl_global_rsvd register.
So some AST2600 SoCs can not set the new/old modes and the clock divider ?
Signed-off-by: Joe Komlodi <koml...@google.com>
Change-Id: I606c5933c527274a9d2b0afe559b2e895767636c
---
hw/arm/aspeed_ast2600.c | 2 ++
hw/i2c/aspeed_i2c.c | 4 ++++
include/hw/i2c/aspeed_i2c.h | 2 ++
3 files changed, 8 insertions(+)
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 43f8223139..9f14a35a75 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -344,6 +344,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev,
Error **errp)
serial_hd(0), DEVICE_LITTLE_ENDIAN);
/* I2C */
+ object_property_set_int(OBJECT(&s->i2c), "ctrl-global-rsvd", 0xfffc3e00,
+ &error_abort);
Ideally, this should be set from a specific machine and not from the SoC
as it impacts all machines. One way to do this is to use an alias. See the
hw-strap1/2 properties.
Thanks,
C.
object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
&error_abort);
if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) {
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 03a4f5a910..97eb9d5792 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -648,6 +648,7 @@ static void aspeed_i2c_ctrl_write(void *opaque, hwaddr
offset,
switch (offset) {
case I2C_CTRL_GLOBAL:
+ value &= ~s->ctrl_global_rsvd;
s->ctrl_global = value;
break;
case I2C_CTRL_STATUS:
@@ -730,6 +731,7 @@ static const VMStateDescription aspeed_i2c_vmstate = {
.minimum_version_id = 2,
.fields = (VMStateField[]) {
VMSTATE_UINT32(intr_status, AspeedI2CState),
+ VMSTATE_UINT32(ctrl_global_rsvd, AspeedI2CState),
VMSTATE_STRUCT_ARRAY(busses, AspeedI2CState,
ASPEED_I2C_NR_BUSSES, 1, aspeed_i2c_bus_vmstate,
AspeedI2CBus),
@@ -828,6 +830,8 @@ static void aspeed_i2c_realize(DeviceState *dev, Error
**errp)
static Property aspeed_i2c_properties[] = {
DEFINE_PROP_LINK("dram", AspeedI2CState, dram_mr,
TYPE_MEMORY_REGION, MemoryRegion *),
+ DEFINE_PROP_UINT32("ctrl-global-rsvd", AspeedI2CState, ctrl_global_rsvd,
+ 0xfffffffe),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h
index 4b9be09274..3912fcc3ff 100644
--- a/include/hw/i2c/aspeed_i2c.h
+++ b/include/hw/i2c/aspeed_i2c.h
@@ -71,6 +71,8 @@ struct AspeedI2CState {
MemoryRegion pool_iomem;
uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE];
+ uint32_t ctrl_global_rsvd;
+
AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES];
MemoryRegion *dram_mr;
AddressSpace dram_as;