qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Zimmerman <pauldzim@gmail.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Stefan Hajnoczi" <stefanha@gmail.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Paul Zimmerman" <pauldzim@gmail.com>,
	"John Snow" <jsnow@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PATCH v4 0/7] dwc-hsotg (aka dwc2) USB host controller emulation
Date: Mon, 27 Apr 2020 19:22:25 -0700	[thread overview]
Message-ID: <20200428022232.18875-1-pauldzim@gmail.com> (raw)

This patch series adds emulation for the dwc-hsotg USB controller,
which is used on the Raspberry Pi 3 and earlier, as well as a number
of other development boards. The main benefit for Raspberry Pi is that
this enables networking on these boards, since the network adapter is
attached via USB.

The emulation is working quite well, I have tested with USB network,
mass storage, mouse, keyboard, and tablet. I have tested with the dwc2
driver in the upstream Linux kernel, and with the dwc-otg driver in the
Raspbian kernel.

One remaining issue is that USB host passthrough does not work. I tried
connecting to a USB stick on the host, but the device generates babble
errors and does not work. This is because the dwc-hsotg controller only
has one root port, so a full-speed dev-hub device is always connected
to it, and high-speed USB devices on the host do not work at full-speed
on the guest. (I have WIP code to add high-speed support to dev-hub to
fix this.)

The patch series also includes a very basic emulation of the MPHI
device on the Raspberry Pi SOC, which provides the FIQ interrupt that
is used by the dwc-otg driver in the Raspbian kernel. But that driver
still does not work in full FIQ mode, so it is necessary to add a
parameter to the kernel command line ("dwc_otg.fiq_fsm_enable=0") to
make it work.

I have used some online sources of information while developing this
emulation, including:

http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf
which has a pretty complete description of the controller starting
on page 370.

https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf
which has a description of the controller registers starting on
page 130.

Changes v3-v4:
  - Reworked the memory region / register access code according to
    an example patch from Felippe Mathieu-Daudé.
  - Moved the Makefile/Kconfig changes for this file into this
    patch, per Felipe.
  - Fixed a missing DEFINE_PROP_END_OF_LIST() in dwc2_usb_properties.

Changes v2-v3:
  - Fixed the high-speed frame time emulation so that high-speed
    mouse/tablet will work correctly once we have high-speed hub
    support.
  - Added a "usb_version" property to the dwc-hsotg controller, to
    allow choosing whether the controller emulates a USB 1 full-speed
    host or a USB 2 high-speed host.
  - Added a test for a working dwc-hsotg controller to the raspi2
    acceptance test, requested by Philippe M.
  - Added #defines for the register array sizes, instead of hard-
    coding them in multiple places.
  - Removed the NB_PORTS #define and the associated iteration code,
    since the controller only supports a single root port.
  - Removed some unused fields from the controller state struct.
  - Added pointers to some online documentation to the top of
    hcd-dwc2.c, requested by Peter M.
  - Reworked the init/realize code to remove some confusing function
    names, requested by Peter M.
  - Added VMStateDescription structs for the controller and MPHI
    state, requested by Peter M (untested).

Changes v1-v2:
  - Fixed checkpatch errors/warnings, except for dwc2-regs.h since
    that is a direct import from the Linux kernel.
  - Switched from debug printfs to tracepoints in hcd-dwc2.c, on the
    advice of Gerd. I just dropped the debug prints in bcm2835_mphi.c,
    since I didn't consider them very useful.
  - Updated a couple of the commit messages with more info.

Thanks for your time,
Paul

---

Paul Zimmerman (7):
  raspi: add BCM2835 SOC MPHI emulation
  dwc-hsotg (dwc2) USB host controller register definitions
  dwc-hsotg (dwc2) USB host controller state definitions
  dwc-hsotg (dwc2) USB host controller emulation
  usb: add short-packet handling to usb-storage driver
  wire in the dwc-hsotg (dwc2) USB host controller emulation
  raspi2 acceptance test: add test for dwc-hsotg (dwc2) USB host

 hw/arm/bcm2835_peripherals.c           |   38 +-
 hw/misc/Makefile.objs                  |    1 +
 hw/misc/bcm2835_mphi.c                 |  190 ++++
 hw/usb/Kconfig                         |    5 +
 hw/usb/Makefile.objs                   |    1 +
 hw/usb/dev-storage.c                   |   15 +-
 hw/usb/hcd-dwc2.c                      | 1378 ++++++++++++++++++++++++
 hw/usb/hcd-dwc2.h                      |  173 +++
 hw/usb/trace-events                    |   47 +
 include/hw/arm/bcm2835_peripherals.h   |    5 +-
 include/hw/misc/bcm2835_mphi.h         |   48 +
 include/hw/usb/dwc2-regs.h             |  895 +++++++++++++++
 tests/acceptance/boot_linux_console.py |    9 +-
 13 files changed, 2800 insertions(+), 5 deletions(-)
 create mode 100644 hw/misc/bcm2835_mphi.c
 create mode 100644 hw/usb/hcd-dwc2.c
 create mode 100644 hw/usb/hcd-dwc2.h
 create mode 100644 include/hw/misc/bcm2835_mphi.h
 create mode 100644 include/hw/usb/dwc2-regs.h

-- 
2.17.1



             reply	other threads:[~2020-04-28  2:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  2:22 Paul Zimmerman [this message]
2020-04-28  2:22 ` [PATCH v4 1/7] raspi: add BCM2835 SOC MPHI emulation Paul Zimmerman
2020-04-28  7:06   ` Philippe Mathieu-Daudé
2020-04-29 19:13     ` Paul Zimmerman
2020-04-28  2:22 ` [PATCH v4 2/7] dwc-hsotg (dwc2) USB host controller register definitions Paul Zimmerman
2020-04-28  2:22 ` [PATCH v4 3/7] dwc-hsotg (dwc2) USB host controller state definitions Paul Zimmerman
2020-04-28  2:22 ` [PATCH v4 4/7] dwc-hsotg (dwc2) USB host controller emulation Paul Zimmerman
2020-04-28  7:15   ` Philippe Mathieu-Daudé
2020-04-28  2:22 ` [PATCH v4 5/7] usb: add short-packet handling to usb-storage driver Paul Zimmerman
2020-04-28  2:22 ` [PATCH v4 6/7] wire in the dwc-hsotg (dwc2) USB host controller emulation Paul Zimmerman
2020-04-28  7:07   ` Philippe Mathieu-Daudé
2020-04-28  2:22 ` [PATCH v4 7/7] raspi2 acceptance test: add test for dwc-hsotg (dwc2) USB host Paul Zimmerman
2020-04-28  7:08   ` Philippe Mathieu-Daudé
2020-04-28  3:48 ` [PATCH v4 0/7] dwc-hsotg (aka dwc2) USB host controller emulation no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200428022232.18875-1-pauldzim@gmail.com \
    --to=pauldzim@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --subject='Re: [PATCH v4 0/7] dwc-hsotg (aka dwc2) USB host controller emulation' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox