qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V2] bcm2835_property: implement "get board revision" query
@ 2016-02-09  4:58 Stephen Warren
  2016-02-09  5:41 ` Andrew Baumann
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2016-02-09  4:58 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Andrew Baumann, Stephen Warren

Return a valid value from the BCM2835 property mailbox query "get board
revision". This query is used by U-Boot. Implementing it fixes the first
obvious difference between qemu and real HW.

The value returned is currently hard-coded to match the RPi2 I own. Other
values are legal, e.g. different board manufacturer field values are
likely to exist in the wild.

Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
---
V2: Set the property in raspi.c, and pass it through to the property mbox
code via property aliases.

 hw/arm/bcm2835_peripherals.c       | 2 ++
 hw/arm/bcm2836.c                   | 2 ++
 hw/arm/raspi.c                     | 2 ++
 hw/misc/bcm2835_property.c         | 4 ++--
 include/hw/misc/bcm2835_property.h | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 18b72ecb696c..e4fb48b8035c 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -58,6 +58,8 @@ static void bcm2835_peripherals_init(Object *obj)
     /* Property channel */
     object_initialize(&s->property, sizeof(s->property), TYPE_BCM2835_PROPERTY);
     object_property_add_child(obj, "property", OBJECT(&s->property), NULL);
+    object_property_add_alias(obj, "board-rev", OBJECT(&s->property),
+                              "board-rev", &error_abort);
     qdev_set_parent_bus(DEVICE(&s->property), sysbus_get_default());
 
     object_property_add_const_link(OBJECT(&s->property), "dma-mr",
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index 69c7438317c4..8a4d13c7d973 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -39,6 +39,8 @@ static void bcm2836_init(Object *obj)
                       TYPE_BCM2835_PERIPHERALS);
     object_property_add_child(obj, "peripherals", OBJECT(&s->peripherals),
                               &error_abort);
+    object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals),
+                              "board-rev", &error_abort);
     qdev_set_parent_bus(DEVICE(&s->peripherals), sysbus_get_default());
 }
 
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 0c9427c40ec4..7d3d21ab3244 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -128,6 +128,8 @@ static void raspi2_init(MachineState *machine)
                                    &error_abort);
     object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
                             &error_abort);
+    object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev",
+                            &error_abort);
     object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort);
 
     setup_boot(machine, 2, machine->ram_size);
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index e42b43e72d56..45bd6c18ce90 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -43,8 +43,7 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
             resplen = 4;
             break;
         case 0x00010002: /* Get board revision */
-            qemu_log_mask(LOG_UNIMP,
-                          "bcm2835_property: %x get board revision NYI\n", tag);
+            stl_phys(&s->dma_as, value + 12, s->board_rev);
             resplen = 4;
             break;
         case 0x00010003: /* Get board MAC address */
@@ -258,6 +257,7 @@ static void bcm2835_property_realize(DeviceState *dev, Error **errp)
 }
 
 static Property bcm2835_property_props[] = {
+    DEFINE_PROP_UINT32("board-rev", BCM2835PropertyState, board_rev, 0),
     DEFINE_PROP_UINT32("ram-size", BCM2835PropertyState, ram_size, 0),
     DEFINE_PROP_END_OF_LIST()
 };
diff --git a/include/hw/misc/bcm2835_property.h b/include/hw/misc/bcm2835_property.h
index fcf5f3decafc..df889eaa08b5 100644
--- a/include/hw/misc/bcm2835_property.h
+++ b/include/hw/misc/bcm2835_property.h
@@ -23,6 +23,7 @@ typedef struct {
     MemoryRegion iomem;
     qemu_irq mbox_irq;
     MACAddr macaddr;
+    uint32_t board_rev;
     uint32_t ram_size;
     uint32_t addr;
     bool pending;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH V2] bcm2835_property: implement "get board revision" query
  2016-02-09  4:58 [Qemu-devel] [PATCH V2] bcm2835_property: implement "get board revision" query Stephen Warren
@ 2016-02-09  5:41 ` Andrew Baumann
  2016-02-09 18:11   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Baumann @ 2016-02-09  5:41 UTC (permalink / raw)
  To: Stephen Warren, Peter Maydell; +Cc: qemu-arm, qemu-devel

> From: Stephen Warren [mailto:swarren@wwwdotorg.org]
> Sent: Tuesday, 9 February 2016 3:59 PM
> 
> Return a valid value from the BCM2835 property mailbox query "get board
> revision". This query is used by U-Boot. Implementing it fixes the first
> obvious difference between qemu and real HW.
> 
> The value returned is currently hard-coded to match the RPi2 I own. Other
> values are legal, e.g. different board manufacturer field values are likely to
> exist in the wild.
> 
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
> V2: Set the property in raspi.c, and pass it through to the property mbox
> code via property aliases.

Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>

Thanks,
Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH V2] bcm2835_property: implement "get board revision" query
  2016-02-09  5:41 ` Andrew Baumann
@ 2016-02-09 18:11   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-02-09 18:11 UTC (permalink / raw)
  To: Andrew Baumann; +Cc: qemu-arm, qemu-devel, Stephen Warren

On 9 February 2016 at 05:41, Andrew Baumann
<Andrew.Baumann@microsoft.com> wrote:
>> From: Stephen Warren [mailto:swarren@wwwdotorg.org]
>> Sent: Tuesday, 9 February 2016 3:59 PM
>>
>> Return a valid value from the BCM2835 property mailbox query "get board
>> revision". This query is used by U-Boot. Implementing it fixes the first
>> obvious difference between qemu and real HW.
>>
>> The value returned is currently hard-coded to match the RPi2 I own. Other
>> values are legal, e.g. different board manufacturer field values are likely to
>> exist in the wild.
>>
>> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
>> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
>> ---
>> V2: Set the property in raspi.c, and pass it through to the property mbox
>> code via property aliases.
>
> Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>



Applied to target-arm.next, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-09 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-09  4:58 [Qemu-devel] [PATCH V2] bcm2835_property: implement "get board revision" query Stephen Warren
2016-02-09  5:41 ` Andrew Baumann
2016-02-09 18:11   ` Peter Maydell

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).