mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
hw/arm: Extract at24c_eeprom_init helper from Aspeed and Nuvoton boards
This helper is useful in board initialization because lets users initialize and realize an EEPROM on an I2C bus with a single function call. Signed-off-by: Peter Delevoryas <peter@pjd.dev> Reviewed-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Corey Minyard <cminyard@mvista.com> Link: https://lore.kernel.org/r/20230128060543.95582-2-peter@pjd.dev Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
parent
ddbf7bd73c
commit
9618ebae45
4 changed files with 41 additions and 24 deletions
|
@ -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,17 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
|
||||
{
|
||||
I2CSlave *i2c_dev = i2c_slave_new(TYPE_AT24C_EE, 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);
|
||||
|
||||
return i2c_dev;
|
||||
}
|
||||
|
||||
static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
EEPROMState *ee = AT24C_EE(dev);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue