diff mbox series

[PULL,23/33] hw/arm/xilinx_zynq: Fix USB port instantiation

Message ID 20200228163840.23585-24-peter.maydell@linaro.org
State New
Headers show
Series None | expand

Commit Message

Peter Maydell Feb. 28, 2020, 4:38 p.m. UTC
From: Guenter Roeck <linux@roeck-us.net>

USB ports on Xilinx Zync must be instantiated as TYPE_CHIPIDEA to work.
Linux expects and checks various chipidea registers, which do not exist
with the basic ehci emulation. This patch series fixes the problem.

Without this patch, USB ports fail to instantiate under Linux.

ci_hdrc ci_hdrc.0: doesn't support host
ci_hdrc ci_hdrc.0: no supported roles

With this patch, USB ports are instantiated, and it is possible
to boot from USB drive.

ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
usb 1-1: new full-speed USB device number 2 using ci_hdrc
usb 1-1: not running at top speed; connect to a high speed hub
usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x81 has invalid maxpacket 512, setting to 64
usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x2 has invalid maxpacket 512, setting to 64
usb-storage 1-1:1.0: USB Mass Storage device detected
scsi host0: usb-storage 1-1:1.0

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200215122354.13706-2-linux@roeck-us.net
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/xilinx_zynq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé May 19, 2021, 5:50 p.m. UTC | #1
On 2/28/20 5:38 PM, Peter Maydell wrote:
> From: Guenter Roeck <linux@roeck-us.net>
> 
> USB ports on Xilinx Zync must be instantiated as TYPE_CHIPIDEA to work.
> Linux expects and checks various chipidea registers, which do not exist
> with the basic ehci emulation. This patch series fixes the problem.
> 
> Without this patch, USB ports fail to instantiate under Linux.
> 
> ci_hdrc ci_hdrc.0: doesn't support host
> ci_hdrc ci_hdrc.0: no supported roles
> 
> With this patch, USB ports are instantiated, and it is possible
> to boot from USB drive.
> 
> ci_hdrc ci_hdrc.0: EHCI Host Controller
> ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
> ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
> usb 1-1: new full-speed USB device number 2 using ci_hdrc
> usb 1-1: not running at top speed; connect to a high speed hub
> usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x81 has invalid maxpacket 512, setting to 64
> usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x2 has invalid maxpacket 512, setting to 64
> usb-storage 1-1:1.0: USB Mass Storage device detected
> scsi host0: usb-storage 1-1:1.0
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
> Message-id: 20200215122354.13706-2-linux@roeck-us.net
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/xilinx_zynq.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
> index 3d439a45d57..571cdcd599e 100644
> --- a/hw/arm/xilinx_zynq.c
> +++ b/hw/arm/xilinx_zynq.c
> @@ -29,6 +29,7 @@
>  #include "hw/loader.h"
>  #include "hw/misc/zynq-xadc.h"
>  #include "hw/ssi/ssi.h"
> +#include "hw/usb/chipidea.h"
>  #include "qemu/error-report.h"
>  #include "hw/sd/sdhci.h"
>  #include "hw/char/cadence_uart.h"
> @@ -225,8 +226,8 @@ static void zynq_init(MachineState *machine)
>      zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
>      zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
>  
> -    sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
> -    sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
> +    sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]);
> +    sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]);

FYI this patch makes the xilinx-zynq-a9 crash when built with
--without-default-devices:

./qemu-system-arm -M xilinx-zynq-a9
**
ERROR:qom/object.c:714:object_new_with_type: assertion failed: (type !=
NULL)
Bail out! ERROR:qom/object.c:714:object_new_with_type: assertion failed:
(type != NULL)

(gdb) bt
#0  0x00007ffff52dd7d5 in raise () at /lib64/libc.so.6
#1  0x00007ffff52c6895 in abort () at /lib64/libc.so.6
#2  0x00007ffff6dc4b6c in g_assertion_message_expr.cold () at
/lib64/libglib-2.0.so.0
#3  0x00007ffff6e229ff in g_assertion_message_expr () at
/lib64/libglib-2.0.so.0
#4  0x00005555558d3f01 in object_new_with_type (type=<optimized out>) at
qom/object.c:714
#5  0x00005555558d3f59 in object_new
(typename=typename@entry=0x555555ad4545 "usb-chipidea") at qom/object.c:747
#6  0x00005555558cd526 in qdev_new (name=name@entry=0x555555ad4545
"usb-chipidea") at hw/core/qdev.c:153
#7  0x0000555555739fc6 in sysbus_create_varargs
(name=name@entry=0x555555ad4545 "usb-chipidea",
addr=addr@entry=3758104576) at hw/core/sysbus.c:234
#8  0x0000555555796b57 in sysbus_create_simple (irq=<optimized out>,
addr=3758104576, name=0x555555ad4545 "usb-chipidea") at
/home/phil/source/qemu/include/hw/sysbus.h:104
#9  zynq_init (machine=0x555555de07a0) at hw/arm/xilinx_zynq.c:254
#10 0x000055555573707c in machine_run_board_init
(machine=machine@entry=0x555555de07a0) at hw/core/machine.c:1238
#11 0x0000555555838cff in qemu_init_board () at softmmu/vl.c:2513
#12 qmp_x_exit_preconfig (errp=<optimized out>) at softmmu/vl.c:2587
#13 0x000055555583cbfb in qmp_x_exit_preconfig (errp=<optimized out>) at
softmmu/vl.c:3609
#14 qemu_init (argc=<optimized out>, argv=<optimized out>,
envp=<optimized out>) at softmmu/vl.c:3609
#15 0x0000555555684749 in main (argc=<optimized out>, argv=<optimized
out>, envp=<optimized out>) at softmmu/main.c:49

This is because TYPE_CHIPIDEA is only built when an IMX machine is
selected:

softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('chipidea.c'))

I'll send a fix later.
diff mbox series

Patch

diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 3d439a45d57..571cdcd599e 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -29,6 +29,7 @@ 
 #include "hw/loader.h"
 #include "hw/misc/zynq-xadc.h"
 #include "hw/ssi/ssi.h"
+#include "hw/usb/chipidea.h"
 #include "qemu/error-report.h"
 #include "hw/sd/sdhci.h"
 #include "hw/char/cadence_uart.h"
@@ -225,8 +226,8 @@  static void zynq_init(MachineState *machine)
     zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
     zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
 
-    sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
-    sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
+    sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]);
+    sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]);
 
     cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0));
     cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1));