From patchwork Fri Mar 26 16:06:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 48697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7942AB7CF1 for ; Sat, 27 Mar 2010 05:47:50 +1100 (EST) Received: from localhost ([127.0.0.1]:38075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NvDr7-0007Tn-Fl for incoming@patchwork.ozlabs.org; Fri, 26 Mar 2010 14:02:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NvC5u-0004Q9-7U for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:09:10 -0400 Received: from [140.186.70.92] (port=41537 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NvC5j-0003be-L5 for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:09:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NvC4G-0006wz-Kv for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:07:55 -0400 Received: from afflict.kos.to ([92.243.29.197]:33627) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NvC4B-0006tG-12 for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:07:25 -0400 Received: by afflict.kos.to (Postfix, from userid 1000) id 4C649265BB; Fri, 26 Mar 2010 16:07:22 +0000 (UTC) From: Riku Voipio To: qemu-devel@nongnu.org Date: Fri, 26 Mar 2010 16:06:40 +0000 Message-Id: <29979b1fbd55b989283b22245e66da64bb335d20.1269617186.git.riku.voipio@nokia.com> X-Mailer: git-send-email 1.6.5 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Riku Voipio , =?UTF-8?q?Juha=20Riihim=C3=A4ki?= Subject: [Qemu-devel] [PATCH 20/48] add reset support for musb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Juha Riihimäki Signed-Off-By: Riku Voipio Signed-Off-By: Juha Riihimäki --- hw/usb-musb.c | 29 +++++++++++++++++++++++------ hw/usb.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/hw/usb-musb.c b/hw/usb-musb.c index 7f15842..a83cd85 100644 --- a/hw/usb-musb.c +++ b/hw/usb-musb.c @@ -8,7 +8,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or - * (at your option) version 3 of the License. + * (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -307,7 +307,9 @@ struct MUSBState { uint16_t rx_intr; uint16_t rx_mask; +#ifdef SETUPLEN_HACK int setup_len; +#endif int session; uint8_t buf[0x8000]; @@ -315,15 +317,16 @@ struct MUSBState { /* Duplicating the world since 2008!... probably we should have 32 * logical, single endpoints instead. */ MUSBEndPoint ep[16]; -} *musb_init(qemu_irq *irqs) +}; + +void musb_reset(MUSBState *s) { - MUSBState *s = qemu_mallocz(sizeof(*s)); int i; - s->irqs = irqs; - s->faddr = 0x00; + s->devctl = 0; s->power = MGC_M_POWER_HSENAB; + s->tx_intr = 0x0000; s->rx_intr = 0x0000; s->tx_mask = 0xffff; @@ -332,6 +335,12 @@ struct MUSBState { s->mask = 0x06; s->idx = 0; +#ifdef SETUPLEN_HACK + s->setup_len = 0; +#endif + s->session = 0; + memset(s->buf, 0, sizeof(s->buf)); + /* TODO: _DW */ s->ep[0].config = MGC_M_CONFIGDATA_SOFTCONE | MGC_M_CONFIGDATA_DYNFIFO; for (i = 0; i < 16; i ++) { @@ -341,6 +350,14 @@ struct MUSBState { s->ep[i].musb = s; s->ep[i].epnum = i; } +} + +struct MUSBState *musb_init(qemu_irq *irqs) +{ + MUSBState *s = qemu_mallocz(sizeof(*s)); + + s->irqs = irqs; + musb_reset(s); usb_bus_new(&s->bus, NULL /* FIXME */); usb_register_port(&s->bus, &s->port, s, 0, musb_attach); @@ -1481,7 +1498,7 @@ static void musb_writew(void *opaque, target_phys_addr_t addr, uint32_t value) musb_write_fifo(s->ep + ep, (value >> 8 ) & 0xff); musb_write_fifo(s->ep + ep, (value >> 16) & 0xff); musb_write_fifo(s->ep + ep, (value >> 24) & 0xff); - break; + break; default: TRACE("unknown register 0x%02x", (int) addr); break; diff --git a/hw/usb.h b/hw/usb.h index 106d174..71df75b 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -284,6 +284,7 @@ enum musb_irq_source_e { typedef struct MUSBState MUSBState; MUSBState *musb_init(qemu_irq *irqs); +void musb_reset(MUSBState *s); uint32_t musb_core_intr_get(MUSBState *s); void musb_core_intr_clear(MUSBState *s, uint32_t mask); void musb_set_size(MUSBState *s, int epnum, int size, int is_tx);