Skip to contentSkip to conversation

aspeed: add a witherspoon-bmc machine

PATCH Superseded Cédric Le Goater 4 participants 30 messages Sep 20, 2017 – Oct 16, 2017 Arm/Aspeed machine support

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover aspeed: add a witherspoon-bmc machine

Hello,

This series adds a new Aspeed machine to emulate the BMC of a Witherspoon system. It also extends the other Aspeed machines with I2C devices and adds a simple model for the pca9552 LED blinker present on the witherspoon board.

Thanks,

C.

Changes since v1:

- introduced smbus_eeprom_init_one()

Cédric Le Goater (6):
aspeed: add support for the witherspoon-bmc board
aspeed: add an I2C RTC device to all machines
smbus: add a smbus_eeprom_init_one() routine
aspeed: Add EEPROM I2C devices
misc: add pca9552 LED blinker model
aspeed: add the pc9552 chips to the witherspoon machine

 default-configs/arm-softmmu.mak |   1 +
 hw/arm/aspeed.c                 |  85 ++++++++++++++++
 hw/i2c/smbus_eeprom.c           |  16 ++-
 hw/misc/Makefile.objs           |   1 +
 hw/misc/pca9552.c               | 212 ++++++++++++++++++++++++++++++++++++++++
 include/hw/i2c/smbus.h          |   1 +
 include/hw/misc/pca9552.h       |  32 ++++++
 7 files changed, 343 insertions(+), 5 deletions(-)
 create mode 100644 hw/misc/pca9552.c
 create mode 100644 include/hw/misc/pca9552.h
Signature · 1 line
2.13.5
#1 lore raw

PATCH v2 1/6 aspeed: add support for the witherspoon-bmc board

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
hw/arm/aspeed.c +49 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
     PALMETTO_BMC,
     AST2500_EVB,
     ROMULUS_BMC,
+    WITHERSPOON_BMC,
 };
 
 /* Palmetto hardware value: 0x120CE416 */
@@ -83,8 +84,12 @@ enum {
         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
 
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 
 static const AspeedBoardConfig aspeed_boards[] = {
     [PALMETTO_BMC] = {
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
         .spi_model = "mx66l1g45g",
         .num_cs    = 2,
     },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
 };
 
 #define FIRMWARE_ADDR 0x0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
     .class_init = romulus_bmc_class_init,
 };
 
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
+}
+
+static void witherspoon_bmc_init(MachineState *machine)
+{
+    aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
+}
+
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
+    mc->init = witherspoon_bmc_init;
+    mc->max_cpus = 1;
+    mc->no_sdcard = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->no_parallel = 1;
+    mc->ignore_memory_transaction_failures = true;
+}
+
+static const TypeInfo witherspoon_bmc_type = {
+    .name = MACHINE_TYPE_NAME("witherspoon-bmc"),
+    .parent = TYPE_MACHINE,
+    .class_init = witherspoon_bmc_class_init,
+};
+
 static void aspeed_machine_init(void)
 {
     type_register_static(&palmetto_bmc_type);
     type_register_static(&ast2500_evb_type);
     type_register_static(&romulus_bmc_type);
+    type_register_static(&witherspoon_bmc_type);
 }
 
 type_init(aspeed_machine_init)
Signature · 1 line
2.13.5
#17 lore raw

PATCH v2 2/6 aspeed: add an I2C RTC device to all machines

In reply to Cédric Le Goater

The AST2500 EVB does not have an RTC but we can pretend that one is plugged on the I2C bus header.

The romulus and witherspoon boards expects an Epson RX8900 I2C RTC but a ds1338 is good enough for the basic features we need.

---
 hw/arm/aspeed.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
hw/arm/aspeed.c +19 -0
index 81f522f711ae..362b683e9021 100644
@@ -89,6 +89,7 @@ enum {
 
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
+static void romulus_bmc_i2c_init(AspeedBoardState *bmc);
 static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 
 static const AspeedBoardConfig aspeed_boards[] = {
@@ -114,6 +115,7 @@ static const AspeedBoardConfig aspeed_boards[] = {
         .fmc_model = "n25q256a",
         .spi_model = "mx66l1g45g",
         .num_cs    = 2,
+        .i2c_init  = romulus_bmc_i2c_init,
     },
     [WITHERSPOON_BMC]  = {
         .soc_name  = "ast2500-a1",
@@ -298,6 +300,10 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
 
     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
+
+    /* The AST2500 EVB does not have an RTC. Let's pretend that one is
+     * plugged on the I2C bus header */
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
 }
 
 static void ast2500_evb_init(MachineState *machine)
@@ -325,6 +331,15 @@ static const TypeInfo ast2500_evb_type = {
     .class_init = ast2500_evb_class_init,
 };
 
+static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
+     * good enough */
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
+}
+
 static void romulus_bmc_init(MachineState *machine)
 {
     aspeed_board_init(machine, &aspeed_boards[ROMULUS_BMC]);
@@ -358,6 +373,10 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
 
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
+
+    /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
+     * good enough */
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
 }
 
 static void witherspoon_bmc_init(MachineState *machine)
Signature · 1 line
2.13.5
#19 lore raw

PATCH v2 3/6 smbus: add a smbus_eeprom_init_one() routine

In reply to Cédric Le Goater

This is an helper routine to add a single EEPROM on an I2C bus. It can be directly used by smbus_eeprom_init() which adds a certain number of EEPROMs on mips and x86 machines.

---
 hw/i2c/smbus_eeprom.c  | 16 +++++++++++-----
 include/hw/i2c/smbus.h |  1 +
 2 files changed, 12 insertions(+), 5 deletions(-)
hw/i2c/smbus_eeprom.c +11 -5
index b13ec0fe7a2a..2d24a4cd59bf 100644
@@ -140,6 +140,16 @@ static void smbus_eeprom_register_types(void)
 
 type_init(smbus_eeprom_register_types)
 
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)
+{
+    DeviceState *dev;
+
+    dev = qdev_create((BusState *) smbus, "smbus-eeprom");
+    qdev_prop_set_uint8(dev, "address", address);
+    qdev_prop_set_ptr(dev, "data", eeprom_buf);
+    qdev_init_nofail(dev);
+}
+
 void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
                        const uint8_t *eeprom_spd, int eeprom_spd_size)
 {
@@ -150,10 +160,6 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
     }
 
     for (i = 0; i < nb_eeprom; i++) {
-        DeviceState *eeprom;
-        eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
-        qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
-        qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
-        qdev_init_nofail(eeprom);
+        smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256));
     }
 }
