[PATCH qemu] arm: aspeed: Add palmetto and evb EEPROM I2C devices

Joel Stanley joel at jms.id.au
Fri Sep 15 16:18:30 AEST 2017


Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 hw/arm/aspeed.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 9ef5fb3b6ddc..2f596959649a 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -253,6 +253,7 @@ static void aspeed_board_init(MachineState *machine,
 
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
 {
+    uint8_t *eeprom_buf = g_malloc0(256 * 1024);
     AspeedSoCState *soc = &bmc->soc;
     DeviceState *dev;
 
@@ -260,6 +261,13 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
      * enough to provide basic RTC features. Alarms will be missing */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
 
+    /* 256KB EEPROM */
+    dev = qdev_create((BusState *) aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0),
+                      "smbus-eeprom");
+    qdev_prop_set_uint8(dev, "address", 0x50);
+    qdev_prop_set_ptr(dev, "data", eeprom_buf);
+    qdev_init_nofail(dev);
+
     /* add a TMP423 temperature sensor */
     dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
                            "tmp423", 0x4c);
@@ -295,7 +303,15 @@ static const TypeInfo palmetto_bmc_type = {
 
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
 {
+    uint8_t *eeprom_buf = g_malloc0(8 * 1024);
     AspeedSoCState *soc = &bmc->soc;
+    DeviceState *dev;
+
+    dev = qdev_create((BusState *) aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3),
+                      "smbus-eeprom");
+    qdev_prop_set_uint8(dev, "address", 0x50);
+    qdev_prop_set_ptr(dev, "data", eeprom_buf);
+    qdev_init_nofail(dev);
 
     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
-- 
2.14.1



More information about the openbmc mailing list