[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/31] smbus: add a smbus_eeprom_init_one() routine
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 05/31] smbus: add a smbus_eeprom_init_one() routine |
Date: |
Fri, 8 Jun 2018 13:44:51 +0100 |
From: Cédric Le Goater <address@hidden>
This is an helper routine to add a single EEPROM on an I2C bus. It can
be directly used by smbus_eeprom_init() which adds a certain number of
EEPROMs on mips and x86 machines.
Signed-off-by: Cédric Le Goater <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
include/hw/i2c/smbus.h | 1 +
hw/i2c/smbus_eeprom.c | 16 +++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
index cfe3fa69f32..4fdba022c1f 100644
--- a/include/hw/i2c/smbus.h
+++ b/include/hw/i2c/smbus.h
@@ -76,6 +76,7 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t
command, uint8_t *data);
int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t
*data,
int len);
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t
*eeprom_buf);
void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
const uint8_t *eeprom_spd, int size);
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index 125c887d1f6..f18aa3de35a 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -139,6 +139,16 @@ static void smbus_eeprom_register_types(void)
type_init(smbus_eeprom_register_types)
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)
+{
+ DeviceState *dev;
+
+ dev = qdev_create((BusState *) smbus, "smbus-eeprom");
+ qdev_prop_set_uint8(dev, "address", address);
+ qdev_prop_set_ptr(dev, "data", eeprom_buf);
+ qdev_init_nofail(dev);
+}
+
void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
const uint8_t *eeprom_spd, int eeprom_spd_size)
{
@@ -149,10 +159,6 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
}
for (i = 0; i < nb_eeprom; i++) {
- DeviceState *eeprom;
- eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
- qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
- qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
- qdev_init_nofail(eeprom);
+ smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256));
}
}
--
2.17.1
- [Qemu-devel] [PULL 00/31] target-arm queue, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 10/31] ftgmac100: add IEEE 802.1Q VLAN support, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 11/31] ftgmac100: fix multicast hash routine, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 08/31] aspeed: add the pc9552 chips to the witherspoon machine, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 13/31] hw/arm: Remove the deprecated xlnx-ep108 machine, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 06/31] aspeed: Add EEPROM I2C devices, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 05/31] smbus: add a smbus_eeprom_init_one() routine,
Peter Maydell <=
- [Qemu-devel] [PULL 04/31] aspeed: add an I2C RTC device to all machines, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 12/31] ftgmac100: remove check on runt messages, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 03/31] aspeed: add support for the witherspoon-bmc board, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 09/31] ftgmac100: compute maximum frame size depending on the protocol, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 18/31] ppc/pnv: Add trailing '\n' to qemu_log() calls, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 14/31] hw/i2c: Add trace events, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 16/31] hw/digic: Add trailing '\n' to qemu_log() calls, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 02/31] aspeed: remove ignore_memory_transaction_failures on all boards, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 07/31] misc: add pca9552 LED blinker model, Peter Maydell, 2018/06/08
- [Qemu-devel] [PULL 17/31] xilinx-dp: Add trailing '\n' to qemu_log() call, Peter Maydell, 2018/06/08