include/hw/i2c/smbus.h +1 -0
index 544bbc19574f..666cdeb04c07 100644
@@ -77,6 +77,7 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
 int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
                       int len);
 
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf);
 void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
                        const uint8_t *eeprom_spd, int size);
 
Signature · 1 line
2.13.5
#23 lore raw

PATCH v2 5/6 misc: add pca9552 LED blinker model

In reply to Cédric Le Goater

Specs are available here :

https://www.nxp.com/docs/en/data-sheet/PCA9552.pdf

This is a simple model supporting the basic registers for led and GPIO mode. The device also supports two blinking rates but not the model yet.

---
 default-configs/arm-softmmu.mak |   1 +
 hw/misc/Makefile.objs           |   1 +
 hw/misc/pca9552.c               | 212 ++++++++++++++++++++++++++++++++++++++++
 include/hw/misc/pca9552.h       |  32 ++++++
 4 files changed, 246 insertions(+)
 create mode 100644 hw/misc/pca9552.c
 create mode 100644 include/hw/misc/pca9552.h
default-configs/arm-softmmu.mak +1 -0
index bbdd3c1d8b7f..17b8fc323f27 100644
@@ -16,6 +16,7 @@ CONFIG_TSC2005=y
 CONFIG_LM832X=y
 CONFIG_TMP105=y
 CONFIG_TMP421=y
+CONFIG_PCA9552=y
 CONFIG_STELLARIS=y
 CONFIG_STELLARIS_INPUT=y
 CONFIG_STELLARIS_ENET=y
hw/misc/Makefile.objs +1 -0
index 29fb922cefc6..33ba1d6642f9 100644
@@ -7,6 +7,7 @@ common-obj-$(CONFIG_SGA) += sga.o
 common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o
 common-obj-$(CONFIG_PCI_TESTDEV) += pci-testdev.o
 common-obj-$(CONFIG_EDU) += edu.o
+common-obj-$(CONFIG_PCA9552) += pca9552.o
 
 common-obj-y += unimp.o
 
hw/misc/pca9552.c new file +212 -0

212 lines not on this page · raw message

include/hw/misc/pca9552.h new file +32 -0
new file mode 100644
index 000000000000..875467725526
@@ -0,0 +1,32 @@
+/*
+ * PCA9552 I2C LED blinker
+ *
+ * Copyright (c) 2017, IBM Corporation.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
+ */
+#ifndef PCA9552_H
+#define PCA9552_H
+
+#include "hw/i2c/i2c.h"
+
+#define TYPE_PCA9552 "pca9552"
+#define PCA9552(obj) OBJECT_CHECK(PCA9552State, (obj), TYPE_PCA9552)
+
+
+#define PCA9552_NR_REGS 10
+
+typedef struct PCA9552State {
+    /*< private >*/
+    I2CSlave i2c;
+    /*< public >*/
+
+    uint8_t len;
+    uint8_t pointer;
+    uint8_t buf[1]; /* just to remember how to handle a larger buffer */
+
+    uint8_t regs[PCA9552_NR_REGS];
+} PCA9552State;
+
+#endif
Signature · 1 line
2.13.5
#21 lore raw

PATCH v2 4/6 aspeed: Add EEPROM I2C devices

In reply to Cédric Le Goater

The Aspeed boards have at least one EEPROM to hold the Vital Product Data (VPD).

---

Changes since v1:

- fixed palmetto EEPROM size
- used smbus_eeprom_init_one()

hw/arm/aspeed.c | 13 +++++++++++++

 1 file changed, 13 insertions(+)
hw/arm/aspeed.c +13 -0
index 362b683e9021..462f8008cff5 100644
@@ -17,6 +17,7 @@
 #include "hw/arm/arm.h"
 #include "hw/arm/aspeed_soc.h"
 #include "hw/boards.h"
+#include "hw/i2c/smbus.h"
 #include "qemu/log.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
@@ -255,11 +256,15 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
     DeviceState *dev;
+    uint8_t *eeprom_buf = g_malloc0(32 * 1024);
 
     /* The palmetto platform expects a ds3231 RTC but a ds1338 is
      * enough to provide basic RTC features. Alarms will be missing */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
 
+    smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,
+                          eeprom_buf);
+
     /* add a TMP423 temperature sensor */
     dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
                            "tmp423", 0x4c);
@@ -297,6 +302,10 @@ static const TypeInfo palmetto_bmc_type = {
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
+    uint8_t *eeprom_buf = g_malloc0(8 * 1024);
+
+    smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
+                          eeprom_buf);
 
     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
@@ -368,6 +377,7 @@ static const TypeInfo romulus_bmc_type = {
 static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
+    uint8_t *eeprom_buf = g_malloc0(8 * 1024);
 
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
@@ -377,6 +387,9 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
     /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
      * good enough */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
+
+    smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
+                          eeprom_buf);
 }
 
 static void witherspoon_bmc_init(MachineState *machine)
Signature · 1 line
2.13.5
#26 lore raw

PATCH v2 6/6 aspeed: add the pc9552 chips to the witherspoon machine

In reply to Cédric Le Goater

The pca9552 LED blinkers on the Witherspoon machine are used for leds but also as GPIOs to control fans and GPUs.

---
 hw/arm/aspeed.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/aspeed.c +4 -0
index 462f8008cff5..2ae46d71bff7 100644
@@ -379,6 +379,8 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
     AspeedSoCState *soc = &bmc->soc;
     uint8_t *eeprom_buf = g_malloc0(8 * 1024);
 
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
+
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
 
@@ -390,6 +392,8 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
 
     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
                           eeprom_buf);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552",
