@samitouri / QOSamiQemu / commits / 5aee8a5d3d

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>

Jamin Lin committed Jun 3, 2026 at 04:00 UTC 5aee8a5d3d11172454de11388b0cf94f76abeb72
1 file changed +15
hw/arm/aspeed_ast1040_evb.c
+15
@@ -14,6 +14,7 @@
14 #include "hw/arm/aspeed_soc.h"
15 #include "hw/core/qdev-clock.h"
16 #include "system/system.h"
17 +#include "hw/i2c/smbus_eeprom.h"
18
19 #define AST1040_INTERNAL_FLASH_SIZE (4 * MiB)
20 /* Main SYSCLK frequency in Hz (400MHz) */
@@ -38,12 +39,25 @@ static void aspeed_bic_machine_init(MachineState *machine)
39 aspeed_connect_serial_hds_to_uarts(bmc);
40 qdev_realize(DEVICE(bmc->soc), NULL, &error_abort);
41
42 + if (amc->i2c_init) {
43 + amc->i2c_init(bmc);
44 + }
45 +
46 armv7m_load_kernel(ARM_CPU(first_cpu),
47 machine->kernel_filename,
48 0,
49 AST1040_INTERNAL_FLASH_SIZE);
50 }
51
52 +static void ast1040_evb_i2c_init(AspeedMachineState *bmc)
53 +{
54 + AspeedSoCState *soc = bmc->soc;
55 + uint8_t *eeprom_buf = g_malloc0(256);
56 +
57 + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf);
58 + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 1), "tmp105", 0x4d);
59 +}
60 +
61 static void aspeed_machine_ast1040_evb_class_init(ObjectClass *oc,
62 const void *data)
63 {
@@ -55,6 +69,7 @@ static void aspeed_machine_ast1040_evb_class_init(ObjectClass *oc,
69 amc->hw_strap1 = 0;
70 amc->hw_strap2 = 0;
71 mc->init = aspeed_bic_machine_init;
72 + amc->i2c_init = ast1040_evb_i2c_init;
73 mc->default_ram_size = 0;
74 amc->macs_mask = 0;
75 amc->uart_default = ASPEED_DEV_UART12;