* [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example
@ 2023-01-14 17:01 Peter Delevoryas
2023-01-14 17:01 ` [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper Peter Delevoryas
` (6 more replies)
0 siblings, 7 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
This cleans up some of the code we have creating at24c-eeprom objects in the
Aspeed and Nuvoton files, and adds an example of how to initialize a FRUID
EEPROM with static data using I2C transfers.
Initially I was going to propose a patch to update the at24c-eeprom realize
function to incorporate static data, but then I realized I could just
accomplish the same thing using i2c_send in board reset. The patch at the end
demonstrates this.
Thanks,
Peter
Peter Delevoryas (6):
hw/nvram/eeprom_at24c: Add header w/ init helper
hw/arm/aspeed: Remove local copy of at24c_eeprom_init
hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init
hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init
hw/nvram/eeprom_at24c: Add I2C write helper
hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
hw/arm/aspeed.c | 154 +++++++++++++++++++-------------
hw/arm/npcm7xx_boards.c | 20 ++---
hw/nvram/eeprom_at24c.c | 25 ++++++
include/hw/nvram/eeprom_at24c.h | 12 +++
4 files changed, 135 insertions(+), 76 deletions(-)
create mode 100644 include/hw/nvram/eeprom_at24c.h
--
2.39.0
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
@ 2023-01-14 17:01 ` Peter Delevoryas
2023-01-16 11:13 ` Cédric Le Goater
2023-01-16 12:23 ` Philippe Mathieu-Daudé
2023-01-14 17:01 ` [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init Peter Delevoryas
` (5 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
hw/nvram/eeprom_at24c.c | 10 ++++++++++
include/hw/nvram/eeprom_at24c.h | 10 ++++++++++
2 files changed, 20 insertions(+)
create mode 100644 include/hw/nvram/eeprom_at24c.h
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 2d4d8b952f38..0c27eae2b354 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -12,6 +12,7 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "hw/i2c/i2c.h"
+#include "hw/nvram/eeprom_at24c.h"
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
#include "sysemu/block-backend.h"
@@ -128,6 +129,15 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
return 0;
}
+void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
+{
+ I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", address);
+ DeviceState *dev = DEVICE(i2c_dev);
+
+ qdev_prop_set_uint32(dev, "rom-size", rom_size);
+ i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
+}
+
static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
{
EEPROMState *ee = AT24C_EE(dev);
diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
new file mode 100644
index 000000000000..9d9cf212757c
--- /dev/null
+++ b/include/hw/nvram/eeprom_at24c.h
@@ -0,0 +1,10 @@
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
+#ifndef EEPROM_AT24C_H
+#define EEPROM_AT24C_H
+
+#include "hw/i2c/i2c.h"
+
+void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
+
+#endif
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
2023-01-14 17:01 ` [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper Peter Delevoryas
@ 2023-01-14 17:01 ` Peter Delevoryas
2023-01-16 11:13 ` Cédric Le Goater
2023-01-16 12:24 ` Philippe Mathieu-Daudé
2023-01-14 17:01 ` [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init Peter Delevoryas
` (4 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
hw/arm/aspeed.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 55f114ef729f..1f9799d4321e 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -17,6 +17,7 @@
#include "hw/i2c/i2c_mux_pca954x.h"
#include "hw/i2c/smbus_eeprom.h"
#include "hw/misc/pca9552.h"
+#include "hw/nvram/eeprom_at24c.h"
#include "hw/sensor/tmp105.h"
#include "hw/misc/led.h"
#include "hw/qdev-properties.h"
@@ -429,15 +430,6 @@ static void aspeed_machine_init(MachineState *machine)
arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
}
-static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
-{
- I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
- DeviceState *dev = DEVICE(i2c_dev);
-
- qdev_prop_set_uint32(dev, "rom-size", rsize);
- i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
-}
-
static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
{
AspeedSoCState *soc = &bmc->soc;
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
2023-01-14 17:01 ` [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper Peter Delevoryas
2023-01-14 17:01 ` [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init Peter Delevoryas
@ 2023-01-14 17:01 ` Peter Delevoryas
2023-01-16 11:14 ` Cédric Le Goater
2023-01-16 12:25 ` Philippe Mathieu-Daudé
2023-01-14 17:01 ` [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init Peter Delevoryas
` (3 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
hw/arm/aspeed.c | 95 ++++++++++++++++++++++---------------------------
1 file changed, 43 insertions(+), 52 deletions(-)
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 1f9799d4321e..c929c61d582a 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -660,15 +660,6 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
eeprom_buf);
}
-static void aspeed_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
-{
- I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
- DeviceState *dev = DEVICE(i2c_dev);
-
- qdev_prop_set_uint32(dev, "rom-size", rsize);
- i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
-}
-
static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
{
AspeedSoCState *soc = &bmc->soc;
@@ -701,7 +692,7 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
AspeedSoCState *soc = &bmc->soc;
I2CSlave *i2c_mux;
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
create_pca9552(soc, 3, 0x61);
@@ -714,9 +705,9 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
0x4a);
i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4),
"pca9546", 0x70);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB);
create_pca9552(soc, 4, 0x60);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105,
@@ -727,8 +718,8 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
create_pca9552(soc, 5, 0x61);
i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5),
"pca9546", 0x70);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105,
0x48);
@@ -738,10 +729,10 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
0x4b);
i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6),
"pca9546", 0x70);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB);
create_pca9552(soc, 7, 0x30);
create_pca9552(soc, 7, 0x31);
@@ -754,15 +745,15 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105,
0x48);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "max31785", 0x52);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105,
0x48);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105,
0x4a);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 64 * KiB);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 64 * KiB);
create_pca9552(soc, 8, 0x60);
create_pca9552(soc, 8, 0x61);
/* Bus 8: ucd90320@11 */
@@ -771,11 +762,11 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4d);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4d);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105,
0x48);
@@ -783,18 +774,18 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
0x49);
i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11),
"pca9546", 0x70);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
- aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+ at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
create_pca9552(soc, 11, 0x60);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB);
create_pca9552(soc, 13, 0x60);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB);
create_pca9552(soc, 14, 0x60);
- aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB);
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB);
create_pca9552(soc, 15, 0x60);
}
@@ -838,45 +829,45 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4c);
i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4d);
- aspeed_eeprom_init(i2c[19], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[20], 0x50, 2 * KiB);
- aspeed_eeprom_init(i2c[22], 0x52, 2 * KiB);
+ at24c_eeprom_init(i2c[19], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[20], 0x50, 2 * KiB);
+ at24c_eeprom_init(i2c[22], 0x52, 2 * KiB);
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x48);
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x49);
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x4a);
i2c_slave_create_simple(i2c[3], TYPE_TMP422, 0x4c);
- aspeed_eeprom_init(i2c[8], 0x51, 64 * KiB);
+ at24c_eeprom_init(i2c[8], 0x51, 64 * KiB);
i2c_slave_create_simple(i2c[8], TYPE_LM75, 0x4a);
i2c_slave_create_simple(i2c[50], TYPE_LM75, 0x4c);
- aspeed_eeprom_init(i2c[50], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[50], 0x52, 64 * KiB);
i2c_slave_create_simple(i2c[51], TYPE_TMP75, 0x48);
i2c_slave_create_simple(i2c[52], TYPE_TMP75, 0x49);
i2c_slave_create_simple(i2c[59], TYPE_TMP75, 0x48);
i2c_slave_create_simple(i2c[60], TYPE_TMP75, 0x49);
- aspeed_eeprom_init(i2c[65], 0x53, 64 * KiB);
+ at24c_eeprom_init(i2c[65], 0x53, 64 * KiB);
i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x49);
i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x48);
- aspeed_eeprom_init(i2c[68], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[69], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[70], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[71], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[68], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[69], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[70], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[71], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[73], 0x53, 64 * KiB);
+ at24c_eeprom_init(i2c[73], 0x53, 64 * KiB);
i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x49);
i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x48);
- aspeed_eeprom_init(i2c[76], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[77], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[78], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[79], 0x52, 64 * KiB);
- aspeed_eeprom_init(i2c[28], 0x50, 2 * KiB);
+ at24c_eeprom_init(i2c[76], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[77], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[78], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[79], 0x52, 64 * KiB);
+ at24c_eeprom_init(i2c[28], 0x50, 2 * KiB);
for (int i = 0; i < 8; i++) {
- aspeed_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB);
+ at24c_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB);
i2c_slave_create_simple(i2c[82 + i * 8], TYPE_TMP75, 0x48);
i2c_slave_create_simple(i2c[83 + i * 8], TYPE_TMP75, 0x4b);
i2c_slave_create_simple(i2c[84 + i * 8], TYPE_TMP75, 0x4a);
@@ -947,11 +938,11 @@ static void fby35_i2c_init(AspeedMachineState *bmc)
i2c_slave_create_simple(i2c[12], TYPE_LM75, 0x4e);
i2c_slave_create_simple(i2c[12], TYPE_LM75, 0x4f);
- aspeed_eeprom_init(i2c[4], 0x51, 128 * KiB);
- aspeed_eeprom_init(i2c[6], 0x51, 128 * KiB);
- aspeed_eeprom_init(i2c[8], 0x50, 32 * KiB);
- aspeed_eeprom_init(i2c[11], 0x51, 128 * KiB);
- aspeed_eeprom_init(i2c[11], 0x54, 128 * KiB);
+ at24c_eeprom_init(i2c[4], 0x51, 128 * KiB);
+ at24c_eeprom_init(i2c[6], 0x51, 128 * KiB);
+ at24c_eeprom_init(i2c[8], 0x50, 32 * KiB);
+ at24c_eeprom_init(i2c[11], 0x51, 128 * KiB);
+ at24c_eeprom_init(i2c[11], 0x54, 128 * KiB);
/*
* TODO: There is a multi-master i2c connection to an AST1030 MiniBMC on
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
` (2 preceding siblings ...)
2023-01-14 17:01 ` [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init Peter Delevoryas
@ 2023-01-14 17:01 ` Peter Delevoryas
2023-01-16 11:14 ` Cédric Le Goater
2023-01-16 12:26 ` Philippe Mathieu-Daudé
2023-01-14 17:01 ` [PATCH 5/6] hw/nvram/eeprom_at24c: Add I2C write helper Peter Delevoryas
` (2 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
hw/arm/npcm7xx_boards.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index 6bc6f5d2fe29..9b31207a06e9 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -21,6 +21,7 @@
#include "hw/i2c/i2c_mux_pca954x.h"
#include "hw/i2c/smbus_eeprom.h"
#include "hw/loader.h"
+#include "hw/nvram/eeprom_at24c.h"
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
@@ -140,17 +141,6 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc, uint32_t num)
return I2C_BUS(qdev_get_child_bus(DEVICE(&soc->smbus[num]), "i2c-bus"));
}
-static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr,
- uint32_t rsize)
-{
- I2CBus *i2c_bus = npcm7xx_i2c_get_bus(soc, bus);
- I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
- DeviceState *dev = DEVICE(i2c_dev);
-
- qdev_prop_set_uint32(dev, "rom-size", rsize);
- i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
-}
-
static void npcm7xx_init_pwm_splitter(NPCM7xxMachine *machine,
NPCM7xxState *soc, const int *fan_counts)
{
@@ -253,8 +243,8 @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc)
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x5c);
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x5c);
- at24c_eeprom_init(soc, 9, 0x55, 8192);
- at24c_eeprom_init(soc, 10, 0x55, 8192);
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 9), 0x55, 8192);
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 10), 0x55, 8192);
/*
* i2c-11:
@@ -360,7 +350,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77);
- at24c_eeprom_init(soc, 4, 0x50, 8192); /* mbfru */
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 4), 0x50, 8192); /* mbfru */
i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 13),
TYPE_PCA9548, 0x77);
@@ -371,7 +361,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x48);
i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x49);
- at24c_eeprom_init(soc, 14, 0x55, 8192); /* bmcfru */
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 14), 0x55, 8192); /* bmcfru */
/* TODO: Add remaining i2c devices. */
}
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 5/6] hw/nvram/eeprom_at24c: Add I2C write helper
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
` (3 preceding siblings ...)
2023-01-14 17:01 ` [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init Peter Delevoryas
@ 2023-01-14 17:01 ` Peter Delevoryas
2023-01-14 17:01 ` [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM Peter Delevoryas
2023-01-14 17:07 ` [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
6 siblings, 0 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
hw/nvram/eeprom_at24c.c | 15 +++++++++++++++
include/hw/nvram/eeprom_at24c.h | 2 ++
2 files changed, 17 insertions(+)
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 0c27eae2b354..69565a420c28 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "qemu/bitops.h"
#include "qemu/module.h"
#include "hw/i2c/i2c.h"
#include "hw/nvram/eeprom_at24c.h"
@@ -138,6 +139,20 @@ void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
}
+void at24c_eeprom_write(I2CBus *bus, uint8_t address, uint16_t offset,
+ const uint8_t *buf, uint32_t len)
+{
+ int i;
+
+ i2c_start_send(bus, address);
+ i2c_send(bus, extract16(offset, 8, 8));
+ i2c_send(bus, extract16(offset, 0, 8));
+ for (i = 0; i < len; i++) {
+ i2c_send(bus, buf[i]);
+ }
+ i2c_end_transfer(bus);
+}
+
static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
{
EEPROMState *ee = AT24C_EE(dev);
diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
index 9d9cf212757c..bbca73a07ad1 100644
--- a/include/hw/nvram/eeprom_at24c.h
+++ b/include/hw/nvram/eeprom_at24c.h
@@ -6,5 +6,7 @@
#include "hw/i2c/i2c.h"
void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
+void at24c_eeprom_write(I2CBus *bus, uint8_t address, uint16_t offset,
+ const uint8_t *buf, uint32_t len);
#endif
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
` (4 preceding siblings ...)
2023-01-14 17:01 ` [PATCH 5/6] hw/nvram/eeprom_at24c: Add I2C write helper Peter Delevoryas
@ 2023-01-14 17:01 ` Peter Delevoryas
2023-01-16 12:30 ` Philippe Mathieu-Daudé
2023-01-16 12:42 ` Cédric Le Goater
2023-01-14 17:07 ` [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
6 siblings, 2 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:01 UTC (permalink / raw)
Cc: patrick, peter, clg, peter.maydell, andrew, joal, hskinnemoen,
kfting, qemu-arm, qemu-devel
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index c929c61d582a..4ac8ff11a835 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
}
+static const uint8_t fby35_bmc_fruid[] = {
+ 0x01, 0x00, 0x00, 0x01, 0x0d, 0x00, 0x00, 0xf1, 0x01, 0x0c, 0x00, 0x36,
+ 0xe6, 0xd0, 0xc6, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x42, 0x4d,
+ 0x43, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20, 0x4d, 0x6f,
+ 0x64, 0x75, 0x6c, 0x65, 0xcd, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e,
+ 0x30, 0xc9, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc1, 0x39, 0x01, 0x0c, 0x00, 0xc6,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x59, 0x6f, 0x73, 0x65, 0x6d,
+ 0x69, 0x74, 0x65, 0x20, 0x56, 0x33, 0x2e, 0x35, 0x20, 0x45, 0x56, 0x54,
+ 0x32, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
+ 0x58, 0x58, 0x58, 0x58, 0xc4, 0x45, 0x56, 0x54, 0x32, 0xcd, 0x58, 0x58,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc7,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e, 0x30, 0xc9,
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc8, 0x43, 0x6f,
+ 0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
static void fby35_i2c_init(AspeedMachineState *bmc)
{
AspeedSoCState *soc = &bmc->soc;
@@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
+
+ at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
+ 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
}
static void aspeed_machine_fby35_class_init(ObjectClass *oc, void *data)
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
` (5 preceding siblings ...)
2023-01-14 17:01 ` [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM Peter Delevoryas
@ 2023-01-14 17:07 ` Peter Delevoryas
6 siblings, 0 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-14 17:07 UTC (permalink / raw)
To: patrick, clg, peter.maydell, andrew, hskinnemoen, kfting,
qemu-arm, qemu-devel
On Sat, Jan 14, 2023 at 09:01:45AM -0800, Peter Delevoryas wrote:
> This cleans up some of the code we have creating at24c-eeprom objects in the
> Aspeed and Nuvoton files, and adds an example of how to initialize a FRUID
> EEPROM with static data using I2C transfers.
>
> Initially I was going to propose a patch to update the at24c-eeprom realize
> function to incorporate static data, but then I realized I could just
> accomplish the same thing using i2c_send in board reset. The patch at the end
> demonstrates this.
1. I messed up Joel's email on this thread, sorry about that.
2. I forgot to post the output of the test I used to verify this:
qemu-system-aarch64 -machine fby35-bmc -nographic -mtdblock flash-fby35
...
root@bmc-oob:~# fruid-util bmc
FRU Information : BMC
--------------- : ------------------
Board Mfg Date : Mon Jan 10 21:42:00 2022
Board Mfg : XXXXXX
Board Product : BMC Storage Module
Board Serial : XXXXXXXXXXXXX
Board Part Number : XXXXXXXXXXXXXX
Board FRU ID : 1.0
Board Custom Data 1 : XXXXXXXXX
Board Custom Data 2 : XXXXXXXXXXXXXXXXXX
Product Manufacturer : XXXXXX
Product Name : Yosemite V3.5 EVT2
Product Part Number : XXXXXXXXXXXXXX
Product Version : EVT2
Product Serial : XXXXXXXXXXXXX
Product Asset Tag : XXXXXXX
Product FRU ID : 1.0
Product Custom Data 1 : XXXXXXXXX
Product Custom Data 2 : Config A
A reference flash-fby35 image can be found here:
https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
>
> Thanks,
> Peter
>
> Peter Delevoryas (6):
> hw/nvram/eeprom_at24c: Add header w/ init helper
> hw/arm/aspeed: Remove local copy of at24c_eeprom_init
> hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init
> hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init
> hw/nvram/eeprom_at24c: Add I2C write helper
> hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
>
> hw/arm/aspeed.c | 154 +++++++++++++++++++-------------
> hw/arm/npcm7xx_boards.c | 20 ++---
> hw/nvram/eeprom_at24c.c | 25 ++++++
> include/hw/nvram/eeprom_at24c.h | 12 +++
> 4 files changed, 135 insertions(+), 76 deletions(-)
> create mode 100644 include/hw/nvram/eeprom_at24c.h
>
> --
> 2.39.0
>
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper
2023-01-14 17:01 ` [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper Peter Delevoryas
@ 2023-01-16 11:13 ` Cédric Le Goater
2023-01-16 12:23 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 24+ messages in thread
From: Cédric Le Goater @ 2023-01-16 11:13 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, peter.maydell, andrew, joel, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 1/14/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Please add some short commit log explaining how the helper could be useful.
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> hw/nvram/eeprom_at24c.c | 10 ++++++++++
> include/hw/nvram/eeprom_at24c.h | 10 ++++++++++
> 2 files changed, 20 insertions(+)
> create mode 100644 include/hw/nvram/eeprom_at24c.h
>
> diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
> index 2d4d8b952f38..0c27eae2b354 100644
> --- a/hw/nvram/eeprom_at24c.c
> +++ b/hw/nvram/eeprom_at24c.c
> @@ -12,6 +12,7 @@
> #include "qapi/error.h"
> #include "qemu/module.h"
> #include "hw/i2c/i2c.h"
> +#include "hw/nvram/eeprom_at24c.h"
> #include "hw/qdev-properties.h"
> #include "hw/qdev-properties-system.h"
> #include "sysemu/block-backend.h"
> @@ -128,6 +129,15 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
> return 0;
> }
>
> +void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
> +{
> + I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", address);
> + DeviceState *dev = DEVICE(i2c_dev);
> +
> + qdev_prop_set_uint32(dev, "rom-size", rom_size);
> + i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> +}
> +
> static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
> {
> EEPROMState *ee = AT24C_EE(dev);
> diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
> new file mode 100644
> index 000000000000..9d9cf212757c
> --- /dev/null
> +++ b/include/hw/nvram/eeprom_at24c.h
> @@ -0,0 +1,10 @@
> +/* Copyright (c) Meta Platforms, Inc. and affiliates. */
> +
> +#ifndef EEPROM_AT24C_H
> +#define EEPROM_AT24C_H
> +
> +#include "hw/i2c/i2c.h"
> +
> +void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
> +
> +#endif
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init
2023-01-14 17:01 ` [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init Peter Delevoryas
@ 2023-01-16 11:13 ` Cédric Le Goater
2023-01-16 12:24 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 24+ messages in thread
From: Cédric Le Goater @ 2023-01-16 11:13 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, peter.maydell, andrew, joel, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 1/14/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> hw/arm/aspeed.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 55f114ef729f..1f9799d4321e 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -17,6 +17,7 @@
> #include "hw/i2c/i2c_mux_pca954x.h"
> #include "hw/i2c/smbus_eeprom.h"
> #include "hw/misc/pca9552.h"
> +#include "hw/nvram/eeprom_at24c.h"
> #include "hw/sensor/tmp105.h"
> #include "hw/misc/led.h"
> #include "hw/qdev-properties.h"
> @@ -429,15 +430,6 @@ static void aspeed_machine_init(MachineState *machine)
> arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
> }
>
> -static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
> -{
> - I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> - DeviceState *dev = DEVICE(i2c_dev);
> -
> - qdev_prop_set_uint32(dev, "rom-size", rsize);
> - i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> -}
> -
> static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
> {
> AspeedSoCState *soc = &bmc->soc;
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init
2023-01-14 17:01 ` [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init Peter Delevoryas
@ 2023-01-16 11:14 ` Cédric Le Goater
2023-01-16 12:25 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 24+ messages in thread
From: Cédric Le Goater @ 2023-01-16 11:14 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, peter.maydell, andrew, joel, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 1/14/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> hw/arm/aspeed.c | 95 ++++++++++++++++++++++---------------------------
> 1 file changed, 43 insertions(+), 52 deletions(-)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 1f9799d4321e..c929c61d582a 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -660,15 +660,6 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
> eeprom_buf);
> }
>
> -static void aspeed_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
> -{
> - I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> - DeviceState *dev = DEVICE(i2c_dev);
> -
> - qdev_prop_set_uint32(dev, "rom-size", rsize);
> - i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> -}
> -
> static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
> {
> AspeedSoCState *soc = &bmc->soc;
> @@ -701,7 +692,7 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> AspeedSoCState *soc = &bmc->soc;
> I2CSlave *i2c_mux;
>
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
>
> create_pca9552(soc, 3, 0x61);
>
> @@ -714,9 +705,9 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> 0x4a);
> i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4),
> "pca9546", 0x70);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB);
> create_pca9552(soc, 4, 0x60);
>
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105,
> @@ -727,8 +718,8 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> create_pca9552(soc, 5, 0x61);
> i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5),
> "pca9546", 0x70);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
>
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105,
> 0x48);
> @@ -738,10 +729,10 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> 0x4b);
> i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6),
> "pca9546", 0x70);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB);
>
> create_pca9552(soc, 7, 0x30);
> create_pca9552(soc, 7, 0x31);
> @@ -754,15 +745,15 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105,
> 0x48);
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "max31785", 0x52);
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB);
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB);
>
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105,
> 0x48);
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105,
> 0x4a);
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 64 * KiB);
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 64 * KiB);
> create_pca9552(soc, 8, 0x60);
> create_pca9552(soc, 8, 0x61);
> /* Bus 8: ucd90320@11 */
> @@ -771,11 +762,11 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
>
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c);
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4d);
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
>
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c);
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4d);
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
>
> i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105,
> 0x48);
> @@ -783,18 +774,18 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> 0x49);
> i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11),
> "pca9546", 0x70);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> - aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
> + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
> create_pca9552(soc, 11, 0x60);
>
>
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB);
> create_pca9552(soc, 13, 0x60);
>
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB);
> create_pca9552(soc, 14, 0x60);
>
> - aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB);
> + at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB);
> create_pca9552(soc, 15, 0x60);
> }
>
> @@ -838,45 +829,45 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
> i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4c);
> i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4d);
>
> - aspeed_eeprom_init(i2c[19], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[20], 0x50, 2 * KiB);
> - aspeed_eeprom_init(i2c[22], 0x52, 2 * KiB);
> + at24c_eeprom_init(i2c[19], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[20], 0x50, 2 * KiB);
> + at24c_eeprom_init(i2c[22], 0x52, 2 * KiB);
>
> i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x48);
> i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x49);
> i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x4a);
> i2c_slave_create_simple(i2c[3], TYPE_TMP422, 0x4c);
>
> - aspeed_eeprom_init(i2c[8], 0x51, 64 * KiB);
> + at24c_eeprom_init(i2c[8], 0x51, 64 * KiB);
> i2c_slave_create_simple(i2c[8], TYPE_LM75, 0x4a);
>
> i2c_slave_create_simple(i2c[50], TYPE_LM75, 0x4c);
> - aspeed_eeprom_init(i2c[50], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[50], 0x52, 64 * KiB);
> i2c_slave_create_simple(i2c[51], TYPE_TMP75, 0x48);
> i2c_slave_create_simple(i2c[52], TYPE_TMP75, 0x49);
>
> i2c_slave_create_simple(i2c[59], TYPE_TMP75, 0x48);
> i2c_slave_create_simple(i2c[60], TYPE_TMP75, 0x49);
>
> - aspeed_eeprom_init(i2c[65], 0x53, 64 * KiB);
> + at24c_eeprom_init(i2c[65], 0x53, 64 * KiB);
> i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x49);
> i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x48);
> - aspeed_eeprom_init(i2c[68], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[69], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[70], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[71], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[68], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[69], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[70], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[71], 0x52, 64 * KiB);
>
> - aspeed_eeprom_init(i2c[73], 0x53, 64 * KiB);
> + at24c_eeprom_init(i2c[73], 0x53, 64 * KiB);
> i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x49);
> i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x48);
> - aspeed_eeprom_init(i2c[76], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[77], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[78], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[79], 0x52, 64 * KiB);
> - aspeed_eeprom_init(i2c[28], 0x50, 2 * KiB);
> + at24c_eeprom_init(i2c[76], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[77], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[78], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[79], 0x52, 64 * KiB);
> + at24c_eeprom_init(i2c[28], 0x50, 2 * KiB);
>
> for (int i = 0; i < 8; i++) {
> - aspeed_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB);
> + at24c_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB);
> i2c_slave_create_simple(i2c[82 + i * 8], TYPE_TMP75, 0x48);
> i2c_slave_create_simple(i2c[83 + i * 8], TYPE_TMP75, 0x4b);
> i2c_slave_create_simple(i2c[84 + i * 8], TYPE_TMP75, 0x4a);
> @@ -947,11 +938,11 @@ static void fby35_i2c_init(AspeedMachineState *bmc)
> i2c_slave_create_simple(i2c[12], TYPE_LM75, 0x4e);
> i2c_slave_create_simple(i2c[12], TYPE_LM75, 0x4f);
>
> - aspeed_eeprom_init(i2c[4], 0x51, 128 * KiB);
> - aspeed_eeprom_init(i2c[6], 0x51, 128 * KiB);
> - aspeed_eeprom_init(i2c[8], 0x50, 32 * KiB);
> - aspeed_eeprom_init(i2c[11], 0x51, 128 * KiB);
> - aspeed_eeprom_init(i2c[11], 0x54, 128 * KiB);
> + at24c_eeprom_init(i2c[4], 0x51, 128 * KiB);
> + at24c_eeprom_init(i2c[6], 0x51, 128 * KiB);
> + at24c_eeprom_init(i2c[8], 0x50, 32 * KiB);
> + at24c_eeprom_init(i2c[11], 0x51, 128 * KiB);
> + at24c_eeprom_init(i2c[11], 0x54, 128 * KiB);
>
> /*
> * TODO: There is a multi-master i2c connection to an AST1030 MiniBMC on
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init
2023-01-14 17:01 ` [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init Peter Delevoryas
@ 2023-01-16 11:14 ` Cédric Le Goater
2023-01-16 12:26 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 24+ messages in thread
From: Cédric Le Goater @ 2023-01-16 11:14 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, peter.maydell, andrew, joel, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 1/14/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> hw/arm/npcm7xx_boards.c | 20 +++++---------------
> 1 file changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
> index 6bc6f5d2fe29..9b31207a06e9 100644
> --- a/hw/arm/npcm7xx_boards.c
> +++ b/hw/arm/npcm7xx_boards.c
> @@ -21,6 +21,7 @@
> #include "hw/i2c/i2c_mux_pca954x.h"
> #include "hw/i2c/smbus_eeprom.h"
> #include "hw/loader.h"
> +#include "hw/nvram/eeprom_at24c.h"
> #include "hw/qdev-core.h"
> #include "hw/qdev-properties.h"
> #include "qapi/error.h"
> @@ -140,17 +141,6 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc, uint32_t num)
> return I2C_BUS(qdev_get_child_bus(DEVICE(&soc->smbus[num]), "i2c-bus"));
> }
>
> -static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr,
> - uint32_t rsize)
> -{
> - I2CBus *i2c_bus = npcm7xx_i2c_get_bus(soc, bus);
> - I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> - DeviceState *dev = DEVICE(i2c_dev);
> -
> - qdev_prop_set_uint32(dev, "rom-size", rsize);
> - i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
> -}
> -
> static void npcm7xx_init_pwm_splitter(NPCM7xxMachine *machine,
> NPCM7xxState *soc, const int *fan_counts)
> {
> @@ -253,8 +243,8 @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc)
> i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x5c);
> i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x5c);
>
> - at24c_eeprom_init(soc, 9, 0x55, 8192);
> - at24c_eeprom_init(soc, 10, 0x55, 8192);
> + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 9), 0x55, 8192);
> + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 10), 0x55, 8192);
>
> /*
> * i2c-11:
> @@ -360,7 +350,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
>
> i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77);
>
> - at24c_eeprom_init(soc, 4, 0x50, 8192); /* mbfru */
> + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 4), 0x50, 8192); /* mbfru */
>
> i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 13),
> TYPE_PCA9548, 0x77);
> @@ -371,7 +361,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
> i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x48);
> i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x49);
>
> - at24c_eeprom_init(soc, 14, 0x55, 8192); /* bmcfru */
> + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 14), 0x55, 8192); /* bmcfru */
>
> /* TODO: Add remaining i2c devices. */
> }
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper
2023-01-14 17:01 ` [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper Peter Delevoryas
2023-01-16 11:13 ` Cédric Le Goater
@ 2023-01-16 12:23 ` Philippe Mathieu-Daudé
2023-01-16 17:21 ` Peter Delevoryas
1 sibling, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-16 12:23 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 14/1/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> ---
> hw/nvram/eeprom_at24c.c | 10 ++++++++++
> include/hw/nvram/eeprom_at24c.h | 10 ++++++++++
> 2 files changed, 20 insertions(+)
> create mode 100644 include/hw/nvram/eeprom_at24c.h
> +void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
> +{
> + I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", address);
Please use the type definition: TYPE_AT24C_EE.
> + DeviceState *dev = DEVICE(i2c_dev);
> +
> + qdev_prop_set_uint32(dev, "rom-size", rom_size);
> + i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
Although the allocated object is somehow reachable from the i2c bus
object, it would be simpler to deallocate allowing the parent to keep
a reference to it. So consider this prototype instead:
I2CSlave *at24c_eeprom_create(I2CBus *bus, uint8_t address,
uint32_t rom_size);
> +}
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init
2023-01-14 17:01 ` [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init Peter Delevoryas
2023-01-16 11:13 ` Cédric Le Goater
@ 2023-01-16 12:24 ` Philippe Mathieu-Daudé
2023-01-16 17:21 ` Peter Delevoryas
1 sibling, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-16 12:24 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 14/1/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> ---
> hw/arm/aspeed.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
> -static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
> -{
> - I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> - DeviceState *dev = DEVICE(i2c_dev);
> -
> - qdev_prop_set_uint32(dev, "rom-size", rsize);
> - i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> -}
Why not squash in previous commit as 'extract helper' change?
Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init
2023-01-14 17:01 ` [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init Peter Delevoryas
2023-01-16 11:14 ` Cédric Le Goater
@ 2023-01-16 12:25 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-16 12:25 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 14/1/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> ---
> hw/arm/aspeed.c | 95 ++++++++++++++++++++++---------------------------
> 1 file changed, 43 insertions(+), 52 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init
2023-01-14 17:01 ` [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init Peter Delevoryas
2023-01-16 11:14 ` Cédric Le Goater
@ 2023-01-16 12:26 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-16 12:26 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 14/1/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> ---
> hw/arm/npcm7xx_boards.c | 20 +++++---------------
> 1 file changed, 5 insertions(+), 15 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-14 17:01 ` [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM Peter Delevoryas
@ 2023-01-16 12:30 ` Philippe Mathieu-Daudé
2023-01-16 17:23 ` Peter Delevoryas
2023-01-16 12:42 ` Cédric Le Goater
1 sibling, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-16 12:30 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 14/1/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> ---
> hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c929c61d582a..4ac8ff11a835 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
> i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
> }
>
> +static const uint8_t fby35_bmc_fruid[] = {
[...]
> +};
> +
> static void fby35_i2c_init(AspeedMachineState *bmc)
> {
> AspeedSoCState *soc = &bmc->soc;
> @@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
> object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
> object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
> object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
> +
> + at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
> + 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
Why transfer the prom content on the i2c bus at each reset?
In particular this looks wrong if the prom is initialized with a 'drive'
block backend (using -global).
> }
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-14 17:01 ` [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM Peter Delevoryas
2023-01-16 12:30 ` Philippe Mathieu-Daudé
@ 2023-01-16 12:42 ` Cédric Le Goater
2023-01-16 17:19 ` Peter Delevoryas
1 sibling, 1 reply; 24+ messages in thread
From: Cédric Le Goater @ 2023-01-16 12:42 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, peter.maydell, andrew, joel, hskinnemoen, kfting,
qemu-arm, qemu-devel, Philippe Mathieu-Daudé
On 1/14/23 18:01, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> ---
> hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c929c61d582a..4ac8ff11a835 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
> i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
> }
>
> +static const uint8_t fby35_bmc_fruid[] = {
> + 0x01, 0x00, 0x00, 0x01, 0x0d, 0x00, 0x00, 0xf1, 0x01, 0x0c, 0x00, 0x36,
> + 0xe6, 0xd0, 0xc6, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x42, 0x4d,
> + 0x43, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20, 0x4d, 0x6f,
> + 0x64, 0x75, 0x6c, 0x65, 0xcd, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e,
> + 0x30, 0xc9, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc1, 0x39, 0x01, 0x0c, 0x00, 0xc6,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x59, 0x6f, 0x73, 0x65, 0x6d,
> + 0x69, 0x74, 0x65, 0x20, 0x56, 0x33, 0x2e, 0x35, 0x20, 0x45, 0x56, 0x54,
> + 0x32, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
> + 0x58, 0x58, 0x58, 0x58, 0xc4, 0x45, 0x56, 0x54, 0x32, 0xcd, 0x58, 0x58,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc7,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e, 0x30, 0xc9,
> + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc8, 0x43, 0x6f,
> + 0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
I would introduce a new aspeed_eeprom.c file for these definitions because
each machine could have its own set of eeproms and aspeed.c is already big
enough.
> static void fby35_i2c_init(AspeedMachineState *bmc)
> {
> AspeedSoCState *soc = &bmc->soc;
> @@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
> object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
> object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
> object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
> +
> + at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
> + 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
> }
That's one way to model the default reset values of the eeprom, we would
loose any writes though.
I think we should have a reset_data buffer instead, which would be used
at realize time to set the initial data, if there are no drive backend,
and at reset if !writable. Something like smbus_eeprom_init_one() does
without a proper property API.
We would need some new interface to set a property for a constant buffer
of uint<>_t values. I don't know how complex that would be. It could be
useful to other models to define the init state of registers.
Thanks,
C.
> static void aspeed_machine_fby35_class_init(ObjectClass *oc, void *data)
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-16 12:42 ` Cédric Le Goater
@ 2023-01-16 17:19 ` Peter Delevoryas
0 siblings, 0 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-16 17:19 UTC (permalink / raw)
To: Cédric Le Goater
Cc: patrick, peter.maydell, andrew, joel, hskinnemoen, kfting,
qemu-arm, qemu-devel, Philippe Mathieu-Daudé
On Mon, Jan 16, 2023 at 01:42:48PM +0100, Cédric Le Goater wrote:
> On 1/14/23 18:01, Peter Delevoryas wrote:
> > Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> > ---
> > hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 49 insertions(+)
> >
> > diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> > index c929c61d582a..4ac8ff11a835 100644
> > --- a/hw/arm/aspeed.c
> > +++ b/hw/arm/aspeed.c
> > @@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
> > i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
> > }
> > +static const uint8_t fby35_bmc_fruid[] = {
> > + 0x01, 0x00, 0x00, 0x01, 0x0d, 0x00, 0x00, 0xf1, 0x01, 0x0c, 0x00, 0x36,
> > + 0xe6, 0xd0, 0xc6, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x42, 0x4d,
> > + 0x43, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20, 0x4d, 0x6f,
> > + 0x64, 0x75, 0x6c, 0x65, 0xcd, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e,
> > + 0x30, 0xc9, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc1, 0x39, 0x01, 0x0c, 0x00, 0xc6,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x59, 0x6f, 0x73, 0x65, 0x6d,
> > + 0x69, 0x74, 0x65, 0x20, 0x56, 0x33, 0x2e, 0x35, 0x20, 0x45, 0x56, 0x54,
> > + 0x32, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
> > + 0x58, 0x58, 0x58, 0x58, 0xc4, 0x45, 0x56, 0x54, 0x32, 0xcd, 0x58, 0x58,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc7,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e, 0x30, 0xc9,
> > + 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc8, 0x43, 0x6f,
> > + 0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> > +};
>
>
> I would introduce a new aspeed_eeprom.c file for these definitions because
> each machine could have its own set of eeproms and aspeed.c is already big
> enough.
+1
>
> > static void fby35_i2c_init(AspeedMachineState *bmc)
> > {
> > AspeedSoCState *soc = &bmc->soc;
> > @@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
> > object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
> > object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
> > object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
> > +
> > + at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
> > + 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
> > }
>
> That's one way to model the default reset values of the eeprom, we would
> loose any writes though.
>
> I think we should have a reset_data buffer instead, which would be used
> at realize time to set the initial data, if there are no drive backend,
> and at reset if !writable. Something like smbus_eeprom_init_one() does
> without a proper property API.
I actually did it this way downstream[1], but I thought it would be controversial
without using properties, and I wasn't sure how to model it with properties.
[1] https://github.com/facebook/openbmc/blob/b98f10b7967ebce1f97e14a9a5d4c14f9f7d4c55/common/recipes-devtools/qemu/qemu/0014-hw-nvram-at24c-Add-static-memory-init-option.patch
>
> We would need some new interface to set a property for a constant buffer
> of uint<>_t values. I don't know how complex that would be. It could be
> useful to other models to define the init state of registers.
Would DEFINE_PROP_ARRAY not work? Won't the properties be constant after
qdev_realize()?
Or if that's not preferable, DEFINE_PROP_LINK (uint8_t *reset_data) +
DEFINE_PROP_UINT32 (reset_data_size)?
Otherwise, if the property stuff is too uncertain, I'd be happy just adding an
adhoc API through the helper like smbus_eeprom_init_one does.
>
> Thanks,
>
> C.
>
> > static void aspeed_machine_fby35_class_init(ObjectClass *oc, void *data)
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper
2023-01-16 12:23 ` Philippe Mathieu-Daudé
@ 2023-01-16 17:21 ` Peter Delevoryas
0 siblings, 0 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-16 17:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On Mon, Jan 16, 2023 at 01:23:01PM +0100, Philippe Mathieu-Daudé wrote:
> On 14/1/23 18:01, Peter Delevoryas wrote:
> > Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> > ---
> > hw/nvram/eeprom_at24c.c | 10 ++++++++++
> > include/hw/nvram/eeprom_at24c.h | 10 ++++++++++
> > 2 files changed, 20 insertions(+)
> > create mode 100644 include/hw/nvram/eeprom_at24c.h
>
> > +void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
> > +{
> > + I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", address);
>
> Please use the type definition: TYPE_AT24C_EE.
>
> > + DeviceState *dev = DEVICE(i2c_dev);
> > +
> > + qdev_prop_set_uint32(dev, "rom-size", rom_size);
> > + i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
>
> Although the allocated object is somehow reachable from the i2c bus
> object, it would be simpler to deallocate allowing the parent to keep
> a reference to it. So consider this prototype instead:
>
> I2CSlave *at24c_eeprom_create(I2CBus *bus, uint8_t address,
> uint32_t rom_size);
>
Oh ok, yeah that sounds good. In this case, if I let the parent keep a
reference, maybe I shouldn't use i2c_slave_realize_and_unref, and just use
qdev_realize/etc (to avoid the unref?). I'll try just returning the pointer
from the function to start with though.
> > +}
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init
2023-01-16 12:24 ` Philippe Mathieu-Daudé
@ 2023-01-16 17:21 ` Peter Delevoryas
0 siblings, 0 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-16 17:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On Mon, Jan 16, 2023 at 01:24:36PM +0100, Philippe Mathieu-Daudé wrote:
> On 14/1/23 18:01, Peter Delevoryas wrote:
> > Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> > ---
> > hw/arm/aspeed.c | 10 +---------
> > 1 file changed, 1 insertion(+), 9 deletions(-)
>
> > -static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
> > -{
> > - I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> > - DeviceState *dev = DEVICE(i2c_dev);
> > -
> > - qdev_prop_set_uint32(dev, "rom-size", rsize);
> > - i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> > -}
>
> Why not squash in previous commit as 'extract helper' change?
+1, I'll squash this.
>
> Anyhow,
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-16 12:30 ` Philippe Mathieu-Daudé
@ 2023-01-16 17:23 ` Peter Delevoryas
2023-01-17 6:47 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-16 17:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On Mon, Jan 16, 2023 at 01:30:19PM +0100, Philippe Mathieu-Daudé wrote:
> On 14/1/23 18:01, Peter Delevoryas wrote:
> > Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> > ---
> > hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 49 insertions(+)
> >
> > diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> > index c929c61d582a..4ac8ff11a835 100644
> > --- a/hw/arm/aspeed.c
> > +++ b/hw/arm/aspeed.c
> > @@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
> > i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
> > }
> > +static const uint8_t fby35_bmc_fruid[] = {
> [...]
>
> > +};
> > +
> > static void fby35_i2c_init(AspeedMachineState *bmc)
> > {
> > AspeedSoCState *soc = &bmc->soc;
> > @@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
> > object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
> > object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
> > object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
> > +
> > + at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
> > + 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
>
> Why transfer the prom content on the i2c bus at each reset?
>
> In particular this looks wrong if the prom is initialized with a 'drive'
> block backend (using -global).
Yeah, it looks like this might not be the right way to model it. I'm going
to try Cedric's suggestions.
>
> > }
>
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-16 17:23 ` Peter Delevoryas
@ 2023-01-17 6:47 ` Philippe Mathieu-Daudé
2023-01-17 17:49 ` Peter Delevoryas
0 siblings, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-17 6:47 UTC (permalink / raw)
To: Peter Delevoryas
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On 16/1/23 18:23, Peter Delevoryas wrote:
> On Mon, Jan 16, 2023 at 01:30:19PM +0100, Philippe Mathieu-Daudé wrote:
>> On 14/1/23 18:01, Peter Delevoryas wrote:
>>> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
>>> ---
>>> hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 49 insertions(+)
>>>
>>> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
>>> index c929c61d582a..4ac8ff11a835 100644
>>> --- a/hw/arm/aspeed.c
>>> +++ b/hw/arm/aspeed.c
>>> @@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
>>> i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
>>> }
>>> +static const uint8_t fby35_bmc_fruid[] = {
>> [...]
>>
>>> +};
>>> +
>>> static void fby35_i2c_init(AspeedMachineState *bmc)
>>> {
>>> AspeedSoCState *soc = &bmc->soc;
>>> @@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
>>> object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
>>> object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
>>> object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
>>> +
>>> + at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
>>> + 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
>>
>> Why transfer the prom content on the i2c bus at each reset?
>>
>> In particular this looks wrong if the prom is initialized with a 'drive'
>> block backend (using -global).
>
> Yeah, it looks like this might not be the right way to model it. I'm going
> to try Cedric's suggestions.
OK, but watch out this is a PROM, not a ROM, meaning it is legitimate
for a guest to reprogram it, and expect the reprogrammed content after
reset.
Shouldn't we put the 'fill default content if no -drive provided' option
in the device's realize() handler, to avoid overwriting content possibly
updated by guest before reset?
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM
2023-01-17 6:47 ` Philippe Mathieu-Daudé
@ 2023-01-17 17:49 ` Peter Delevoryas
0 siblings, 0 replies; 24+ messages in thread
From: Peter Delevoryas @ 2023-01-17 17:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: patrick, clg, peter.maydell, andrew, joal, hskinnemoen, kfting,
qemu-arm, qemu-devel
On Tue, Jan 17, 2023 at 07:47:06AM +0100, Philippe Mathieu-Daudé wrote:
> On 16/1/23 18:23, Peter Delevoryas wrote:
> > On Mon, Jan 16, 2023 at 01:30:19PM +0100, Philippe Mathieu-Daudé wrote:
> > > On 14/1/23 18:01, Peter Delevoryas wrote:
> > > > Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> > > > ---
> > > > hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> > > > 1 file changed, 49 insertions(+)
> > > >
> > > > diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> > > > index c929c61d582a..4ac8ff11a835 100644
> > > > --- a/hw/arm/aspeed.c
> > > > +++ b/hw/arm/aspeed.c
> > > > @@ -922,6 +922,52 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
> > > > i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67);
> > > > }
> > > > +static const uint8_t fby35_bmc_fruid[] = {
> > > [...]
> > >
> > > > +};
> > > > +
> > > > static void fby35_i2c_init(AspeedMachineState *bmc)
> > > > {
> > > > AspeedSoCState *soc = &bmc->soc;
> > > > @@ -1363,6 +1409,9 @@ static void fby35_reset(MachineState *state, ShutdownCause reason)
> > > > object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
> > > > object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
> > > > object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
> > > > +
> > > > + at24c_eeprom_write(aspeed_i2c_get_bus(&bmc->soc.i2c, 11),
> > > > + 0x54, 0, fby35_bmc_fruid, sizeof(fby35_bmc_fruid));
> > >
> > > Why transfer the prom content on the i2c bus at each reset?
> > >
> > > In particular this looks wrong if the prom is initialized with a 'drive'
> > > block backend (using -global).
> >
> > Yeah, it looks like this might not be the right way to model it. I'm going
> > to try Cedric's suggestions.
>
> OK, but watch out this is a PROM, not a ROM, meaning it is legitimate
> for a guest to reprogram it, and expect the reprogrammed content after
> reset.
+1
>
> Shouldn't we put the 'fill default content if no -drive provided' option
> in the device's realize() handler, to avoid overwriting content possibly
> updated by guest before reset?
+1, yeah I think you're right, if somebody is providing a -drive option, we
should allow that to override everything else (default zero initialization,
init ROM initialization, etc).
Because, if they're providing a -drive, they shouldn't need to provide an
initial value, they can just initialize the file with the data they want.
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2023-01-17 17:50 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-14 17:01 [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
2023-01-14 17:01 ` [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper Peter Delevoryas
2023-01-16 11:13 ` Cédric Le Goater
2023-01-16 12:23 ` Philippe Mathieu-Daudé
2023-01-16 17:21 ` Peter Delevoryas
2023-01-14 17:01 ` [PATCH 2/6] hw/arm/aspeed: Remove local copy of at24c_eeprom_init Peter Delevoryas
2023-01-16 11:13 ` Cédric Le Goater
2023-01-16 12:24 ` Philippe Mathieu-Daudé
2023-01-16 17:21 ` Peter Delevoryas
2023-01-14 17:01 ` [PATCH 3/6] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init Peter Delevoryas
2023-01-16 11:14 ` Cédric Le Goater
2023-01-16 12:25 ` Philippe Mathieu-Daudé
2023-01-14 17:01 ` [PATCH 4/6] hw/arm/npcm7xx: Remove local copy of at24c_eeprom_init Peter Delevoryas
2023-01-16 11:14 ` Cédric Le Goater
2023-01-16 12:26 ` Philippe Mathieu-Daudé
2023-01-14 17:01 ` [PATCH 5/6] hw/nvram/eeprom_at24c: Add I2C write helper Peter Delevoryas
2023-01-14 17:01 ` [PATCH 6/6] hw/arm/aspeed: Init fby35 BMC FRUID EEPROM Peter Delevoryas
2023-01-16 12:30 ` Philippe Mathieu-Daudé
2023-01-16 17:23 ` Peter Delevoryas
2023-01-17 6:47 ` Philippe Mathieu-Daudé
2023-01-17 17:49 ` Peter Delevoryas
2023-01-16 12:42 ` Cédric Le Goater
2023-01-16 17:19 ` Peter Delevoryas
2023-01-14 17:07 ` [PATCH 0/6] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).