+                     0x60);
 }
 
 static void witherspoon_bmc_init(MachineState *machine)
Signature · 1 line
2.13.5
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Cédric Le Goater
Quoted 70 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
hw/arm/aspeed.c +30 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
     PALMETTO_BMC,
     AST2500_EVB,
     ROMULUS_BMC,
+    WITHERSPOON_BMC,
 };
 
 /* Palmetto hardware value: 0x120CE416 */
@@ -83,8 +84,12 @@ enum {
         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
 
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 
 static const AspeedBoardConfig aspeed_boards[] = {
     [PALMETTO_BMC] = {
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
         .spi_model = "mx66l1g45g",
         .num_cs    = 2,
     },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
 };
 
 #define FIRMWARE_ADDR 0x0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
     .class_init = romulus_bmc_class_init,
 };
 
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
+}
+
+static void witherspoon_bmc_init(MachineState *machine)
+{
+    aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
+}
+
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
+{

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 379

Quoted 10 lines
hw/arm/aspeed.c +10 -0
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
+    mc->init = witherspoon_bmc_init;
+    mc->max_cpus = 1;
+    mc->no_sdcard = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->no_parallel = 1;
+    mc->ignore_memory_transaction_failures = true;

Please don't set this flag for new board models, it is only for our legacy existing ones. Instead implement any devices that you need for guest code to boot (stub them out with create_unimplemented_device() if you like).

thanks
-- PMM

#24 lore raw

Re: [Qemu-arm] [PATCH v2 5/6] misc: add pca9552 LED blinker model

In reply to Cédric Le Goater
Quoted 31 lines · Cédric Le Goater

Specs are available here :

https://www.nxp.com/docs/en/data-sheet/PCA9552.pdf

This is a simple model supporting the basic registers for led and GPIO mode. The device also supports two blinking rates but not the model yet.

include/hw/misc/pca9552.h new file +17 -0
@@ -0,0 +1,32 @@
+/*
+ * PCA9552 I2C LED blinker
+ *
+ * Copyright (c) 2017, IBM Corporation.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
+ */
+#ifndef PCA9552_H
+#define PCA9552_H
+
+#include "hw/i2c/i2c.h"
+
+#define TYPE_PCA9552 "pca9552"
+#define PCA9552(obj) OBJECT_CHECK(PCA9552State, (obj), TYPE_PCA9552)
+
+

include/hw/misc/pca9552.h line 27

Quoted 10 lines
include/hw/misc/pca9552.h new file +10 -0
+#define PCA9552_NR_REGS 10
+
+typedef struct PCA9552State {
+    /*< private >*/
+    I2CSlave i2c;
+    /*< public >*/
+
+    uint8_t len;
+    uint8_t pointer;
+    uint8_t buf[1]; /* just to remember how to handle a larger buffer */

Changing this later is going to be a migration compatibility break (or at least a bit painful to keep compat).
Do we know how big the buffer is supposed to be? If so it would be best to make it the correct size to start with.

include/hw/misc/pca9552.h line 30

Quoted 3 lines
include/hw/misc/pca9552.h new file +3 -0
+
+    uint8_t regs[PCA9552_NR_REGS];
+} PCA9552State;

thanks
-- PMM

#28 lore raw
In reply to Cédric Le Goater
Quoted 15 lines · Cédric Le Goater

Hello,

This series adds a new Aspeed machine to emulate the BMC of a Witherspoon system. It also extends the other Aspeed machines with I2C devices and adds a simple model for the pca9552 LED blinker present on the witherspoon board.

Thanks,

C.

Changes since v1:

- introduced smbus_eeprom_init_one()

Quoted 7 lines

Cédric Le Goater (6):
aspeed: add support for the witherspoon-bmc board
aspeed: add an I2C RTC device to all machines
smbus: add a smbus_eeprom_init_one() routine
aspeed: Add EEPROM I2C devices
misc: add pca9552 LED blinker model
aspeed: add the pc9552 chips to the witherspoon machine

Hi -- I've made a couple of review comments and nothing else leapt out as obviously wrong, but I'm hoping that somebody more familiar with the aspeed devices will do review...

thanks
-- PMM

#25 lore raw

Re: [Qemu-arm] [PATCH v2 5/6] misc: add pca9552 LED blinker model

In reply to Peter Maydell
Quoted 38 lines · Peter Maydell
Quoted 37 lines · Cédric Le Goater

Specs are available here :

https://www.nxp.com/docs/en/data-sheet/PCA9552.pdf

This is a simple model supporting the basic registers for led and GPIO mode. The device also supports two blinking rates but not the model yet.

include/hw/misc/pca9552.h new file +23 -0
@@ -0,0 +1,32 @@
+/*
+ * PCA9552 I2C LED blinker
+ *
+ * Copyright (c) 2017, IBM Corporation.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
+ */
+#ifndef PCA9552_H
+#define PCA9552_H
+
+#include "hw/i2c/i2c.h"
+
+#define TYPE_PCA9552 "pca9552"
+#define PCA9552(obj) OBJECT_CHECK(PCA9552State, (obj), TYPE_PCA9552)
+
+
+#define PCA9552_NR_REGS 10
+
+typedef struct PCA9552State {
+    /*< private >*/
+    I2CSlave i2c;
+    /*< public >*/
Quoted 8 lines

include/hw/misc/pca9552.h line 27

Quoted 4 lines
include/hw/misc/pca9552.h new file +4 -0
+
+    uint8_t len;
+    uint8_t pointer;
+    uint8_t buf[1]; /* just to remember how to handle a larger buffer */

Changing this later is going to be a migration compatibility break (or at least a bit painful to keep compat).
Do we know how big the buffer is supposed to be?

one.

Quoted 1 line

If so it would be best to make it the correct size to start with.

yes I will change that.

Thanks,

C.

Quoted 8 lines

include/hw/misc/pca9552.h line 30

Quoted 4 lines
include/hw/misc/pca9552.h new file +3 -0
+
+    uint8_t regs[PCA9552_NR_REGS];
+} PCA9552State;

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Peter Maydell
Quoted 78 lines · Peter Maydell
Quoted 77 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
hw/arm/aspeed.c +37 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
     PALMETTO_BMC,
     AST2500_EVB,
     ROMULUS_BMC,
+    WITHERSPOON_BMC,
 };
 
 /* Palmetto hardware value: 0x120CE416 */
