qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l
@ 2025-11-13  0:43 Yubin Zou
  2025-11-13  0:43 ` [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom Yubin Zou
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yubin Zou @ 2025-11-13  0:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cédric Le Goater, Peter Maydell, Steven Lee, Troy Lee,
	Jamin Lin, Andrew Jeffery, Joel Stanley, qemu-arm, Yubin Zou,
	Hao Wu, Patrick Venture

Overview of Changes:
This two-patch series introduces I2C EEPROM devices (AT24C64) to the
quanta-q71l machine model, representing the Baseboard, Frontpanel,
BIOS, PDB, and BMC FRUs.

Improvement to QEMU:
These changes enhance the simulation fidelity of the quanta-q71l board.
By modeling the FRU EEPROMs and allowing them to be backed by drives.

Impact (Before/After):
Before:
The quanta-q71l machine model did not include the I2C EEPROMs for FRU
data storage.

After:
The EEPROMs are added to the appropriate I2C buses at their respective
addresses. Each eeprom now can be associated with a QEMU driver backend
by using the `-drive`option.

Signed-off-by: Yubin Zou <yubinz@google.com>
---
Changes in v2:
Include a patch to add a auxiliary function in the at24c eeprom module to assign unique
unit numbers for each eeproms in each board

- Link to v1: https://lore.kernel.org/qemu-devel/20250916-quanta-q71l-eeproms-v1-0-3648692cc441@google.com

---
Hao Wu (1):
      hw/nvram: Add a new auxiliary function to init at24c eeprom

Patrick Venture (2):
      hw/arm: add eeproms to quanta-q7l1 board
      hw/arm: enable eeproms for quanta-q71l

 hw/arm/aspeed.c                 | 15 ++++++++++-----
 hw/nvram/eeprom_at24c.c         | 17 +++++++++++++++++
 include/hw/nvram/eeprom_at24c.h |  4 ++++
 3 files changed, 31 insertions(+), 5 deletions(-)
---
base-commit: 190d5d7fd725ff754f94e8e0cbfb69f279c82b5d
change-id: 20250916-quanta-q71l-eeproms-0ebc6e0486d7

Best regards,
-- 
Yubin Zou <yubinz@google.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom
  2025-11-13  0:43 [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Yubin Zou
@ 2025-11-13  0:43 ` Yubin Zou
  2025-11-13 11:09   ` Cédric Le Goater
  2025-11-13  0:43 ` [PATCH v2 2/3] hw/arm: add eeproms to quanta-q7l1 board Yubin Zou
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Yubin Zou @ 2025-11-13  0:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cédric Le Goater, Peter Maydell, Steven Lee, Troy Lee,
	Jamin Lin, Andrew Jeffery, Joel Stanley, qemu-arm, Yubin Zou,
	Hao Wu

From: Hao Wu <wuhaotsh@google.com>

In NPCM7xx boards, at24c eeproms are backed by drives. However,
these drives use unit number as unique identifier. So if we
specify two drives with the same unit number, error will occured:
`Device with id 'none85' exists`.

Instead of using i2c address as unit number, we now assign unique
unit numbers for each eeproms in each board. This avoids conflict
in providing multiple eeprom contents with the same address.

We add an auxiliary function in the at24c eeprom module for this.
This allows it to easily add at24c eeprom to non-nuvoton boards
like aspeed as well.

Change-Id: I2f056cc0507d39164335a03bc18b5c94015b4b11
Signed-off-by: Hao Wu <wuhaotsh@google.com>
---
 hw/nvram/eeprom_at24c.c         | 17 +++++++++++++++++
 include/hw/nvram/eeprom_at24c.h |  4 ++++
 2 files changed, 21 insertions(+)

diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 82ea97e552a15c8bcd38e38939b53545b01ad273..8542ca2b037d6e896c7b394e7ff4b6ec27297ad7 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -17,6 +17,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "system/block-backend.h"
+#include "system/blockdev.h"
 #include "qom/object.h"
 
 /* #define DEBUG_AT24C */
@@ -264,3 +265,19 @@ static void at24c_eeprom_register(void)
 }
 
 type_init(at24c_eeprom_register)
