Hello Yubin,
On 11/13/25 01:43, Yubin Zou wrote:
From: Hao Wu <[email protected]>
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 <[email protected]>
---
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