@@ -83,8 +84,12 @@ enum {
         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
 
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 
 static const AspeedBoardConfig aspeed_boards[] = {
     [PALMETTO_BMC] = {
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
         .spi_model = "mx66l1g45g",
         .num_cs    = 2,
     },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
 };
 
 #define FIRMWARE_ADDR 0x0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
     .class_init = romulus_bmc_class_init,
 };
 
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
+}
+
+static void witherspoon_bmc_init(MachineState *machine)
+{
+    aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
+}
+
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
+    mc->init = witherspoon_bmc_init;
+    mc->max_cpus = 1;
+    mc->no_sdcard = 1;
+    mc->no_floppy = 1;
Quoted 8 lines

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 379

Quoted 3 lines
hw/arm/aspeed.c +3 -0
+    mc->no_cdrom = 1;
+    mc->no_parallel = 1;
+    mc->ignore_memory_transaction_failures = true;

Please don't set this flag for new board models, it is only for our legacy existing ones. Instead implement any devices that you need for guest code to boot (stub them out with create_unimplemented_device() if you like).

OK. I am discovering this. I will take a look for the next round.

C.

#29 lore raw
In reply to Peter Maydell
Quoted 24 lines · Peter Maydell
Quoted 15 lines · Cédric Le Goater

Hello,

This series adds a new Aspeed machine to emulate the BMC of a Witherspoon system. It also extends the other Aspeed machines with I2C devices and adds a simple model for the pca9552 LED blinker present on the witherspoon board.

Thanks,

C.

Changes since v1:

- introduced smbus_eeprom_init_one()

Quoted 7 lines

Cédric Le Goater (6):
aspeed: add support for the witherspoon-bmc board
aspeed: add an I2C RTC device to all machines
smbus: add a smbus_eeprom_init_one() routine
aspeed: Add EEPROM I2C devices
misc: add pca9552 LED blinker model
aspeed: add the pc9552 chips to the witherspoon machine

Quoted 3 lines

Hi -- I've made a couple of review comments and nothing else leapt out as obviously wrong, but I'm hoping that somebody more familiar with the aspeed devices will do review...

Joel,

Now that we have updated the DTs, could you please take a look to make sure that the I2C busses in the models have devices which makes sense with the real boards.

Thanks,

C.

Reviewed-by on v2 1/6
#11 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Cédric Le Goater
Quoted 53 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

 1 file changed, 49 insertions(+)

hw/arm/aspeed.c +1 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
      PALMETTO_BMC,
      AST2500_EVB,
      ROMULUS_BMC,
+    WITHERSPOON_BMC,
  };


 /* Palmetto hardware value: 0x120CE416 */

hw/arm/aspeed.c +0 -0
@@ -83,8 +84,12 @@ enum {
          SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
          SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))

hw/arm/aspeed.c +3 -0
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+

 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); static void ast2500_evb_i2c_init(AspeedBoardState *bmc); +static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC] = {

hw/arm/aspeed.c +8 -0
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
          .spi_model = "mx66l1g45g",
          .num_cs    = 2,
      },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
  };


 #define FIRMWARE_ADDR 0x0

hw/arm/aspeed.c +0 -0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
      .class_init = romulus_bmc_class_init,
  };

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 360

Quoted 8 lines
hw/arm/aspeed.c +8 -0
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);

Looks like I need to track down newer versions of the schematics I have.

Quoted 9 lines
hw/arm/aspeed.c +9 -0
+}
+
+static void witherspoon_bmc_init(MachineState *machine)
+{
+    aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
+}
+
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
+{

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 379

Quoted 10 lines
hw/arm/aspeed.c +10 -0
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
+    mc->init = witherspoon_bmc_init;
+    mc->max_cpus = 1;
+    mc->no_sdcard = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->no_parallel = 1;
+    mc->ignore_memory_transaction_failures = true;

Aside from the issue with the above as pointed out by Peter,

Quoted 17 lines
hw/arm/aspeed.c +8 -0
+}
+
+static const TypeInfo witherspoon_bmc_type = {
+    .name = MACHINE_TYPE_NAME("witherspoon-bmc"),
+    .parent = TYPE_MACHINE,
+    .class_init = witherspoon_bmc_class_init,
+};
+

 static void aspeed_machine_init(void)
 {
     type_register_static(&palmetto_bmc_type);
     type_register_static(&ast2500_evb_type);
     type_register_static(&romulus_bmc_type);
+    type_register_static(&witherspoon_bmc_type);
 }

 type_init(aspeed_machine_init)

Reviewed-by on v2 2/6
#18 lore raw

Re: [Qemu-arm] [PATCH v2 2/6] aspeed: add an I2C RTC device to all machines

In reply to Cédric Le Goater
Quoted 7 lines · Cédric Le Goater

The AST2500 EVB does not have an RTC but we can pretend that one is plugged on the I2C bus header.

The romulus and witherspoon boards expects an Epson RX8900 I2C RTC but a ds1338 is good enough for the basic features we need.

Quoted 62 lines

---
 hw/arm/aspeed.c | 19 +++++++++++++++++++

 1 file changed, 19 insertions(+)

hw/arm/aspeed.c +0 -0
index 81f522f711ae..362b683e9021 100644
@@ -89,6 +89,7 @@ enum {


 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); static void ast2500_evb_i2c_init(AspeedBoardState *bmc); +static void romulus_bmc_i2c_init(AspeedBoardState *bmc); static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 static const AspeedBoardConfig aspeed_boards[] = {

hw/arm/aspeed.c +1 -0
@@ -114,6 +115,7 @@ static const AspeedBoardConfig aspeed_boards[] = {
          .fmc_model = "n25q256a",
          .spi_model = "mx66l1g45g",
          .num_cs    = 2,
+        .i2c_init  = romulus_bmc_i2c_init,
      },
      [WITHERSPOON_BMC]  = {
          .soc_name  = "ast2500-a1",
@@ -298,6 +300,10 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)


     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d); +
