qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices
Date: Tue, 19 Sep 2017 13:26:43 +0200	[thread overview]
Message-ID: <20170919112645.8574-4-clg@kaod.org> (raw)
In-Reply-To: <20170919112645.8574-1-clg@kaod.org>

The Aspeed boards have at least one EEPROM to hold the Vital Product
Data (VPD).

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/arm/aspeed.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 362b683e9021..3e74970d7ad2 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -251,6 +251,17 @@ static void aspeed_board_init(MachineState *machine,
     arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo);
 }
 
+static void aspeed_i2c_add_eeprom(I2CBus *bus, uint8_t address, size_t size)
+{
+    uint8_t *eeprom_buf = g_malloc0(size);
+    DeviceState *dev;
+
+    dev = qdev_create((BusState *) bus, "smbus-eeprom");
+    qdev_prop_set_uint8(dev, "address", address);
+    qdev_prop_set_ptr(dev, "data", eeprom_buf);
+    qdev_init_nofail(dev);
+}
+
 static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
@@ -260,6 +271,9 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
      * enough to provide basic RTC features. Alarms will be missing */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
 
+    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,
+                          256 * 1024);
+
     /* add a TMP423 temperature sensor */
     dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
                            "tmp423", 0x4c);
@@ -298,6 +312,9 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
 
+    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
+                          8 * 1024);
+
     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
 
@@ -377,6 +394,9 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
     /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
      * good enough */
     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
+
+    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
+                          8 * 1024);
 }
 
 static void witherspoon_bmc_init(MachineState *machine)
-- 
2.13.5

  parent reply	other threads:[~2017-09-19 11:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19 11:26 [Qemu-devel] [PATCH 0/5] aspeed: add a witherspoon-bmc machine Cédric Le Goater
2017-09-19 11:26 ` [Qemu-devel] [PATCH 1/5] aspeed: add support for the witherspoon-bmc board Cédric Le Goater
2017-09-19 11:26 ` [Qemu-devel] [PATCH 2/5] aspeed: add an I2C RTC device to all machines Cédric Le Goater
2017-09-19 11:26 ` Cédric Le Goater [this message]
2017-09-19 12:12   ` [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices Philippe Mathieu-Daudé
2017-09-19 12:42     ` Cédric Le Goater
2017-09-19 11:26 ` [Qemu-devel] [PATCH 4/5] misc: add pca9552 LED blinker model Cédric Le Goater
2017-09-19 13:27   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-09-20  6:55     ` Cédric Le Goater
2017-09-19 11:26 ` [Qemu-devel] [PATCH 5/5] aspeed: add the pc9552 chips to the witherspoon machine Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170919112645.8574-4-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=andrew@aj.id.au \
    --cc=joel@jms.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).