diff mbox

[3/5] hw/pl061.c: Implement ARM PL061 as well as Luminary one

Message ID 1298321873-17064-4-git-send-email-peter.maydell@linaro.org
State Accepted
Commit 7063f49f59807ac6f32c69281cf956d14d6c0310
Headers show

Commit Message

Peter Maydell Feb. 21, 2011, 8:57 p.m. UTC
ARM's PL061 has a different set of ID registers to the one in the
Luminary Stellaris; implement this so that the Linux driver can
identify the Realview PBX PL061 correctly.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/pl061.c     |   23 +++++++++++++++++++----
 hw/stellaris.c |    2 +-
 2 files changed, 20 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/hw/pl061.c b/hw/pl061.c
index 1997b7c..2e181f8 100644
--- a/hw/pl061.c
+++ b/hw/pl061.c
@@ -24,6 +24,8 @@  do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__);} while (0)
 #endif
 
 static const uint8_t pl061_id[12] =
+  { 0x00, 0x00, 0x00, 0x00, 0x61, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
+static const uint8_t pl061_id_luminary[12] =
   { 0x00, 0x00, 0x00, 0x00, 0x61, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1 };
 
 typedef struct {
@@ -50,6 +52,7 @@  typedef struct {
     uint8_t float_high;
     qemu_irq irq;
     qemu_irq out[8];
+    const unsigned char *id;
 } pl061_state;
 
 static void pl061_update(pl061_state *s)
@@ -83,7 +86,7 @@  static uint32_t pl061_read(void *opaque, target_phys_addr_t offset)
     pl061_state *s = (pl061_state *)opaque;
 
     if (offset >= 0xfd0 && offset < 0x1000) {
-        return pl061_id[(offset - 0xfd0) >> 2];
+        return s->id[(offset - 0xfd0) >> 2];
     }
     if (offset < 0x400) {
         return s->data & (offset >> 2);
@@ -291,11 +294,11 @@  static int pl061_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static int pl061_init(SysBusDevice *dev)
+static int pl061_init(SysBusDevice *dev, const unsigned char *id)
 {
     int iomemtype;
     pl061_state *s = FROM_SYSBUS(pl061_state, dev);
-
+    s->id = id;
     iomemtype = cpu_register_io_memory(pl061_readfn,
                                        pl061_writefn, s,
                                        DEVICE_NATIVE_ENDIAN);
@@ -308,10 +311,22 @@  static int pl061_init(SysBusDevice *dev)
     return 0;
 }
 
+static int pl061_init_luminary(SysBusDevice *dev)
+{
+    return pl061_init(dev, pl061_id_luminary);
+}
+
+static int pl061_init_arm(SysBusDevice *dev)
+{
+    return pl061_init(dev, pl061_id);
+}
+
 static void pl061_register_devices(void)
 {
     sysbus_register_dev("pl061", sizeof(pl061_state),
-                        pl061_init);
+                        pl061_init_arm);
+    sysbus_register_dev("pl061_luminary", sizeof(pl061_state),
+                        pl061_init_luminary);
 }
 
 device_init(pl061_register_devices)
diff --git a/hw/stellaris.c b/hw/stellaris.c
index b903273..5d8bd55 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1338,7 +1338,7 @@  static void stellaris_init(const char *kernel_filename, const char *cpu_model,
 
     for (i = 0; i < 7; i++) {
         if (board->dc4 & (1 << i)) {
-            gpio_dev[i] = sysbus_create_simple("pl061", gpio_addr[i],
+            gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i],
                                                pic[gpio_irq[i]]);
             for (j = 0; j < 8; j++) {
                 gpio_in[i][j] = qdev_get_gpio_in(gpio_dev[i], j);