+    /* The AST2500 EVB does not have an RTC. Let's pretend that one is +     * plugged on the I2C bus header */
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); }

 static void ast2500_evb_init(MachineState *machine)

hw/arm/aspeed.c +0 -0
@@ -325,6 +331,15 @@ static const TypeInfo ast2500_evb_type = {
      .class_init = ast2500_evb_class_init,
  };

hw/arm/aspeed.c +9 -0
+static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
+     * good enough */
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
+}
+

 static void romulus_bmc_init(MachineState *machine) {
     aspeed_board_init(machine, &aspeed_boards[ROMULUS_BMC]);

hw/arm/aspeed.c +0 -0
@@ -358,6 +373,10 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
      i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);


     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a); +
+    /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is +     * good enough */
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); }

 static void witherspoon_bmc_init(MachineState *machine)

Reviewed-by on v2 4/6
#22 lore raw

Re: [Qemu-arm] [PATCH v2 4/6] aspeed: Add EEPROM I2C devices

In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater

The Aspeed boards have at least one EEPROM to hold the Vital Product Data (VPD).

Quoted 67 lines

---

Changes since v1:

 - fixed palmetto EEPROM size
 - used smbus_eeprom_init_one()

hw/arm/aspeed.c | 13 +++++++++++++

 1 file changed, 13 insertions(+)

hw/arm/aspeed.c +2 -0
index 362b683e9021..462f8008cff5 100644
@@ -17,6 +17,7 @@
  #include "hw/arm/arm.h"
  #include "hw/arm/aspeed_soc.h"
  #include "hw/boards.h"
+#include "hw/i2c/smbus.h"
  #include "qemu/log.h"
  #include "sysemu/block-backend.h"
  #include "sysemu/blockdev.h"
@@ -255,11 +256,15 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
  {
      AspeedSoCState *soc = &bmc->soc;
      DeviceState *dev;
+    uint8_t *eeprom_buf = g_malloc0(32 * 1024);


     /* The palmetto platform expects a ds3231 RTC but a ds1338 is
      * enough to provide basic RTC features. Alarms will be missing */ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
+    smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50, +                          eeprom_buf);
+
     /* add a TMP423 temperature sensor */
     dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp423", 0x4c);

hw/arm/aspeed.c +4 -0
@@ -297,6 +302,10 @@ static const TypeInfo palmetto_bmc_type = {
  static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
  {
      AspeedSoCState *soc = &bmc->soc;
+    uint8_t *eeprom_buf = g_malloc0(8 * 1024);
+
+    smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
+                          eeprom_buf);


     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);

hw/arm/aspeed.c +1 -0
@@ -368,6 +377,7 @@ static const TypeInfo romulus_bmc_type = {
  static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
  {
      AspeedSoCState *soc = &bmc->soc;
+    uint8_t *eeprom_buf = g_malloc0(8 * 1024);


     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);

hw/arm/aspeed.c +3 -0
@@ -377,6 +387,9 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
      /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
       * good enough */
      i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
+
+    smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
+                          eeprom_buf);
  }


 static void witherspoon_bmc_init(MachineState *machine)

Reviewed-by on v2 6/6
#27 lore raw

Re: [Qemu-arm] [PATCH v2 6/6] aspeed: add the pc9552 chips to the witherspoon machine

In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater

The pca9552 LED blinkers on the Witherspoon machine are used for leds but also as GPIOs to control fans and GPUs.

Quoted 26 lines

---
 hw/arm/aspeed.c | 4 ++++

 1 file changed, 4 insertions(+)

hw/arm/aspeed.c +0 -0
index 462f8008cff5..2ae46d71bff7 100644
@@ -379,6 +379,8 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
      AspeedSoCState *soc = &bmc->soc;
      uint8_t *eeprom_buf = g_malloc0(8 * 1024);


+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); +
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);

hw/arm/aspeed.c +0 -0
@@ -390,6 +392,8 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)


     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, eeprom_buf);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552", +                     0x60);
 }

 static void witherspoon_bmc_init(MachineState *machine)

Reviewed-by on v2 3/6
#20 lore raw

Re: [Qemu-arm] [PATCH v2 3/6] smbus: add a smbus_eeprom_init_one() routine

In reply to Cédric Le Goater
Quoted 5 lines · Cédric Le Goater

This is an helper routine to add a single EEPROM on an I2C bus. It can be directly used by smbus_eeprom_init() which adds a certain number of EEPROMs on mips and x86 machines.

Quoted 51 lines
---
 hw/i2c/smbus_eeprom.c  | 16 +++++++++++-----
 include/hw/i2c/smbus.h |  1 +
 2 files changed, 12 insertions(+), 5 deletions(-)
hw/i2c/smbus_eeprom.c +11 -5
index b13ec0fe7a2a..2d24a4cd59bf 100644
@@ -140,6 +140,16 @@ static void smbus_eeprom_register_types(void)
 
 type_init(smbus_eeprom_register_types)
 
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)
+{
+    DeviceState *dev;
+
+    dev = qdev_create((BusState *) smbus, "smbus-eeprom");
+    qdev_prop_set_uint8(dev, "address", address);
+    qdev_prop_set_ptr(dev, "data", eeprom_buf);
+    qdev_init_nofail(dev);
+}
+
 void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
                        const uint8_t *eeprom_spd, int eeprom_spd_size)
 {
@@ -150,10 +160,6 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
     }
 
     for (i = 0; i < nb_eeprom; i++) {
-        DeviceState *eeprom;
-        eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
-        qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
-        qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
-        qdev_init_nofail(eeprom);
+        smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256));
     }
 }
include/hw/i2c/smbus.h +1 -0
index 544bbc19574f..666cdeb04c07 100644
@@ -77,6 +77,7 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
 int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
                       int len);
 
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf);
 void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
                        const uint8_t *eeprom_spd, int size);
 