+
+void at24c_eeprom_init_one(I2CBus *i2c_bus, int bus, uint8_t addr,
+                           uint32_t rsize, int unit_number)
+{
+    I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
+    DeviceState *dev = DEVICE(i2c_dev);
+    BlockInterfaceType type = IF_NONE;
+    DriveInfo *dinfo;
+
+    dinfo = drive_get(type, bus, unit_number);
+    if (dinfo) {
+        qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo));
+    }
+    qdev_prop_set_uint32(dev, "rom-size", rsize);
+    i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
+}
diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
index acb9857b2adddd1fe5a924652f6ebae13b674b66..fdac7c1c022f9f73307bb3ecf761caa732e999bc 100644
--- a/include/hw/nvram/eeprom_at24c.h
+++ b/include/hw/nvram/eeprom_at24c.h
@@ -36,4 +36,8 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
 I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
                                 const uint8_t *init_rom, uint32_t init_rom_size);
 
+/* Init one at24c eeprom device */
+void at24c_eeprom_init_one(I2CBus *i2c_bus, int bus, uint8_t addr,
+                           uint32_t rsize, int unit_number);
+
 #endif

-- 
2.51.2.1041.gc1ab5b90ca-goog



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] hw/arm: add eeproms to quanta-q7l1 board
  2025-11-13  0:43 [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Yubin Zou
  2025-11-13  0:43 ` [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom Yubin Zou
@ 2025-11-13  0:43 ` Yubin Zou
  2025-11-13  0:43 ` [PATCH v2 3/3] hw/arm: enable eeproms for quanta-q71l Yubin Zou
  2025-11-13  5:06 ` [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Jamin Lin
  3 siblings, 0 replies; 6+ messages in thread
From: Yubin Zou @ 2025-11-13  0:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cédric Le Goater, Peter Maydell, Steven Lee, Troy Lee,
	Jamin Lin, Andrew Jeffery, Joel Stanley, qemu-arm, Yubin Zou,
	Patrick Venture

From: Patrick Venture <venture@google.com>

Adds eeprom init for aspeed helper method and adds 24c64 eeproms to the
quanta-q71l bmc board.

Tested: Booted quanta-q71l bmc firmware to userspace.
Signed-off-by: Patrick Venture <venture@google.com>
---
 hw/arm/aspeed.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index c31bbe7701381f6980e874f9fca51805ff9fb9b4..bae59ae7394882e3fc93863049a37ff5a8737ff8 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -561,14 +561,17 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 1), "tmp105", 0x4e);
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 1), "tmp105", 0x4f);
 
-    /* TODO: i2c-1: Add baseboard FRU eeprom@54 24c64 */
-    /* TODO: i2c-1: Add Frontpanel FRU eeprom@57 24c64 */
+    /* Baseboard FRU */
+    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x54, 8192);
+    /* Frontpanel FRU */
+    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x57, 8192);
     /* TODO: Add Memory Riser i2c mux and eeproms. */
 
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "pca9546", 0x74);
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "pca9548", 0x77);
 
-    /* TODO: i2c-3: Add BIOS FRU eeprom@56 24c64 */
+    /* Add BIOS FRU */
+    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 3), 0x56, 8192);
 
     /* i2c-7 */
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9546", 0x70);
@@ -577,8 +580,10 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)
     /*        - i2c@2: pmbus@58 */
     /*        - i2c@3: pmbus@59 */
 
-    /* TODO: i2c-7: Add PDB FRU eeprom@52 */
-    /* TODO: i2c-8: Add BMC FRU eeprom@50 */
+    /* PDB FRU */
+    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x52, 8192);
+    /* BMC FRU */
+    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 8192);
 }
 
 static void ast2500_evb_i2c_init(AspeedMachineState *bmc)

-- 
2.51.2.1041.gc1ab5b90ca-goog



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] hw/arm: enable eeproms for quanta-q71l
  2025-11-13  0:43 [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Yubin Zou
  2025-11-13  0:43 ` [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom Yubin Zou
  2025-11-13  0:43 ` [PATCH v2 2/3] hw/arm: add eeproms to quanta-q7l1 board Yubin Zou
@ 2025-11-13  0:43 ` Yubin Zou
  2025-11-13  5:06 ` [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Jamin Lin
  3 siblings, 0 replies; 6+ messages in thread
From: Yubin Zou @ 2025-11-13  0:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cédric Le Goater, Peter Maydell, Steven Lee, Troy Lee,
	Jamin Lin, Andrew Jeffery, Joel Stanley, qemu-arm, Yubin Zou,
	Patrick Venture

From: Patrick Venture <venture@google.com>

Tested: Quanta-q71l firmware booted to login and was populated via the
-drives for the corresponding eeproms.
Signed-off-by: Patrick Venture <venture@google.com>
---
 hw/arm/aspeed.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index bae59ae7394882e3fc93863049a37ff5a8737ff8..8cef387a0b431576a873553704920886222cca86 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -562,16 +562,16 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 1), "tmp105", 0x4f);
 
     /* Baseboard FRU */
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x54, 8192);
+    at24c_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 1), 1, 0x54, 8192, 0);
     /* Frontpanel FRU */
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x57, 8192);
+    at24c_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 1), 1, 0x57, 8192, 1);
     /* TODO: Add Memory Riser i2c mux and eeproms. */
 
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "pca9546", 0x74);
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "pca9548", 0x77);
 
     /* Add BIOS FRU */
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 3), 0x56, 8192);
+    at24c_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 3), 3, 0x56, 8192, 2);
 
     /* i2c-7 */
     i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9546", 0x70);
