From patchwork Mon Feb 21 20:57:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 83873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2355BB715A for ; Tue, 22 Feb 2011 08:01:02 +1100 (EST) Received: from localhost ([127.0.0.1]:56711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Prcro-0000dM-S1 for incoming@patchwork.ozlabs.org; Mon, 21 Feb 2011 16:00:24 -0500 Received: from [140.186.70.92] (port=39003 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrcpT-00089J-HQ for qemu-devel@nongnu.org; Mon, 21 Feb 2011 15:58:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrcpR-0001iv-1s for qemu-devel@nongnu.org; Mon, 21 Feb 2011 15:57:59 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:60890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrcpQ-0001i9-PS for qemu-devel@nongnu.org; Mon, 21 Feb 2011 15:57:57 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1PrcpN-0004Rl-OY; Mon, 21 Feb 2011 20:57:53 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 21 Feb 2011 20:57:51 +0000 Message-Id: <1298321873-17064-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1298321873-17064-1-git-send-email-peter.maydell@linaro.org> References: <1298321873-17064-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: patches@linaro.org Subject: [Qemu-devel] [PATCH 3/5] hw/pl061.c: Implement ARM PL061 as well as Luminary one X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- hw/pl061.c | 23 +++++++++++++++++++---- hw/stellaris.c | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) 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);