#4 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Peter Maydell
Quoted 78 lines · Peter Maydell
Quoted 77 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
hw/arm/aspeed.c +37 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
     PALMETTO_BMC,
     AST2500_EVB,
     ROMULUS_BMC,
+    WITHERSPOON_BMC,
 };
 
 /* Palmetto hardware value: 0x120CE416 */
@@ -83,8 +84,12 @@ enum {
         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
 
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
 static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 
 static const AspeedBoardConfig aspeed_boards[] = {
     [PALMETTO_BMC] = {
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
         .spi_model = "mx66l1g45g",
         .num_cs    = 2,
     },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
 };
 
 #define FIRMWARE_ADDR 0x0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
     .class_init = romulus_bmc_class_init,
 };
 
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
+}
+
+static void witherspoon_bmc_init(MachineState *machine)
+{
+    aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
+}
+
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
+    mc->init = witherspoon_bmc_init;
+    mc->max_cpus = 1;
+    mc->no_sdcard = 1;
+    mc->no_floppy = 1;
Quoted 8 lines

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 379

Quoted 3 lines
hw/arm/aspeed.c +3 -0
+    mc->no_cdrom = 1;
+    mc->no_parallel = 1;
+    mc->ignore_memory_transaction_failures = true;

Please don't set this flag for new board models, it is only for our legacy existing ones. Instead implement any devices that you need for guest code to boot (stub them out with create_unimplemented_device() if you like).

I have dug into this a little more and it seems that it is required for the Aspeed bootloader (a modified u-boot) which uses static variables in early init phases. So legacy firmwares won't work in QEMU but will on real HW.

It's fine with me but what is the goal of the approach ? Force SoC providers into fixing their FW when they use QEMU ?

Thanks,

C.

#5 lore raw

Re: [Qemu-devel] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 8 lines · Cédric Le Goater
Quoted 6 lines · Peter Maydell
Quoted 1 line

+ mc->ignore_memory_transaction_failures = true;

Please don't set this flag for new board models, it is only for our legacy existing ones. Instead implement any devices that you need for guest code to boot (stub them out with create_unimplemented_device() if you like).

Quoted 7 lines

I have dug into this a little more and it seems that it is required for the Aspeed bootloader (a modified u-boot) which uses static variables in early init phases. So legacy firmwares won't work in QEMU but will on real HW.

It's fine with me but what is the goal of the approach ? Force SoC providers into fixing their FW when they use QEMU ?

The goal is to model hardware correctly. Hardware gives aborts if you touch a physical address with no device there, and so QEMU's model should do the same. If you have guest code that touches a physical address and blows up because of an abort (but doesn't when run on h/w) then either:
* it is trying to probe a device that exists in real h/w:
you need to provide a stub implementation in QEMU
* the SoC's bus fabric really doesn't pass aborts back to the CPU; I think this is unlikely, but you can model it at the SoC level with a suitable default memory region

The purpose of the flag is purely for existing board models, where it is impossible to enable the correct (abort) behaviour without possibly breaking guest code images that work for people using released QEMU code. On a new board model we don't have that problem and we can get it right from the start. If we don't get it right from the start then we will never have a chance to fix it in future.

Our mismodelling of this (not turning accesses to invalid addresses into CPU aborts) meant that in the past it was possible to be lazy when implementing a board model and just not model half the hardware at all. Now it isn't, but I don't think that adding a set of calls to create_unimplemented_device() is a significant imposition.

thanks
-- PMM

#6 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 17 lines · Peter Maydell
Quoted 8 lines · Cédric Le Goater
Quoted 6 lines · Peter Maydell
Quoted 1 line

+ mc->ignore_memory_transaction_failures = true;

Please don't set this flag for new board models, it is only for our legacy existing ones. Instead implement any devices that you need for guest code to boot (stub them out with create_unimplemented_device() if you like).

Quoted 7 lines

I have dug into this a little more and it seems that it is required for the Aspeed bootloader (a modified u-boot) which uses static variables in early init phases. So legacy firmwares won't work in QEMU but will on real HW.

It's fine with me but what is the goal of the approach ? Force SoC providers into fixing their FW when they use QEMU ?

Quoted 10 lines

The goal is to model hardware correctly. Hardware gives aborts if you touch a physical address with no device there, and so QEMU's model should do the same. If you have guest code that touches a physical address and blows up because of an abort (but doesn't when run on h/w) then either:
* it is trying to probe a device that exists in real h/w:
you need to provide a stub implementation in QEMU
* the SoC's bus fabric really doesn't pass aborts back to the CPU; I think this is unlikely, but you can model it at the SoC level with a suitable default memory region

well, that is case it seems.

Anyhow, I found the required fixes in u-boot, so I will go with ignore_memory_transaction_failures=false with this new machine.

Thanks,

C.

Quoted 18 lines

The purpose of the flag is purely for existing board models, where it is impossible to enable the correct (abort) behaviour without possibly breaking guest code images that work for people using released QEMU code. On a new board model we don't have that problem and we can get it right from the start. If we don't get it right from the start then we will never have a chance to fix it in future.

Our mismodelling of this (not turning accesses to invalid addresses into CPU aborts) meant that in the past it was possible to be lazy when implementing a board model and just not model half the hardware at all. Now it isn't, but I don't think that adding a set of calls to create_unimplemented_device() is a significant imposition.

thanks
-- PMM

#7 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 12 lines · Cédric Le Goater
Quoted 10 lines · Peter Maydell

The goal is to model hardware correctly. Hardware gives aborts if you touch a physical address with no device there, and so QEMU's model should do the same. If you have guest code that touches a physical address and blows up because of an abort (but doesn't when run on h/w) then either:
* it is trying to probe a device that exists in real h/w:
you need to provide a stub implementation in QEMU
* the SoC's bus fabric really doesn't pass aborts back to the CPU; I think this is unlikely, but you can model it at the SoC level with a suitable default memory region

Quoted 1 line

well, that is case it seems.

If it is, then we should model the SoC that way, ie find out from the hardware docs what part of the bus fabric ignores decode errors and use memory regions with the right default behaviour to cover the relevant address ranges.

