From patchwork Tue Jan 29 05:43:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuo-Jung Su X-Patchwork-Id: 216436 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 CF6E12C0090 for ; Tue, 29 Jan 2013 16:45:12 +1100 (EST) Received: from localhost ([::1]:45499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U040M-0000ni-Vh for incoming@patchwork.ozlabs.org; Tue, 29 Jan 2013 00:45:10 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U03zw-0008Uv-FZ for qemu-devel@nongnu.org; Tue, 29 Jan 2013 00:44:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U03zs-0008J3-Fw for qemu-devel@nongnu.org; Tue, 29 Jan 2013 00:44:44 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U03zs-0008Iy-6z for qemu-devel@nongnu.org; Tue, 29 Jan 2013 00:44:40 -0500 Received: by mail-pa0-f51.google.com with SMTP id fb11so170907pad.24 for ; Mon, 28 Jan 2013 21:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=H8vtfkeb4yFhhROQ4LXF1r8TpAgyHqiyGuapgBxH5gg=; b=zpZ3W8B8ccJrPxnEa+fHYMV8FYeBD0pNCZVCbGIdCGCqxRa6ats8zZoNFcV7hqNKxI 7/vJDAiVK9OupvI225KsvRxkgFLmvwBjJ4diD/e+ISq1b2D355QCnnZCddQ0Y4PY0uaH mjPWnU8/q4Zi8GI2OsnThrUAWIsVPpOupGr+0a5+4N6cjmgFQw5S906rc/M0/qja4B/a Lqd75h9l0aicpfOQUYZJUIWCYgH3vkbKR8MxWJwvv7MZS/tFomFJamZQ3qrRnADndJR8 bEQDSh2jxN5/y2/kC8b59zBy1lvE3o/1hKU7SolG/knG2S79qecY3e5IyfT0ww4Nwb39 KGaw== X-Received: by 10.69.0.4 with SMTP id au4mr767169pbd.152.1359438279439; Mon, 28 Jan 2013 21:44:39 -0800 (PST) Received: from localhost.localdomain ([220.132.37.35]) by mx.google.com with ESMTPS id ai8sm7724443pbd.14.2013.01.28.21.44.36 (version=TLSv1 cipher=DES-CBC3-SHA bits=168/168); Mon, 28 Jan 2013 21:44:38 -0800 (PST) From: Kuo-Jung Su To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2013 13:43:54 +0800 Message-Id: <1359438234-5337-3-git-send-email-dantesu@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1359438234-5337-1-git-send-email-dantesu@gmail.com> References: <1359438234-5337-1-git-send-email-dantesu@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.51 Cc: Peter Crosthwaite , Gerd Hoffmann , Kuo-Jung Su , Andreas Subject: [Qemu-devel] [PATCH 2/2] usb-ehci: add Faraday FUSBH200 support 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 From: Kuo-Jung Su Add Faraday FUSBH200 support, which is slightly different from EHCI spec. (Or maybe simply a bad/wrong implementation...) Signed-off-by: Kuo-Jung Su Cc: Gerd Hoffmann Cc: Andreas Cc: Peter Crosthwaite --- hw/usb/hcd-ehci-sysbus.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ hw/usb/hcd-ehci.h | 5 ++++ 2 files changed, 71 insertions(+) diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c index ae2db1a..404a227 100644 --- a/hw/usb/hcd-ehci-sysbus.c +++ b/hw/usb/hcd-ehci-sysbus.c @@ -17,6 +17,49 @@ #include "hw/usb/hcd-ehci.h" +/* + * Faraday FUSBH200 USB 2.0 EHCI + */ + +static uint64_t +ehci_fusbh200_read(void *ptr, hwaddr addr, unsigned size) +{ + hwaddr off = 0x34 + addr; + + switch (off) { + case 0x34: /* fusbh200: EOF/Async. Sleep Timer Register */ + return 0x00000041; + case 0x40: /* fusbh200: Bus Monitor Control/Status Register */ + /* High-Speed, VBUS valid, interrupt level-high active */ + return (2 << 9) | (1 << 8) | (1 << 3); + } + + return 0; +} + +static void +ehci_fusbh200_write(void *ptr, hwaddr addr, uint64_t val, unsigned size) +{ +} + +static const MemoryRegionOps ehci_mmio_fusbh200_ops = { + .read = ehci_fusbh200_read, + .write = ehci_fusbh200_write, + .valid.min_access_size = 4, + .valid.max_access_size = 4, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +static void +usb_ehci_fusbh200_initfn(EHCIState *s, DeviceState *dev) +{ + memory_region_init_io(&s->mem_vendor, &ehci_mmio_fusbh200_ops, s, + "fusbh200", 0x4c); + memory_region_add_subregion(&s->mem, + s->opregbase + s->portscbase + 4 * s->portnr, + &s->mem_vendor); +} + static const VMStateDescription vmstate_ehci_sysbus = { .name = "ehci-sysbus", .version_id = 2, @@ -46,6 +89,9 @@ static void usb_ehci_sysbus_realizefn(DeviceState *dev, Error **errp) s->dma = &dma_context_memory; usb_ehci_initfn(s, dev); + if (sec->vendor_init) { + sec->vendor_init(s, DEVICE(dev)); + } sysbus_init_irq(d, &s->irq); sysbus_init_mmio(d, &s->mem); } @@ -76,6 +122,7 @@ static void ehci_xlnx_class_init(ObjectClass *oc, void *data) sec->opregbase = 0x140; sec->portscbase = 0x44; sec->portnr = NB_PORTS; + sec->vendor_init = NULL; } static const TypeInfo ehci_xlnx_type_info = { @@ -92,6 +139,7 @@ static void ehci_exynos4210_class_init(ObjectClass *oc, void *data) sec->opregbase = 0x10; sec->portscbase = 0x44; sec->portnr = NB_PORTS; + sec->vendor_init = NULL; } static const TypeInfo ehci_exynos4210_type_info = { @@ -100,11 +148,29 @@ static const TypeInfo ehci_exynos4210_type_info = { .class_init = ehci_exynos4210_class_init, }; +static void ehci_fusbh200_class_init(ObjectClass *oc, void *data) +{ + SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(oc); + + sec->capsbase = 0x0; + sec->opregbase = 0x10; + sec->portscbase = 0x20; + sec->portnr = 1; + sec->vendor_init = usb_ehci_fusbh200_initfn; +} + +static const TypeInfo ehci_fusbh200_type_info = { + .name = TYPE_FUSBH200_EHCI, + .parent = TYPE_SYS_BUS_EHCI, + .class_init = ehci_fusbh200_class_init, +}; + static void ehci_sysbus_register_types(void) { type_register_static(&ehci_type_info); type_register_static(&ehci_xlnx_type_info); type_register_static(&ehci_exynos4210_type_info); + type_register_static(&ehci_fusbh200_type_info); } type_init(ehci_sysbus_register_types) diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index e587b67..3ca9c8f 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -261,6 +261,7 @@ struct EHCIState { MemoryRegion mem_caps; MemoryRegion mem_opreg; MemoryRegion mem_ports; + MemoryRegion mem_vendor; int companion_count; uint16_t capsbase; uint16_t opregbase; @@ -336,6 +337,7 @@ typedef struct EHCIPCIState { #define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" #define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" +#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" #define SYS_BUS_EHCI(obj) \ OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI) @@ -361,6 +363,9 @@ typedef struct SysBusEHCIClass { uint16_t opregbase; uint16_t portscbase; uint16_t portnr; + + /* vendor specific init function */ + void (*vendor_init)(EHCIState *s, DeviceState *dev); } SysBusEHCIClass; #endif