Commit 5aee8a5d3d for qemu.org
commit 5aee8a5d3d11172454de11388b0cf94f76abeb72
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date: Wed Jun 3 04:00:39 2026 +0000
hw/arm/aspeed_ast1040_evb: Introduce onboard I2C device
Introduce onboard I2C device initialization for the AST1040
EVB model.
Instantiate:
- A 24C08-compatible EEPROM at address 0x50 on I2C bus 0
- A TMP105 temperature sensor at address 0x4d on I2C bus 1
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260603040027.938816-10-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
diff --git a/hw/arm/aspeed_ast1040_evb.c b/hw/arm/aspeed_ast1040_evb.c
index 1d9b55247f..2b93d4dfbc 100644
--- a/hw/arm/aspeed_ast1040_evb.c
+++ b/hw/arm/aspeed_ast1040_evb.c
@@ -14,6 +14,7 @@
#include "hw/arm/aspeed_soc.h"
#include "hw/core/qdev-clock.h"
#include "system/system.h"
+#include "hw/i2c/smbus_eeprom.h"
#define AST1040_INTERNAL_FLASH_SIZE (4 * MiB)
/* Main SYSCLK frequency in Hz (400MHz) */
@@ -38,12 +39,25 @@ static void aspeed_bic_machine_init(MachineState *machine)
aspeed_connect_serial_hds_to_uarts(bmc);
qdev_realize(DEVICE(bmc->soc), NULL, &error_abort);
+ if (amc->i2c_init) {
+ amc->i2c_init(bmc);
+ }
+
armv7m_load_kernel(ARM_CPU(first_cpu),
machine->kernel_filename,
0,
AST1040_INTERNAL_FLASH_SIZE);
}
+static void ast1040_evb_i2c_init(AspeedMachineState *bmc)
+{
+ AspeedSoCState *soc = bmc->soc;
+ uint8_t *eeprom_buf = g_malloc0(256);
+
+ smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf);
+ i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 1), "tmp105", 0x4d);
+}
+
static void aspeed_machine_ast1040_evb_class_init(ObjectClass *oc,
const void *data)
{
@@ -55,6 +69,7 @@ static void aspeed_machine_ast1040_evb_class_init(ObjectClass *oc,
amc->hw_strap1 = 0;
amc->hw_strap2 = 0;
mc->init = aspeed_bic_machine_init;
+ amc->i2c_init = ast1040_evb_i2c_init;
mc->default_ram_size = 0;
amc->macs_mask = 0;
amc->uart_default = ASPEED_DEV_UART12;