From patchwork Mon Mar 23 14:55:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 453492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 106841400D5 for ; Tue, 24 Mar 2015 01:56:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=iHHNKSgE; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost ([::1]:56415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya3m6-0008L9-3R for incoming@patchwork.ozlabs.org; Mon, 23 Mar 2015 10:56:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya3le-0007dR-3g for qemu-devel@nongnu.org; Mon, 23 Mar 2015 10:55:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya3ld-0005m1-4C for qemu-devel@nongnu.org; Mon, 23 Mar 2015 10:55:50 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:38354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya3lc-0005ls-Ta for qemu-devel@nongnu.org; Mon, 23 Mar 2015 10:55:49 -0400 Received: by wibgn9 with SMTP id gn9so65292351wib.1 for ; Mon, 23 Mar 2015 07:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LuCTiWN1bsYWTDPOKyXS9NsRQ7NSXLVzcWi2YjaIuM0=; b=iHHNKSgEnpmrTQB8eiXu02OemINxuhap1CRVCy+00wHDWV2wkZ4pD7+HZaRMdH3ykE m/+G6bbqwns7Mx7ZAvMbXffT0boImQsyBzpU38TP5jv0DtJ7D/X4/qobO+wcsErg85Q5 afn45fPO8ADP2tx4hxGUCSHrFGIf7XmOrWx32BJiEfReXU3vVvCa9M447xp4cwP6mPSG 8+R5gt103uS4S4HRzDKUVb7gGFqPiBavI1BpMi3ADJGwOiLI41ZClvo9kUZ+3yuOysnW SLO99rllsjfYng+6AnGXlw2JhpGX0c+i0ti1Qsn0/l8HAT6XMF0E8o1QwcYJ4R845Iy0 xDrQ== X-Received: by 10.194.240.73 with SMTP id vy9mr2484044wjc.41.1427122548218; Mon, 23 Mar 2015 07:55:48 -0700 (PDT) Received: from donizetti.redhat.com (net-93-66-123-41.cust.vodafonedsl.it. [93.66.123.41]) by mx.google.com with ESMTPSA id v8sm11575115wib.0.2015.03.23.07.55.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 07:55:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 23 Mar 2015 15:55:38 +0100 Message-Id: <1427122538-26060-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1427122538-26060-1-git-send-email-pbonzini@redhat.com> References: <1427122538-26060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::235 Cc: edgar.iglesias@gmail.com, peter.crosthwaite@xilinx.com, michael@walle.cc, armbru@redhat.com, peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH for-2.3 v2 2/2] sdhci: add "drive" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a drive property that can be used with sdhci-pci (instead of the odd "-drive if=sd,... -device sdhci-pci" that has no equivalent in the rest of QEMU). Then adjust the zynq platform to set it based on the DriveInfo that it gets. Note that in this case the BlockBackend is attached to the SDHCI controller. This is not a problem; the ->dev field is really unused and the dev_opaque still points to the SDState struct. Required for 2.3, as it changes how users access the sdhci-pci device. Signed-off-by: Paolo Bonzini --- hw/arm/xilinx_zynq.c | 11 ++++++++++- hw/sd/sdhci.c | 11 ++--------- hw/sd/sdhci.h | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 5c37521..3d25c1a 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -114,6 +114,7 @@ static void zynq_init(MachineState *machine) MemoryRegion *ext_ram = g_new(MemoryRegion, 1); MemoryRegion *ocm_ram = g_new(MemoryRegion, 1); DeviceState *dev; + DriveInfo *dinfo; SysBusDevice *busdev; qemu_irq pic[64]; Error *err = NULL; @@ -172,7 +173,7 @@ static void zynq_init(MachineState *machine) vmstate_register_ram_global(ocm_ram); memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram); - DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0); + dinfo = drive_get(IF_PFLASH, 0, 0); /* AMD */ pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE, @@ -217,11 +218,19 @@ static void zynq_init(MachineState *machine) gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]); dev = qdev_create(NULL, "generic-sdhci"); + dinfo = drive_get_next(IF_SD); + if (dinfo) { + qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(dinfo)); + } qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]); dev = qdev_create(NULL, "generic-sdhci"); + dinfo = drive_get_next(IF_SD); + if (dinfo) { + qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(dinfo)); + } qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]); diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index ed60674..078b0bd 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1144,15 +1144,7 @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s) static void sdhci_initfn(SDHCIState *s) { - DriveInfo *di; - BlockBackend *blk; - - di = drive_get_next(IF_SD); - blk = di ? blk_by_legacy_dinfo(di) : NULL; - if (blk) { - blk_attach_dev_nofail(blk, s); - } - s->card = sd_init(blk, false); + s->card = sd_init(s->blk, false); if (s->card == NULL) { exit(1); } @@ -1222,6 +1214,7 @@ static Property sdhci_properties[] = { DEFINE_PROP_UINT32("capareg", SDHCIState, capareg, SDHC_CAPAB_REG_DEFAULT), DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0), + DEFINE_PROP_DRIVE("drive", SDHCIState, blk), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/sd/sdhci.h b/hw/sd/sdhci.h index 3352d23..69ccf58 100644 --- a/hw/sd/sdhci.h +++ b/hw/sd/sdhci.h @@ -237,6 +237,7 @@ typedef struct SDHCIState { PCIDevice pcidev; SysBusDevice busdev; }; + BlockBackend *blk; SDState *card; MemoryRegion iomem;