aspeed: add a witherspoon-bmc machine
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.
Cédric Le Goater (5):
aspeed: add support for the witherspoon-bmc board
aspeed: add an I2C RTC device to all machines
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 | 92 +++++++++++++++++ hw/misc/Makefile.objs | 1 + hw/misc/pca9552.c | 212 ++++++++++++++++++++++++++++++++++++++++ include/hw/misc/pca9552.h | 32 ++++++ 5 files changed, 338 insertions(+) create mode 100644 hw/misc/pca9552.c create mode 100644 include/hw/misc/pca9552.h
Signature · 1 line
2.13.5
PATCH 1/5 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
@@ -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
PATCH 2/5 aspeed: add an I2C RTC device to all machines
In reply to Cédric Le GoaterThe 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
@@ -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
PATCH 3/5 aspeed: Add EEPROM I2C devices
In reply to Cédric Le GoaterThe Aspeed boards have at least one EEPROM to hold the Vital Product Data (VPD).
--- hw/arm/aspeed.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
hw/arm/aspeed.c +20 -0
@@ -251,6 +251,17 @@ static void aspeed_board_init(MachineState *machine,arm_load_kernel (ARM_CPU (first_cpu), &aspeed_board_binfo); } +static void aspeed_i2c_add_eeprom (I2CBus *bus,uint8_t address,size_t size) +{ +uint8_t *eeprom_buf =g_malloc0 (size); +DeviceState *dev; + + dev =qdev_create ((BusState *) bus,"smbus-eeprom" ); +qdev_prop_set_uint8 (dev,"address" , address); +qdev_prop_set_ptr (dev,"data" , eeprom_buf); +qdev_init_nofail (dev); +} +static void palmetto_bmc_i2c_init (AspeedBoardState *bmc) {AspeedSoCState *soc = &bmc->soc;
@@ -260,6 +271,9 @@ 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 ); +aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),0 ),0x50 , +256 *1024 ); +/* add a TMP423 temperature sensor */ dev =i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),2 ),"tmp423" ,0x4c );
@@ -298,6 +312,9 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) {AspeedSoCState *soc = &bmc->soc; +aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),3 ),0x50 , +8 *1024 ); +/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),7 ),"tmp105" ,0x4d );
@@ -377,6 +394,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 ); + +aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),11 ),0x51 , +8 *1024 ); }static void witherspoon_bmc_init (MachineState *machine)
Signature · 1 line
2.13.5
Re: [Qemu-arm] [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices
Hi Cédric,
Quoted 15 lines · Cédric Le Goater
The Aspeed boards have at least one EEPROM to hold the Vital Product Data (VPD).
Signed-off-by Cédric Le Goater <[email protected]>--- hw/arm/aspeed.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)hw/arm/aspeed.c +0
-0@@ -251,6 +251,17 @@ static void aspeed_board_init(MachineState *machine,arm_load_kernel (ARM_CPU (first_cpu), &aspeed_board_binfo); }
hw/arm/aspeed.c static void aspeed_board_init(MachineState *machine, · line 262
Quoted 10 lines
hw/arm/aspeed.c +9
-0+static void aspeed_i2c_add_eeprom (I2CBus *bus,uint8_t address,size_t size) +{ +uint8_t *eeprom_buf =g_malloc0 (size); +DeviceState *dev; + + dev =qdev_create ((BusState *) bus,"smbus-eeprom" ); +qdev_prop_set_uint8 (dev,"address" , address); +qdev_prop_set_ptr (dev,"data" , eeprom_buf); +qdev_init_nofail (dev);
Can you merge this with smbus_eeprom_init() ?
I think the cleaner way would be add "include/hw/i2c/eeprom.h" defining SMB_EEPROM_TYPE "smbus-eeprom" and declare smbus_eeprom_init() there or as inlined.
Quoted 36 lines
hw/arm/aspeed.c +11
-0+} +static void palmetto_bmc_i2c_init (AspeedBoardState *bmc) {AspeedSoCState *soc = &bmc->soc;@@ -260,6 +271,9 @@ 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 ); +aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),0 ),0x50 , +256 *1024 ); +/* add a TMP423 temperature sensor */ dev =i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),2 ),"tmp423" ,0x4c );@@ -298,6 +312,9 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) {AspeedSoCState *soc = &bmc->soc; +aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),3 ),0x50 , +8 *1024 ); +/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),7 ),"tmp105" ,0x4d );@@ -377,6 +394,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 ); + +aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),11 ),0x51 , +8 *1024 ); }static void witherspoon_bmc_init (MachineState *machine)
Re: [Qemu-arm] [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices
Quoted 22 lines · Philippe Mathieu-Daudé
Hi Cédric,
Quoted 19 lines · Cédric Le Goater
The Aspeed boards have at least one EEPROM to hold the Vital Product Data (VPD).
Signed-off-by Cédric Le Goater <[email protected]>---
hw/arm/aspeed.c| 20 ++++++++++++++++++++1 file changed, 20 insertions(+)hw/arm/aspeed.c +3
-0@@ -251,6 +251,17 @@ static void aspeed_board_init(MachineState *machine, arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo); } +static void aspeed_i2c_add_eeprom(I2CBus *bus, uint8_t address, size_t size) +{ + uint8_t *eeprom_buf = g_malloc0(size); + DeviceState *dev;
Quoted 8 lines
hw/arm/aspeed.c static void aspeed_board_init(MachineState *machine, · line 262
Quoted 5 lines
hw/arm/aspeed.c +5
-0+ + dev = qdev_create((BusState *) bus, "smbus-eeprom"); + qdev_prop_set_uint8(dev, "address", address); + qdev_prop_set_ptr(dev, "data", eeprom_buf); + qdev_init_nofail(dev);Can you merge this with
smbus_eeprom_init()?
I think the cleaner way would be add "include/hw/i2c/eeprom.h" definingSMB_EEPROM_TYPE"smbus-eeprom" and declaresmbus_eeprom_init()there or as inlined.
yes. That would remove some duplicated code.
I will wait for some feedback before doing a resend or a followup.
Thanks,
C.
Quoted 33 lines
Quoted 33 lines
hw/arm/aspeed.c +6
-0+} + static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) { AspeedSoCState *soc = &bmc->soc;@@ -260,6 +271,9 @@ 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); + aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50, + 256 * 1024); + /* add a TMP423 temperature sensor */ dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp423", 0x4c);@@ -298,6 +312,9 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) { AspeedSoCState *soc = &bmc->soc; + aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50, + 8 * 1024); + /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d); @@ -377,6 +394,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); +
+ aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11),0x51, + 8 * 1024);
}
static voidwitherspoon_bmc_init(MachineState *machine)
PATCH 4/5 misc: add pca9552 LED blinker model
In reply to Cédric Le GoaterSpecs 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
@@ -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
@@ -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
@@ -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
Re: [Qemu-devel] [Qemu-arm] [PATCH 4/5] misc: add pca9552 LED blinker model
Quoted 8 lines · Cédric Le Goater
Specs are available here :
https://www.nxp.com/docs/en/data-sheet/PCA9552.pdfThis 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.
Quoted 6 lines
Signed-off-by Cédric Le Goater <[email protected]>--- default-configs/arm-softmmu.mak | 1 + hw/misc/Makefile.objs | 1 + hw/misc/pca9552.c | 212 ++++++++++++++++++++++++++++++++++++++++ include/hw/misc/pca9552.h | 32 ++++++
I'd rather move it to hw/display/
Quoted 3 lines
4 files changed, 246 insertions(+)create mode 100644
hw/misc/pca9552.c
create mode 100644include/hw/misc/pca9552.h
Re: [Qemu-arm] [PATCH 4/5] misc: add pca9552 LED blinker model
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 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.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Cédric Le Goater <[email protected]>---
default-configs/arm-softmmu.mak | 1 +
hw/misc/Makefile.objs | 1 +
hw/misc/pca9552.c | 212 ++++++++++++++++++++++++++++++++++++++++ include/hw/misc/pca9552.h | 32 ++++++I'd rather move it to hw/display/
The device is not related to displays. It is just an I2C expander chip. I would leave it under misc/
C.
Quoted 4 lines
Quoted 4 lines
4 files changed, 246 insertions(+)create mode 100644
hw/misc/pca9552.c
create mode 100644include/hw/misc/pca9552.h
PATCH 5/5 aspeed: add the pc9552 chips to the witherspoon machine
In reply to Cédric Le GoaterThe 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
@@ -386,6 +386,8 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) {AspeedSoCState *soc = &bmc->soc; +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 );
@@ -397,6 +399,8 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)aspeed_i2c_add_eeprom (aspeed_i2c_get_bus (DEVICE (&soc->i2c),11 ),0x51 ,8 *1024 ); +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