From patchwork Thu Aug 16 13:45:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 10771 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 B7F5F23E1B for ; Thu, 16 Aug 2012 13:46:03 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 72AF1A18D09 for ; Thu, 16 Aug 2012 13:46:03 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3063922yhp.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=0Ecbrj/bu2yeZBUGeQYpCuD1y+QLYL3oJch0yd2SPoA=; b=hF3yKgQpeCGbtCDUInV+N3rZUygM5gaEgQYVIs5ZiJ7fdSmD2CRVSWuu7QeH58PlTm T2Z75jwRZj/bLBk5MvrOhmLVOG97ZSxK5VoXeoTCNYzAdqFWbTwWAx102W2Q7PxtlkHE GNceqm9OHnjyAcyWr5tfQbBIt7qNSC+DU17USPhIg5UQi4sEMKTYml4FuArDMqKQ4Jwk 8bF+48ibXZaWCryxWm+P1pgxs5gWduObvevz0YAJuQry6wZBvqr/VIXI0KtxUbaEYQIb eTcIBW2v6l7N1dd48Ky+kUAPjJg83gcekfBMxjCdGIKHXmDYKZOyoxYZ4x6p9OOucVPE uAPQ== Received: by 10.50.170.3 with SMTP id ai3mr2571930igc.9.1345124762750; Thu, 16 Aug 2012 06:46:02 -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 ew8csp126730igc; Thu, 16 Aug 2012 06:46:00 -0700 (PDT) Received: by 10.204.129.16 with SMTP id m16mr540633bks.136.1345124760053; Thu, 16 Aug 2012 06:46:00 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id hc18si4681879bkc.146.2012.08.16.06.45.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 06:45:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1T20OZ-00015m-14; 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 1/3] omap: Get BlockDriverState* in mmc controller init, not board init Date: Thu, 16 Aug 2012 14:45:52 +0100 Message-Id: <1345124754-4173-2-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: ALoCoQn8/ggM5nH3pTFE/aRlqercovnOSg183kU16NyN4jlDd9hrcwUFp5QJeHOJtu64HK27bT2y Instead of getting the BlockDriverState* in the omap 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/omap.h | 3 +-- hw/omap1.c | 8 +------- hw/omap2.c | 8 +------- hw/omap_mmc.c | 12 ++++++++---- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/hw/omap.h b/hw/omap.h index 413851b..de5ec8c 100644 --- a/hw/omap.h +++ b/hw/omap.h @@ -754,10 +754,9 @@ void omap_rfbi_attach(struct omap_dss_s *s, int cs, struct rfbi_chip_s *chip); struct omap_mmc_s; struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base, MemoryRegion *sysmem, - BlockDriverState *bd, qemu_irq irq, qemu_irq dma[], omap_clk clk); struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, - BlockDriverState *bd, qemu_irq irq, qemu_irq dma[], + qemu_irq irq, qemu_irq dma[], omap_clk fclk, omap_clk iclk); void omap_mmc_reset(struct omap_mmc_s *s); void omap_mmc_handlers(struct omap_mmc_s *s, qemu_irq ro, qemu_irq cover); diff --git a/hw/omap1.c b/hw/omap1.c index ad60cc4..641e260 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -3823,7 +3823,6 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory, g_malloc0(sizeof(struct omap_mpu_state_s)); qemu_irq *cpu_irq; qemu_irq dma_irqs[6]; - DriveInfo *dinfo; SysBusDevice *busdev; if (!core) @@ -3961,12 +3960,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory, s->dpll[2] = omap_dpll_init(system_memory, 0xfffed100, omap_findclk(s, "dpll3")); - dinfo = drive_get(IF_SD, 0, 0); - if (!dinfo) { - fprintf(stderr, "qemu: missing SecureDigital device\n"); - exit(1); - } - s->mmc = omap_mmc_init(0xfffb7800, system_memory, dinfo->bdrv, + s->mmc = omap_mmc_init(0xfffb7800, system_memory, qdev_get_gpio_in(s->ih[1], OMAP_INT_OQN), &s->drq[OMAP_DMA_MMC_TX], omap_findclk(s, "mmc_ck")); diff --git a/hw/omap2.c b/hw/omap2.c index 4278dd1..28178dd 100644 --- a/hw/omap2.c +++ b/hw/omap2.c @@ -2246,7 +2246,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, g_malloc0(sizeof(struct omap_mpu_state_s)); qemu_irq *cpu_irq; qemu_irq dma_irqs[4]; - DriveInfo *dinfo; int i; SysBusDevice *busdev; struct omap_target_agent_s *ta; @@ -2454,12 +2453,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPMC_IRQ), s->drq[OMAP24XX_DMA_GPMC]); - dinfo = drive_get(IF_SD, 0, 0); - if (!dinfo) { - fprintf(stderr, "qemu: missing SecureDigital device\n"); - exit(1); - } - s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), dinfo->bdrv, + s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MMC_IRQ), &s->drq[OMAP24XX_DMA_MMC1_TX], omap_findclk(s, "mmc_fclk"), omap_findclk(s, "mmc_iclk")); diff --git a/hw/omap_mmc.c b/hw/omap_mmc.c index aec0285..eada07d 100644 --- a/hw/omap_mmc.c +++ b/hw/omap_mmc.c @@ -19,6 +19,7 @@ #include "hw.h" #include "omap.h" #include "sd.h" +#include "blockdev.h" struct omap_mmc_s { qemu_irq irq; @@ -574,9 +575,9 @@ static void omap_mmc_cover_cb(void *opaque, int line, int level) struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base, MemoryRegion *sysmem, - BlockDriverState *bd, qemu_irq irq, qemu_irq dma[], omap_clk clk) { + DriveInfo *dinfo; struct omap_mmc_s *s = (struct omap_mmc_s *) g_malloc0(sizeof(struct omap_mmc_s)); @@ -592,15 +593,17 @@ struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base, memory_region_add_subregion(sysmem, base, &s->iomem); /* Instantiate the storage */ - s->card = sd_init(bd, 0); + dinfo = drive_get_next(IF_SD); + s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0); return s; } struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, - BlockDriverState *bd, qemu_irq irq, qemu_irq dma[], + qemu_irq irq, qemu_irq dma[], omap_clk fclk, omap_clk iclk) { + DriveInfo *dinfo; struct omap_mmc_s *s = (struct omap_mmc_s *) g_malloc0(sizeof(struct omap_mmc_s)); @@ -617,7 +620,8 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, omap_l4_attach(ta, 0, &s->iomem); /* Instantiate the storage */ - s->card = sd_init(bd, 0); + dinfo = drive_get_next(IF_SD); + s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0); s->cdet = qemu_allocate_irqs(omap_mmc_cover_cb, s, 1)[0]; sd_set_cb(s->card, NULL, s->cdet);