[PATCH qemu 11/38] aspeed/smc: get the number of flash modules from hw strapping
Cédric Le Goater
clg at kaod.org
Sat Nov 19 01:21:51 AEDT 2016
If the second watchdog is activated, a second flash module is
available. It should be of the same model.
Signed-off-by: Cédric Le Goater <clg at kaod.org>
---
hw/arm/aspeed_soc.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 503efe0f5f77..fcf029f8c1c2 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -170,12 +170,30 @@ static void aspeed_soc_init(Object *obj)
"ram-size", &error_abort);
}
+static int aspeed_fmc_get_cs(AspeedSoCState *s, Error **errp)
+{
+ Error *err = NULL;
+ uint32_t hw_strap1;
+
+ hw_strap1 = object_property_get_int(OBJECT(&s->scu), "hw-strap1", errp);
+ if (err) {
+ error_propagate(errp, err);
+ return -1;
+ }
+
+ /*
+ * If the second watchdog is activated, then we have two chips.
+ */
+ return hw_strap1 & SCU_HW_STRAP_2ND_BOOT_WDT ? 2 : 1;
+}
+
static void aspeed_soc_realize(DeviceState *dev, Error **errp)
{
int i;
AspeedSoCState *s = ASPEED_SOC(dev);
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
Error *err = NULL, *local_err = NULL;
+ int fmc_num_cs;
/* IO space */
memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL,
@@ -251,7 +269,13 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->vic), 12));
/* FMC */
- object_property_set_int(OBJECT(&s->fmc), 1, "num-cs", &err);
+ fmc_num_cs = aspeed_fmc_get_cs(s, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+
+ object_property_set_int(OBJECT(&s->fmc), fmc_num_cs, "num-cs", &err);
object_property_set_bool(OBJECT(&s->fmc), true, "realized", &local_err);
error_propagate(&err, local_err);
if (err) {
--
2.7.4
More information about the openbmc
mailing list