@@ -581,9 +581,9 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)
     /*        - i2c@3: pmbus@59 */
 
     /* PDB FRU */
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x52, 8192);
+    at24c_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 7), 7, 0x52, 8192, 3);
     /* BMC FRU */
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 8192);
+    at24c_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 8), 8, 0x50, 8192, 4);
 }
 
 static void ast2500_evb_i2c_init(AspeedMachineState *bmc)

-- 
2.51.2.1041.gc1ab5b90ca-goog



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l
  2025-11-13  0:43 [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Yubin Zou
                   ` (2 preceding siblings ...)
  2025-11-13  0:43 ` [PATCH v2 3/3] hw/arm: enable eeproms for quanta-q71l Yubin Zou
@ 2025-11-13  5:06 ` Jamin Lin
  3 siblings, 0 replies; 6+ messages in thread
From: Jamin Lin @ 2025-11-13  5:06 UTC (permalink / raw)
  To: Yubin Zou, qemu-devel@nongnu.org
  Cc: Cédric Le Goater, Peter Maydell, Steven Lee, Troy Lee,
	Andrew Jeffery, Joel Stanley, qemu-arm@nongnu.org, Hao Wu,
	Patrick Venture

Hi Yubin,

> Overview of Changes:
> This two-patch series introduces I2C EEPROM devices (AT24C64) to the
> quanta-q71l machine model, representing the Baseboard, Frontpanel, BIOS,
> PDB, and BMC FRUs.
> 
> Improvement to QEMU:
> These changes enhance the simulation fidelity of the quanta-q71l board.
> By modeling the FRU EEPROMs and allowing them to be backed by drives.
> 
> Impact (Before/After):
> Before:
> The quanta-q71l machine model did not include the I2C EEPROMs for FRU
> data storage.

Please rebase your codebase.
The quanta-q71l board has been moved into aspeed_ast2400_quanta-q71l.c
You can find it here:
https://github.com/qemu/qemu/blob/master/hw/arm/aspeed_ast2400_quanta-q71l.c

Thanks-Jamin

> 
> After:
> The EEPROMs are added to the appropriate I2C buses at their respective
> addresses. Each eeprom now can be associated with a QEMU driver backend
> by using the `-drive`option.
> 
> Signed-off-by: Yubin Zou <yubinz@google.com>
> ---
> Changes in v2:
> Include a patch to add a auxiliary function in the at24c eeprom module to
> assign unique unit numbers for each eeproms in each board
> 
> - Link to v1:
> https://lore.kernel.org/qemu-devel/20250916-quanta-q71l-eeproms-v1-0-3648
> 692cc441@google.com
> 
> ---
> Hao Wu (1):
>       hw/nvram: Add a new auxiliary function to init at24c eeprom
> 
> Patrick Venture (2):
>       hw/arm: add eeproms to quanta-q7l1 board
>       hw/arm: enable eeproms for quanta-q71l
> 
>  hw/arm/aspeed.c                 | 15 ++++++++++-----
>  hw/nvram/eeprom_at24c.c         | 17 +++++++++++++++++
>  include/hw/nvram/eeprom_at24c.h |  4 ++++
>  3 files changed, 31 insertions(+), 5 deletions(-)
> ---
> base-commit: 190d5d7fd725ff754f94e8e0cbfb69f279c82b5d
> change-id: 20250916-quanta-q71l-eeproms-0ebc6e0486d7
> 
> Best regards,
> --
> Yubin Zou <yubinz@google.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom
  2025-11-13  0:43 ` [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom Yubin Zou
@ 2025-11-13 11:09   ` Cédric Le Goater
  0 siblings, 0 replies; 6+ messages in thread
From: Cédric Le Goater @ 2025-11-13 11:09 UTC (permalink / raw)
  To: Yubin Zou, qemu-devel
  Cc: Peter Maydell, Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery,
	Joel Stanley, qemu-arm, Hao Wu

Hello Yubin,

On 11/13/25 01:43, Yubin Zou wrote:
> From: Hao Wu <wuhaotsh@google.com>
> 
> In NPCM7xx boards, at24c eeproms are backed by drives. 

Are they ? I don't see any drive usage apart from the flash devices.

> However,
> these drives use unit number as unique identifier. So if we
> specify two drives with the same unit number, error will occured:
> `Device with id 'none85' exists`.

Yes. The drive interface is very poor when it comes to the user
interface. Something to avoid.

A better alternative is to define the devices on the command line
using a blockdev, something like :

   -blockdev node-name=eprom0,driver=file,filename=/path/to/eprom0-contents \
   -device at24c-eeprom,bus=aspeed.i2c.bus.1,address=0x54,id=foobar,drive=eprom0

Please try that instead. Or use at24c_eeprom_init_rom() like the
other machines.

A functional test of the quanta-q71l board would be appreciated.

Thanks,

C.



> Instead of using i2c address as unit number, we now assign unique
> unit numbers for each eeproms in each board. This avoids conflict
> in providing multiple eeprom contents with the same address.
> 
> We add an auxiliary function in the at24c eeprom module for this.
> This allows it to easily add at24c eeprom to non-nuvoton boards
> like aspeed as well.
> 
> Change-Id: I2f056cc0507d39164335a03bc18b5c94015b4b11
> Signed-off-by: Hao Wu <wuhaotsh@google.com>
> ---
>   hw/nvram/eeprom_at24c.c         | 17 +++++++++++++++++
>   include/hw/nvram/eeprom_at24c.h |  4 ++++
>   2 files changed, 21 insertions(+)
> 
> diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
> index 82ea97e552a15c8bcd38e38939b53545b01ad273..8542ca2b037d6e896c7b394e7ff4b6ec27297ad7 100644
> --- a/hw/nvram/eeprom_at24c.c
> +++ b/hw/nvram/eeprom_at24c.c
> @@ -17,6 +17,7 @@
>   #include "hw/qdev-properties.h"
>   #include "hw/qdev-properties-system.h"
>   #include "system/block-backend.h"
> +#include "system/blockdev.h"
>   #include "qom/object.h"
>   
>   /* #define DEBUG_AT24C */
> @@ -264,3 +265,19 @@ static void at24c_eeprom_register(void)
>   }
>   
>   type_init(at24c_eeprom_register)
> +
> +void at24c_eeprom_init_one(I2CBus *i2c_bus, int bus, uint8_t addr,
> +                           uint32_t rsize, int unit_number)
> +{
> +    I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> +    DeviceState *dev = DEVICE(i2c_dev);
> +    BlockInterfaceType type = IF_NONE;
> +    DriveInfo *dinfo;
> +
> +    dinfo = drive_get(type, bus, unit_number);
> +    if (dinfo) {
> +        qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo));
> +    }

> +    qdev_prop_set_uint32(dev, "rom-size", rsize);> +    i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
> +}
> diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
> index acb9857b2adddd1fe5a924652f6ebae13b674b66..fdac7c1c022f9f73307bb3ecf761caa732e999bc 100644
> --- a/include/hw/nvram/eeprom_at24c.h
> +++ b/include/hw/nvram/eeprom_at24c.h
> @@ -36,4 +36,8 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
>   I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
>                                   const uint8_t *init_rom, uint32_t init_rom_size);
>   
> +/* Init one at24c eeprom device */
> +void at24c_eeprom_init_one(I2CBus *i2c_bus, int bus, uint8_t addr,
> +                           uint32_t rsize, int unit_number);
> +
>   #endif
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-13 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13  0:43 [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Yubin Zou
2025-11-13  0:43 ` [PATCH v2 1/3] hw/nvram: Add a new auxiliary function to init at24c eeprom Yubin Zou
2025-11-13 11:09   ` Cédric Le Goater
2025-11-13  0:43 ` [PATCH v2 2/3] hw/arm: add eeproms to quanta-q7l1 board Yubin Zou
2025-11-13  0:43 ` [PATCH v2 3/3] hw/arm: enable eeproms for quanta-q71l Yubin Zou
2025-11-13  5:06 ` [PATCH v2 0/3] Add drive-backed EEPROM support to quanta-q71l Jamin Lin

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).