aspeed: add a witherspoon-bmc machine
v5 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 v4:
- use a ROM memory region
Changes since v3:
- introduce a dummy ROM device to catch invalid writes
- removed 'ignore_memory_transaction_failures' on all Aspeed machines
- reworked PCA9552 device :
. simpler I2C handles
. auto-increment support
. unit test
Changes since v2:
- removed comments on the I2C buffer size pf the PCA9552 device.
- removed 'ignore_memory_transaction_failures' flag on the witherspoon machine.
Changes since v1:
- introduced smbus_eeprom_init_one()
Cédric Le Goater (8):
aspeed: use a ROM memory region to catch invalid writes
aspeed: remove ignore_memory_transaction_failures all boards
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 | 110 ++++++++++++++++- hw/i2c/smbus_eeprom.c | 16 ++- hw/misc/Makefile.objs | 1 + hw/misc/pca9552.c | 259 ++++++++++++++++++++++++++++++++++++++++ include/hw/i2c/smbus.h | 1 + include/hw/misc/pca9552.h | 33 +++++ tests/Makefile.include | 2 + tests/pca9552-test.c | 131 ++++++++++++++++++++ 9 files changed, 544 insertions(+), 10 deletions(-) create mode 100644 hw/misc/pca9552.c create mode 100644 include/hw/misc/pca9552.h create mode 100644 tests/pca9552-test.c
Signature · 1 line
2.13.6
PATCH v5 1/8 aspeed: use a ROM memory region to catch invalid writes
Some legacy firmwares access unimplemented addresses on the Aspeed SoC (old U-Boot code using variables in the bss when it shouldn't do). Let's use a ROM memory region to catch the invalid writes and support new boards without using the 'ignore_memory_transaction_failures' flag.
---
Changes since v4 :
- use a ROM memory region
hw/arm/aspeed.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
hw/arm/aspeed.c +20 -2
@@ -166,6 +166,23 @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, } } +/* +* This is to track invalid writes done in the ROM by some legacy +* firmwares +*/ +static void boot_rom_write (void *opaque,hwaddr offset,uint64_t value, +unsigned size) +{ +qemu_log_mask (LOG_GUEST_ERROR , +"%s: 0x%" HWADDR_PRIx" <- 0x%" PRIx64" [%u]\n" , + __func__, offset, value, size); +} + +static const MemoryRegionOps boot_rom_ops = { + .write = boot_rom_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; +static void aspeed_board_init (MachineState *machine,const AspeedBoardConfig *cfg) {
@@ -216,8 +233,9 @@ static void aspeed_board_init(MachineState *machine,* SoC and 128MB for the AST2500 SoC, which is twice as big as * needed by the flash modules of the Aspeed machines. */ -memory_region_init_rom_nomigrate (boot_rom,OBJECT (bmc),"aspeed.boot_rom" , - fl->size, &error_abort); +memory_region_init_rom_device (boot_rom,OBJECT (bmc), &boot_rom_ops, +NULL ,"aspeed.boot_rom" , fl->size, + &error_abort);memory_region_add_subregion (get_system_memory (),FIRMWARE_ADDR , boot_rom);write_boot_rom (drive0,FIRMWARE_ADDR , fl->size, &error_abort);
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v5 1/8] aspeed: use a ROM memory region to catch invalid writes
Quoted 6 lines · Cédric Le Goater
Some legacy firmwares access unimplemented addresses on the Aspeed SoC (old U-Boot code using variables in the bss when it shouldn't do). Let's use a ROM memory region to catch the invalid writes and support new boards without using the '
ignore_memory_transaction_failures' flag.
Quoted 6 lines
Signed-off-by Cédric Le Goater <[email protected]>---
Changes since v4 :
- use a ROM memory region
Probably worth mentioning in the commit message that this is a migration compatibility break for these boards.
Quoted 34 lines
hw/arm/aspeed.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)hw/arm/aspeed.c +17
-0@@ -166,6 +166,23 @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, } } +/* +* This is to track invalid writes done in the ROM by some legacy +* firmwares +*/ +static void boot_rom_write (void *opaque,hwaddr offset,uint64_t value, +unsigned size) +{ +qemu_log_mask (LOG_GUEST_ERROR , +"%s: 0x%" HWADDR_PRIx" <- 0x%" PRIx64" [%u]\n" , + __func__, offset, value, size); +} + +static const MemoryRegionOps boot_rom_ops = { + .write = boot_rom_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; +static void aspeed_board_init (MachineState *machine,const AspeedBoardConfig *cfg) {@@ -216,8 +233,9 @@ static void aspeed_board_init(MachineState *machine,* SoC and 128MB for the AST2500 SoC, which is twice as big as * needed by the flash modules of the Aspeed machines.
hw/arm/aspeed.c static void aspeed_board_init(MachineState *machine,
Quoted 10 lines
hw/arm/aspeed.c +3
-3*/ -memory_region_init_rom_nomigrate (boot_rom,OBJECT (bmc),"aspeed.boot_rom" , - fl->size, &error_abort); +memory_region_init_rom_device (boot_rom,OBJECT (bmc), &boot_rom_ops, +NULL ,"aspeed.boot_rom" , fl->size, + &error_abort);memory_region_add_subregion (get_system_memory (),FIRMWARE_ADDR , boot_rom);write_boot_rom (drive0,FIRMWARE_ADDR , fl->size, &error_abort); --
Don't you want to create the ROM device even if there happens not to be any contents specified by the user? The thing is still there in the SoC even if it's empty...
thanks
-- PMM
Re: [Qemu-arm] [PATCH v5 1/8] aspeed: use a ROM memory region to catch invalid writes
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Cédric Le Goater
Some legacy firmwares access unimplemented addresses on the Aspeed SoC (old U-Boot code using variables in the bss when it shouldn't do). Let's use a ROM memory region to catch the invalid writes and support new boards without using the '
ignore_memory_transaction_failures' flag.Signed-off-by Cédric Le Goater <[email protected]>---
Quoted 6 lines
Quoted 3 lines
Changes since v4 :
- use a ROM memory region
Probably worth mentioning in the commit message that this is a migration compatibility break for these boards.
ah. Indeed :/
I tend to forget about migration for these emulated machines but people are starting to use these Aspeed guests on large Intel hosts as if they were real BMCs. And so being able to change host is a valid requirement. I will add a comment.
Quoted 40 lines
Quoted 40 lines
hw/arm/aspeed.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)hw/arm/aspeed.c +20
-2@@ -166,6 +166,23 @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, } } +/* +* This is to track invalid writes done in the ROM by some legacy +* firmwares +*/ +static void boot_rom_write (void *opaque,hwaddr offset,uint64_t value, +unsigned size) +{ +qemu_log_mask (LOG_GUEST_ERROR , +"%s: 0x%" HWADDR_PRIx" <- 0x%" PRIx64" [%u]\n" , + __func__, offset, value, size); +} + +static const MemoryRegionOps boot_rom_ops = { + .write = boot_rom_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; +static void aspeed_board_init (MachineState *machine,const AspeedBoardConfig *cfg) {@@ -216,8 +233,9 @@ static void aspeed_board_init(MachineState *machine,* SoC and 128MB for the AST2500 SoC, which is twickende as big as * needed by the flash modules of the Aspeed machines. */ -memory_region_init_rom_nomigrate (boot_rom,OBJECT (bmc),"aspeed.boot_rom" , - fl->size, &error_abort); +memory_region_init_rom_device (boot_rom,OBJECT (bmc), &boot_rom_ops, +NULL ,"aspeed.boot_rom" , fl->size, + &error_abort);
Quoted 8 lines
hw/arm/aspeed.c static void aspeed_board_init(MachineState *machine,
Quoted 4 lines
hw/arm/aspeed.c +0
-1memory_region_add_subregion (get_system_memory (),FIRMWARE_ADDR , boot_rom);write_boot_rom (drive0,FIRMWARE_ADDR , fl->size, &error_abort); --Don't you want to create the ROM device even if there happens not to be any contents specified by the user? The thing is still there in the SoC even if it's empty...
Do you mean that we should create the boot ROM device even if there is no file backend ? I think so yes. Let's do a v6 :)
Thanks,
C.
Re: [Qemu-arm] [PATCH v5 1/8] aspeed: use a ROM memory region to catch invalid writes
In reply to Peter MaydellQuoted 10 lines · Peter Maydell
Quoted 9 lines · Cédric Le Goater
Some legacy firmwares access unimplemented addresses on the Aspeed SoC (old U-Boot code using variables in the bss when it shouldn't do). Let's use a ROM memory region to catch the invalid writes and support new boards without using the '
ignore_memory_transaction_failures' flag.Signed-off-by Cédric Le Goater <[email protected]>---
Quoted 6 lines
Quoted 3 lines
Changes since v4 :
- use a ROM memory region
Probably worth mentioning in the commit message that this is a migration compatibility break for these boards.
What about the eeprom_buf from patch 6 "Add EEPROM I2C devices"?
My understanding is a migrated board would resume with a zeroized eeprom, is this the expected behaviour?
Regards,
Phil.
Re: [Qemu-arm] [PATCH v5 1/8] aspeed: use a ROM memory region to catch invalid writes
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Peter Maydell
Quoted 12 lines · Cédric Le Goater
Some legacy firmwares access unimplemented addresses on the Aspeed SoC (old U-Boot code using variables in the bss when it shouldn't do). Let's use a ROM memory region to catch the invalid writes and support new boards without using the '
ignore_memory_transaction_failures' flag.Signed-off-by Cédric Le Goater <[email protected]>---
Changes since v4 :
- use a ROM memory region
Quoted 7 lines
Quoted 2 lines
Probably worth mentioning in the commit message that this is a migration compatibility break for these boards.
What about the
eeprom_buffrom patch 6 "Add EEPROM I2C devices"?My understanding is a migrated board would resume with a zeroized eeprom, is this the expected behaviour?
That would be probably the case. yes. As we don't populate the eeprom with VPD at machine init time and that migration is clearly not tested, I think we will address this issue later.
Thanks,
C.
PATCH v5 2/8 aspeed: remove ignore_memory_transaction_failures all boards
In reply to Cédric Le GoaterNow that we have a dummy ROM device catching the invalid writes, we can remove this flag and work on fixing the current firwmares still accessing unimplemented addresses.
--- hw/arm/aspeed.c | 3 --- 1 file changed, 3 deletions(-)
hw/arm/aspeed.c +0 -3
@@ -288,7 +288,6 @@ static void palmetto_bmc_class_init(ObjectClass *oc, void *data) mc->no_floppy =1 ; mc->no_cdrom =1 ; mc->no_parallel =1 ; - mc->ignore_memory_transaction_failures = true; }static const TypeInfo palmetto_bmc_type = {
@@ -321,7 +320,6 @@ static void ast2500_evb_class_init(ObjectClass *oc, void *data) mc->no_floppy =1 ; mc->no_cdrom =1 ; mc->no_parallel =1 ; - mc->ignore_memory_transaction_failures = true; }static const TypeInfo ast2500_evb_type = {
@@ -346,7 +344,6 @@ static void romulus_bmc_class_init(ObjectClass *oc, void *data) mc->no_floppy =1 ; mc->no_cdrom =1 ; mc->no_parallel =1 ; - mc->ignore_memory_transaction_failures = true; }static const TypeInfo romulus_bmc_type = {
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v5 2/8] aspeed: remove ignore_memory_transaction_failures all boards
Quoted 6 lines · Cédric Le Goater
Now that we have a dummy ROM device catching the invalid writes, we can remove this flag and work on fixing the current firwmares still accessing unimplemented addresses.
Signed-off-by Cédric Le Goater <[email protected]>---
thanks
-- PMM
PATCH v5 3/8 aspeed: add support for the witherspoon-bmc board
In reply to Cédric Le GoaterThe 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.
---
Changes since v2:
- removed 'ignore_memory_transaction_failures' flag on the machine.
- Added a comment on the I2C device used.
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
@@ -352,11 +365,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 ); + +/* The Witherspoon expects a TMP275 but a TMP105 is compatible */ +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 ; +} + +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.6
PATCH v5 4/8 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",
@@ -315,6 +317,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)
@@ -341,6 +347,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 ]);
@@ -374,6 +389,10 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)/* The Witherspoon expects a TMP275 but a TMP105 is compatible */ 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.6
PATCH v5 5/8 smbus: add a smbus_eeprom_init_one() routine
In reply to Cédric Le GoaterThis 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
@@ -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
@@ -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.6
PATCH v5 6/8 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hw/arm/aspeed.c +13 -0
@@ -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"
@@ -273,11 +274,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 );
@@ -314,6 +319,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 );
@@ -383,6 +392,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 );
@@ -393,6 +403,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.6
PATCH v5 7/8 misc: add pca9552 LED blinker model
In reply to Cédric Le GoaterSpecs are available here :
https://www.nxp.com/docs/en/application-note/AN264.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.
---
Changes since v3:
- introduced auto-increment support
- removed the buffer collecting bytes on the bus
- improved reset
- used extract32
- added a unit test
Changes since v2:
- removed comments on the I2C buffer size, but kept the array. I did not want to rewrite the buffer handling
default-configs/arm-softmmu.mak | 1 + hw/misc/Makefile.objs | 1 + hw/misc/pca9552.c | 259 ++++++++++++++++++++++++++++++++++++++++ include/hw/misc/pca9552.h | 33 +++++ tests/Makefile.include | 2 + tests/pca9552-test.c | 131 ++++++++++++++++++++ 6 files changed, 427 insertions(+) create mode 100644 hw/misc/pca9552.c create mode 100644 include/hw/misc/pca9552.h create mode 100644 tests/pca9552-test.c
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 +259 -0
259 lines not on this page · raw message
include/hw/misc/pca9552.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* 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 regs[PCA9552_NR_REGS ]; +uint8_t max_reg; +uint8_t nr_leds; +}PCA9552State ; + +#endif
tests/Makefile.include +2 -0
@@ -347,6 +347,7 @@ check-qtest-sparc64-y = tests/endianness-test$(EXESUF) check-qtest-sparc64-y += tests/prom-env-test$(EXESUF) check-qtest-arm-y = tests/tmp105-test$(EXESUF) +check-qtest-arm-y += tests/pca9552-test$(EXESUF) check-qtest-arm-y += tests/ds1338-test$(EXESUF) check-qtest-arm-y += tests/m25p80-test$(EXESUF) gcov-files-arm-y += hw/misc/tmp105.c
@@ -739,6 +740,7 @@ tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \ tests/boot-sector.o tests/acpi-utils.o $(libqos-obj-y) tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) +tests/pca9552-test$(EXESUF): tests/pca9552-test.o $(libqos-omap-obj-y) tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y) tests/m25p80-test$(EXESUF): tests/m25p80-test.o tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
tests/pca9552-test.c new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v5 7/8] misc: add pca9552 LED blinker model
Quoted 19 lines · Cédric Le Goater
Specs are available here :
https://www.nxp.com/docs/en/application-note/AN264.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.
Signed-off-by Cédric Le Goater <[email protected]>---
Changes since v3:
- introduced auto-increment support
- removed the buffer collecting bytes on the bus
- improved reset
- used extract32
- added a unit test
Quoted 5 lines
Changes since v2:
- removed comments on the I2C buffer size, but kept the array. I did not want to rewrite the buffer handling
thanks
-- PMM
PATCH v5 8/8 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
@@ -394,6 +394,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 );
@@ -406,6 +408,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.6
Quoted 11 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.
Quoted 8 lines
Changes since v4:
- use a ROM memory region
Changes since v3:
- introduce a dummy ROM device to catch invalid writes
- removed 'ignore_memory_transaction_failures' on all Aspeed machines
So that was a bad idea because old firwmares run load/store loops beyond the address space to guess how much RAM the SoC has.
I am wondering if it is possible to model the same behavior with a MMIO region (of a correct size depending on the max ram size of the SoC) and mapped beyond the RAM region to catch such accesses and keep 'ignore_memory_transaction_failures' to false.
Thanks,
C.
Quoted 39 lines
- reworked PCA9552 device :
. simpler I2C handles
. auto-increment support
. unit testChanges since v2:
- removed comments on the I2C buffer size pf the PCA9552 device.
- removed 'ignore_memory_transaction_failures' flag on the witherspoon machine.Changes since v1:
- introduced
smbus_eeprom_init_one()Cédric Le Goater (8):
aspeed: use a ROM memory region to catch invalid writes
aspeed: removeignore_memory_transaction_failuresall boards
aspeed: add support for the witherspoon-bmc board
aspeed: add an I2C RTC device to all machines
smbus: add asmbus_eeprom_init_one()routine
aspeed: Add EEPROM I2C devices
misc: add pca9552 LED blinker model
aspeed: add the pc9552 chips to the witherspoon machinedefault-configs/arm-softmmu.mak | 1 + hw/arm/aspeed.c | 110 ++++++++++++++++- hw/i2c/smbus_eeprom.c | 16 ++- hw/misc/Makefile.objs | 1 + hw/misc/pca9552.c | 259 ++++++++++++++++++++++++++++++++++++++++ include/hw/i2c/smbus.h | 1 + include/hw/misc/pca9552.h | 33 +++++ tests/Makefile.include | 2 + tests/pca9552-test.c | 131 ++++++++++++++++++++ 9 files changed, 544 insertions(+), 10 deletions(-) create mode 100644 hw/misc/pca9552.c create mode 100644 include/hw/misc/pca9552.h create mode 100644 tests/pca9552-test.c
Quoted 11 lines · Cédric Le Goater
Quoted 2 lines · Cédric Le Goater
- introduce a dummy ROM device to catch invalid writes
- removed 'ignore_memory_transaction_failures' on all Aspeed machinesSo that was a bad idea because old firwmares run load/store loops beyond the address space to guess how much RAM the SoC has.
I am wondering if it is possible to model the same behavior with a MMIO region (of a correct size depending on the max ram size of the SoC) and mapped beyond the RAM region to catch such accesses and keep '
ignore_memory_transaction_failures' to false.
Yeah, if the hardware genuinely ignores accesses to a particular region of the address space then you can model this with an appropriate background memory region. You just need to figure out what range of the address space it should apply to...
thanks
-- PMM