From patchwork Mon Feb 17 20:48:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1239574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=phPSBihY; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Lx100cnHz9sPK for ; Tue, 18 Feb 2020 07:49:08 +1100 (AEDT) Received: from localhost ([::1]:52732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nKD-00065a-U7 for incoming@patchwork.ozlabs.org; Mon, 17 Feb 2020 15:49:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38205) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nJU-0005Y9-AE for qemu-devel@nongnu.org; Mon, 17 Feb 2020 15:48:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3nJT-0007R1-AF for qemu-devel@nongnu.org; Mon, 17 Feb 2020 15:48:20 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:43551) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3nJR-0007Pd-6M; Mon, 17 Feb 2020 15:48:17 -0500 Received: by mail-pf1-x444.google.com with SMTP id s1so9507407pfh.10; Mon, 17 Feb 2020 12:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jUTT4M0L8QDIDF54nsaAa0WO27b/nakwYQvzOrU6Ztw=; b=phPSBihY8AJQIjrwsRfg0abA5X9X77YiZkwqdMrRCdzwDPTKiH7KXB77ryFCyFAFI1 OlAo3z2JfUYoPbevHU+JOLabkT1Ez+SpR/6jVo4Z3DzkZH/XdAEK1fVMv/phRludrSDa SlCiTOfs45ZUQR8ByC+QDNI9781bwH75+Ai2IbOLCqf5QbmcAKHfWxA1LOIDI2wmzNtE NPNDhPFlUNIJ4fuzjqaIEpuAiisHOygj3/4BpVGb09z/Fv4eFvAQ7lQ9ucjwV86EMvg/ Co/oOIhJ4ftHhnl8YV12hWk7Lt80C2lBVWFNmT61k88EVvSQPpuaUCP4GaYneDDWy+R+ PZIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jUTT4M0L8QDIDF54nsaAa0WO27b/nakwYQvzOrU6Ztw=; b=an6Ldt3i86gjR+QOZ+jT7gu5Tg+v4zToGfkBR6DEh+ldESPlQAs7PDIvz7rcmtu3Nr B8PHvYV/0IUnDesyNwCWhF2CFyhJAvYEaxPNbTR2WTwOiFvUEW15P0tLHWb5PAf7359O io2h8mgIGOmQE/rYbpe9YFgvis60eXLAZfqgC09c5v22ZjEiYDsFDk0BCPYIAxCilBGN 5G0xkYm+hBt5fqINBFVDA4YpNKVvnV2ZPvBnT7WXccjURMfmrdYsg7y9RVA/6yVuSAJy gnpzrWNgvJ57+qC3nfNmY0GRdJqfZlLccDAKaI2XBFWXF1W61g+fVGXSVhkH+voMIxjV fpbg== X-Gm-Message-State: APjAAAXHsakbyHnLZZUhNGq6ssNjR/5bIfP3xrk0RtKgn8ZC4c1fk77z S/4bBkWqtFFiYGWZJU4iBHI= X-Google-Smtp-Source: APXvYqxP6Oi0A8J6gvapYkqPB3AV9FXqDOGBnPoUbwWVzrhm8+AY5ecBDM2Mq9ob4gU64xfqK3Z5rQ== X-Received: by 2002:aa7:8ec1:: with SMTP id b1mr18030005pfr.95.1581972496332; Mon, 17 Feb 2020 12:48:16 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r14sm1327729pfh.10.2020.02.17.12.48.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Feb 2020 12:48:15 -0800 (PST) From: Guenter Roeck To: Peter Maydell Subject: [PATCH v3 1/3] hw: usb: hcd-ohci: Move OHCISysBusState and TYPE_SYSBUS_OHCI to include file Date: Mon, 17 Feb 2020 12:48:10 -0800 Message-Id: <20200217204812.9857-2-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217204812.9857-1-linux@roeck-us.net> References: <20200217204812.9857-1-linux@roeck-us.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Beniamino Galvani , qemu-arm@nongnu.org, Gerd Hoffmann , Guenter Roeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We need to be able to use OHCISysBusState outside hcd-ohci.c, so move it to its include file. Reviewed-by: Gerd Hoffmann Signed-off-by: Guenter Roeck --- v3: Rebased to master Added Gerd's Reviewed-by: tag v2: no changes hw/usb/hcd-ohci.c | 15 --------------- hw/usb/hcd-ohci.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 8a94bd004a..1e6e85e86a 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1870,21 +1870,6 @@ void ohci_sysbus_die(struct OHCIState *ohci) ohci_bus_stop(ohci); } -#define TYPE_SYSBUS_OHCI "sysbus-ohci" -#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI) - -typedef struct { - /*< private >*/ - SysBusDevice parent_obj; - /*< public >*/ - - OHCIState ohci; - char *masterbus; - uint32_t num_ports; - uint32_t firstport; - dma_addr_t dma_offset; -} OHCISysBusState; - static void ohci_realize_pxa(DeviceState *dev, Error **errp) { OHCISysBusState *s = SYSBUS_OHCI(dev); diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h index 16e3f1e13a..5c8819aedf 100644 --- a/hw/usb/hcd-ohci.h +++ b/hw/usb/hcd-ohci.h @@ -22,6 +22,7 @@ #define HCD_OHCI_H #include "sysemu/dma.h" +#include "hw/usb.h" /* Number of Downstream Ports on the root hub: */ #define OHCI_MAX_PORTS 15 @@ -90,6 +91,21 @@ typedef struct OHCIState { void (*ohci_die)(struct OHCIState *ohci); } OHCIState; +#define TYPE_SYSBUS_OHCI "sysbus-ohci" +#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI) + +typedef struct { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + + OHCIState ohci; + char *masterbus; + uint32_t num_ports; + uint32_t firstport; + dma_addr_t dma_offset; +} OHCISysBusState; + extern const VMStateDescription vmstate_ohci_state; void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports, From patchwork Mon Feb 17 20:48:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1239575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=W41gQYMP; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Lx272gWNz9sRJ for ; Tue, 18 Feb 2020 07:50:07 +1100 (AEDT) Received: from localhost ([::1]:52744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nLB-0007vx-BX for incoming@patchwork.ozlabs.org; Mon, 17 Feb 2020 15:50:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38228) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nJV-0005Zt-Gv for qemu-devel@nongnu.org; Mon, 17 Feb 2020 15:48:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3nJU-0007Rg-HQ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 15:48:21 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:43827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3nJS-0007QG-Iz; Mon, 17 Feb 2020 15:48:18 -0500 Received: by mail-pg1-x544.google.com with SMTP id u12so9468965pgb.10; Mon, 17 Feb 2020 12:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=hdyy5mzVQwTZ4ysWQDKS3IsSlEm90LXUWXOGjwvknKU=; b=W41gQYMP8CCoDZzt0wEPFrUIZf0A9EEcS/ZLfEmAmAilOMFypwhhwzGb8PXJVBuUFz ZWP67I6EBb10VR+SkYJpH7oYbrkupGeXRP1OE9sA3GsA7zgvP3Bqa0sVa/gRnjEHEAmd foDdK+sstX+rARtHAnU/xcbnRy529JhSMf+WafNuHQNQVTw07ERH/bSf7fbYZOJ5c6Ny Y2UKkdLQxxltqyLIXzc/a4Vm/do5tcgnjgzpK59UDYcKWYi+SBe/0D5zWDg0s52nj1f5 UhXt9R3TTdKUR0jnEQpK+gaD61djgqddeZasRIuX14fCVT/FV1+7AqrgY9R8kZLMgMYc AW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=hdyy5mzVQwTZ4ysWQDKS3IsSlEm90LXUWXOGjwvknKU=; b=ZXUOIu6vDgf2Lakn2CqIbIBrt8qYfpVocP5Gp9J7gVxOEovwLIJCUAILaC/jBlbct5 rfdtKrsV6ntWuzQpwbn3cQXsaghZt1m5Dvk3017yiyRJYrU2Ob4UvIPPM98oer54NX3s qZvSS2oNlKU4kaEENr5FMx9JkWz5GV4Ts7RvCejz8MVdvzR6C1uKpdbkKwXPMOrwaUgy QjaajW3wBZ2KgA5sbY7oudMC4rZdJoGJ0cwmZ6s4etRJP3WcMykDsC9yu6lgCOGrMQRY CG2A65MCuto+u3FBU60CBvcLAvDVSsv/CGDJHcRARm09E7jBZkrVxJass5aS/SP+XlAL Vhtg== X-Gm-Message-State: APjAAAWcm9hLwJ6xxl29AL2Y54vpwAJ1B2IrAIWHW+XGA+Hvvs2q4ECu kcy96VmREKn5HTg7Aho9RD1hEXJy X-Google-Smtp-Source: APXvYqwkFbRMkqJu8fWWWzCi7GL4oQq2HAek/5vBz49+HIedXjqlxRH3w570d1YOo6nSUPO8btFwUQ== X-Received: by 2002:a62:7b54:: with SMTP id w81mr18183240pfc.127.1581972497734; Mon, 17 Feb 2020 12:48:17 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 144sm1409481pfc.45.2020.02.17.12.48.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Feb 2020 12:48:17 -0800 (PST) From: Guenter Roeck To: Peter Maydell Subject: [PATCH v3 2/3] hcd-ehci: Introduce "companion-enable" sysbus property Date: Mon, 17 Feb 2020 12:48:11 -0800 Message-Id: <20200217204812.9857-3-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217204812.9857-1-linux@roeck-us.net> References: <20200217204812.9857-1-linux@roeck-us.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Beniamino Galvani , qemu-arm@nongnu.org, Gerd Hoffmann , Guenter Roeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We'll use this property in a follow-up patch to insantiate an EHCI bus with companion support. Reviewed-by: Gerd Hoffmann Signed-off-by: Guenter Roeck --- v3: Rebased to master Added Gerd's Reviewed-by: tag v2: Added patch hw/usb/hcd-ehci-sysbus.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c index 8d4738565e..b22fb258be 100644 --- a/hw/usb/hcd-ehci-sysbus.c +++ b/hw/usb/hcd-ehci-sysbus.c @@ -33,6 +33,8 @@ static const VMStateDescription vmstate_ehci_sysbus = { static Property ehci_sysbus_properties[] = { DEFINE_PROP_UINT32("maxframes", EHCISysBusState, ehci.maxframes, 128), + DEFINE_PROP_BOOL("companion-enable", EHCISysBusState, ehci.companion_enable, + false), DEFINE_PROP_END_OF_LIST(), }; From patchwork Mon Feb 17 20:48:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1239579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ZmUP+Ay9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Lx3X6YGxz9sPK for ; Tue, 18 Feb 2020 07:51:19 +1100 (AEDT) Received: from localhost ([::1]:52766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nMK-0000Zw-0P for incoming@patchwork.ozlabs.org; Mon, 17 Feb 2020 15:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38246) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nJY-0005jt-BH for qemu-devel@nongnu.org; Mon, 17 Feb 2020 15:48:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3nJX-0007Sn-0o for qemu-devel@nongnu.org; Mon, 17 Feb 2020 15:48:24 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3nJU-0007RD-8M; Mon, 17 Feb 2020 15:48:20 -0500 Received: by mail-pl1-x644.google.com with SMTP id a6so7194178plm.3; Mon, 17 Feb 2020 12:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3dwRimbCUvS0eAuYvuE/OQDNqnH9kNQy8jPuRwTKHSo=; b=ZmUP+Ay9MZ2Zo6o5m3nqaVt0FAJIW2Dx8Jb2vFov3W102E2ngLHM1NbnLm8F0a4Om6 C2Fk0KuctIgIfvePwTs2dtNVLFMtbqNH8HO0M6TUw+BoD3Ry/l+PQkN8+6sIM+OQu23b NoOQ5Db0AH+FRFZ+Gv6CV1fH4AqlXFng5meV6zw6zMSRd/pMaqcKsjwYWpWBcSpyTuvz rHscZZHElgArgk1nFOfHGfMXsuyyO1QkZebtOUXfVTr/an4ujj+FF7aC5jzI4SbwJ3i/ ueY/GwmPPNDXcQDkKkXcD93WQF3iD8hDnoipgXdz0eXIeCTDRluMsLpm0CQcn61MzLuM iXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3dwRimbCUvS0eAuYvuE/OQDNqnH9kNQy8jPuRwTKHSo=; b=LbvZ6we2OVcb0BP6zzoCGGWSl60DYNxM+5qpf7gM3qIsvIX0YFqSG9INu18ndjJmdx OCOedqlDOjIt2dmIH0n2XzJzqxqaMyrmzMYcZTwqqB0ECd1+WRlywn657ZLR4x5htHLC zNqtUhhsGGADrSvA7VBHZ3PNe8j1WV2XXwoKg3AvGf8uL9n1CGU12sg3XT2mR4KAs1pr eB8hWDCAenytU4+LObnDON/4CyZPn32LrSOsXqOVLu5PA/01WKH1vlCPSx3Dr+FhMx2K AedtyYWrzjEUTggubuN8kZRrRwZHumOx0QJz82grC8qW9OTB8eXiF21jIEZBVPqr0TM3 BjJw== X-Gm-Message-State: APjAAAU7a21I/UJJZOE4ttH4ax+IXOQCn+MsmMNacgga4CzBhjvvmHbo miQoIPxQzyalDbM76EcnUM4= X-Google-Smtp-Source: APXvYqz0YJVTeLX4qep8DC3f8OSnWZWIJXYfEfOQRxmVxDsvAWFyY969D4gPNkaFvXD1RxbyRcHKpg== X-Received: by 2002:a17:902:8308:: with SMTP id bd8mr17636816plb.210.1581972499290; Mon, 17 Feb 2020 12:48:19 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k29sm1371042pfh.77.2020.02.17.12.48.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Feb 2020 12:48:18 -0800 (PST) From: Guenter Roeck To: Peter Maydell Subject: [PATCH v3 3/3] arm: allwinner: Wire up USB ports Date: Mon, 17 Feb 2020 12:48:12 -0800 Message-Id: <20200217204812.9857-4-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217204812.9857-1-linux@roeck-us.net> References: <20200217204812.9857-1-linux@roeck-us.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Beniamino Galvani , qemu-arm@nongnu.org, Gerd Hoffmann , Guenter Roeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instantiate EHCI and OHCI controllers on Allwinner A10. OHCI ports are modeled as companions of the respective EHCI ports. With this patch applied, USB controllers are discovered and instantiated when booting the cubieboard machine with a recent Linux kernel. ehci-platform 1c14000.usb: EHCI Host Controller ehci-platform 1c14000.usb: new USB bus registered, assigned bus number 1 ehci-platform 1c14000.usb: irq 26, io mem 0x01c14000 ehci-platform 1c14000.usb: USB 2.0 started, EHCI 1.00 ehci-platform 1c1c000.usb: EHCI Host Controller ehci-platform 1c1c000.usb: new USB bus registered, assigned bus number 2 ehci-platform 1c1c000.usb: irq 31, io mem 0x01c1c000 ehci-platform 1c1c000.usb: USB 2.0 started, EHCI 1.00 ohci-platform 1c14400.usb: Generic Platform OHCI controller ohci-platform 1c14400.usb: new USB bus registered, assigned bus number 3 ohci-platform 1c14400.usb: irq 27, io mem 0x01c14400 ohci-platform 1c1c400.usb: Generic Platform OHCI controller ohci-platform 1c1c400.usb: new USB bus registered, assigned bus number 4 ohci-platform 1c1c400.usb: irq 32, io mem 0x01c1c400 usb 2-1: new high-speed USB device number 2 using ehci-platform usb-storage 2-1:1.0: USB Mass Storage device detected scsi host1: usb-storage 2-1:1.0 usb 3-1: new full-speed USB device number 2 using ohci-platform input: QEMU QEMU USB Mouse as /devices/platform/soc/1c14400.usb/usb3/3-1/3-1:1.0/0003:0627:0001.0001/input/input0 Reviewed-by: Gerd Hoffmann Signed-off-by: Guenter Roeck --- v3: Rebased to master Added Gerd's Reviewed-by: tag v2: Instantiate EHCI and OHCI in a single patch Use define instead of ARRAY_SIZE to get the number of USB ports Instantiate OHCI in companion mode Use &error_fatal to handle error conditions hw/arm/allwinner-a10.c | 43 ++++++++++++++++++++++++++++++++++ include/hw/arm/allwinner-a10.h | 6 +++++ 2 files changed, 49 insertions(+) diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 1cde165611..2ae9c15311 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -24,11 +24,15 @@ #include "hw/arm/allwinner-a10.h" #include "hw/misc/unimp.h" #include "sysemu/sysemu.h" +#include "hw/boards.h" +#include "hw/usb/hcd-ohci.h" #define AW_A10_PIC_REG_BASE 0x01c20400 #define AW_A10_PIT_REG_BASE 0x01c20c00 #define AW_A10_UART0_REG_BASE 0x01c28000 #define AW_A10_EMAC_BASE 0x01c0b000 +#define AW_A10_EHCI_BASE 0x01c14000 +#define AW_A10_OHCI_BASE 0x01c14400 #define AW_A10_SATA_BASE 0x01c18000 static void aw_a10_init(Object *obj) @@ -49,6 +53,17 @@ static void aw_a10_init(Object *obj) sysbus_init_child_obj(obj, "sata", &s->sata, sizeof(s->sata), TYPE_ALLWINNER_AHCI); + + if (machine_usb(current_machine)) { + int i; + + for (i = 0; i < AW_A10_NUM_USB; i++) { + sysbus_init_child_obj(obj, "ehci[*]", OBJECT(&s->ehci[i]), + sizeof(s->ehci[i]), TYPE_PLATFORM_EHCI); + sysbus_init_child_obj(obj, "ohci[*]", OBJECT(&s->ohci[i]), + sizeof(s->ohci[i]), TYPE_SYSBUS_OHCI); + } + } } static void aw_a10_realize(DeviceState *dev, Error **errp) @@ -121,6 +136,34 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) serial_mm_init(get_system_memory(), AW_A10_UART0_REG_BASE, 2, qdev_get_gpio_in(dev, 1), 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); + + if (machine_usb(current_machine)) { + int i; + + for (i = 0; i < AW_A10_NUM_USB; i++) { + char bus[16]; + + sprintf(bus, "usb-bus.%d", i); + + object_property_set_bool(OBJECT(&s->ehci[i]), true, + "companion-enable", &error_fatal); + object_property_set_bool(OBJECT(&s->ehci[i]), true, "realized", + &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, + AW_A10_EHCI_BASE + i * 0x8000); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, + qdev_get_gpio_in(dev, 39 + i)); + + object_property_set_str(OBJECT(&s->ohci[i]), bus, "masterbus", + &error_fatal); + object_property_set_bool(OBJECT(&s->ohci[i]), true, "realized", + &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ohci[i]), 0, + AW_A10_OHCI_BASE + i * 0x8000); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ohci[i]), 0, + qdev_get_gpio_in(dev, 64 + i)); + } + } } static void aw_a10_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h index 40d0b1d9c0..8af724548f 100644 --- a/include/hw/arm/allwinner-a10.h +++ b/include/hw/arm/allwinner-a10.h @@ -8,12 +8,16 @@ #include "hw/intc/allwinner-a10-pic.h" #include "hw/net/allwinner_emac.h" #include "hw/ide/ahci.h" +#include "hw/usb/hcd-ohci.h" +#include "hw/usb/hcd-ehci.h" #include "target/arm/cpu.h" #define AW_A10_SDRAM_BASE 0x40000000 +#define AW_A10_NUM_USB 2 + #define TYPE_AW_A10 "allwinner-a10" #define AW_A10(obj) OBJECT_CHECK(AwA10State, (obj), TYPE_AW_A10) @@ -28,6 +32,8 @@ typedef struct AwA10State { AwEmacState emac; AllwinnerAHCIState sata; MemoryRegion sram_a; + EHCISysBusState ehci[AW_A10_NUM_USB]; + OHCISysBusState ohci[AW_A10_NUM_USB]; } AwA10State; #endif