Re: [PATCH v2 0/6] dwc-hsotg (aka dwc2) USB host controller emulation

2020-03-31 Thread Paul Zimmerman
On Tue, Mar 31, 2020 at 4:16 AM Philippe Mathieu-Daudé 
wrote:

> On 3/31/20 11:28 AM, Gerd Hoffmann wrote:
> > On Sat, Mar 28, 2020 at 05:16:59PM -0700, Paul Zimmerman wrote:
> >> 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 redirection does not
> >> work, I tried connecting to a USB stick on the host, but the device
> >> generates babble errors and does not work. I will continue to work on
> >> this issue.
> >>
> >> 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 on-line sources of information while developing
> >> this emulation, including:
> >>
> >> http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf
> >> 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
> >> has a description of the controller registers starting on page
> >> 130.
> >>
> >> Changes from v1:
> >>- 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
> >
> > Looks good to me.  We are in 5.0 freeze now though, so this has to wait
> > until the tree is open for 5.1 development.
>
> Plenty of time to complete this series with an acceptance test using
> your device :)
>
> As a starting point you can look at do_test_arm_raspi2() in
> tests/acceptance/boot_linux_console.py.
>
> Regards,
>
> Phil.
>
>
 Ok Phil, I will look into that.

Thanks,
Paul


Re: [PATCH v2 0/6] dwc-hsotg (aka dwc2) USB host controller emulation

2020-03-31 Thread Philippe Mathieu-Daudé

On 3/31/20 11:28 AM, Gerd Hoffmann wrote:

On Sat, Mar 28, 2020 at 05:16:59PM -0700, Paul Zimmerman wrote:

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 redirection does not
work, I tried connecting to a USB stick on the host, but the device
generates babble errors and does not work. I will continue to work on
this issue.

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 on-line sources of information while developing
this emulation, including:

http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf
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
has a description of the controller registers starting on page
130.

Changes from v1:
   - 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


Looks good to me.  We are in 5.0 freeze now though, so this has to wait
until the tree is open for 5.1 development.


Plenty of time to complete this series with an acceptance test using 
your device :)


As a starting point you can look at do_test_arm_raspi2() in 
tests/acceptance/boot_linux_console.py.


Regards,

Phil.




Re: [PATCH v2 0/6] dwc-hsotg (aka dwc2) USB host controller emulation

2020-03-31 Thread Gerd Hoffmann
On Sat, Mar 28, 2020 at 05:16:59PM -0700, Paul Zimmerman wrote:
> 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 redirection does not
> work, I tried connecting to a USB stick on the host, but the device
> generates babble errors and does not work. I will continue to work on
> this issue.
> 
> 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 on-line sources of information while developing
> this emulation, including:
> 
> http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf
> 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
> has a description of the controller registers starting on page
> 130.
> 
> Changes from v1:
>   - 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

Looks good to me.  We are in 5.0 freeze now though, so this has to wait
until the tree is open for 5.1 development.

cheers,
  Gerd




Re: [PATCH v2 0/6] dwc-hsotg (aka dwc2) USB host controller emulation

2020-03-28 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20200329001705.15966-1-pauld...@gmail.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH v2 0/6] dwc-hsotg (aka dwc2) USB host controller emulation
Message-id: 20200329001705.15966-1-pauld...@gmail.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
814b833 Wire in the dwc-hsotg USB host controller emulation
6b74a73 Add short-packet handling to usb-storage driver
8f3ea22 dwc-hsotg USB host controller emulation
dfe2b0d dwc-hsotg USB host controller state definitions
6c3ebf7 dwc-hsotg USB host controller register definitions
55c66de Add BCM2835 SOC MPHI emulation