thanks
-- PMM

#12 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Andrew Jeffery
Quoted 56 lines · Andrew Jeffery
Quoted 55 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

 1 file changed, 49 insertions(+)

hw/arm/aspeed.c +1 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
      PALMETTO_BMC,
      AST2500_EVB,
      ROMULUS_BMC,
+    WITHERSPOON_BMC,
  };


 /* Palmetto hardware value: 0x120CE416 */

hw/arm/aspeed.c +0 -0
@@ -83,8 +84,12 @@ enum {
          SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
          SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))

hw/arm/aspeed.c +3 -0
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+

 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); static void ast2500_evb_i2c_init(AspeedBoardState *bmc); +static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC] = {

hw/arm/aspeed.c +8 -0
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
          .spi_model = "mx66l1g45g",
          .num_cs    = 2,
      },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
  };


 #define FIRMWARE_ADDR 0x0

hw/arm/aspeed.c +0 -0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
      .class_init = romulus_bmc_class_init,
  };

hw/arm/aspeed.c +2 -0
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
Quoted 8 lines

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 360

Quoted 6 lines

+    AspeedSoCState *soc = &bmc->soc;

hw/arm/aspeed.c +5 -0
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);

Looks like I need to track down newer versions of the schematics I have.

the device on the board is a tmp275 but the tmp105 model is compatible.

Quoted 22 lines
Quoted 9 lines
hw/arm/aspeed.c +9 -0
+}
+
+static void witherspoon_bmc_init(MachineState *machine)
+{
+    aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
+}
+
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
+{

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 379

Quoted 10 lines
hw/arm/aspeed.c +10 -0
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
+    mc->init = witherspoon_bmc_init;
+    mc->max_cpus = 1;
+    mc->no_sdcard = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->no_parallel = 1;
+    mc->ignore_memory_transaction_failures = true;

Aside from the issue with the above as pointed out by Peter,

Quoted 1 line

Thanks,

C.

Quoted 18 lines
Quoted 18 lines
hw/arm/aspeed.c +8 -0
+}
+
+static const TypeInfo witherspoon_bmc_type = {
+    .name = MACHINE_TYPE_NAME("witherspoon-bmc"),
+    .parent = TYPE_MACHINE,
+    .class_init = witherspoon_bmc_class_init,
+};
+

 static void aspeed_machine_init(void)
 {
     type_register_static(&palmetto_bmc_type);
     type_register_static(&ast2500_evb_type);
     type_register_static(&romulus_bmc_type);
+    type_register_static(&witherspoon_bmc_type);
 }

 type_init(aspeed_machine_init)

#13 lore raw

Re: [Qemu-devel] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 13 lines · Cédric Le Goater
Quoted 11 lines · Andrew Jeffery

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 360

Quoted 8 lines · Cédric Le Goater
hw/arm/aspeed.c +8 -0
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);

Looks like I need to track down newer versions of the schematics I have.

Quoted 1 line

the device on the board is a tmp275 but the tmp105 model is compatible.

This kind of deviation from the real hardware is worth having a comment to document, I think.

thanks
-- PMM

#8 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Peter Maydell
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Cédric Le Goater
Quoted 10 lines · Peter Maydell

The goal is to model hardware correctly. Hardware gives aborts if you touch a physical address with no device there, and so QEMU's model should do the same. If you have guest code that touches a physical address and blows up because of an abort (but doesn't when run on h/w) then either:
* it is trying to probe a device that exists in real h/w:
you need to provide a stub implementation in QEMU
* the SoC's bus fabric really doesn't pass aborts back to the CPU; I think this is unlikely, but you can model it at the SoC level with a suitable default memory region

Quoted 7 lines
Quoted 1 line

well, that is case it seems.

If it is, then we should model the SoC that way, ie find out from the hardware docs what part of the bus fabric ignores decode errors and use memory regions with the right default behaviour to cover the relevant address ranges.

The addresses generating memory fault errors are all in the region where the BMC SPI Flash Memory is mapped :
[ 20000000-2FFFFFFF ]

but we should not be doing any writes there. I will make some inquiries.

Thanks,

C.

#9 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 22 lines · Cédric Le Goater
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Cédric Le Goater
Quoted 10 lines · Peter Maydell

The goal is to model hardware correctly. Hardware gives aborts if you touch a physical address with no device there, and so QEMU's model should do the same. If you have guest code that touches a physical address and blows up because of an abort (but doesn't when run on h/w) then either:
* it is trying to probe a device that exists in real h/w:
you need to provide a stub implementation in QEMU
* the SoC's bus fabric really doesn't pass aborts back to the CPU; I think this is unlikely, but you can model it at the SoC level with a suitable default memory region

Quoted 7 lines
Quoted 1 line

well, that is case it seems.

If it is, then we should model the SoC that way, ie find out from the hardware docs what part of the bus fabric ignores decode errors and use memory regions with the right default behaviour to cover the relevant address ranges.

Quoted 3 lines

The addresses generating memory fault errors are all in the region where the BMC SPI Flash Memory is mapped :
[ 20000000-2FFFFFFF ]

If there's an actual flash device there then this sounds like my first case above, where we just need to stub out that range of addresses until we get round to really implementing the flash device.

thanks
-- PMM

#10 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 23 lines · Peter Maydell
Quoted 22 lines · Cédric Le Goater
Quoted 20 lines · Peter Maydell
Quoted 12 lines · Cédric Le Goater
Quoted 10 lines · Peter Maydell

The goal is to model hardware correctly. Hardware gives aborts if you touch a physical address with no device there, and so QEMU's model should do the same. If you have guest code that touches a physical address and blows up because of an abort (but doesn't when run on h/w) then either:
* it is trying to probe a device that exists in real h/w:
you need to provide a stub implementation in QEMU
* the SoC's bus fabric really doesn't pass aborts back to the CPU; I think this is unlikely, but you can model it at the SoC level with a suitable default memory region

Quoted 1 line

well, that is case it seems.

