[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 7/8] hw/arm: Set drive property for at24c eeprom
From: |
Hao Wu |
Subject: |
[PATCH v5 7/8] hw/arm: Set drive property for at24c eeprom |
Date: |
Thu, 14 Jul 2022 11:28:35 -0700 |
This patch allows the user to attach an external drive as a property
for an onboard at24c eeprom device. It uses an unit number to
distinguish different devices.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
---
hw/arm/npcm7xx_boards.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index b083b0c572..b8337871ba 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -141,11 +141,16 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc,
uint32_t num)
}
static void at24c_eeprom_init(I2CBus *i2c_bus, int bus, uint8_t addr,
- uint32_t rsize)
+ uint32_t rsize, int unit)
{
I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
DeviceState *dev = DEVICE(i2c_dev);
+ DriveInfo *dinfo;
+ dinfo = drive_get(IF_OTHER, bus, unit);
+ 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);
}
@@ -252,8 +257,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(npcm7xx_i2c_get_bus(soc, 9), 9, 0x55, 8192);
- at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 10), 10, 0x55, 8192);
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 9), 9, 0x55, 8192, 0);
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 10), 10, 0x55, 8192, 1);
/*
* i2c-11:
@@ -360,7 +365,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77);
/* mbfru */
- at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 4), 4, 0x50, 8192);
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 4), 4, 0x50, 8192, 0);
i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 13),
TYPE_PCA9548, 0x77);
@@ -372,7 +377,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x49);
/* bmcfru */
- at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 14), 14, 0x55, 8192);
+ at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 14), 14, 0x55, 8192, 1);
/* TODO: Add remaining i2c devices. */
}
--
2.37.0.170.g444d1eabd0-goog
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, (continued)
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Kevin Wolf, 2022/07/27
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Peter Maydell, 2022/07/28
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Kevin Wolf, 2022/07/28
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Peter Maydell, 2022/07/28
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Cédric Le Goater, 2022/07/28
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Markus Armbruster, 2022/07/28
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Peter Maydell, 2022/07/28
- Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER, Kevin Wolf, 2022/07/28
[PATCH v5 6/8] hw/arm: npcm8xx_boards: EEPROMs can take bus as parameter, Hao Wu, 2022/07/14
[PATCH v5 8/8] hw/arm: quanta-gbs-bmc add i2c devices, Hao Wu, 2022/07/14
[PATCH v5 7/8] hw/arm: Set drive property for at24c eeprom,
Hao Wu <=
Re: [PATCH v5 0/8] Misc NPCM7XX patches, Peter Maydell, 2022/07/15