=== OUTPUT BEGIN ===
1/6 Checking commit 55c66de0e143 (Add BCM2835 SOC MPHI emulation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#62: 
new file mode 100644

total: 0 errors, 1 warnings, 293 lines checked

Patch 1/6 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/6 Checking commit 6c3ebf707965 (dwc-hsotg USB host controller register 
definitions)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#16: 
new file mode 100644

WARNING: architecture specific defines should be avoided
#58: FILE: include/hw/usb/dwc2-regs.h:38:
+#ifndef __DWC2_HW_H__

ERROR: code indent should never use tabs
#61: FILE: include/hw/usb/dwc2-regs.h:41:
+#define HSOTG_REG(x)^I(x)$

ERROR: code indent should never use tabs
#63: FILE: include/hw/usb/dwc2-regs.h:43:
+#define GOTGCTL^I^I^I^IHSOTG_REG(0x000)$

ERROR: code indent should never use tabs
#64: FILE: include/hw/usb/dwc2-regs.h:44:
+#define GOTGCTL_CHIRPEN^I^I^IBIT(27)$

ERROR: code indent should never use tabs
#65: FILE: include/hw/usb/dwc2-regs.h:45:
+#define GOTGCTL_MULT_VALID_BC_MASK^I(0x1f << 22)$

ERROR: code indent should never use tabs
#66: FILE: include/hw/usb/dwc2-regs.h:46:
+#define GOTGCTL_MULT_VALID_BC_SHIFT^I22$

ERROR: code indent should never use tabs
#67: FILE: include/hw/usb/dwc2-regs.h:47:
+#define GOTGCTL_OTGVER^I^I^IBIT(20)$

ERROR: code indent should never use tabs
#68: FILE: include/hw/usb/dwc2-regs.h:48:
+#define GOTGCTL_BSESVLD^I^I^IBIT(19)$

ERROR: code indent should never use tabs
#69: FILE: include/hw/usb/dwc2-regs.h:49:
+#define GOTGCTL_ASESVLD^I^I^IBIT(18)$

ERROR: code indent should never use tabs
#70: FILE: include/hw/usb/dwc2-regs.h:50:
+#define GOTGCTL_DBNC_SHORT^I^IBIT(17)$

ERROR: code indent should never use tabs
#71: FILE: include/hw/usb/dwc2-regs.h:51:
+#define GOTGCTL_CONID_B^I^I^IBIT(16)$

ERROR: code indent should never use tabs
#72: FILE: include/hw/usb/dwc2-regs.h:52:
+#define GOTGCTL_DBNCE_FLTR_BYPASS^IBIT(15)$

ERROR: code indent should never use tabs
#73: FILE: include/hw/usb/dwc2-regs.h:53:
+#define GOTGCTL_DEVHNPEN^I^IBIT(11)$

ERROR: code indent should never use tabs
#74: FILE: include/hw/usb/dwc2-regs.h:54:
+#define GOTGCTL_HSTSETHNPEN^I^IBIT(10)$

ERROR: code indent should never use tabs
#75: FILE: include/hw/usb/dwc2-regs.h:55:
+#define GOTGCTL_HNPREQ^I^I^IBIT(9)$

ERROR: code indent should never use tabs
#76: FILE: include/hw/usb/dwc2-regs.h:56:
+#define GOTGCTL_HSTNEGSCS^I^IBIT(8)$

ERROR: code indent should never use tabs
#77: FILE: include/hw/usb/dwc2-regs.h:57:
+#define GOTGCTL_SESREQ^I^I^IBIT(1)$

ERROR: code indent should never use tabs
#78: FILE: include/hw/usb/dwc2-regs.h:58:
+#define GOTGCTL_SESREQSCS^I^IBIT(0)$

ERROR: code indent should never use tabs
#80: FILE: include/hw/usb/dwc2-regs.h:60:
+#define GOTGINT^I^I^I^IHSOTG_REG(0x004)$

ERROR: code indent should never use tabs
#81: FILE: include/hw/usb/dwc2-regs.h:61:
+#define GOTGINT_DBNCE_DONE^I^IBIT(19)$

ERROR: code indent should never use tabs
#82: FILE: include/hw/usb/dwc2-regs.h:62:
+#define GOTGINT_A_DEV_TOUT_CHG^I^IBIT(18)$

ERROR: code indent should never use tabs
#83: FILE: include/hw/usb/dwc2-regs.h:63:
+#define GOTGINT_HST_NEG_DET^I^IBIT(17)$

ERROR: code indent should never use tabs
#84: FILE: include/hw/usb/dwc2-regs.h:64:
+#define GOTGINT_HST_NEG_SUC_STS_CHNG^IBIT(9)$

ERROR: code indent should never use tabs
#85: FILE: include/hw/usb/dwc2-regs.h:65:
+#define GOTGINT_SES_REQ_SUC_STS_CHNG^IBIT(8)$

ERROR: code indent should never use tabs
#86: FILE: include/hw/usb/dwc2-regs.h:66:
+#define GOTGINT_SES_END_DET^I^IBIT(2)$

ERROR: code indent should never use tabs
#88: FILE: include/hw/usb/dwc2-regs.h:68:
+#define GAHBCFG^I^I^I^IHSOTG_REG(0x008)$

ERROR: code indent should never use tabs
#89: FILE: include/hw/usb/dwc2-regs.h:69:
+#define GAHBCFG_AHB_SINGLE^I^IBIT(23)$

ERROR: code indent should never use tabs
#90: FILE: inclu

[PATCH v2 0/6] dwc-hsotg (aka dwc2) USB host controller emulation

2020-03-28 Thread Paul Zimmerman
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 redirection does not
work, I tried connecting to a USB stick on the host, but the device
generates babble errors and does not work. I will continue to work on
this issue.

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 on-line sources of information while developing
this emulation, including:

http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf
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
has a description of the controller registers starting on page
130.

Changes from v1:
  - 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 (6):
  Add BCM2835 SOC MPHI emulation
  dwc-hsotg USB host controller register definitions
  dwc-hsotg USB host controller state definitions
  dwc-hsotg USB host controller emulation
  Add short-packet handling to usb-storage driver
  Wire in the dwc-hsotg USB host controller emulation

 hw/arm/bcm2835_peripherals.c |   38 +-
 hw/misc/Makefile.objs|1 +
 hw/misc/bcm2835_mphi.c   |  193 
 hw/usb/Kconfig   |5 +
 hw/usb/Makefile.objs |1 +
 hw/usb/dev-storage.c |   15 +-
 hw/usb/hcd-dwc2.c| 1301 ++
 hw/usb/hcd-dwc2.h|  180 
 hw/usb/trace-events  |   47 +
 include/hw/arm/bcm2835_peripherals.h |5 +-
 include/hw/misc/bcm2835_mphi.h   |   50 +
 include/hw/usb/dwc2-regs.h   |  895 ++
 12 files changed, 2728 insertions(+), 3 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