If it is, then we should model the SoC that way, ie find out from the hardware docs what part of the bus fabric ignores decode errors and use memory regions with the right default behaviour to cover the relevant address ranges.

Quoted 8 lines
Quoted 3 lines

The addresses generating memory fault errors are all in the region where the BMC SPI Flash Memory is mapped :
[ 20000000-2FFFFFFF ]

If there's an actual flash device there then this sounds like my first case above, where we just need to stub out that range of addresses until we get round to really implementing the flash device.

but it is implemented ! and the region available.

C.

#14 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

In reply to Cédric Le Goater
Quoted 66 lines · Cédric Le Goater
Quoted 56 lines · Andrew Jeffery
Quoted 55 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

Quoted 1 line
Quoted 1 line
Quoted 1 line

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

 1 file changed, 49 insertions(+)

hw/arm/aspeed.c +1 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
      PALMETTO_BMC,
      AST2500_EVB,
      ROMULUS_BMC,
+    WITHERSPOON_BMC,
  };


 /* Palmetto hardware value: 0x120CE416 */

hw/arm/aspeed.c +0 -0
@@ -83,8 +84,12 @@ enum {
          SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
          SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))

hw/arm/aspeed.c +3 -0
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+

 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); static void ast2500_evb_i2c_init(AspeedBoardState *bmc); +static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC] = {

hw/arm/aspeed.c +8 -0
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
          .spi_model = "mx66l1g45g",
          .num_cs    = 2,
      },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
  };


 #define FIRMWARE_ADDR 0x0

hw/arm/aspeed.c +0 -0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
      .class_init = romulus_bmc_class_init,
  };

hw/arm/aspeed.c +2 -0
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
Quoted 8 lines

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 360

Quoted 6 lines

+    AspeedSoCState *soc = &bmc->soc;

hw/arm/aspeed.c +5 -0
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);

Looks like I need to track down newer versions of the schematics I have.

Quoted 1 line

the device on the board is a tmp275 but the tmp105 model is compatible.

It neither device is listed in the version I have :)

Andrew

#15 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 67 lines · Andrew Jeffery
Quoted 66 lines · Cédric Le Goater
Quoted 64 lines · Andrew Jeffery
Quoted 53 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

Quoted 1 line
Quoted 1 line
Quoted 1 line

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

 1 file changed, 49 insertions(+)

hw/arm/aspeed.c +1 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
      PALMETTO_BMC,
      AST2500_EVB,
      ROMULUS_BMC,
+    WITHERSPOON_BMC,
  };


 /* Palmetto hardware value: 0x120CE416 */

hw/arm/aspeed.c +0 -0
@@ -83,8 +84,12 @@ enum {
          SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
          SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))

hw/arm/aspeed.c +3 -0
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+

 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); static void ast2500_evb_i2c_init(AspeedBoardState *bmc); +static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC] = {

hw/arm/aspeed.c +8 -0
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
          .spi_model = "mx66l1g45g",
          .num_cs    = 2,
      },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
  };


 #define FIRMWARE_ADDR 0x0

hw/arm/aspeed.c +0 -0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
      .class_init = romulus_bmc_class_init,
  };

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 360

Quoted 8 lines
hw/arm/aspeed.c +8 -0
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);

Looks like I need to track down newer versions of the schematics I have.

Quoted 3 lines
Quoted 1 line

the device on the board is a tmp275 but the tmp105 model is compatible.

It neither device is listed in the version I have :)

Here is my source :

	https://github.com/openbmc/linux/blob/dev-4.10/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts#L504

C.

#16 lore raw

Re: [Qemu-arm] [PATCH v2 1/6] aspeed: add support for the witherspoon-bmc board

Quoted 69 lines · Cédric Le Goater
Quoted 68 lines · Andrew Jeffery
Quoted 67 lines · Cédric Le Goater
Quoted 65 lines · Andrew Jeffery
Quoted 54 lines · Cédric Le Goater

The Witherspoon boards are OpenPOWER system hosting POWER9 Processors. Let's add support for their BMC including a couple of I2C devices as found on real HW.

Quoted 1 line
Quoted 1 line
Quoted 1 line

---
 hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

 1 file changed, 49 insertions(+)

hw/arm/aspeed.c +1 -0
index ab895ad490af..81f522f711ae 100644
@@ -46,6 +46,7 @@ enum {
      PALMETTO_BMC,
      AST2500_EVB,
      ROMULUS_BMC,
+    WITHERSPOON_BMC,
  };


 /* Palmetto hardware value: 0x120CE416 */

hw/arm/aspeed.c +0 -0
@@ -83,8 +84,12 @@ enum {
          SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
          SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))

hw/arm/aspeed.c +3 -0
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
+

 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); static void ast2500_evb_i2c_init(AspeedBoardState *bmc); +static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
 static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC] = {

hw/arm/aspeed.c +8 -0
@@ -110,6 +115,14 @@ static const AspeedBoardConfig aspeed_boards[] = {
          .spi_model = "mx66l1g45g",
          .num_cs    = 2,
      },
+    [WITHERSPOON_BMC]  = {
+        .soc_name  = "ast2500-a1",
+        .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
+        .fmc_model = "mx25l25635e",
+        .spi_model = "mx66l1g45g",
+        .num_cs    = 2,
+        .i2c_init  = witherspoon_bmc_i2c_init,
+    },
  };


 #define FIRMWARE_ADDR 0x0

hw/arm/aspeed.c +0 -0
@@ -337,11 +350,47 @@ static const TypeInfo romulus_bmc_type = {
      .class_init = romulus_bmc_class_init,
  };

hw/arm/aspeed.c static const TypeInfo romulus_bmc_type = { · line 360

Quoted 8 lines
hw/arm/aspeed.c +8 -0
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
+
+    i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);

Looks like I need to track down newer versions of the schematics I have.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

the device on the board is a tmp275 but the tmp105 model is compatible.

It neither device is listed in the version I have :)

Here is my source :

	https://github.com/openbmc/linux/blob/dev-4.10/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts#L504

Yeah, I ended up jumping on a machine and verifying the device was on the bus.

Cheers,

Andrew