From patchwork Thu Aug 16 13:45:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 10772 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1494C23E1B for ; Thu, 16 Aug 2012 13:46:04 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id C38DDA18D03 for ; Thu, 16 Aug 2012 13:46:03 +0000 (UTC) Received: by ghbg10 with SMTP id g10so3066807ghb.11 for ; Thu, 16 Aug 2012 06:46:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=0eGyex6p4dA1cY/SL9sVIdhv/aEwYgjnhwlxwwKiAtY=; b=Cktxo0mzw37DKtWSB2HGHYE1KZDmqPIBSlCXBNSFgQRG6CqX65fhHfdd9Mb9Vve+YY 6NuWK34d/cL1bz8QEg8jYPyBVdc2dl/20M20VIkCNaFjykJr9oJlhnCfTde74iBG/38i x/iiTHQ1mivCIhw8/81YpNeBjI4z1R+VVRNIuDBjf8nB50cLbFWMujJN5oH1ZB8UHaoV rTgFwBa83T9A8lD/SJcmgjzli8VOi71NLsGnI/X6sLwq7LH/rEMZRPCQW3VbcjbJSj5K QfXTbIXhbgkayPkJhQUHX9msnTPUXJaQVX8/vNf91QWZB/EAsKMlOhq6JZnS4p71w2ma IcYg== Received: by 10.50.94.133 with SMTP id dc5mr2517915igb.16.1345124763105; Thu, 16 Aug 2012 06:46:03 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.200 with SMTP id ew8csp126733igc; Thu, 16 Aug 2012 06:46:00 -0700 (PDT) Received: by 10.14.215.193 with SMTP id e41mr1627531eep.44.1345124760398; Thu, 16 Aug 2012 06:46:00 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id o42si3039755eep.47.2012.08.16.06.45.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 06:46:00 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1T20OZ-00015o-2H; Thu, 16 Aug 2012 14:45:55 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Markus Armbruster , Kevin Wolf , Paul Brook Subject: [PATCH 2/3] pxa2xx: Get BlockDriverState* in mmc controller init, not board init Date: Thu, 16 Aug 2012 14:45:53 +0100 Message-Id: <1345124754-4173-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1345124754-4173-1-git-send-email-peter.maydell@linaro.org> References: <1345124754-4173-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQlneU+G6yYc0dN2TynRqWF7ZXDpytQqFa4xzEtw9U0LvxlpTrSeRhADfnzEUBhHd7NgonOU Instead of getting the BlockDriverState* in the pxa2xx board init and passing it to the mmc controller's init function, have the mmc controller get the next IF_SD device and use it if present. This brings us into line with other SD controller models and means that we correctly emulate an SD controller with no card present if the user didn't ask for an SD card. Signed-off-by: Peter Maydell --- hw/pxa.h | 2 +- hw/pxa2xx.c | 16 ++-------------- hw/pxa2xx_mmci.c | 7 +++++-- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/hw/pxa.h b/hw/pxa.h index 6a21205..569994b 100644 --- a/hw/pxa.h +++ b/hw/pxa.h @@ -87,7 +87,7 @@ void pxa2xx_lcdc_oritentation(void *opaque, int angle); typedef struct PXA2xxMMCIState PXA2xxMMCIState; PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, target_phys_addr_t base, - BlockDriverState *bd, qemu_irq irq, + qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma); void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly, qemu_irq coverswitch); diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index d5f1420..2c3ef1f 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -2006,7 +2006,6 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, { PXA2xxState *s; int i; - DriveInfo *dinfo; s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState)); if (revision && strncmp(revision, "pxa27", 5)) { @@ -2047,12 +2046,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->gpio = pxa2xx_gpio_init(0x40e00000, &s->cpu->env, s->pic, 121); - dinfo = drive_get(IF_SD, 0, 0); - if (!dinfo) { - fprintf(stderr, "qemu: missing SecureDigital device\n"); - exit(1); - } - s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, dinfo->bdrv, + s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC), qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI), qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI)); @@ -2143,7 +2137,6 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) { PXA2xxState *s; int i; - DriveInfo *dinfo; s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState)); @@ -2178,12 +2171,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) s->gpio = pxa2xx_gpio_init(0x40e00000, &s->cpu->env, s->pic, 85); - dinfo = drive_get(IF_SD, 0, 0); - if (!dinfo) { - fprintf(stderr, "qemu: missing SecureDigital device\n"); - exit(1); - } - s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, dinfo->bdrv, + s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC), qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI), qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI)); diff --git a/hw/pxa2xx_mmci.c b/hw/pxa2xx_mmci.c index b505a4c..f645773 100644 --- a/hw/pxa2xx_mmci.c +++ b/hw/pxa2xx_mmci.c @@ -14,6 +14,7 @@ #include "pxa.h" #include "sd.h" #include "qdev.h" +#include "blockdev.h" struct PXA2xxMMCIState { MemoryRegion iomem; @@ -523,10 +524,11 @@ static int pxa2xx_mmci_load(QEMUFile *f, void *opaque, int version_id) PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, target_phys_addr_t base, - BlockDriverState *bd, qemu_irq irq, + qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma) { PXA2xxMMCIState *s; + DriveInfo *dinfo; s = (PXA2xxMMCIState *) g_malloc0(sizeof(PXA2xxMMCIState)); s->irq = irq; @@ -538,7 +540,8 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, memory_region_add_subregion(sysmem, base, &s->iomem); /* Instantiate the actual storage */ - s->card = sd_init(bd, 0); + dinfo = drive_get_next(IF_SD); + s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0); register_savevm(NULL, "pxa2xx_mmci", 0, 0, pxa2xx_mmci_save, pxa2xx_mmci_load, s);