From patchwork Fri Oct 26 05:47:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 194377 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CB7012C00B0 for ; Fri, 26 Oct 2012 17:24:15 +1100 (EST) Received: from localhost ([::1]:37885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRcmq-0004L9-Cs for incoming@patchwork.ozlabs.org; Fri, 26 Oct 2012 01:48:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRcmZ-0003pE-1O for qemu-devel@nongnu.org; Fri, 26 Oct 2012 01:48:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRcmX-000129-PS for qemu-devel@nongnu.org; Fri, 26 Oct 2012 01:48:34 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:33400) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRcmX-000123-In for qemu-devel@nongnu.org; Fri, 26 Oct 2012 01:48:33 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so2425801pbb.4 for ; Thu, 25 Oct 2012 22:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=HhnkKM9dnTGm245j9lEXkptuCoQbR84Y246IRoRuhCU=; b=GNqUNxiJh6UhboJYKiGAXBx5dgoXYwXxlpGoxoouX+uzvExugkzWD/WJBP2W+EG6MS uqeL3tq4uEGL/Y28W627T4P+MlmYckOsm3V5ZX+UVx86wR3zsJeboYv1xpBw1IqNbuWb ODqUH1f5K0FyHgf2/NhjQGOH5RGD2/tVUsMOsHMnADzjinc+3TGWe/QDUBuPD1hdS4d3 fXwQ38ZXLngs1hk3DDzBp6lw8zFK5t6wbkZpMpCGiZoP28R0R1zrk/Ck2unmEZKDZ3/E 7eHvmSas2LSoSCRJb2g1HnnLHWWOoV7zqDV4hExQQLnP0saRQGNYKUDPh53m1If+V1r2 4SBw== Received: by 10.68.238.34 with SMTP id vh2mr67231111pbc.6.1351230512410; Thu, 25 Oct 2012 22:48:32 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id kr4sm612980pbc.76.2012.10.25.22.48.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Oct 2012 22:48:31 -0700 (PDT) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2012 15:47:46 +1000 Message-Id: <1303394fe7068b327c5c756b97fc4b15a2a14757.1351229557.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQnnrTY9kLntn+3vMrl0J9Qlpl9QCcgDHNrffolxeAbDUVn5EVuA3NVjsBOxlDMFJUubqeBF X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: vineshp@xilinx.com, peter.maydell@linaro.org, Peter Crosthwaite , john.williams@xilinx.com, kraxel@redhat.com, edgar.iglesias@gmail.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 06/11] usb/ehci: Add Sysbus Infrastructure 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 QOM class definition helpers for sysbus attached EHCI implementations. Signed-off-by: Peter Crosthwaite --- changed from v1: Dont create a QOM definition for Sysbus EHCI, rather just add all the bits and pieces. (Multiple) sysbus EHCI defs can be created by adding to the type_info[] table. Use dma_context_memory for sysbus DMA (PMM review) hw/usb/hcd-ehci.c | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 1c5e5ed..50a85d5 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -35,6 +35,8 @@ #include "trace.h" #include "dma.h" #include "sysemu.h" +#include "hw/sysbus.h" +#include "exec-memory.h" #define EHCI_DEBUG 0 @@ -448,6 +450,7 @@ struct EHCIState { typedef struct EHCItfState { union { PCIDevice pcidev; + SysBusDevice busdev; }; struct EHCIState ehci; } EHCIItfState; @@ -2546,6 +2549,7 @@ static const MemoryRegionOps ehci_mmio_port_ops = { }; static int usb_ehci_pci_initfn(PCIDevice *dev); +static int usb_ehci_sysbus_initfn(SysBusDevice *dev); static USBPortOps ehci_port_ops = { .attach = ehci_attach, @@ -2652,6 +2656,16 @@ static const VMStateDescription vmstate_ehci_pci = { } }; +static const VMStateDescription vmstate_ehci_sysbus = { + .name = "ehci-sysbus", + .version_id = 2, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(ehci, EHCIItfState, 2, vmstate_ehci, EHCIState), + VMSTATE_END_OF_LIST() + } +}; + static Property ehci_properties[] = { DEFINE_PROP_UINT32("maxframes", EHCIItfState, ehci.maxframes, 128), DEFINE_PROP_END_OF_LIST(), @@ -2660,6 +2674,7 @@ static Property ehci_properties[] = { typedef struct EHCIClass { union { PCIDeviceClass pci; + SysBusDeviceClass sysbus; }; uint16_t capabase; @@ -2694,6 +2709,14 @@ static void ehci_pci_class_init(ObjectClass *klass, void *data) ehci_class_init(klass, data); } +static void ehci_sysbus_class_init(ObjectClass *klass, void *data) +{ + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); + + k->init = usb_ehci_sysbus_initfn; + ehci_class_init(klass, data); +} + static TypeInfo ehci_info[] = { { .name = "usb-ehci", @@ -2726,7 +2749,6 @@ static TypeInfo ehci_info[] = { }, { .name = NULL } }; - static void usb_ehci_initfn(EHCIState *s, DeviceState *dev) { EHCIClass *c = (EHCIClass *)object_get_class(OBJECT(dev)); @@ -2778,6 +2800,20 @@ static void usb_ehci_initfn(EHCIState *s, DeviceState *dev) &s->mem_ports); } +static int usb_ehci_sysbus_initfn(SysBusDevice *dev) +{ + EHCIItfState *i = FROM_SYSBUS(EHCIItfState, dev); + EHCIState *s = &i->ehci; + + s->dma = &dma_context_memory; + + usb_ehci_initfn(s, DEVICE(dev)); + sysbus_init_irq(dev, &s->irq); + sysbus_init_mmio(dev, &s->mem); + + return 0; +} + static int usb_ehci_pci_initfn(PCIDevice *dev) { EHCIItfState *i = DO_UPCAST(EHCIItfState, pcidev, dev);