From patchwork Sat Feb 12 00:15:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 82880 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 04C2AB70A7 for ; Sat, 12 Feb 2011 11:17:25 +1100 (EST) Received: from localhost ([127.0.0.1]:50244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Po3Av-0002tR-7b for incoming@patchwork.ozlabs.org; Fri, 11 Feb 2011 19:17:21 -0500 Received: from [140.186.70.92] (port=50647 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Po39T-0002rU-Jx for qemu-devel@nongnu.org; Fri, 11 Feb 2011 19:15:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Po39S-0003s9-3q for qemu-devel@nongnu.org; Fri, 11 Feb 2011 19:15:51 -0500 Received: from mail-ey0-f173.google.com ([209.85.215.173]:61114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Po39R-0003rs-Ri for qemu-devel@nongnu.org; Fri, 11 Feb 2011 19:15:49 -0500 Received: by mail-ey0-f173.google.com with SMTP id 7so1642429eyg.4 for ; Fri, 11 Feb 2011 16:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=giVtQc4Jv1s7NgznDgh0+W6big2u8UWxsz2e8jQvvKI=; b=ejCZDwmnDnV0V/vDXUI7VO3IJ3gENYWMkSgTTBkBgZ9+Q7Xlm3Yzhj0h5GvBT3ItOl f3+apJmuHus04yfnOS/HN85zv/zxPwZQ6aquhb6oTCjxJGC9jCjFXBDc8v5tveneJip7 c7VPOs2k8wyOddL/mlhIbRtjgLCWSAklQorhk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; b=nkNhIF+WOiDMQjTFYcrtDWh99/66oIirD5asyelxk/pMX6aV4yM2gznnT9yLp0kIML GDF8P2htxvwqOgfGbZQpzIv+ELTodvPRaAbrQajNV1F+YB2Kd10SzyLbnXBTvvxH/eoX niuJ9Q4VrYvge5nshHVQYWaQ3BCCFjjkanxRk= Received: by 10.14.119.72 with SMTP id m48mr1132145eeh.30.1297469748814; Fri, 11 Feb 2011 16:15:48 -0800 (PST) Received: from doriath.ww600.siemens.net (ppp89-110-8-230.pppoe.avangarddsl.ru [89.110.8.230]) by mx.google.com with ESMTPS id t5sm1202197eeh.20.2011.02.11.16.15.46 (version=SSLv3 cipher=OTHER); Fri, 11 Feb 2011 16:15:47 -0800 (PST) From: Dmitry Eremin-Solenikov To: qemu-devel@nongnu.org Date: Sat, 12 Feb 2011 03:15:24 +0300 Message-Id: <1297469725-31730-2-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1297469725-31730-1-git-send-email-dbaryshkov@gmail.com> References: <1297469725-31730-1-git-send-email-dbaryshkov@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.215.173 Subject: [Qemu-devel] [PATCH 2/3] mainstone: convert FPGA emulation code to use QDev/SysBus 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 Signed-off-by: Dmitry Eremin-Solenikov --- hw/mainstone.c | 10 +++-- hw/mainstone.h | 3 -- hw/mst_fpga.c | 96 ++++++++++++++++++++++++++++---------------------------- 3 files changed, 54 insertions(+), 55 deletions(-) diff --git a/hw/mainstone.c b/hw/mainstone.c index 18d1415..9c8bc15 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -18,6 +18,7 @@ #include "sysemu.h" #include "flash.h" #include "blockdev.h" +#include "sysbus.h" static struct keymap map[0xE0] = { [0 ... 0xDF] = { -1, -1 }, @@ -77,7 +78,7 @@ static void mainstone_common_init(ram_addr_t ram_size, uint32_t sector_len = 256 * 1024; target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 }; PXA2xxState *cpu; - qemu_irq *mst_irq; + DeviceState *mst_irq; DriveInfo *dinfo; int i; int be; @@ -117,16 +118,17 @@ static void mainstone_common_init(ram_addr_t ram_size, } } - mst_irq = mst_irq_init(MST_FPGA_PHYS, cpu->pic[PXA2XX_PIC_GPIO_0]); + mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS, + cpu->pic[PXA2XX_PIC_GPIO_0]); /* setup keypad */ printf("map addr %p\n", &map); pxa27x_register_keypad(cpu->kp, map, 0xe0); /* MMC/SD host */ - pxa2xx_mmci_handlers(cpu->mmc, NULL, mst_irq[MMC_IRQ]); + pxa2xx_mmci_handlers(cpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ)); - smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]); + smc91c111_init(&nd_table[0], MST_ETH_PHYS, qdev_get_gpio_in(mst_irq, ETHERNET_IRQ)); mainstone_binfo.kernel_filename = kernel_filename; mainstone_binfo.kernel_cmdline = kernel_cmdline; diff --git a/hw/mainstone.h b/hw/mainstone.h index 35329f1..e6a2b67 100644 --- a/hw/mainstone.h +++ b/hw/mainstone.h @@ -32,7 +32,4 @@ #define S1_STSCHG_IRQ 14 #define S1_IRQ 15 -extern qemu_irq -*mst_irq_init(uint32_t base, qemu_irq irq); - #endif /* __MAINSTONE_H__ */ diff --git a/hw/mst_fpga.c b/hw/mst_fpga.c index 3c594b8..afed2ac 100644 --- a/hw/mst_fpga.c +++ b/hw/mst_fpga.c @@ -8,7 +8,7 @@ * This code is licensed under the GNU GPL v2. */ #include "hw.h" -#include "mainstone.h" +#include "sysbus.h" /* Mainstone FPGA for extern irqs */ #define FPGA_GPIO_PIN 0 @@ -27,8 +27,9 @@ #define MST_PCMCIA1 0xe4 typedef struct mst_irq_state{ + SysBusDevice busdev; + qemu_irq parent; - qemu_irq *pins; uint32_t prev_level; uint32_t leddat1; @@ -163,68 +164,67 @@ static CPUWriteMemoryFunc * const mst_fpga_writefn[] = { mst_fpga_writeb, }; -static void -mst_fpga_save(QEMUFile *f, void *opaque) -{ - struct mst_irq_state *s = (mst_irq_state *) opaque; - - qemu_put_be32s(f, &s->prev_level); - qemu_put_be32s(f, &s->leddat1); - qemu_put_be32s(f, &s->leddat2); - qemu_put_be32s(f, &s->ledctrl); - qemu_put_be32s(f, &s->gpswr); - qemu_put_be32s(f, &s->mscwr1); - qemu_put_be32s(f, &s->mscwr2); - qemu_put_be32s(f, &s->mscwr3); - qemu_put_be32s(f, &s->mscrd); - qemu_put_be32s(f, &s->intmskena); - qemu_put_be32s(f, &s->intsetclr); - qemu_put_be32s(f, &s->pcmcia0); - qemu_put_be32s(f, &s->pcmcia1); -} -static int -mst_fpga_load(QEMUFile *f, void *opaque, int version_id) +static int mst_fpga_post_load(void *opaque, int version_id) { mst_irq_state *s = (mst_irq_state *) opaque; - qemu_get_be32s(f, &s->prev_level); - qemu_get_be32s(f, &s->leddat1); - qemu_get_be32s(f, &s->leddat2); - qemu_get_be32s(f, &s->ledctrl); - qemu_get_be32s(f, &s->gpswr); - qemu_get_be32s(f, &s->mscwr1); - qemu_get_be32s(f, &s->mscwr2); - qemu_get_be32s(f, &s->mscwr3); - qemu_get_be32s(f, &s->mscrd); - qemu_get_be32s(f, &s->intmskena); - qemu_get_be32s(f, &s->intsetclr); - qemu_get_be32s(f, &s->pcmcia0); - qemu_get_be32s(f, &s->pcmcia1); - qemu_set_irq(s->parent, s->intsetclr & s->intmskena); return 0; } -qemu_irq *mst_irq_init(uint32_t base, qemu_irq irq) +static int mst_fpga_init(SysBusDevice *dev) { mst_irq_state *s; int iomemtype; - qemu_irq *qi; - s = (mst_irq_state *) - qemu_mallocz(sizeof(mst_irq_state)); + s = FROM_SYSBUS(mst_irq_state, dev); - s->parent = irq; + sysbus_init_irq(dev, &s->parent); /* alloc the external 16 irqs */ - qi = qemu_allocate_irqs(mst_fpga_set_irq, s, MST_NUM_IRQS); - s->pins = qi; + qdev_init_gpio_in(&dev->qdev, mst_fpga_set_irq, MST_NUM_IRQS); iomemtype = cpu_register_io_memory(mst_fpga_readfn, mst_fpga_writefn, s, DEVICE_NATIVE_ENDIAN); - cpu_register_physical_memory(base, 0x00100000, iomemtype); - register_savevm(NULL, "mainstone_fpga", 0, 0, mst_fpga_save, - mst_fpga_load, s); - return qi; + sysbus_init_mmio(dev, 0x00100000, iomemtype); + return 0; +} + +static VMStateDescription vmstate_mst_fpga_regs = { + .name = "mainstone_fpga", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .post_load = mst_fpga_post_load, + .fields = (VMStateField []) { + VMSTATE_UINT32(prev_level, mst_irq_state), + VMSTATE_UINT32(leddat1, mst_irq_state), + VMSTATE_UINT32(leddat2, mst_irq_state), + VMSTATE_UINT32(ledctrl, mst_irq_state), + VMSTATE_UINT32(gpswr, mst_irq_state), + VMSTATE_UINT32(mscwr1, mst_irq_state), + VMSTATE_UINT32(mscwr2, mst_irq_state), + VMSTATE_UINT32(mscwr3, mst_irq_state), + VMSTATE_UINT32(mscrd, mst_irq_state), + VMSTATE_UINT32(intmskena, mst_irq_state), + VMSTATE_UINT32(intsetclr, mst_irq_state), + VMSTATE_UINT32(pcmcia0, mst_irq_state), + VMSTATE_UINT32(pcmcia1, mst_irq_state), + VMSTATE_END_OF_LIST(), + }, +}; + +static SysBusDeviceInfo mst_fpga_info = { + .init = mst_fpga_init, + .qdev.name = "mainstone-fpga", + .qdev.desc = "Mainstone II FPGA", + .qdev.size = sizeof(mst_irq_state), + .qdev.vmsd = &vmstate_mst_fpga_regs, +}; + +static void mst_fpga_register(void) +{ + sysbus_register_withprop(&mst_fpga_info); } +device_init(mst_fpga_register);