hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/
cover hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/
Hi,
This is the second time I try to replace a magic typename string by a constant, and Zoltan warns me this is counter productive as "hw/usb.h" pulls in an insane amount of code.
Time to give the usb subsystem some love and move forward.
This series can be decomposed as follow:
1-2: preliminary machine cleanups (arm/ppc) 3-13: usb related headers cleanups 14-15: usb quirks cleanup 16-18: refactor usb_get_dev_path() to add usb_get_port_path() 19: let spapr use usb_get_port_path() to make USBDevice opaque 20: extract the public USB API (for machine/board/soc) 21: make the older "usb.h" internal to hw/usb/ 22-25: use TYPENAME definitions 26: cover dwc2 in MAINTAINERS
Please review.
Phil.
Philippe Mathieu-Daudé (26):
hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header hw/usb: Remove unused VM_USB_HUB_SIZE definition hw/usb: Reduce 'exec/memory.h' inclusion
hw/usb/desc: Add missing header
hw/usb/hcd-dwc2: Remove unnecessary includes hw/usb/hcd-dwc2: Restrict some headers to source hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope hw/usb/hcd-ehci: Remove unnecessary include hw/usb/hcd-ehci: Move few definitions from header to source hw/usb/hcd-xhci: Add missing header
hw/usb/hcd-musb: Restrict header scope
hw/usb/desc: Reduce some declarations scope hw/usb/quirks: Rename included source with '.inc.c' suffix hw/usb: Add new 'usb-quirks.h' local header hw/usb/bus: Simplify usb_get_dev_path()
hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path() hw/usb/bus: Add usb_get_port_path()
hw/ppc/spapr: Use usb_get_port_path()
hw/usb: Introduce "hw/usb/usb.h" public API
hw/usb: Move internal API to local 'usb-internal.h' header hw/usb/usb-hcd: Use OHCI type definitions hw/usb/usb-hcd: Use EHCI type definitions hw/usb/usb-hcd: Use UHCI type definitions hw/usb/usb-hcd: Use XHCI type definitions
MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation
hw/usb/desc.h | 11 +++++
{include/hw => hw}/usb/dwc2-regs.h | 0
hw/usb/hcd-dwc2.h | 5 +-
hw/usb/hcd-ehci.h | 24 +---------
{include/hw => hw}/usb/hcd-musb.h | 2 +
hw/usb/hcd-ohci.h | 4 +-
hw/usb/hcd-xhci.h | 4 +-
include/hw/usb.h => hw/usb/usb-internal.h | 50 ++-----------------
hw/usb/usb-quirks.h | 27 +++++++++++
include/hw/usb/chipidea.h | 2 +-
include/hw/usb/usb-hcd.h | 36 ++++++++++++++
include/hw/usb/usb.h | 58 +++++++++++++++++++++++
chardev/baum.c | 2 +-
hw/arm/allwinner-a10.c | 2 +-
hw/arm/allwinner-h3.c | 10 ++--
hw/arm/exynos4210.c | 2 +-
hw/arm/pxa2xx.c | 3 +-
hw/arm/realview.c | 3 +-
hw/arm/sbsa-ref.c | 4 +-
hw/arm/versatilepb.c | 3 +-
hw/arm/xilinx_zynq.c | 2 +-
hw/display/sm501.c | 3 +-
hw/i386/pc.c | 2 +-
hw/i386/pc_piix.c | 5 +-
hw/i386/pc_q35.c | 15 +++---
hw/isa/piix4.c | 3 +-
hw/mips/fuloong2e.c | 5 +-
hw/ppc/mac_newworld.c | 5 +-
hw/ppc/mac_oldworld.c | 3 +-
hw/ppc/sam460ex.c | 6 ++-
hw/ppc/spapr.c | 13 +++--
hw/sh4/r2d.c | 2 +-
hw/usb/bus.c | 40 +++++++++-------
hw/usb/chipidea.c | 1 +
hw/usb/combined-packet.c | 2 +-
hw/usb/core.c | 2 +-
hw/usb/desc-msos.c | 2 +-
hw/usb/desc.c | 3 +-
hw/usb/dev-audio.c | 2 +-
hw/usb/dev-hid.c | 2 +-
hw/usb/dev-hub.c | 2 +-
hw/usb/dev-mtp.c | 2 +-
hw/usb/dev-network.c | 2 +-
hw/usb/dev-serial.c | 2 +-
hw/usb/dev-smartcard-reader.c | 2 +-
hw/usb/dev-storage.c | 2 +-
hw/usb/dev-uas.c | 2 +-
hw/usb/dev-wacom.c | 2 +-
hw/usb/hcd-dwc2.c | 8 ++--
hw/usb/hcd-ehci-sysbus.c | 1 +
hw/usb/hcd-ehci.c | 13 ++++-
hw/usb/hcd-musb.c | 4 +-
hw/usb/hcd-ohci-pci.c | 4 +-
hw/usb/hcd-ohci.c | 1 -
hw/usb/hcd-uhci.c | 21 ++++----
hw/usb/hcd-xhci-nec.c | 3 +-
hw/usb/hcd-xhci.c | 2 +-
hw/usb/host-libusb.c | 2 +-
hw/usb/host-stub.c | 2 +-
hw/usb/libhw.c | 2 +-
hw/usb/quirks.c | 5 +-
hw/usb/{quirks.h => quirks.inc.c} | 5 --
hw/usb/redirect.c | 3 +-
hw/usb/tusb6010.c | 4 +-
hw/usb/xen-usb.c | 2 +-
monitor/misc.c | 2 +-
softmmu/vl.c | 2 +-
MAINTAINERS | 7 ++-
68 files changed, 294 insertions(+), 185 deletions(-)
rename {include/hw => hw}/usb/dwc2-regs.h (100%)
rename {include/hw => hw}/usb/hcd-musb.h (98%)
rename include/hw/usb.h => hw/usb/usb-internal.h (92%)
create mode 100644 hw/usb/usb-quirks.h
create mode 100644 include/hw/usb/usb-hcd.h
create mode 100644 include/hw/usb/usb.h
rename hw/usb/{quirks.h => quirks.inc.c} (99%)Signature · 1 line
2.21.3
PATCH 1/26 hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header
This file doesn't access anything from "hw/usb.h", remove its inclusion.
--- hw/arm/sbsa-ref.c | 1 - 1 file changed, 1 deletion(-)
hw/arm/sbsa-ref.c +0 -1
@@ -38,7 +38,6 @@#include "hw/loader.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "hw/char/pl011.h" #include "net/net.h"
Signature · 1 line
2.21.3
Re: [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header
Quoted 5 lines · Philippe Mathieu-Daudé
This file doesn't access anything from "
hw/usb.h", remove its inclusion.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 20 lines
--- hw/arm/sbsa-ref.c | 1 - 1 file changed, 1 deletion(-)hw/arm/sbsa-ref.c +0
-2@@ -38,7 +38,6 @@#include "hw/loader.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "hw/char/pl011.h" #include "net/net.h" --2.21.3
PATCH 2/26 hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header
In reply to Philippe Mathieu-DaudéThis file uses pci_create_simple() and PCI_DEVFN() which are both declared in "hw/pci/pci.h". This include is indirectly included by an USB header. As we want to reduce the USB header inclusions later, include the PCI header now, to avoid later:
hw/ppc/sam460ex.c:397:5: error: implicit declaration of function ‘pci_create_simple’; did you mean ‘sysbus_create_simple’? [-Werror=implicit-function-declaration]
397 | pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
| ^~~~~~~~~~~~~~~~~
| sysbus_create_simple
hw/ppc/sam460ex.c:397:5: error: nested extern declaration of ‘pci_create_simple’ [-Werror=nested-externs]
hw/ppc/sam460ex.c:397:32: error: implicit declaration of function ‘PCI_DEVFN’ [-Werror=implicit-function-declaration]
397 | pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
| ^~~~~~~~~ hw/ppc/sam460ex.c:397:32: error: nested extern declaration of ‘PCI_DEVFN’ [-Werror=nested-externs]
--- hw/ppc/sam460ex.c | 1 + 1 file changed, 1 insertion(+)
hw/ppc/sam460ex.c +1 -0
@@ -38,6 +38,7 @@#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" +#include "hw/pci/pci.h" #include <libfdt.h>
Signature · 1 line
2.21.3
Re: [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header
Quoted 9 lines · Philippe Mathieu-Daudé
This file uses
pci_create_simple()andPCI_DEVFN()which are both declared in "hw/pci/pci.h". This include is indirectly included by an USB header. As we want to reduce the USB header inclusions later, include the PCI header now, to avoid later:
hw/ppc/sam460ex.c:397:5: error: implicit declaration of function ‘pci_create_simple’; did you mean ‘sysbus_create_simple’? [-Werror=implicit-function-declaration]397 | pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501"); | ^~~~~~~~~~~~~~~~~ | sysbus_create_simple
Quoted 7 lines
hw/ppc/sam460ex.c:397:5: error: nested extern declaration of ‘pci_create_simple’ [-Werror=nested-externs]hw/ppc/sam460ex.c:397:32: error: implicit declaration of function ‘PCI_DEVFN’ [-Werror=implicit-function-declaration]
397 |pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
| ^~~~~~~~~
hw/ppc/sam460ex.c:397:32: error: nested extern declaration of ‘PCI_DEVFN’ [-Werror=nested-externs]Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 17 lines
---
hw/ppc/sam460ex.c| 1 +1 file changed, 1 insertion(+)hw/ppc/sam460ex.c +1
-0@@ -38,6 +38,7 @@#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" +#include "hw/pci/pci.h" #include <libfdt.h>
Re: [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header
In reply to Philippe Mathieu-DaudéQuoted 14 lines · Philippe Mathieu-Daudé
This file uses
pci_create_simple()andPCI_DEVFN()which are both declared in "hw/pci/pci.h". This include is indirectly included by an USB header. As we want to reduce the USB header inclusions later, include the PCI header now, to avoid later:
hw/ppc/sam460ex.c:397:5: error: implicit declaration of function ‘pci_create_simple’; did you mean ‘sysbus_create_simple’? [-Werror=implicit-function-declaration]397 | pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501"); | ^~~~~~~~~~~~~~~~~ | sysbus_create_simple hw/ppc/sam460ex.c:397:5: error: nested extern declaration of ‘pci_create_simple’ [-Werror=nested-externs] hw/ppc/sam460ex.c:397:32: error: implicit declaration of function ‘PCI_DEVFN’ [-Werror=implicit-function-declaration] 397 | pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501"); | ^~~~~~~~~
Quoted 3 lines
hw/ppc/sam460ex.c:397:32: error: nested extern declaration of ‘PCI_DEVFN’ [-Werror=nested-externs]Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 20 lines
--- hw/ppc/sam460ex.c | 1 + 1 file changed, 1 insertion(+)hw/ppc/sam460ex.c +1
-1@@ -38,6 +38,7 @@#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" +#include "hw/pci/pci.h" #include <libfdt.h> --2.21.3
PATCH 3/26 hw/usb: Remove unused VM_USB_HUB_SIZE definition
In reply to Philippe Mathieu-DaudéCommit a5d2f7273c ("qdev/usb: make qemu aware of usb busses") removed the last use of VM_USB_HUB_SIZE, 11 years ago. Time to drop it.
--- include/hw/usb.h | 4 ---- 1 file changed, 4 deletions(-)
include/hw/usb.h +0 -4
@@ -470,10 +470,6 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);void hmp_info_usbhost (Monitor *mon,const QDict *qdict);bool usb_host_dev_is_scsi_storage (USBDevice *usbdev); -/* usb ports of the VM */ - -#define VM_USB_HUB_SIZE 8 -/* usb-bus.c */ #define TYPE_USB_BUS "usb-bus"
Signature · 1 line
2.21.3
Re: [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition
Quoted 6 lines · Philippe Mathieu-Daudé
Commit
a5d2f7273c("qdev/usb: make qemu aware of usb busses") removed the last use ofVM_USB_HUB_SIZE, 11 years ago. Time to drop it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 23 lines
--- include/hw/usb.h | 4 ---- 1 file changed, 4 deletions(-)include/hw/usb.h +0
-5@@ -470,10 +470,6 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);void hmp_info_usbhost (Monitor *mon,const QDict *qdict);bool usb_host_dev_is_scsi_storage (USBDevice *usbdev); -/* usb ports of the VM */ - -#define VM_USB_HUB_SIZE 8 -/* usb-bus.c */ #define TYPE_USB_BUS "usb-bus" --2.21.3
PATCH 4/26 hw/usb: Reduce 'exec/memory.h' inclusion
In reply to Philippe Mathieu-Daudé"exec/memory.h" is only required by "hw/usb/hcd-musb.h". Include it there directly.
--- include/hw/usb.h | 1 - include/hw/usb/hcd-musb.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)
include/hw/usb.h +0 -1
@@ -25,7 +25,6 @@* THE SOFTWARE. */ -#include "exec/memory.h" #include "hw/qdev-core.h" #include "qemu/iov.h" #include "qemu/queue.h"
include/hw/usb/hcd-musb.h +2 -0
@@ -13,6 +13,8 @@#ifndef HW_USB_MUSB_H #define HW_USB_MUSB_H +#include "exec/memory.h" +enum musb_irq_source_e { musb_irq_suspend =0 , musb_irq_resume,
Signature · 1 line
2.21.3
Re: [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion
Quoted 5 lines · Philippe Mathieu-Daudé
"
exec/memory.h" is only required by "hw/usb/hcd-musb.h". Include it there directly.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 34 lines
--- include/hw/usb.h | 1 - include/hw/usb/hcd-musb.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)include/hw/usb.h +0
-1@@ -25,7 +25,6 @@* THE SOFTWARE. */ -#include "exec/memory.h" #include "hw/qdev-core.h" #include "qemu/iov.h" #include "qemu/queue.h" include/hw/usb/hcd-musb.h +2
-1@@ -13,6 +13,8 @@#ifndef HW_USB_MUSB_H #define HW_USB_MUSB_H +#include "exec/memory.h" +enum musb_irq_source_e { musb_irq_suspend =0 , musb_irq_resume, --2.21.3
PATCH 5/26 hw/usb/desc: Add missing header
In reply to Philippe Mathieu-DaudéThis header uses the USBPacket and USBDevice types which are forward declared in "hw/usb.h".
--- hw/usb/desc.h | 1 + 1 file changed, 1 insertion(+)
hw/usb/desc.h +1 -0
@@ -2,6 +2,7 @@#define QEMU_HW_USB_DESC_H #include <wchar.h> +#include "hw/usb.h" /* binary representation */ typedef struct USBDescriptor {
Signature · 1 line
2.21.3
Re: [PATCH 05/26] hw/usb/desc: Add missing header
Quoted 5 lines · Philippe Mathieu-Daudé
This header uses the USBPacket and USBDevice types which are forward declared in "
hw/usb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 20 lines
--- hw/usb/desc.h | 1 + 1 file changed, 1 insertion(+)hw/usb/desc.h +1
-1@@ -2,6 +2,7 @@#define QEMU_HW_USB_DESC_H #include <wchar.h> +#include "hw/usb.h" /* binary representation */ typedef struct USBDescriptor { --2.21.3
PATCH 6/26 hw/usb/hcd-dwc2: Remove unnecessary includes
In reply to Philippe Mathieu-Daudé"qemu/error-report.h" and "qemu/main-loop.h" are not used. Remove them.
--- hw/usb/hcd-dwc2.c | 2 -- 1 file changed, 2 deletions(-)
hw/usb/hcd-dwc2.c +0 -2
@@ -39,8 +39,6 @@#include "migration/vmstate.h" #include "trace.h" #include "qemu/log.h" -#include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "hw/qdev-properties.h" #define USB_HZ_FS 12000000
Signature · 1 line
2.21.3
Re: [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes
Quoted 5 lines · Philippe Mathieu-Daudé
"
qemu/error-report.h" and "qemu/main-loop.h" are not used. Remove them.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 21 lines
--- hw/usb/hcd-dwc2.c | 2 -- 1 file changed, 2 deletions(-)hw/usb/hcd-dwc2.c +0
-3@@ -39,8 +39,6 @@#include "migration/vmstate.h" #include "trace.h" #include "qemu/log.h" -#include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "hw/qdev-properties.h" #define USB_HZ_FS 12000000 --2.21.3
Re: [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes
In reply to Philippe Mathieu-DaudéQuoted 22 lines · Philippe Mathieu-Daudé
"
qemu/error-report.h" and "qemu/main-loop.h" are not used. Remove them.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/usb/hcd-dwc2.c | 2 -- 1 file changed, 2 deletions(-)hw/usb/hcd-dwc2.c +0
-3@@ -39,8 +39,6 @@#include "migration/vmstate.h" #include "trace.h" #include "qemu/log.h" -#include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "hw/qdev-properties.h" #define USB_HZ_FS 12000000 --
Quoted 3 lines
2.21.3
PATCH 7/26 hw/usb/hcd-dwc2: Restrict some headers to source
In reply to Philippe Mathieu-DaudéThe header "usb/hcd-dwc2.h" doesn't need to include "qemu/timer.h", "sysemu/dma.h", "hw/irq.h" (the types required are forward declared). Include them in the source file which is the only one requiring the function declarations.
--- hw/usb/hcd-dwc2.h | 3 --- hw/usb/hcd-dwc2.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
hw/usb/hcd-dwc2.h +0 -3
@@ -19,11 +19,8 @@#ifndef HW_USB_DWC2_H #define HW_USB_DWC2_H -#include "qemu/timer.h" -#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/usb.h" -#include "sysemu/dma.h" #define DWC2_MMIO_SIZE 0x11000
hw/usb/hcd-dwc2.c +3 -0
@@ -36,8 +36,11 @@#include "qapi/error.h" #include "hw/usb/dwc2-regs.h" #include "hw/usb/hcd-dwc2.h" +#include "hw/irq.h" +#include "sysemu/dma.h" #include "migration/vmstate.h" #include "trace.h" +#include "qemu/timer.h" #include "qemu/log.h" #include "hw/qdev-properties.h"
Signature · 1 line
2.21.3
Re: [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source
Quoted 7 lines · Philippe Mathieu-Daudé
The header "
usb/hcd-dwc2.h" doesn't need to include "qemu/timer.h", "sysemu/dma.h", "hw/irq.h" (the types required are forward declared). Include them in the source file which is the only one requiring the function declarations.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 41 lines
--- hw/usb/hcd-dwc2.h | 3 --- hw/usb/hcd-dwc2.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)hw/usb/hcd-dwc2.h +0
-3@@ -19,11 +19,8 @@#ifndef HW_USB_DWC2_H #define HW_USB_DWC2_H -#include "qemu/timer.h" -#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/usb.h" -#include "sysemu/dma.h" #define DWC2_MMIO_SIZE 0x11000hw/usb/hcd-dwc2.c +3
-1@@ -36,8 +36,11 @@#include "qapi/error.h" #include "hw/usb/dwc2-regs.h" #include "hw/usb/hcd-dwc2.h" +#include "hw/irq.h" +#include "sysemu/dma.h" #include "migration/vmstate.h" #include "trace.h" +#include "qemu/timer.h" #include "qemu/log.h" #include "hw/qdev-properties.h" --2.21.3
Re: [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source
In reply to Philippe Mathieu-DaudéQuoted 44 lines · Philippe Mathieu-Daudé
The header "
usb/hcd-dwc2.h" doesn't need to include "qemu/timer.h", "sysemu/dma.h", "hw/irq.h" (the types required are forward declared). Include them in the source file which is the only one requiring the function declarations.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/usb/hcd-dwc2.h | 3 --- hw/usb/hcd-dwc2.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)hw/usb/hcd-dwc2.h +0
-3@@ -19,11 +19,8 @@#ifndef HW_USB_DWC2_H #define HW_USB_DWC2_H -#include "qemu/timer.h" -#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/usb.h" -#include "sysemu/dma.h" #define DWC2_MMIO_SIZE 0x11000hw/usb/hcd-dwc2.c +3
-1@@ -36,8 +36,11 @@#include "qapi/error.h" #include "hw/usb/dwc2-regs.h" #include "hw/usb/hcd-dwc2.h" +#include "hw/irq.h" +#include "sysemu/dma.h" #include "migration/vmstate.h" #include "trace.h" +#include "qemu/timer.h" #include "qemu/log.h" #include "hw/qdev-properties.h" --
Quoted 3 lines
2.21.3
PATCH 8/26 hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
In reply to Philippe Mathieu-DaudéWe only use these register definitions in files under the hw/usb/ directory. Keep that header local by moving it there.
---
{include/hw => hw}/usb/dwc2-regs.h | 0
hw/usb/hcd-dwc2.c | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename {include/hw => hw}/usb/dwc2-regs.h (100%)hw/usb/dwc2-regs.h renamed from include/hw/usb/dwc2-regs.h +0 -0
hw/usb/hcd-dwc2.c +1 -1
@@ -34,7 +34,6 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" -#include "hw/usb/dwc2-regs.h" #include "hw/usb/hcd-dwc2.h" #include "hw/irq.h" #include "sysemu/dma.h"
@@ -43,6 +42,7 @@#include "qemu/timer.h" #include "qemu/log.h" #include "hw/qdev-properties.h" +#include "dwc2-regs.h" #define USB_HZ_FS 12000000#define USB_HZ_HS 96000000
Signature · 1 line
2.21.3
Re: [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
Quoted 5 lines · Philippe Mathieu-Daudé
We only use these register definitions in files under the hw/usb/ directory. Keep that header local by moving it there.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 34 lines
--- {include/hw => hw}/usb/dwc2-regs.h | 0 hw/usb/hcd-dwc2.c | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {include/hw => hw}/usb/dwc2-regs.h (100%)hw/usb/dwc2-regs.h renamed from include/hw/usb/dwc2-regs.h +0
-0hw/usb/hcd-dwc2.c +1
-2@@ -34,7 +34,6 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" -#include "hw/usb/dwc2-regs.h" #include "hw/usb/hcd-dwc2.h" #include "hw/irq.h" #include "sysemu/dma.h" @@ -43,6 +42,7 @@#include "qemu/timer.h" #include "qemu/log.h" #include "hw/qdev-properties.h" +#include "dwc2-regs.h" #define USB_HZ_FS 12000000#define USB_HZ_HS 96000000 --2.21.3
Re: [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
In reply to Philippe Mathieu-DaudéQuoted 35 lines · Philippe Mathieu-Daudé
We only use these register definitions in files under the hw/usb/ directory. Keep that header local by moving it there.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- {include/hw => hw}/usb/dwc2-regs.h | 0 hw/usb/hcd-dwc2.c | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {include/hw => hw}/usb/dwc2-regs.h (100%)hw/usb/dwc2-regs.h renamed from include/hw/usb/dwc2-regs.h +0
-0hw/usb/hcd-dwc2.c +1
-2@@ -34,7 +34,6 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" -#include "hw/usb/dwc2-regs.h" #include "hw/usb/hcd-dwc2.h" #include "hw/irq.h" #include "sysemu/dma.h" @@ -43,6 +42,7 @@#include "qemu/timer.h" #include "qemu/log.h" #include "hw/qdev-properties.h" +#include "dwc2-regs.h" #define USB_HZ_FS 12000000#define USB_HZ_HS 96000000 --
Quoted 3 lines
2.21.3
PATCH 9/26 hw/usb/hcd-ehci: Remove unnecessary include
In reply to Philippe Mathieu-DaudéAs "qemu/main-loop.h" is not used, remove it.
--- hw/usb/hcd-ehci.c | 1 - 1 file changed, 1 deletion(-)
hw/usb/hcd-ehci.c +0 -1
@@ -34,7 +34,6 @@#include "migration/vmstate.h" #include "trace.h" #include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "sysemu/runstate.h" #define FRAME_TIMER_FREQ 1000
Signature · 1 line
2.21.3
Re: [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include
Quoted 4 lines · Philippe Mathieu-Daudé
As "
qemu/main-loop.h" is not used, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 20 lines
--- hw/usb/hcd-ehci.c | 1 - 1 file changed, 1 deletion(-)hw/usb/hcd-ehci.c +0
-2@@ -34,7 +34,6 @@#include "migration/vmstate.h" #include "trace.h" #include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "sysemu/runstate.h" #define FRAME_TIMER_FREQ 1000 --2.21.3
PATCH 10/26 hw/usb/hcd-ehci: Move few definitions from header to source
In reply to Philippe Mathieu-DaudéMove definitions only useful for hcd-ehci.c to this source file.
--- hw/usb/hcd-ehci.h | 11 ----------- hw/usb/hcd-ehci.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-)
hw/usb/hcd-ehci.h +0 -11
@@ -24,17 +24,6 @@#include "hw/pci/pci.h" #include "hw/sysbus.h" -#ifndef EHCI_DEBUG -#define EHCI_DEBUG 0 -#endif - -#if EHCI_DEBUG -#define DPRINTF printf -#else -#define DPRINTF (...) -#endif - -#define MMIO_SIZE 0x1000#define CAPA_SIZE 0x10#define NB_PORTS 6/* Max. Number of downstream ports */
hw/usb/hcd-ehci.c +12 -0
@@ -36,6 +36,18 @@#include "qemu/error-report.h" #include "sysemu/runstate.h" +#ifndef EHCI_DEBUG +#define EHCI_DEBUG 0 +#endif + +#if EHCI_DEBUG +#define DPRINTF printf +#else +#define DPRINTF (...) +#endif + +#define MMIO_SIZE 0x1000 +#define FRAME_TIMER_FREQ 1000#define FRAME_TIMER_NS (NANOSECONDS_PER_SECOND / FRAME_TIMER_FREQ)#define UFRAME_TIMER_NS (FRAME_TIMER_NS / 8)
Signature · 1 line
2.21.3
Re: [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source
Quoted 4 lines · Philippe Mathieu-Daudé
Move definitions only useful for
hcd-ehci.cto this source file.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 54 lines
--- hw/usb/hcd-ehci.h | 11 ----------- hw/usb/hcd-ehci.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-)hw/usb/hcd-ehci.h +0
-11@@ -24,17 +24,6 @@#include "hw/pci/pci.h" #include "hw/sysbus.h" -#ifndef EHCI_DEBUG -#define EHCI_DEBUG 0 -#endif - -#if EHCI_DEBUG -#define DPRINTF printf -#else -#define DPRINTF (...) -#endif - -#define MMIO_SIZE 0x1000#define CAPA_SIZE 0x10#define NB_PORTS 6/* Max. Number of downstream ports */ hw/usb/hcd-ehci.c +12
-1@@ -36,6 +36,18 @@#include "qemu/error-report.h" #include "sysemu/runstate.h" +#ifndef EHCI_DEBUG +#define EHCI_DEBUG 0 +#endif + +#if EHCI_DEBUG +#define DPRINTF printf +#else +#define DPRINTF (...) +#endif + +#define MMIO_SIZE 0x1000 +#define FRAME_TIMER_FREQ 1000#define FRAME_TIMER_NS (NANOSECONDS_PER_SECOND / FRAME_TIMER_FREQ)#define UFRAME_TIMER_NS (FRAME_TIMER_NS / 8) --2.21.3
PATCH 11/26 hw/usb/hcd-xhci: Add missing header
In reply to Philippe Mathieu-DaudéThis header uses the USBPort type which is forward declared by "hw/usb.h".
--- hw/usb/hcd-xhci.h | 2 ++ 1 file changed, 2 insertions(+)
hw/usb/hcd-xhci.h +2 -0
@@ -22,6 +22,8 @@#ifndef HW_USB_HCD_XHCI_H #define HW_USB_HCD_XHCI_H +#include "hw/usb.h" +#define TYPE_XHCI "base-xhci"#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci"
Signature · 1 line
2.21.3
Re: [PATCH 11/26] hw/usb/hcd-xhci: Add missing header
Quoted 5 lines · Philippe Mathieu-Daudé
This header uses the USBPort type which is forward declared by "
hw/usb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 21 lines
--- hw/usb/hcd-xhci.h | 2 ++ 1 file changed, 2 insertions(+)hw/usb/hcd-xhci.h +2
-1@@ -22,6 +22,8 @@#ifndef HW_USB_HCD_XHCI_H #define HW_USB_HCD_XHCI_H +#include "hw/usb.h" +#define TYPE_XHCI "base-xhci"#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci" --2.21.3
PATCH 12/26 hw/usb/hcd-musb: Restrict header scope
In reply to Philippe Mathieu-Daudé"hcd-musb.h" is only required by USB device implementions. As we keep these implementations in the hw/usb/ directory, move the header there.
---
{include/hw => hw}/usb/hcd-musb.h | 0
hw/usb/hcd-musb.c | 2 +-
hw/usb/tusb6010.c | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
rename {include/hw => hw}/usb/hcd-musb.h (100%)hw/usb/hcd-musb.h renamed from include/hw/usb/hcd-musb.h +0 -0
hw/usb/hcd-musb.c +1 -1
@@ -23,9 +23,9 @@#include "qemu/osdep.h" #include "qemu/timer.h" #include "hw/usb.h" -#include "hw/usb/hcd-musb.h" #include "hw/irq.h" #include "hw/hw.h" +#include "hcd-musb.h" /* Common USB registers */ #define MUSB_HDRC_FADDR 0x00/* 8-bit */
hw/usb/tusb6010.c +1 -1
@@ -23,11 +23,11 @@#include "qemu/module.h" #include "qemu/timer.h" #include "hw/usb.h" -#include "hw/usb/hcd-musb.h" #include "hw/arm/omap.h" #include "hw/hw.h" #include "hw/irq.h" #include "hw/sysbus.h" +#include "hcd-musb.h" #define TYPE_TUSB6010 "tusb6010"#define TUSB (obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
Signature · 1 line
2.21.3
Re: [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope
Quoted 6 lines · Philippe Mathieu-Daudé
"
hcd-musb.h" is only required by USB device implementions. As we keep these implementations in the hw/usb/ directory, move the header there.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 47 lines
--- {include/hw => hw}/usb/hcd-musb.h | 0 hw/usb/hcd-musb.c | 2 +- hw/usb/tusb6010.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {include/hw => hw}/usb/hcd-musb.h (100%)hw/usb/hcd-musb.h renamed from include/hw/usb/hcd-musb.h +0
-0hw/usb/hcd-musb.c +1
-1@@ -23,9 +23,9 @@#include "qemu/osdep.h" #include "qemu/timer.h" #include "hw/usb.h" -#include "hw/usb/hcd-musb.h" #include "hw/irq.h" #include "hw/hw.h" +#include "hcd-musb.h" /* Common USB registers */ #define MUSB_HDRC_FADDR 0x00/* 8-bit */ hw/usb/tusb6010.c +1
-2@@ -23,11 +23,11 @@#include "qemu/module.h" #include "qemu/timer.h" #include "hw/usb.h" -#include "hw/usb/hcd-musb.h" #include "hw/arm/omap.h" #include "hw/hw.h" #include "hw/irq.h" #include "hw/sysbus.h" +#include "hcd-musb.h" #define TYPE_TUSB6010 "tusb6010"#define TUSB (obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010) --2.21.3
PATCH 13/26 hw/usb/desc: Reduce some declarations scope
In reply to Philippe Mathieu-DaudéUSBDescString is forward-declared. Only bus.c uses the usb_device_get_product_desc() and usb_device_get_usb_desc() function. Move all that to the "desc.h" header to reduce the big "hw/usb.h" header a bit.
--- hw/usb/desc.h | 10 ++++++++++ include/hw/usb.h | 10 ---------- hw/usb/bus.c | 1 + 3 files changed, 11 insertions(+), 10 deletions(-)
hw/usb/desc.h +10 -0
@@ -242,4 +242,14 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,int usb_desc_handle_control (USBDevice *dev,USBPacket *p,int request,int value,int index,int length,uint8_t *data); +const char *usb_device_get_product_desc (USBDevice *dev); + +const USBDesc *usb_device_get_usb_desc (USBDevice *dev); + +struct USBDescString { +uint8_t index; +char *str; +QLIST_ENTRY (USBDescString) next; +}; +#endif /* QEMU_HW_USB_DESC_H */
include/hw/usb.h +0 -10
@@ -192,12 +192,6 @@ typedef struct USBDescOther USBDescOther;typedef struct USBDescString USBDescString ;typedef struct USBDescMSOS USBDescMSOS ; -struct USBDescString { -uint8_t index; -char *str; -QLIST_ENTRY (USBDescString) next; -}; -#define USB_MAX_ENDPOINTS 15#define USB_MAX_INTERFACES 16
@@ -555,10 +549,6 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps, int streams);void usb_device_free_streams (USBDevice *dev,USBEndpoint **eps,int nr_eps); -const char *usb_device_get_product_desc (USBDevice *dev); - -const USBDesc *usb_device_get_usb_desc (USBDevice *dev); -/* quirks.c */ /* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
hw/usb/bus.c +1 -0
@@ -9,6 +9,7 @@#include "monitor/monitor.h" #include "trace.h" #include "qemu/cutils.h" +#include "desc.h" static void usb_bus_dev_print (Monitor *mon,DeviceState *qdev,int indent);
Signature · 1 line
2.21.3
Re: [PATCH 13/26] hw/usb/desc: Reduce some declarations scope
Quoted 7 lines · Philippe Mathieu-Daudé
USBDescString is forward-declared. Only
bus.cuses theusb_device_get_product_desc()andusb_device_get_usb_desc()function. Move all that to the "desc.h" header to reduce the big "hw/usb.h" header a bit.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 69 lines
--- hw/usb/desc.h | 10 ++++++++++ include/hw/usb.h | 10 ---------- hw/usb/bus.c | 1 + 3 files changed, 11 insertions(+), 10 deletions(-)hw/usb/desc.h +10
-0@@ -242,4 +242,14 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,int usb_desc_handle_control (USBDevice *dev,USBPacket *p,int request,int value,int index,int length,uint8_t *data); +const char *usb_device_get_product_desc (USBDevice *dev); + +const USBDesc *usb_device_get_usb_desc (USBDevice *dev); + +struct USBDescString { +uint8_t index; +char *str; +QLIST_ENTRY (USBDescString) next; +}; +#endif /* QEMU_HW_USB_DESC_H */ include/hw/usb.h +0
-10@@ -192,12 +192,6 @@ typedef struct USBDescOther USBDescOther;typedef struct USBDescString USBDescString ;typedef struct USBDescMSOS USBDescMSOS ; -struct USBDescString { -uint8_t index; -char *str; -QLIST_ENTRY (USBDescString) next; -}; -#define USB_MAX_ENDPOINTS 15#define USB_MAX_INTERFACES 16@@ -555,10 +549,6 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps, int streams);void usb_device_free_streams (USBDevice *dev,USBEndpoint **eps,int nr_eps); -const char *usb_device_get_product_desc (USBDevice *dev); - -const USBDesc *usb_device_get_usb_desc (USBDevice *dev); -/* quirks.c */ /* In bulk endpoints are streaming data sources (iow behave like isoc eps) */ hw/usb/bus.c +1
-1@@ -9,6 +9,7 @@#include "monitor/monitor.h" #include "trace.h" #include "qemu/cutils.h" +#include "desc.h" static void usb_bus_dev_print (Monitor *mon,DeviceState *qdev,int indent); --2.21.3
PATCH 14/26 hw/usb/quirks: Rename included source with '.inc.c' suffix
In reply to Philippe Mathieu-DaudéThis file is not a header, but contains source code which is included and compiled once. We use the '.inc.c' suffix in few other cases in the repository. Follow the same convention with this file.
---
hw/usb/quirks.c | 2 +-
hw/usb/{quirks.h => quirks.inc.c} | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
rename hw/usb/{quirks.h => quirks.inc.c} (99%)hw/usb/quirks.c +1 -1
@@ -13,7 +13,7 @@*/ #include "qemu/osdep.h" -#include "quirks.h" +#include "quirks.inc.c" #include "hw/usb.h" static bool usb_id_match(const struct usb_device_id *ids,
hw/usb/quirks.inc.c renamed from hw/usb/quirks.h +0 -5
@@ -12,9 +12,6 @@* (at your option) any later version. */ -#ifndef HW_USB_QUIRKS_H -#define HW_USB_QUIRKS_H -/* 1 on 1 copy of linux/drivers/usb/serial/ftdi_sio_ids.h */ #include "quirks-ftdi-ids.h" /* 1 on 1 copy of linux/drivers/usb/serial/pl2303.h */
@@ -915,5 +912,3 @@ static const struct usb_device_id usbredir_ftdi_serial_ids[] = {#undef USB_DEVICE#undef USB_DEVICE_AND_INTERFACE_INFO - -#endif
Signature · 1 line
2.21.3
Re: [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix
Quoted 7 lines · Philippe Mathieu-Daudé
This file is not a header, but contains source code which is included and compiled once. We use the '
.inc.c' suffix in few other cases in the repository. Follow the same convention with this file.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 46 lines
--- hw/usb/quirks.c | 2 +- hw/usb/{quirks.h => quirks.inc.c} | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) rename hw/usb/{quirks.h => quirks.inc.c} (99%)hw/usb/quirks.c +1
-1@@ -13,7 +13,7 @@*/ #include "qemu/osdep.h" -#include "quirks.h" +#include "quirks.inc.c" #include "hw/usb.h" static bool usb_id_match(const struct usb_device_id *ids,hw/usb/quirks.inc.c renamed from hw/usb/quirks.h +0
-6@@ -12,9 +12,6 @@* (at your option) any later version. */ -#ifndef HW_USB_QUIRKS_H -#define HW_USB_QUIRKS_H -/* 1 on 1 copy of linux/drivers/usb/serial/ftdi_sio_ids.h */ #include "quirks-ftdi-ids.h" /* 1 on 1 copy of linux/drivers/usb/serial/pl2303.h */ @@ -915,5 +912,3 @@ static const struct usb_device_id usbredir_ftdi_serial_ids[] = {#undef USB_DEVICE#undef USB_DEVICE_AND_INTERFACE_INFO - -#endif --2.21.3
PATCH 15/26 hw/usb: Add new 'usb-quirks.h' local header
In reply to Philippe Mathieu-DaudéOnly redirect.c consumes the quirks API. Reduce the big "hw/usb.h" header by moving the quirks related declaration into their own header. As nothing out of hw/usb/ requires it, keep it local.
--- hw/usb/usb-quirks.h | 27 +++++++++++++++++++++++++++ include/hw/usb.h | 11 ----------- hw/usb/quirks.c | 1 + hw/usb/redirect.c | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 hw/usb/usb-quirks.h
hw/usb/usb-quirks.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* USB quirk handling +* +* Copyright (c) 2012 Red Hat, Inc. +* +* Red Hat Authors: +* Hans de Goede <[email protected]> +* +* 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 of the License, or +* (at your option) any later version. +*/ + +#ifndef HW_USB_QUIRKS_H +#define HW_USB_QUIRKS_H + +/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */ +#define USB_QUIRK_BUFFER_BULK_IN 0x01 +/* Bulk pkts in FTDI format, need special handling when combining packets */ +#define USB_QUIRK_IS_FTDI 0x02 + +int usb_get_quirks (uint16_t vendor_id,uint16_t product_id, +uint8_t interface_class,uint8_t interface_subclass, +uint8_t interface_protocol); + +#endif
include/hw/usb.h +0 -11
@@ -549,15 +549,4 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps, int streams);void usb_device_free_streams (USBDevice *dev,USBEndpoint **eps,int nr_eps); -/* quirks.c */ - -/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */ -#define USB_QUIRK_BUFFER_BULK_IN 0x01 -/* Bulk pkts in FTDI format, need special handling when combining packets */ -#define USB_QUIRK_IS_FTDI 0x02 - -int usb_get_quirks (uint16_t vendor_id,uint16_t product_id, -uint8_t interface_class,uint8_t interface_subclass, -uint8_t interface_protocol); -#endif
hw/usb/quirks.c +1 -0
@@ -15,6 +15,7 @@#include "qemu/osdep.h" #include "quirks.inc.c" #include "hw/usb.h" +#include "usb-quirks.h" static bool usb_id_match(const struct usb_device_id *ids, uint16_t vendor_id, uint16_t product_id,
hw/usb/redirect.c +1 -0
@@ -45,6 +45,7 @@#include "hw/usb.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" +#include "usb-quirks.h" /* ERROR is defined below. Remove any previous definition. */ #undef ERROR
Signature · 1 line
2.21.3
Re: [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header
Quoted 6 lines · Philippe Mathieu-Daudé
Only
redirect.cconsumes the quirks API. Reduce the big "hw/usb.h" header by moving the quirks related declaration into their own header. As nothing out of hw/usb/ requires it, keep it local.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 89 lines
--- hw/usb/usb-quirks.h | 27 +++++++++++++++++++++++++++ include/hw/usb.h | 11 ----------- hw/usb/quirks.c | 1 + hw/usb/redirect.c | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 hw/usb/usb-quirks.hhw/usb/usb-quirks.h new file +27
-0@@ -0,0 +1,27 @@ +/* +* USB quirk handling +* +* Copyright (c) 2012 Red Hat, Inc. +* +* Red Hat Authors: +* Hans de Goede <[email protected]> +* +* 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 of the License, or +* (at your option) any later version. +*/ + +#ifndef HW_USB_QUIRKS_H +#define HW_USB_QUIRKS_H + +/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */ +#define USB_QUIRK_BUFFER_BULK_IN 0x01 +/* Bulk pkts in FTDI format, need special handling when combining packets */ +#define USB_QUIRK_IS_FTDI 0x02 + +int usb_get_quirks (uint16_t vendor_id,uint16_t product_id, +uint8_t interface_class,uint8_t interface_subclass, +uint8_t interface_protocol); + +#endif include/hw/usb.h +0
-11@@ -549,15 +549,4 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps, int streams);void usb_device_free_streams (USBDevice *dev,USBEndpoint **eps,int nr_eps); -/* quirks.c */ - -/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */ -#define USB_QUIRK_BUFFER_BULK_IN 0x01 -/* Bulk pkts in FTDI format, need special handling when combining packets */ -#define USB_QUIRK_IS_FTDI 0x02 - -int usb_get_quirks (uint16_t vendor_id,uint16_t product_id, -uint8_t interface_class,uint8_t interface_subclass, -uint8_t interface_protocol); -#endif hw/usb/quirks.c +1
-0@@ -15,6 +15,7 @@#include "qemu/osdep.h" #include "quirks.inc.c" #include "hw/usb.h" +#include "usb-quirks.h" static bool usb_id_match(const struct usb_device_id *ids, uint16_t vendor_id, uint16_t product_id,hw/usb/redirect.c +1
-1@@ -45,6 +45,7 @@#include "hw/usb.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" +#include "usb-quirks.h" /* ERROR is defined below. Remove any previous definition. */ #undef ERROR --2.21.3
PATCH 16/26 hw/usb/bus: Simplify usb_get_dev_path()
In reply to Philippe Mathieu-DaudéSimplify usb_get_dev_path() a bit.
--- hw/usb/bus.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
hw/usb/bus.c +9 -10
@@ -580,19 +580,18 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)static char *usb_get_dev_path (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev); -DeviceState *hcd = qdev->parent_bus->parent; -char *id =NULL ;if (dev->flags & (1 <<USB_DEV_FLAG_FULL_PATH )) { - id =qdev_get_dev_path (hcd); - } -if (id) { -char *ret =g_strdup_printf ("%s/%s" , id, dev->port->path); -g_free (id); -return ret; - }else { -return g_strdup (dev->port->path); +DeviceState *hcd = qdev->parent_bus->parent; +char *id =qdev_get_dev_path (hcd); + +if (id) { +char *ret =g_strdup_printf ("%s/%s" , id, dev->port->path); +g_free (id); +return ret; + } } +return g_strdup (dev->port->path); }static char *usb_get_fw_dev_path (DeviceState *qdev)
Signature · 1 line
2.21.3
Re: [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path()
Quoted 4 lines · Philippe Mathieu-Daudé
Simplify
usb_get_dev_path()a bit.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 41 lines
--- hw/usb/bus.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)hw/usb/bus.c +9
-11@@ -580,19 +580,18 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)static char *usb_get_dev_path (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev); -DeviceState *hcd = qdev->parent_bus->parent; -char *id =NULL ;if (dev->flags & (1 <<USB_DEV_FLAG_FULL_PATH )) { - id =qdev_get_dev_path (hcd); - } -if (id) { -char *ret =g_strdup_printf ("%s/%s" , id, dev->port->path); -g_free (id); -return ret; - }else { -return g_strdup (dev->port->path); +DeviceState *hcd = qdev->parent_bus->parent; +char *id =qdev_get_dev_path (hcd); + +if (id) { +char *ret =g_strdup_printf ("%s/%s" , id, dev->port->path); +g_free (id); +return ret; + } } +return g_strdup (dev->port->path); }static char *usb_get_fw_dev_path (DeviceState *qdev) --2.21.3
PATCH 17/26 hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path()
In reply to Philippe Mathieu-DaudéIf the device has USB_DEV_FLAG_FULL_PATH set, usb_get_dev_path() returns the full port path. Rename the function accordingly.
--- hw/usb/bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/usb/bus.c +3 -3
@@ -13,7 +13,7 @@static void usb_bus_dev_print (Monitor *mon,DeviceState *qdev,int indent); -static char *usb_get_dev_path (DeviceState *dev); +static char *usb_get_full_dev_path (DeviceState *dev);static char *usb_get_fw_dev_path (DeviceState *qdev);static void usb_qdev_unrealize (DeviceState *qdev);
@@ -33,7 +33,7 @@ static void usb_bus_class_init(ObjectClass *klass, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass); k->print_dev = usb_bus_dev_print; - k->get_dev_path = usb_get_dev_path; + k->get_dev_path = usb_get_full_dev_path; k->get_fw_dev_path = usb_get_fw_dev_path; hc->unplug = qdev_simple_device_unplug_cb; }
@@ -577,7 +577,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) dev->attached ? ", attached" : ""); } -static char *usb_get_dev_path (DeviceState *qdev) +static char *usb_get_full_dev_path (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev);
Signature · 1 line
2.21.3
Re: [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path()
Quoted 5 lines · Philippe Mathieu-Daudé
If the device has
USB_DEV_FLAG_FULL_PATHset,usb_get_dev_path()returns the full port path. Rename the function accordingly.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 39 lines
--- hw/usb/bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/usb/bus.c +3
-4@@ -13,7 +13,7 @@static void usb_bus_dev_print (Monitor *mon,DeviceState *qdev,int indent); -static char *usb_get_dev_path (DeviceState *dev); +static char *usb_get_full_dev_path (DeviceState *dev);static char *usb_get_fw_dev_path (DeviceState *qdev);static void usb_qdev_unrealize (DeviceState *qdev);@@ -33,7 +33,7 @@ static void usb_bus_class_init(ObjectClass *klass, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass); k->print_dev = usb_bus_dev_print; - k->get_dev_path = usb_get_dev_path; + k->get_dev_path = usb_get_full_dev_path; k->get_fw_dev_path = usb_get_fw_dev_path; hc->unplug = qdev_simple_device_unplug_cb; }@@ -577,7 +577,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) dev->attached ? ", attached" : ""); } -static char *usb_get_dev_path (DeviceState *qdev) +static char *usb_get_full_dev_path (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev); --2.21.3
PATCH 18/26 hw/usb/bus: Add usb_get_port_path()
In reply to Philippe Mathieu-DaudéRefactor usb_get_full_dev_path() to take a 'want_full_path' argument, and add usb_get_port_path() which returns a short path.
--- include/hw/usb.h | 10 ++++++++++ hw/usb/bus.c | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-)
include/hw/usb.h +10 -0
@@ -506,6 +506,16 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);void usb_unregister_port (USBBus *bus,USBPort *port);void usb_claim_port (USBDevice *dev,Error **errp);void usb_release_port (USBDevice *dev); +/** +* usb_get_port_path: +* @dev: the USB device +* +* The returned data must be released with g_free() +* when no longer required. +* +* Returns: a dynamically allocated pathname. +*/ +char *usb_get_port_path (USBDevice *dev);void usb_device_attach (USBDevice *dev,Error **errp);int usb_device_detach (USBDevice *dev);void usb_check_attach (USBDevice *dev,Error **errp);
hw/usb/bus.c +13 -5
@@ -577,12 +577,10 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) dev->attached ? ", attached" : ""); } -static char *usb_get_full_dev_path (DeviceState *qdev) +static char *usb_get_dev_path (USBDevice *dev,bool want_full_path) { -USBDevice *dev =USB_DEVICE (qdev); - -if (dev->flags & (1 <<USB_DEV_FLAG_FULL_PATH )) { -DeviceState *hcd = qdev->parent_bus->parent; +if (want_full_path && (dev->flags & (1 <<USB_DEV_FLAG_FULL_PATH ))) { +DeviceState *hcd =DEVICE (dev)->parent_bus->parent;char *id =qdev_get_dev_path (hcd);if (id) {
@@ -594,6 +592,16 @@ static char *usb_get_full_dev_path(DeviceState *qdev)return g_strdup (dev->port->path); } +static char *usb_get_full_dev_path (DeviceState *qdev) +{ +return usb_get_dev_path (USB_DEVICE (qdev), true); +} + +char *usb_get_port_path (USBDevice *dev) +{ +return usb_get_dev_path (dev, false); +} +static char *usb_get_fw_dev_path (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev);
Signature · 1 line
2.21.3
Re: [PATCH 18/26] hw/usb/bus: Add usb_get_port_path()
Quoted 6 lines · Philippe Mathieu-Daudé
Refactor
usb_get_full_dev_path()to take a 'want_full_path' argument, and addusb_get_port_path()which returns a short path.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 67 lines
--- include/hw/usb.h | 10 ++++++++++ hw/usb/bus.c | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-)include/hw/usb.h +10
-0@@ -506,6 +506,16 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);void usb_unregister_port (USBBus *bus,USBPort *port);void usb_claim_port (USBDevice *dev,Error **errp);void usb_release_port (USBDevice *dev); +/** +* usb_get_port_path: +* @dev: the USB device +* +* The returned data must be released with g_free() +* when no longer required. +* +* Returns: a dynamically allocated pathname. +*/ +char *usb_get_port_path (USBDevice *dev);void usb_device_attach (USBDevice *dev,Error **errp);int usb_device_detach (USBDevice *dev);void usb_check_attach (USBDevice *dev,Error **errp);hw/usb/bus.c +13
-6@@ -577,12 +577,10 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) dev->attached ? ", attached" : ""); } -static char *usb_get_full_dev_path (DeviceState *qdev) +static char *usb_get_dev_path (USBDevice *dev,bool want_full_path) { -USBDevice *dev =USB_DEVICE (qdev); - -if (dev->flags & (1 <<USB_DEV_FLAG_FULL_PATH )) { -DeviceState *hcd = qdev->parent_bus->parent; +if (want_full_path && (dev->flags & (1 <<USB_DEV_FLAG_FULL_PATH ))) { +DeviceState *hcd =DEVICE (dev)->parent_bus->parent;char *id =qdev_get_dev_path (hcd);if (id) {@@ -594,6 +592,16 @@ static char *usb_get_full_dev_path(DeviceState *qdev)return g_strdup (dev->port->path); } +static char *usb_get_full_dev_path (DeviceState *qdev) +{ +return usb_get_dev_path (USB_DEVICE (qdev), true); +} + +char *usb_get_port_path (USBDevice *dev) +{ +return usb_get_dev_path (dev, false); +} +static char *usb_get_fw_dev_path (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev); --2.21.3
PATCH 19/26 hw/ppc/spapr: Use usb_get_port_path()
In reply to Philippe Mathieu-DaudéTo avoid to access the USBDevice internals, and use the recently added usb_get_port_path() helper instead.
--- hw/ppc/spapr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +4 -2
@@ -3121,7 +3121,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,* We use SRP luns of the form 01000000 | (usb-port << 16) | lun * in the top 32 bits of the 64-bit LUN */ -unsigned usb_port =atoi (usb->port->path); + g_autofree char *usb_port_path = usb_get_port_path(usb); +unsigned usb_port =atoi (usb_port_path);unsigned id =0x1000000 | (usb_port <<16 ) | d->lun;return g_strdup_printf ("%s@%" PRIX64 ,qdev_fw_name (dev), (uint64_t )id <<32 );
@@ -3137,7 +3138,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,if (strcmp ("usb-host" ,qdev_fw_name (dev)) ==0 ) {USBDevice *usbdev =CAST (USBDevice, dev,TYPE_USB_DEVICE );if (usb_host_dev_is_scsi_storage (usbdev)) { -return g_strdup_printf ("storage@%s/disk" , usbdev->port->path); + g_autofree char *usb_port_path = usb_get_port_path(usbdev); +return g_strdup_printf ("storage@%s/disk" , usb_port_path); } }
Signature · 1 line
2.21.3
Re: [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path()
Quoted 5 lines · Philippe Mathieu-Daudé
To avoid to access the USBDevice internals, and use the recently added
usb_get_port_path()helper instead.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 32 lines
--- hw/ppc/spapr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)hw/ppc/spapr.c +4
-3@@ -3121,7 +3121,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,* We use SRP luns of the form 01000000 | (usb-port << 16) | lun * in the top 32 bits of the 64-bit LUN */ -unsigned usb_port =atoi (usb->port->path); + g_autofree char *usb_port_path = usb_get_port_path(usb); +unsigned usb_port =atoi (usb_port_path);unsigned id =0x1000000 | (usb_port <<16 ) | d->lun;return g_strdup_printf ("%s@%" PRIX64 ,qdev_fw_name (dev), (uint64_t )id <<32 );@@ -3137,7 +3138,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,if (strcmp ("usb-host" ,qdev_fw_name (dev)) ==0 ) {USBDevice *usbdev =CAST (USBDevice, dev,TYPE_USB_DEVICE );if (usb_host_dev_is_scsi_storage (usbdev)) { -return g_strdup_printf ("storage@%s/disk" , usbdev->port->path); + g_autofree char *usb_port_path = usb_get_port_path(usbdev); +return g_strdup_printf ("storage@%s/disk" , usb_port_path); } } --2.21.3
PATCH 20/26 hw/usb: Introduce "hw/usb/usb.h" public API
In reply to Philippe Mathieu-DaudéOnly the USB devices require to access the USB internal APIs.
The rest of the code base only wants to consume USB devices with a generic API. Move the generic declarations to the new "hw/usb/usb.h" header.
--- include/hw/usb.h | 27 +------------------- include/hw/usb/usb.h | 58 +++++++++++++++++++++++++++++++++++++++++++ chardev/baum.c | 2 +- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/sam460ex.c | 1 + hw/ppc/spapr.c | 2 +- hw/sh4/r2d.c | 2 +- hw/usb/host-stub.c | 2 +- monitor/misc.c | 2 +- softmmu/vl.c | 2 +- 13 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 include/hw/usb/usb.h
include/hw/usb.h +1 -26
@@ -26,6 +26,7 @@*/ #include "hw/qdev-core.h" +#include "hw/usb/usb.h" #include "qemu/iov.h" #include "qemu/queue.h"
@@ -176,7 +177,6 @@typedef struct USBBus USBBus ;typedef struct USBBusOps USBBusOps ;typedef struct USBPort USBPort ; -typedef struct USBDevice USBDevice ;typedef struct USBPacket USBPacket ;typedef struct USBCombinedPacket USBCombinedPacket ;typedef struct USBEndpoint USBEndpoint ;
@@ -256,9 +256,6 @@ struct USBDevice {const USBDescIface *ifaces[USB_MAX_INTERFACES ]; }; -#define TYPE_USB_DEVICE "usb-device" -#define USB_DEVICE (obj) \ - OBJECT_CHECK(USBDevice, (obj), TYPE_USB_DEVICE)#define USB_DEVICE_CLASS (klass) \ OBJECT_CLASS_CHECK(USBDeviceClass, (klass), TYPE_USB_DEVICE)#define USB_DEVICE_GET_CLASS (obj) \
@@ -459,15 +456,8 @@ void usb_device_reset(USBDevice *dev);void usb_wakeup (USBEndpoint *ep,unsigned int stream);void usb_generic_async_ctrl_complete (USBDevice *s,USBPacket *p); -/* usb-linux.c */ -void hmp_info_usbhost (Monitor *mon,const QDict *qdict); -bool usb_host_dev_is_scsi_storage (USBDevice *usbdev); -/* usb-bus.c */ -#define TYPE_USB_BUS "usb-bus" -#define USB_BUS (obj) OBJECT_CHECK(USBBus, (obj), TYPE_USB_BUS) -struct USBBus {BusState qbus;USBBusOps *ops;
@@ -489,13 +479,8 @@ struct USBBusOps {void usb_bus_new (USBBus *bus,size_t bus_size,USBBusOps *ops,DeviceState *host);void usb_bus_release (USBBus *bus); -USBBus *usb_bus_find (int busnr);void usb_legacy_register (const char *typename,const char *usbdevice_name,USBDevice *(*usbdevice_init)(const char *params)); -USBDevice *usb_new (const char *name); -bool usb_realize_and_unref (USBDevice *dev,USBBus *bus,Error **errp); -USBDevice *usb_create_simple (USBBus *bus,const char *name); -USBDevice *usbdevice_create (const char *cmdline);void usb_register_port (USBBus *bus,USBPort *port,void *opaque,int index,USBPortOps *ops,int speedmask); void usb_register_companion(const char *masterbus, USBPort *ports[],
@@ -506,16 +491,6 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);void usb_unregister_port (USBBus *bus,USBPort *port);void usb_claim_port (USBDevice *dev,Error **errp);void usb_release_port (USBDevice *dev); -/** -* usb_get_port_path: -* @dev: the USB device -* -* The returned data must be released with g_free() -* when no longer required. -* -* Returns: a dynamically allocated pathname. -*/ -char *usb_get_port_path (USBDevice *dev);void usb_device_attach (USBDevice *dev,Error **errp);int usb_device_detach (USBDevice *dev);void usb_check_attach (USBDevice *dev,Error **errp);
include/hw/usb/usb.h new file +58 -0
58 lines not on this page · raw message
chardev/baum.c +1 -1
@@ -28,7 +28,7 @@#include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/timer.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "ui/console.h" #include <brlapi.h> #include <brlapi_constants.h>
hw/i386/pc.c +1 -1
@@ -83,7 +83,7 @@#include "qapi/qapi-visit-common.h" #include "qapi/visitor.h" #include "hw/core/cpu.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" #include "standard-headers/asm-x86/bootparam.h"
hw/i386/pc_piix.c +1 -1
@@ -36,7 +36,7 @@#include "hw/firmware/smbios.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "net/net.h" #include "hw/ide/pci.h" #include "hw/irq.h"
hw/i386/pc_q35.c +1 -1
@@ -50,7 +50,7 @@#include "hw/firmware/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h"
hw/ppc/mac_newworld.c +1 -1
@@ -69,7 +69,7 @@#include "sysemu/kvm.h" #include "sysemu/reset.h" #include "kvm_ppc.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "exec/address-spaces.h" #include "hw/sysbus.h" #include "trace.h"
hw/ppc/sam460ex.c +1 -0
@@ -35,6 +35,7 @@#include "hw/char/serial.h" #include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" +#include "hw/usb/usb.h" #include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h"
hw/ppc/spapr.c +1 -1
@@ -70,7 +70,7 @@#include "exec/address-spaces.h" #include "exec/ram_addr.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "trace.h"
hw/sh4/r2d.c +1 -1
@@ -40,7 +40,7 @@#include "hw/ide.h" #include "hw/irq.h" #include "hw/loader.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "hw/block/flash.h" #include "exec/address-spaces.h"
hw/usb/host-stub.c +1 -1
@@ -32,7 +32,7 @@#include "qemu/osdep.h" #include "ui/console.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "monitor/monitor.h" void hmp_info_usbhost (Monitor *mon,const QDict *qdict)
monitor/misc.c +1 -1
@@ -26,7 +26,7 @@#include "monitor-internal.h" #include "cpu.h" #include "monitor/qdev.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "hw/pci/pci.h" #include "sysemu/watchdog.h" #include "hw/loader.h"
softmmu/vl.c +1 -1
@@ -41,7 +41,7 @@#include "qemu/error-report.h" #include "qemu/sockets.h" #include "sysemu/accel.h" -#include "hw/usb.h" +#include "hw/usb/usb.h" #include "hw/isa/isa.h" #include "hw/scsi/scsi.h" #include "hw/display/vga.h"
Signature · 1 line
2.21.3
PATCH 21/26 hw/usb: Move internal API to local 'usb-internal.h' header
In reply to Philippe Mathieu-DaudéOnly the files under hw/usb/ require access to the USB internal API. Move include/hw/usb.h to hw/usb/usb-internal.h to reduce its scope.
--- hw/usb/desc.h | 2 +- hw/usb/hcd-dwc2.h | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/hcd-ohci.h | 2 +- hw/usb/hcd-xhci.h | 2 +- include/hw/usb.h => hw/usb/usb-internal.h | 7 +++---- hw/usb/bus.c | 2 +- hw/usb/combined-packet.c | 2 +- hw/usb/core.c | 2 +- hw/usb/desc-msos.c | 2 +- hw/usb/desc.c | 3 +-- hw/usb/dev-audio.c | 2 +- hw/usb/dev-hid.c | 2 +- hw/usb/dev-hub.c | 2 +- hw/usb/dev-mtp.c | 2 +- hw/usb/dev-network.c | 2 +- hw/usb/dev-serial.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 2 +- hw/usb/dev-uas.c | 2 +- hw/usb/dev-wacom.c | 2 +- hw/usb/hcd-dwc2.c | 1 + hw/usb/hcd-musb.c | 2 +- hw/usb/hcd-ohci-pci.c | 2 +- hw/usb/hcd-ohci.c | 1 - hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci-nec.c | 3 +-- hw/usb/hcd-xhci.c | 2 +- hw/usb/host-libusb.c | 2 +- hw/usb/libhw.c | 2 +- hw/usb/quirks.c | 2 +- hw/usb/redirect.c | 2 +- hw/usb/tusb6010.c | 2 +- hw/usb/xen-usb.c | 2 +- MAINTAINERS | 1 - 35 files changed, 35 insertions(+), 39 deletions(-) rename include/hw/usb.h => hw/usb/usb-internal.h (99%)
hw/usb/desc.h +1 -1
@@ -2,7 +2,7 @@#define QEMU_HW_USB_DESC_H #include <wchar.h> -#include "hw/usb.h" +#include "usb-internal.h" /* binary representation */ typedef struct USBDescriptor {
hw/usb/hcd-dwc2.h +1 -1
@@ -20,7 +20,7 @@#define HW_USB_DWC2_H #include "hw/sysbus.h" -#include "hw/usb.h" +#include "usb-internal.h" #define DWC2_MMIO_SIZE 0x11000
hw/usb/hcd-ehci.h +1 -1
@@ -19,10 +19,10 @@#define HW_USB_HCD_EHCI_H #include "qemu/timer.h" -#include "hw/usb.h" #include "sysemu/dma.h" #include "hw/pci/pci.h" #include "hw/sysbus.h" +#include "usb-internal.h" #define CAPA_SIZE 0x10
hw/usb/hcd-ohci.h +1 -1
@@ -22,7 +22,7 @@#define HCD_OHCI_H #include "sysemu/dma.h" -#include "hw/usb.h" +#include "usb-internal.h" /* Number of Downstream Ports on the root hub: */ #define OHCI_MAX_PORTS 15
hw/usb/hcd-xhci.h +1 -1
@@ -22,7 +22,7 @@#ifndef HW_USB_HCD_XHCI_H #define HW_USB_HCD_XHCI_H -#include "hw/usb.h" +#include "usb-internal.h" #define TYPE_XHCI "base-xhci"#define TYPE_NEC_XHCI "nec-usb-xhci"
hw/usb/usb-internal.h renamed from include/hw/usb.h +3 -4
@@ -1,8 +1,5 @@ -#ifndef QEMU_USB_H -#define QEMU_USB_H -/* -* QEMU USB API +* QEMU USB internal API * * Copyright (c) 2005 Fabrice Bellard *
@@ -24,6 +21,8 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef QEMU_USB_INTERNAL_H +#define QEMU_USB_INTERNAL_H #include "hw/qdev-core.h" #include "hw/usb/usb.h"
hw/usb/bus.c +1 -1
@@ -1,6 +1,5 @@#include "qemu/osdep.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/module.h"
@@ -9,6 +8,7 @@#include "monitor/monitor.h" #include "trace.h" #include "qemu/cutils.h" +#include "usb-internal.h" #include "desc.h" static void usb_bus_dev_print (Monitor *mon,DeviceState *qdev,int indent);
hw/usb/combined-packet.c +1 -1
@@ -21,9 +21,9 @@*/ #include "qemu/osdep.h" #include "qemu/units.h" -#include "hw/usb.h" #include "qemu/iov.h" #include "trace.h" +#include "usb-internal.h" static void usb_combined_packet_add (USBCombinedPacket *combined,USBPacket *p) {
hw/usb/core.c +1 -1
@@ -24,9 +24,9 @@* THE SOFTWARE. */ #include "qemu/osdep.h" -#include "hw/usb.h" #include "qemu/iov.h" #include "trace.h" +#include "usb-internal.h" void usb_pick_speed (USBPort *port) {
hw/usb/desc-msos.c +1 -1
@@ -1,6 +1,6 @@#include "qemu/osdep.h" -#include "hw/usb.h" #include "desc.h" +#include "usb-internal.h" /* * Microsoft OS Descriptors
hw/usb/desc.c +1 -2
@@ -1,8 +1,7 @@#include "qemu/osdep.h" - -#include "hw/usb.h" #include "desc.h" #include "trace.h" +#include "usb-internal.h" /* ------------------------------------------------------------------ */
hw/usb/dev-audio.c +1 -1
@@ -32,10 +32,10 @@#include "qemu/osdep.h" #include "qemu/module.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "audio/audio.h" +#include "usb-internal.h" static void usb_audio_reinit (USBDevice *dev,unsigned channels);
hw/usb/dev-hid.c +1 -1
@@ -25,7 +25,6 @@#include "qemu/osdep.h" #include "ui/console.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "qapi/error.h"
@@ -33,6 +32,7 @@#include "qemu/timer.h" #include "hw/input/hid.h" #include "hw/qdev-properties.h" +#include "usb-internal.h" /* HID interface requests */ #define GET_REPORT 0xa101
hw/usb/dev-hub.c +1 -1
@@ -27,11 +27,11 @@#include "qemu/timer.h" #include "trace.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "usb-internal.h" #define MAX_PORTS 8
hw/usb/dev-mtp.c +1 -1
@@ -24,10 +24,10 @@#include "qemu/filemonitor.h" #include "trace.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "qemu/units.h" +#include "usb-internal.h" /* ----------------------------------------------------------------------- */
hw/usb/dev-network.c +1 -1
@@ -26,7 +26,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "net/net.h"
@@ -37,6 +36,7 @@#include "qemu/iov.h" #include "qemu/module.h" #include "qemu/cutils.h" +#include "usb-internal.h" /*#define TRAFFIC_DEBUG*/ /* Thanks to NetChip Technologies for donating this product ID.
hw/usb/dev-serial.c +1 -1
@@ -14,11 +14,11 @@#include "qemu/error-report.h" #include "qemu/module.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "chardev/char-serial.h" #include "chardev/char-fe.h" +#include "usb-internal.h" //#define DEBUG_Serial
hw/usb/dev-smartcard-reader.c +1 -1
@@ -41,9 +41,9 @@#include "qemu/error-report.h" #include "qemu/module.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" +#include "usb-internal.h" #include "ccid.h"
hw/usb/dev-storage.c +1 -1
@@ -13,7 +13,6 @@#include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "hw/usb.h" #include "desc.h" #include "hw/qdev-properties.h" #include "hw/scsi/scsi.h"
@@ -22,6 +21,7 @@#include "sysemu/block-backend.h" #include "qapi/visitor.h" #include "qemu/cutils.h" +#include "usb-internal.h" //#define DEBUG_MSD
hw/usb/dev-uas.c +1 -1
@@ -17,12 +17,12 @@#include "qemu/main-loop.h" #include "qemu/module.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" #include "hw/qdev-properties.h" #include "hw/scsi/scsi.h" #include "scsi/constants.h" +#include "usb-internal.h" /* --------------------------------------------------------------------- */
hw/usb/dev-wacom.c +1 -1
@@ -28,10 +28,10 @@#include "qemu/osdep.h" #include "ui/console.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "qemu/module.h" #include "desc.h" +#include "usb-internal.h" /* Interface requests */ #define WACOM_GET_REPORT 0x2101
hw/usb/hcd-dwc2.c +1 -0
@@ -43,6 +43,7 @@#include "qemu/log.h" #include "hw/qdev-properties.h" #include "dwc2-regs.h" +#include "usb-internal.h" #define USB_HZ_FS 12000000#define USB_HZ_HS 96000000
hw/usb/hcd-musb.c +1 -1
@@ -22,10 +22,10 @@*/ #include "qemu/osdep.h" #include "qemu/timer.h" -#include "hw/usb.h" #include "hw/irq.h" #include "hw/hw.h" #include "hcd-musb.h" +#include "usb-internal.h" /* Common USB registers */ #define MUSB_HDRC_FADDR 0x00/* 8-bit */
hw/usb/hcd-ohci-pci.c +1 -1
@@ -21,7 +21,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/timer.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" #include "hw/sysbus.h"
@@ -29,6 +28,7 @@#include "hw/qdev-properties.h" #include "trace.h" #include "hcd-ohci.h" +#include "usb-internal.h" #define TYPE_PCI_OHCI "pci-ohci"#define PCI_OHCI (obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
hw/usb/hcd-ohci.c +0 -1
@@ -30,7 +30,6 @@#include "qapi/error.h" #include "qemu/module.h" #include "qemu/timer.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "hw/sysbus.h" #include "hw/qdev-dma.h"
hw/usb/hcd-uhci.c +1 -1
@@ -27,7 +27,6 @@*/ #include "qemu/osdep.h" -#include "hw/usb.h" #include "hw/usb/uhci-regs.h" #include "migration/vmstate.h" #include "hw/pci/pci.h"
@@ -39,6 +38,7 @@#include "trace.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "usb-internal.h" #define FRAME_TIMER_FREQ 1000
hw/usb/hcd-xhci-nec.c +1 -2
@@ -20,11 +20,10 @@*/ #include "qemu/osdep.h" -#include "hw/usb.h" #include "qemu/module.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" - +#include "usb-internal.h" #include "hcd-xhci.h" static Property nec_xhci_properties[] = {
hw/usb/hcd-xhci.c +1 -1
@@ -23,7 +23,6 @@#include "qemu/timer.h" #include "qemu/module.h" #include "qemu/queue.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h"
@@ -33,6 +32,7 @@#include "qapi/error.h" #include "hcd-xhci.h" +#include "usb-internal.h" //#define DEBUG_XHCI //#define DEBUG_DATA
hw/usb/host-libusb.c +1 -1
@@ -50,7 +50,7 @@#include "trace.h" #include "hw/qdev-properties.h" -#include "hw/usb.h" +#include "usb-internal.h" /* ------------------------------------------------------------------------ */
hw/usb/libhw.c +1 -1
@@ -20,8 +20,8 @@* THE SOFTWARE. */ #include "qemu/osdep.h" -#include "hw/usb.h" #include "sysemu/dma.h" +#include "usb-internal.h" int usb_packet_map (USBPacket *p,QEMUSGList *sgl) {
hw/usb/quirks.c +1 -1
@@ -14,7 +14,7 @@#include "qemu/osdep.h" #include "quirks.inc.c" -#include "hw/usb.h" +#include "usb-internal.h" #include "usb-quirks.h" static bool usb_id_match(const struct usb_device_id *ids,
hw/usb/redirect.c +1 -1
@@ -42,9 +42,9 @@#include <usbredirfilter.h> #include "hw/qdev-properties.h" -#include "hw/usb.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" +#include "usb-internal.h" #include "usb-quirks.h" /* ERROR is defined below. Remove any previous definition. */
hw/usb/tusb6010.c +1 -1
@@ -22,12 +22,12 @@#include "qemu/osdep.h" #include "qemu/module.h" #include "qemu/timer.h" -#include "hw/usb.h" #include "hw/arm/omap.h" #include "hw/hw.h" #include "hw/irq.h" #include "hw/sysbus.h" #include "hcd-musb.h" +#include "usb-internal.h" #define TYPE_TUSB6010 "tusb6010"#define TUSB (obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
hw/usb/xen-usb.c +1 -1
@@ -27,12 +27,12 @@#include "qemu/main-loop.h" #include "qemu/option.h" #include "hw/sysbus.h" -#include "hw/usb.h" #include "hw/xen/xen-legacy-backend.h" #include "monitor/qdev.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" +#include "usb-internal.h" #include "hw/xen/interface/io/usbif.h"
MAINTAINERS +0 -1
@@ -1642,7 +1642,6 @@ F: hw/usb/* F: tests/qtest/usb-*-test.c F: docs/usb2.txt F: docs/usb-storage.txt -F: include/hw/usb.h F: include/hw/usb/ F: default-configs/usb.mak
Signature · 1 line
2.21.3
PATCH 22/26 hw/usb/usb-hcd: Use OHCI type definitions
In reply to Philippe Mathieu-DaudéVarious machine/board/soc models create OHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
--- hw/usb/hcd-ohci.h | 2 +- include/hw/usb/usb-hcd.h | 16 ++++++++++++++++ hw/arm/allwinner-a10.c | 2 +- hw/arm/allwinner-h3.c | 9 +++++---- hw/arm/pxa2xx.c | 3 ++- hw/arm/realview.c | 3 ++- hw/arm/versatilepb.c | 3 ++- hw/display/sm501.c | 3 ++- hw/ppc/mac_newworld.c | 3 ++- hw/ppc/mac_oldworld.c | 3 ++- hw/ppc/sam460ex.c | 3 ++- hw/ppc/spapr.c | 3 ++- hw/usb/hcd-ohci-pci.c | 2 +- 13 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 include/hw/usb/usb-hcd.h
hw/usb/hcd-ohci.h +1 -1
@@ -21,6 +21,7 @@#ifndef HCD_OHCI_H #define HCD_OHCI_H +#include "hw/usb/usb-hcd.h" #include "sysemu/dma.h" #include "usb-internal.h"
@@ -91,7 +92,6 @@ 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 {
include/hw/usb/usb-hcd.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* QEMU USB HCD types +* +* Copyright (c) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_USB_HCD_TYPES_H +#define HW_USB_HCD_TYPES_H + +/* OHCI */ +#define TYPE_SYSBUS_OHCI "sysbus-ohci" +#define TYPE_PCI_OHCI "pci-ohci" + +#endif
hw/arm/allwinner-a10.c +1 -1
@@ -25,7 +25,7 @@#include "hw/misc/unimp.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/usb/hcd-ohci.h" +#include "hw/usb/usb-hcd.h" #define AW_A10_MMC0_BASE 0x01c0f000#define AW_A10_PIC_REG_BASE 0x01c20400
hw/arm/allwinner-h3.c +5 -4
@@ -28,6 +28,7 @@#include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/misc/unimp.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h"
@@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (&s->gic), AW_H3_GIC_SPI_EHCI3)); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI0 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI0 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI1 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI1 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI2 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI2 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI3 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI3 ));
hw/arm/pxa2xx.c +2 -1
@@ -18,6 +18,7 @@#include "hw/arm/pxa.h" #include "sysemu/sysemu.h" #include "hw/char/serial.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h"
@@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->ssp[i] = (SSIBus *)qdev_get_child_bus (dev,"ssi" ); } -sysbus_create_simple ("sysbus-ohci" ,0x4c000000 , +sysbus_create_simple (TYPE_SYSBUS_OHCI ,0x4c000000 ,qdev_get_gpio_in (s->pic,PXA2XX_PIC_USBH1 )); s->pcmcia[0 ] =pxa2xx_pcmcia_init (address_space,0x20000000 );
hw/arm/realview.c +2 -1
@@ -16,6 +16,7 @@#include "hw/net/lan9118.h" #include "hw/net/smc91c111.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h"
@@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,sysbus_connect_irq (busdev,3 , pic[51 ]); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) {
hw/arm/versatilepb.c +2 -1
@@ -17,6 +17,7 @@#include "net/net.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/irq.h"
@@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int board_id) } }if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) {
hw/display/sm501.c +2 -1
@@ -33,6 +33,7 @@#include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/qdev-properties.h" #include "hw/i2c/i2c.h" #include "hw/display/i2c-ddc.h"
@@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->state.mmio_region);/* bridge to usb host emulation module */ - usb_dev =qdev_new ("sysbus-ohci" ); + usb_dev =qdev_new (TYPE_SYSBUS_OHCI );qdev_prop_set_uint32 (usb_dev,"num-ports" ,2 );qdev_prop_set_uint64 (usb_dev,"dma-offset" , s->base);sysbus_realize_and_unref (SYS_BUS_DEVICE (usb_dev), &error_fatal);
hw/ppc/mac_newworld.c +2 -1
@@ -55,6 +55,7 @@#include "hw/input/adb.h" #include "hw/ppc/mac_dbdma.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h"
@@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */
hw/ppc/mac_oldworld.c +2 -1
@@ -37,6 +37,7 @@#include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" +#include "hw/usb/usb-hcd.h" #include "hw/boards.h" #include "hw/nvram/fw_cfg.h" #include "hw/char/escc.h"
@@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); }if (graphic_depth !=15 && graphic_depth !=32 && graphic_depth !=8 )
hw/ppc/sam460ex.c +2 -1
@@ -36,6 +36,7 @@#include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h"
@@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)/* USB */ sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , uic[2 ][29 ]); - dev =qdev_new ("sysbus-ohci" ); + dev =qdev_new (TYPE_SYSBUS_OHCI );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);
hw/ppc/spapr.c +2 -1
@@ -71,6 +71,7 @@#include "exec/address-spaces.h" #include "exec/ram_addr.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "trace.h"
@@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine)if (machine->usb) {if (smc->use_ohci_by_default) { -pci_create_simple (phb->bus,-1 ,"pci-ohci" ); +pci_create_simple (phb->bus,-1 ,TYPE_PCI_OHCI ); }else {pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); }
hw/usb/hcd-ohci-pci.c +1 -1
@@ -29,8 +29,8 @@#include "trace.h" #include "hcd-ohci.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" -#define TYPE_PCI_OHCI "pci-ohci"#define PCI_OHCI (obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI) typedef struct {
Signature · 1 line
2.21.3
Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
Quoted 11 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create OHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/usb/hcd-ohci.h| 2 +-include/hw/usb/usb-hcd.h| 16 ++++++++++++++++
I wonder if we need a new header for this or these could just go in the new public hw/usb/usb.h as machines creating a HCD may also add devices (like keyboard/mouse) so probably will need both headers anyway so splitting it up may not worth it but I don't really mind, either way.
For sm501 and sam460ex parts:
Regards,
BALATON Zoltan
Quoted 285 lines
hw/arm/allwinner-a10.c | 2 +- hw/arm/allwinner-h3.c | 9 +++++---- hw/arm/pxa2xx.c | 3 ++- hw/arm/realview.c | 3 ++- hw/arm/versatilepb.c | 3 ++- hw/display/sm501.c | 3 ++- hw/ppc/mac_newworld.c | 3 ++- hw/ppc/mac_oldworld.c | 3 ++- hw/ppc/sam460ex.c | 3 ++- hw/ppc/spapr.c | 3 ++- hw/usb/hcd-ohci-pci.c | 2 +- 13 files changed, 40 insertions(+), 15 deletions(-)create mode 100644
include/hw/usb/usb-hcd.hhw/usb/hcd-ohci.h +1
-1@@ -21,6 +21,7 @@#ifndef HCD_OHCI_H #define HCD_OHCI_H +#include "hw/usb/usb-hcd.h" #include "sysemu/dma.h" #include "usb-internal.h" @@ -91,7 +92,6 @@ 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 {include/hw/usb/usb-hcd.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* QEMU USB HCD types +* +* Copyright (c) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_USB_HCD_TYPES_H +#define HW_USB_HCD_TYPES_H + +/* OHCI */ +#define TYPE_SYSBUS_OHCI "sysbus-ohci" +#define TYPE_PCI_OHCI "pci-ohci" + +#endif hw/arm/allwinner-a10.c +1
-1@@ -25,7 +25,7 @@#include "hw/misc/unimp.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/usb/hcd-ohci.h" +#include "hw/usb/usb-hcd.h" #define AW_A10_MMC0_BASE 0x01c0f000#define AW_A10_PIC_REG_BASE 0x01c20400hw/arm/allwinner-h3.c +5
-4@@ -28,6 +28,7 @@#include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/misc/unimp.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h" @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (&s->gic), AW_H3_GIC_SPI_EHCI3)); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI0 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI0 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI1 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI1 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI2 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI2 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI3 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI3 ));hw/arm/pxa2xx.c +2
-1@@ -18,6 +18,7 @@#include "hw/arm/pxa.h" #include "sysemu/sysemu.h" #include "hw/char/serial.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" @@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->ssp[i] = (SSIBus *)qdev_get_child_bus (dev,"ssi" ); } -sysbus_create_simple ("sysbus-ohci" ,0x4c000000 , +sysbus_create_simple (TYPE_SYSBUS_OHCI ,0x4c000000 ,qdev_get_gpio_in (s->pic,PXA2XX_PIC_USBH1 )); s->pcmcia[0 ] =pxa2xx_pcmcia_init (address_space,0x20000000 );hw/arm/realview.c +2
-1@@ -16,6 +16,7 @@#include "hw/net/lan9118.h" #include "hw/net/smc91c111.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,sysbus_connect_irq (busdev,3 , pic[51 ]); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) {hw/arm/versatilepb.c +2
-1@@ -17,6 +17,7 @@#include "net/net.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/irq.h" @@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int board_id) } }if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) {hw/display/sm501.c +2
-1@@ -33,6 +33,7 @@#include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/qdev-properties.h" #include "hw/i2c/i2c.h" #include "hw/display/i2c-ddc.h" @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->state.mmio_region);/* bridge to usb host emulation module */ - usb_dev =qdev_new ("sysbus-ohci" ); + usb_dev =qdev_new (TYPE_SYSBUS_OHCI );qdev_prop_set_uint32 (usb_dev,"num-ports" ,2 );qdev_prop_set_uint64 (usb_dev,"dma-offset" , s->base);sysbus_realize_and_unref (SYS_BUS_DEVICE (usb_dev), &error_fatal);hw/ppc/mac_newworld.c +2
-1@@ -55,6 +55,7 @@#include "hw/input/adb.h" #include "hw/ppc/mac_dbdma.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */ hw/ppc/mac_oldworld.c +2
-1@@ -37,6 +37,7 @@#include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" +#include "hw/usb/usb-hcd.h" #include "hw/boards.h" #include "hw/nvram/fw_cfg.h" #include "hw/char/escc.h" @@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); }if (graphic_depth !=15 && graphic_depth !=32 && graphic_depth !=8 )hw/ppc/sam460ex.c +2
-1@@ -36,6 +36,7 @@#include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" @@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)/* USB */ sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , uic[2 ][29 ]); - dev =qdev_new ("sysbus-ohci" ); + dev =qdev_new (TYPE_SYSBUS_OHCI );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);hw/ppc/spapr.c +2
-1@@ -71,6 +71,7 @@#include "exec/address-spaces.h" #include "exec/ram_addr.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "trace.h" @@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine)if (machine->usb) {if (smc->use_ohci_by_default) { -pci_create_simple (phb->bus,-1 ,"pci-ohci" ); +pci_create_simple (phb->bus,-1 ,TYPE_PCI_OHCI ); }else {pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); }hw/usb/hcd-ohci-pci.c +1
-1@@ -29,8 +29,8 @@#include "trace.h" #include "hcd-ohci.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" -#define TYPE_PCI_OHCI "pci-ohci"#define PCI_OHCI (obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI) typedef struct {
Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
Quoted 13 lines · BALATON Zoltan
Quoted 11 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create OHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/usb/hcd-ohci.h | 2 +-include/hw/usb/usb-hcd.h| 16 ++++++++++++++++
Quoted 4 lines
I wonder if we need a new header for this or these could just go in the new public
hw/usb/usb.has machines creating a HCD may also add devices (like keyboard/mouse) so probably will need both headers anyway so splitting it up may not worth it but I don't really mind, either way.
Hmm the rationale for this choice is: SoC might only instanciate USB HCI via sysbus/qdev API, without any use of "hw/usb/usb.h". This is the machine / board that instanciate USB devices and plug them to the HCI on the SoC.
I can reword better the description.
Quoted 300 lines
For sm501 and sam460ex parts:
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATON ZoltanQuoted 292 lines
hw/arm/allwinner-a10.c | 2 +-
hw/arm/allwinner-h3.c | 9 +++++----
hw/arm/pxa2xx.c | 3 ++-
hw/arm/realview.c | 3 ++-
hw/arm/versatilepb.c | 3 ++-
hw/display/sm501.c | 3 ++-
hw/ppc/mac_newworld.c | 3 ++-
hw/ppc/mac_oldworld.c | 3 ++-
hw/ppc/sam460ex.c | 3 ++-
hw/ppc/spapr.c | 3 ++-
hw/usb/hcd-ohci-pci.c | 2 +-13 files changed, 40 insertions(+), 15 deletions(-)create mode 100644
include/hw/usb/usb-hcd.hhw/usb/hcd-ohci.h +1
-1@@ -21,6 +21,7 @@#ifndef HCD_OHCI_H #define HCD_OHCI_H +#include "hw/usb/usb-hcd.h" #include "sysemu/dma.h" #include "usb-internal.h" @@ -91,7 +92,6 @@ 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 {
include/hw/usb/usb-hcd.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* QEMU USB HCD types +* +* Copyright (c) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_USB_HCD_TYPES_H +#define HW_USB_HCD_TYPES_H + +/* OHCI */ +#define TYPE_SYSBUS_OHCI "sysbus-ohci" +#define TYPE_PCI_OHCI "pci-ohci" + +#endif hw/arm/allwinner-a10.c +1
-1@@ -25,7 +25,7 @@#include "hw/misc/unimp.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/usb/hcd-ohci.h" +#include "hw/usb/usb-hcd.h" #define AW_A10_MMC0_BASE 0x01c0f000#define AW_A10_PIC_REG_BASE 0x01c20400hw/arm/allwinner-h3.c +5
-4@@ -28,6 +28,7 @@#include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/misc/unimp.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h" @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_EHCI3)); - sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI0], + sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI0], qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_OHCI0)); - sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI1], + sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI1], qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_OHCI1)); - sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI2], + sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI2], qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_OHCI2)); - sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI3], + sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI3], qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_OHCI3));hw/arm/pxa2xx.c +2
-1@@ -18,6 +18,7 @@#include "hw/arm/pxa.h" #include "sysemu/sysemu.h" #include "hw/char/serial.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" @@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); } - sysbus_create_simple("sysbus-ohci", 0x4c000000, + sysbus_create_simple(TYPE_SYSBUS_OHCI, 0x4c000000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));s->pcmcia[0] =
pxa2xx_pcmcia_init(address_space, 0x20000000);hw/arm/realview.c +2
-1@@ -16,6 +16,7 @@#include "hw/net/lan9118.h" #include "hw/net/smc91c111.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -256,7 +257,7 @@ static void realview_init(MachineState *machine, sysbus_connect_irq(busdev, 3, pic[51]); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (machine_usb(machine)) { - pci_create_simple(pci_bus, -1, "pci-ohci"); + pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) {hw/arm/versatilepb.c +2
-1@@ -17,6 +17,7 @@#include "net/net.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/irq.h" @@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int board_id) } } if (machine_usb(machine)) { - pci_create_simple(pci_bus, -1, "pci-ohci"); + pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI); } n = drive_get_max_bus(IF_SCSI);while (n >= 0) {
hw/display/sm501.c +2
-1@@ -33,6 +33,7 @@#include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/qdev-properties.h" #include "hw/i2c/i2c.h" #include "hw/display/i2c-ddc.h" @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->state.mmio_region); /* bridge to usb host emulation module */ - usb_dev = qdev_new("sysbus-ohci"); + usb_dev = qdev_new(TYPE_SYSBUS_OHCI); qdev_prop_set_uint32(usb_dev, "num-ports", 2); qdev_prop_set_uint64(usb_dev, "dma-offset", s->base);
sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);hw/ppc/mac_newworld.c +2
-1@@ -55,6 +55,7 @@#include "hw/input/adb.h" #include "hw/ppc/mac_dbdma.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine) } if (machine->usb) { - pci_create_simple(pci_bus, -1, "pci-ohci"); + pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI); /* U3 needs to use USB for input because Linux doesn't supportvia-cuda
on PPC64 */hw/ppc/mac_oldworld.c +2
-1@@ -37,6 +37,7 @@#include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" +#include "hw/usb/usb-hcd.h" #include "hw/boards.h" #include "hw/nvram/fw_cfg.h" #include "hw/char/escc.h" @@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine) qdev_realize_and_unref(dev, adb_bus, &error_fatal); if (machine_usb(machine)) { - pci_create_simple(pci_bus, -1, "pci-ohci"); + pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)hw/ppc/sam460ex.c +2
-1@@ -36,6 +36,7 @@#include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" @@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine) /* USB */ sysbus_create_simple(TYPE_PPC4xx_EHCI, 0x4bffd0400, uic[2][29]); - dev = qdev_new("sysbus-ohci"); + dev = qdev_new(TYPE_SYSBUS_OHCI); qdev_prop_set_string(dev, "masterbus", "usb-bus.0"); qdev_prop_set_uint32(dev, "num-ports", 6); sbdev = SYS_BUS_DEVICE(dev);hw/ppc/spapr.c +2
-1@@ -71,6 +71,7 @@#include "exec/address-spaces.h" #include "exec/ram_addr.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "trace.h" @@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine) if (machine->usb) { if (smc->use_ohci_by_default) { - pci_create_simple(phb->bus, -1, "pci-ohci"); + pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI); } else { pci_create_simple(phb->bus, -1, "nec-usb-xhci");}
hw/usb/hcd-ohci-pci.c +1
-1@@ -29,8 +29,8 @@#include "trace.h" #include "hcd-ohci.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" -#define TYPE_PCI_OHCI "pci-ohci"#define PCI_OHCI (obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI) typedef struct {
Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
In reply to Philippe Mathieu-DaudéQuoted 9 lines · On Sat, Jul 4, 2020, 16:50 Philippe Mathieu-Daudé <[email protected]> wrote:
Various machine/board/soc models create OHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
---
Quoted 295 lines
hw/usb/hcd-ohci.h | 2 +- include/hw/usb/usb-hcd.h | 16 ++++++++++++++++ hw/arm/allwinner-a10.c | 2 +- hw/arm/allwinner-h3.c | 9 +++++---- hw/arm/pxa2xx.c | 3 ++- hw/arm/realview.c | 3 ++- hw/arm/versatilepb.c | 3 ++- hw/display/sm501.c | 3 ++- hw/ppc/mac_newworld.c | 3 ++- hw/ppc/mac_oldworld.c | 3 ++- hw/ppc/sam460ex.c | 3 ++- hw/ppc/spapr.c | 3 ++- hw/usb/hcd-ohci-pci.c | 2 +- 13 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 include/hw/usb/usb-hcd.hhw/usb/hcd-ohci.h +1
-1@@ -21,6 +21,7 @@#ifndef HCD_OHCI_H #define HCD_OHCI_H +#include "hw/usb/usb-hcd.h" #include "sysemu/dma.h" #include "usb-internal.h" @@ -91,7 +92,6 @@ 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 {
include/hw/usb/usb-hcd.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* QEMU USB HCD types +* +* Copyright (c) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_USB_HCD_TYPES_H +#define HW_USB_HCD_TYPES_H + +/* OHCI */ +#define TYPE_SYSBUS_OHCI "sysbus-ohci" +#define TYPE_PCI_OHCI "pci-ohci" + +#endif hw/arm/allwinner-a10.c +1
-1@@ -25,7 +25,7 @@#include "hw/misc/unimp.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/usb/hcd-ohci.h" +#include "hw/usb/usb-hcd.h" #define AW_A10_MMC0_BASE 0x01c0f000#define AW_A10_PIC_REG_BASE 0x01c20400hw/arm/allwinner-h3.c +5
-4@@ -28,6 +28,7 @@#include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/misc/unimp.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h" @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_EHCI3)); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI0 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI0 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI1 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI1 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI2 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI2 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_OHCI3 ], +sysbus_create_simple (TYPE_SYSBUS_OHCI , s->memmap[AW_H3_OHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI3 ));hw/arm/pxa2xx.c +2
-1@@ -18,6 +18,7 @@#include "hw/arm/pxa.h" #include "sysemu/sysemu.h" #include "hw/char/serial.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" @@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->ssp[i] = (SSIBus *)qdev_get_child_bus (dev,"ssi" ); } -sysbus_create_simple ("sysbus-ohci" ,0x4c000000 , +sysbus_create_simple (TYPE_SYSBUS_OHCI ,0x4c000000 ,qdev_get_gpio_in (s->pic,PXA2XX_PIC_USBH1 )); s->pcmcia[0 ] =pxa2xx_pcmcia_init (address_space,0x20000000 );hw/arm/realview.c +2
-1@@ -16,6 +16,7 @@#include "hw/net/lan9118.h" #include "hw/net/smc91c111.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,sysbus_connect_irq (busdev,3 , pic[51 ]); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) {hw/arm/versatilepb.c +2
-1@@ -17,6 +17,7 @@#include "net/net.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/i2c/i2c.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/irq.h" @@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int board_id) } }if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); } n =drive_get_max_bus (IF_SCSI );while (n >= 0) {hw/display/sm501.c +2
-1@@ -33,6 +33,7 @@#include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "hw/qdev-properties.h" #include "hw/i2c/i2c.h" #include "hw/display/i2c-ddc.h" @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->state.mmio_region);/* bridge to usb host emulation module */ - usb_dev =qdev_new ("sysbus-ohci" ); + usb_dev =qdev_new (TYPE_SYSBUS_OHCI );qdev_prop_set_uint32 (usb_dev,"num-ports" ,2 );qdev_prop_set_uint64 (usb_dev,"dma-offset" , s->base);sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);hw/ppc/mac_newworld.c +2
-1@@ -55,6 +55,7 @@#include "hw/input/adb.h" #include "hw/ppc/mac_dbdma.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI );/* U3 needs to use USB for input because Linux doesn't support via-cuda
on PPC64 */hw/ppc/mac_oldworld.c +2
-1@@ -37,6 +37,7 @@#include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" +#include "hw/usb/usb-hcd.h" #include "hw/boards.h" #include "hw/nvram/fw_cfg.h" #include "hw/char/escc.h" @@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple (pci_bus,-1 ,TYPE_PCI_OHCI ); }if (graphic_depth !=15 && graphic_depth !=32 && graphic_depth !=8 )hw/ppc/sam460ex.c +2
-1@@ -36,6 +36,7 @@#include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" @@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)/* USB */ sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , uic[2 ][29 ]); - dev =qdev_new ("sysbus-ohci" ); + dev =qdev_new (TYPE_SYSBUS_OHCI );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);hw/ppc/spapr.c +2
-1@@ -71,6 +71,7 @@#include "exec/address-spaces.h" #include "exec/ram_addr.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "trace.h" @@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine)if (machine->usb) {if (smc->use_ohci_by_default) { -pci_create_simple (phb->bus,-1 ,"pci-ohci" ); +pci_create_simple (phb->bus,-1 ,TYPE_PCI_OHCI ); }else {pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); }hw/usb/hcd-ohci-pci.c +1
-2@@ -29,8 +29,8 @@#include "trace.h" #include "hcd-ohci.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" -#define TYPE_PCI_OHCI "pci-ohci"#define PCI_OHCI (obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI) typedef struct { --2.21.3
PATCH 23/26 hw/usb/usb-hcd: Use EHCI type definitions
In reply to Philippe Mathieu-DaudéVarious machine/board/soc models create EHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
--- hw/usb/hcd-ehci.h | 11 +---------- include/hw/usb/chipidea.h | 2 +- include/hw/usb/usb-hcd.h | 11 +++++++++++ hw/arm/allwinner-h3.c | 1 - hw/arm/exynos4210.c | 2 +- hw/arm/sbsa-ref.c | 3 ++- hw/arm/xilinx_zynq.c | 2 +- hw/ppc/sam460ex.c | 1 - hw/usb/chipidea.c | 1 + hw/usb/hcd-ehci-sysbus.c | 1 + 10 files changed, 19 insertions(+), 16 deletions(-)
hw/usb/hcd-ehci.h +1 -10
@@ -23,6 +23,7 @@#include "hw/pci/pci.h" #include "hw/sysbus.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define CAPA_SIZE 0x10
@@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp);void usb_ehci_unrealize (EHCIState *s,DeviceState *dev);void ehci_reset (void *opaque); -#define TYPE_PCI_EHCI "pci-ehci-usb"#define PCI_EHCI (obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI) typedef struct EHCIPCIState {
@@ -327,15 +327,6 @@ typedef struct EHCIPCIState {EHCIState ehci; } EHCIPCIState; - -#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" -#define TYPE_PLATFORM_EHCI "platform-ehci-usb" -#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" -#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" -#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" -#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" -#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" -#define SYS_BUS_EHCI (obj) \ OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)#define SYS_BUS_EHCI_CLASS (class) \
include/hw/usb/chipidea.h +1 -1
@@ -2,6 +2,7 @@#define CHIPIDEA_H #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" typedef struct ChipideaState { /*< private >*/
@@ -10,7 +11,6 @@ typedef struct ChipideaState { MemoryRegion iomem[3]; } ChipideaState; -#define TYPE_CHIPIDEA "usb-chipidea"#define CHIPIDEA (obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA)#endif /* CHIPIDEA_H */
include/hw/usb/usb-hcd.h +11 -0
@@ -13,4 +13,15 @@#define TYPE_SYSBUS_OHCI "sysbus-ohci"#define TYPE_PCI_OHCI "pci-ohci" +/* EHCI */ +#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" +#define TYPE_PCI_EHCI "pci-ehci-usb" +#define TYPE_PLATFORM_EHCI "platform-ehci-usb" +#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" +#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" +#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" +#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" +#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" +#define TYPE_CHIPIDEA "usb-chipidea" +#endif
hw/arm/allwinner-h3.c +0 -1
@@ -29,7 +29,6 @@#include "hw/char/serial.h" #include "hw/misc/unimp.h" #include "hw/usb/usb-hcd.h" -#include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h" #include "hw/arm/allwinner-h3.h"
hw/arm/exynos4210.c +1 -1
@@ -35,7 +35,7 @@#include "hw/qdev-properties.h" #include "hw/arm/exynos4210.h" #include "hw/sd/sdhci.h" -#include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #define EXYNOS4210_CHIPID_ADDR 0x10000000
hw/arm/sbsa-ref.c +2 -1
@@ -38,6 +38,7 @@#include "hw/loader.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" +#include "hw/usb/usb-hcd.h" #include "hw/char/pl011.h" #include "net/net.h"
@@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms)hwaddr base = sbsa_ref_memmap[SBSA_EHCI ].base;int irq = sbsa_ref_irqmap[SBSA_EHCI ]; -sysbus_create_simple ("platform-ehci-usb" , base, +sysbus_create_simple (TYPE_PLATFORM_EHCI , base,qdev_get_gpio_in (sms->gic, irq)); }
hw/arm/xilinx_zynq.c +1 -1
@@ -29,7 +29,7 @@#include "hw/loader.h" #include "hw/misc/zynq-xadc.h" #include "hw/ssi/ssi.h" -#include "hw/usb/chipidea.h" +#include "hw/usb/usb-hcd.h" #include "qemu/error-report.h" #include "hw/sd/sdhci.h" #include "hw/char/cadence_uart.h"
hw/ppc/sam460ex.c +0 -1
@@ -37,7 +37,6 @@#include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" #include "hw/usb/usb-hcd.h" -#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" #include "hw/pci/pci.h"
hw/usb/chipidea.c +1 -0
@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/chipidea.h" #include "qemu/log.h" #include "qemu/module.h"
hw/usb/hcd-ehci-sysbus.c +1 -0
@@ -18,6 +18,7 @@#include "qemu/osdep.h" #include "hw/qdev-properties.h" #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #include "migration/vmstate.h" #include "qemu/module.h"
Signature · 1 line
2.21.3
Re: [PATCH 23/26] hw/usb/usb-hcd: Use EHCI type definitions
Quoted 185 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create EHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/usb/hcd-ehci.h | 11 +---------- include/hw/usb/chipidea.h | 2 +- include/hw/usb/usb-hcd.h | 11 +++++++++++ hw/arm/allwinner-h3.c | 1 - hw/arm/exynos4210.c | 2 +- hw/arm/sbsa-ref.c | 3 ++- hw/arm/xilinx_zynq.c | 2 +- hw/ppc/sam460ex.c | 1 - hw/usb/chipidea.c | 1 + hw/usb/hcd-ehci-sysbus.c | 1 + 10 files changed, 19 insertions(+), 16 deletions(-)hw/usb/hcd-ehci.h +1
-10@@ -23,6 +23,7 @@#include "hw/pci/pci.h" #include "hw/sysbus.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define CAPA_SIZE 0x10@@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp);void usb_ehci_unrealize (EHCIState *s,DeviceState *dev);void ehci_reset (void *opaque); -#define TYPE_PCI_EHCI "pci-ehci-usb"#define PCI_EHCI (obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI) typedef struct EHCIPCIState {@@ -327,15 +327,6 @@ typedef struct EHCIPCIState {EHCIState ehci; } EHCIPCIState; - -#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" -#define TYPE_PLATFORM_EHCI "platform-ehci-usb" -#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" -#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" -#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" -#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" -#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" -#define SYS_BUS_EHCI (obj) \ OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)#define SYS_BUS_EHCI_CLASS (class) \include/hw/usb/chipidea.h +1
-1@@ -2,6 +2,7 @@#define CHIPIDEA_H #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" typedef struct ChipideaState { /*< private >*/@@ -10,7 +11,6 @@ typedef struct ChipideaState { MemoryRegion iomem[3]; } ChipideaState; -#define TYPE_CHIPIDEA "usb-chipidea"#define CHIPIDEA (obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA)#endif /* CHIPIDEA_H */ include/hw/usb/usb-hcd.h +11
-0@@ -13,4 +13,15 @@#define TYPE_SYSBUS_OHCI "sysbus-ohci"#define TYPE_PCI_OHCI "pci-ohci" +/* EHCI */ +#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" +#define TYPE_PCI_EHCI "pci-ehci-usb" +#define TYPE_PLATFORM_EHCI "platform-ehci-usb" +#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" +#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" +#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" +#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" +#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" +#define TYPE_CHIPIDEA "usb-chipidea" +#endif hw/arm/allwinner-h3.c +0
-1@@ -29,7 +29,6 @@#include "hw/char/serial.h" #include "hw/misc/unimp.h" #include "hw/usb/usb-hcd.h" -#include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h" #include "hw/arm/allwinner-h3.h" hw/arm/exynos4210.c +1
-1@@ -35,7 +35,7 @@#include "hw/qdev-properties.h" #include "hw/arm/exynos4210.h" #include "hw/sd/sdhci.h" -#include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #define EXYNOS4210_CHIPID_ADDR 0x10000000hw/arm/sbsa-ref.c +2
-1@@ -38,6 +38,7 @@#include "hw/loader.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" +#include "hw/usb/usb-hcd.h" #include "hw/char/pl011.h" #include "net/net.h" @@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms)hwaddr base = sbsa_ref_memmap[SBSA_EHCI ].base;int irq = sbsa_ref_irqmap[SBSA_EHCI ]; -sysbus_create_simple ("platform-ehci-usb" , base, +sysbus_create_simple (TYPE_PLATFORM_EHCI , base,qdev_get_gpio_in (sms->gic, irq)); }hw/arm/xilinx_zynq.c +1
-1@@ -29,7 +29,7 @@#include "hw/loader.h" #include "hw/misc/zynq-xadc.h" #include "hw/ssi/ssi.h" -#include "hw/usb/chipidea.h" +#include "hw/usb/usb-hcd.h" #include "qemu/error-report.h" #include "hw/sd/sdhci.h" #include "hw/char/cadence_uart.h" hw/ppc/sam460ex.c +0
-1@@ -37,7 +37,6 @@#include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" #include "hw/usb/usb-hcd.h" -#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" #include "hw/pci/pci.h" hw/usb/chipidea.c +1
-0@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/chipidea.h" #include "qemu/log.h" #include "qemu/module.h" hw/usb/hcd-ehci-sysbus.c +0
-0
hw/usb/hcd-ehci-sysbus.c line 23
Quoted 6 lines
hw/usb/hcd-ehci-sysbus.c +1
-0@@ -18,6 +18,7 @@#include "qemu/osdep.h" #include "hw/qdev-properties.h" #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #include "migration/vmstate.h" #include "qemu/module.h"
Do these last two still need hw/usb/hcd-ehci.h? If so do they get hw/usb/usb-hcd.h via that one so do they need to explicitely include it again?
Regards,
BALATON Zoltan
Re: [PATCH 23/26] hw/usb/usb-hcd: Use EHCI type definitions
Quoted 189 lines · BALATON Zoltan
Quoted 188 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create EHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/usb/hcd-ehci.h | 11 +----------include/hw/usb/chipidea.h| 2 +-
include/hw/usb/usb-hcd.h | 11 +++++++++++
hw/arm/allwinner-h3.c | 1 -
hw/arm/exynos4210.c | 2 +-
hw/arm/sbsa-ref.c | 3 ++-
hw/arm/xilinx_zynq.c | 2 +-
hw/ppc/sam460ex.c | 1 -
hw/usb/chipidea.c | 1 +
hw/usb/hcd-ehci-sysbus.c | 1 +10 files changed, 19 insertions(+), 16 deletions(-)hw/usb/hcd-ehci.h +1
-1@@ -23,6 +23,7 @@#include "hw/pci/pci.h" #include "hw/sysbus.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define CAPA_SIZE 0x10@@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp);void usb_ehci_unrealize (EHCIState *s,DeviceState *dev);void ehci_reset (void *opaque); -#define TYPE_PCI_EHCI "pci-ehci-usb"#define PCI_EHCI (obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)typedef struct EHCIPCIState {
hw/usb/hcd-ehci.h +0
-9@@ -327,15 +327,6 @@ typedef struct EHCIPCIState { EHCIState ehci; } EHCIPCIState; - -#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" -#define TYPE_PLATFORM_EHCI "platform-ehci-usb" -#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" -#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" -#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" -#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" -#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" -#define SYS_BUS_EHCI (obj) \ OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)#define SYS_BUS_EHCI_CLASS (class) \include/hw/usb/chipidea.h +1
-1@@ -2,6 +2,7 @@#define CHIPIDEA_H #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" typedef struct ChipideaState { /*< private >*/@@ -10,7 +11,6 @@ typedef struct ChipideaState { MemoryRegion iomem[3]; } ChipideaState; -#define TYPE_CHIPIDEA "usb-chipidea"#define CHIPIDEA (obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA)#endif /* CHIPIDEA_H */ include/hw/usb/usb-hcd.h +11
-0@@ -13,4 +13,15 @@#define TYPE_SYSBUS_OHCI "sysbus-ohci"#define TYPE_PCI_OHCI "pci-ohci" +/* EHCI */ +#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" +#define TYPE_PCI_EHCI "pci-ehci-usb" +#define TYPE_PLATFORM_EHCI "platform-ehci-usb" +#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" +#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" +#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" +#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" +#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" +#define TYPE_CHIPIDEA "usb-chipidea" +#endif hw/arm/allwinner-h3.c +0
-1@@ -29,7 +29,6 @@#include "hw/char/serial.h" #include "hw/misc/unimp.h" #include "hw/usb/usb-hcd.h" -#include "hw/usb/hcd-ehci.h" #include "hw/loader.h" #include "sysemu/sysemu.h" #include "hw/arm/allwinner-h3.h" hw/arm/exynos4210.c +1
-1@@ -35,7 +35,7 @@#include "hw/qdev-properties.h" #include "hw/arm/exynos4210.h" #include "hw/sd/sdhci.h" -#include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #define EXYNOS4210_CHIPID_ADDR 0x10000000hw/arm/sbsa-ref.c +2
-1@@ -38,6 +38,7 @@#include "hw/loader.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" +#include "hw/usb/usb-hcd.h" #include "hw/char/pl011.h" #include "net/net.h" @@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms) hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; int irq = sbsa_ref_irqmap[SBSA_EHCI]; - sysbus_create_simple("platform-ehci-usb", base, + sysbus_create_simple(TYPE_PLATFORM_EHCI, base, qdev_get_gpio_in(sms->gic, irq)); }hw/arm/xilinx_zynq.c +1
-1@@ -29,7 +29,7 @@#include "hw/loader.h" #include "hw/misc/zynq-xadc.h" #include "hw/ssi/ssi.h" -#include "hw/usb/chipidea.h" +#include "hw/usb/usb-hcd.h" #include "qemu/error-report.h" #include "hw/sd/sdhci.h" #include "hw/char/cadence_uart.h" hw/ppc/sam460ex.c +0
-1@@ -37,7 +37,6 @@#include "hw/i2c/smbus_eeprom.h" #include "hw/usb/usb.h" #include "hw/usb/usb-hcd.h" -#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" #include "hw/pci/pci.h" hw/usb/chipidea.c +1
-0@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #include "hw/usb/chipidea.h" #include "qemu/log.h" #include "qemu/module.h" hw/usb/hcd-ehci-sysbus.c +0
-0@@ -18,6 +18,7 @@#include "qemu/osdep.h" #include "hw/qdev-properties.h"
Quoted 8 lines
hw/usb/hcd-ehci-sysbus.c line 23
Quoted 4 lines
hw/usb/hcd-ehci-sysbus.c +1
-0#include "hw/usb/hcd-ehci.h" +#include "hw/usb/usb-hcd.h" #include "migration/vmstate.h" #include "qemu/module.h" Do these last two still need
hw/usb/hcd-ehci.h? If so do they gethw/usb/usb-hcd.hvia that one so do they need to explicitely include it again?
chipidea.c implements an HCI, so it uses the hcd-ehci.h internals, else we get:
usb/chipidea.c:96:5: error: unknown type name ‘EHCIState’
96 | EHCIState *ehci = &SYS_BUS_EHCI(obj)->ehci;
| ^~~~~~~~~
hw/usb/chipidea.c:152:5: error: unknown type name ‘SysBusEHCIClass’
152 | SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass);
| ^~~~~~~~~~~~~~~
hw/usb/chipidea.c:152:28: error: implicit declaration of function
‘SYS_BUS_EHCI_CLASS’ [-Werror=implicit-function-declaration]
152 | SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass);
| ^~~~~~~~~~~~~~~~~~Similarly with hcd-ehci-sysbus.c:
hw/usb/hcd-ehci-sysbus.c:30:50: error: ‘vmstate_ehci’ undeclared here (not in a function)
30 | VMSTATE_STRUCT(ehci, EHCISysBusState, 2, vmstate_ehci,
EHCIState),
| ^~~~~~~~~~~~hw/usb/hcd-ehci-sysbus.c:45:26: error: implicit declaration of function ‘SYS_BUS_EHCI’; did you mean ‘TYPE_SYS_BUS_EHCI’? [-Werror=implicit-function-declaration]
45 | EHCISysBusState *i = SYS_BUS_EHCI(dev);
| ^~~~~~~~~~~~
| TYPE_SYS_BUS_EHCI
hw/usb/hcd-ehci-sysbus.c:48:5: error: implicit declaration of function
‘usb_ehci_realize’; did you mean ‘usb_ehci_sysbus_realize’?
[-Werror=implicit-function-declaration]
48 | usb_ehci_realize(s, dev, errp);
| ^~~~~~~~~~~~~~~~
| usb_ehci_sysbus_realize
hw/usb/hcd-ehci-sysbus.c:74:5: error: implicit declaration of function
‘usb_ehci_init’ [-Werror=implicit-function-declaration]
74 | usb_ehci_init(s, DEVICE(obj));
| ^~~~~~~~~~~~~The idea of "hw/usb/usb-hcd.h" is to keep USB internals opaque to machine/board/soc using controllers, they just want to use the devices.
I'll see how to reword the description to make that clearer.
Quoted 3 lines
Regards,
BALATON Zoltan
PATCH 24/26 hw/usb/usb-hcd: Use UHCI type definitions
In reply to Philippe Mathieu-DaudéVarious machine/board/soc models create UHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
--- include/hw/usb/usb-hcd.h | 6 ++++++ hw/i386/pc_piix.c | 3 ++- hw/i386/pc_q35.c | 13 +++++++------ hw/isa/piix4.c | 3 ++- hw/mips/fuloong2e.c | 5 +++-- hw/usb/hcd-uhci.c | 19 ++++++++++--------- 6 files changed, 30 insertions(+), 19 deletions(-)
include/hw/usb/usb-hcd.h +6 -0
@@ -24,4 +24,10 @@#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"#define TYPE_CHIPIDEA "usb-chipidea" +/* UHCI */ +#define TYPE_PIIX3_USB_UHCI "piix3-usb-uhci" +#define TYPE_PIIX4_USB_UHCI "piix4-usb-uhci" +#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci" +#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #n +#endif
hw/i386/pc_piix.c +2 -1
@@ -37,6 +37,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "hw/ide/pci.h" #include "hw/irq.h"
@@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,#endif if (pcmc->pci_enabled &&machine_usb (machine)) { -pci_create_simple (pci_bus, piix3_devfn +2 ,"piix3-usb-uhci" ); +pci_create_simple (pci_bus, piix3_devfn +2 ,TYPE_PIIX3_USB_UHCI ); }if (pcmc->pci_enabled &&x86_machine_is_acpi_enabled (X86_MACHINE (pcms))) {
hw/i386/pc_q35.c +7 -6
@@ -51,6 +51,7 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h"
@@ -68,15 +69,15 @@ struct ehci_companions { };static const struct ehci_companions ich9_1d[] = { - { .name ="ich9-usb-uhci1" , .func =0 , .port =0 }, - { .name ="ich9-usb-uhci2" , .func =1 , .port =2 }, - { .name ="ich9-usb-uhci3" , .func =2 , .port =4 }, + { .name =TYPE_ICH9_USB_UHCI (1 ), .func =0 , .port =0 }, + { .name =TYPE_ICH9_USB_UHCI (2 ), .func =1 , .port =2 }, + { .name =TYPE_ICH9_USB_UHCI (3 ), .func =2 , .port =4 }, };static const struct ehci_companions ich9_1a[] = { - { .name ="ich9-usb-uhci4" , .func =0 , .port =0 }, - { .name ="ich9-usb-uhci5" , .func =1 , .port =2 }, - { .name ="ich9-usb-uhci6" , .func =2 , .port =4 }, + { .name =TYPE_ICH9_USB_UHCI (4 ), .func =0 , .port =0 }, + { .name =TYPE_ICH9_USB_UHCI (5 ), .func =1 , .port =2 }, + { .name =TYPE_ICH9_USB_UHCI (6 ), .func =2 , .port =4 }, };static int ehci_create_ich9_with_companions (PCIBus *bus,int slot)
hw/isa/piix4.c +2 -1
@@ -29,6 +29,7 @@#include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" +#include "hw/usb/usb-hcd.h" #include "hw/sysbus.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h"
@@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci =pci_create_simple (pci_bus, devfn +1 ,"piix4-ide" );pci_ide_create_devs (pci); -pci_create_simple (pci_bus, devfn +2 ,"piix4-usb-uhci" ); +pci_create_simple (pci_bus, devfn +2 ,TYPE_PIIX4_USB_UHCI );if (smbus) { *smbus =piix4_pm_init (pci_bus, devfn +3 ,0x1100 ,isa_get_irq (NULL ,9 ),NULL ,0 ,NULL );
hw/mips/fuloong2e.c +3 -2
@@ -33,6 +33,7 @@#include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide/pci.h"
@@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc, dev =pci_create_simple (pci_bus,PCI_DEVFN (slot,1 ),"via-ide" );pci_ide_create_devs (dev); -pci_create_simple (pci_bus,PCI_DEVFN (slot,2 ),"vt82c686b-usb-uhci" ); -pci_create_simple (pci_bus,PCI_DEVFN (slot,3 ),"vt82c686b-usb-uhci" ); +pci_create_simple (pci_bus,PCI_DEVFN (slot,2 ),TYPE_VT82C686B_USB_UHCI ); +pci_create_simple (pci_bus,PCI_DEVFN (slot,3 ),TYPE_VT82C686B_USB_UHCI ); *i2c_bus =vt82c686b_pm_init (pci_bus,PCI_DEVFN (slot,4 ),0xeee1 ,NULL );
hw/usb/hcd-uhci.c +10 -9
@@ -39,6 +39,7 @@#include "qemu/main-loop.h" #include "qemu/module.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define FRAME_TIMER_FREQ 1000
@@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)static UHCIInfo uhci_info[] = { { - .name ="piix3-usb-uhci" , + .name =TYPE_PIIX3_USB_UHCI , .vendor_id =PCI_VENDOR_ID_INTEL , .device_id =PCI_DEVICE_ID_INTEL_82371SB_2 , .revision =0x01 , .irq_pin =3 , .unplug = true, },{ - .name ="piix4-usb-uhci" , + .name =TYPE_PIIX4_USB_UHCI , .vendor_id =PCI_VENDOR_ID_INTEL , .device_id =PCI_DEVICE_ID_INTEL_82371AB_2 , .revision =0x01 , .irq_pin =3 , .unplug = true, },{ - .name ="vt82c686b-usb-uhci" , + .name =TYPE_VT82C686B_USB_UHCI , .vendor_id =PCI_VENDOR_ID_VIA , .device_id =PCI_DEVICE_ID_VIA_UHCI , .revision =0x01 ,
@@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = { .realize = usb_uhci_vt82c686b_realize, .unplug = true, },{ - .name = "ich9-usb-uhci1", /* 00:1d.0 */ + .name = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci2", /* 00:1d.1 */ + .name = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci3", /* 00:1d.2 */ + .name = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3, .revision = 0x03, .irq_pin = 2, .unplug = false, },{ - .name = "ich9-usb-uhci4", /* 00:1a.0 */ + .name = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci5", /* 00:1a.1 */ + .name = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci6", /* 00:1a.2 */ + .name = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6, .revision = 0x03,
Signature · 1 line
2.21.3
Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
Quoted 22 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create UHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/usb/usb-hcd.h | 6 ++++++ hw/i386/pc_piix.c | 3 ++- hw/i386/pc_q35.c | 13 +++++++------ hw/isa/piix4.c | 3 ++- hw/mips/fuloong2e.c | 5 +++-- hw/usb/hcd-uhci.c | 19 ++++++++++--------- 6 files changed, 30 insertions(+), 19 deletions(-)include/hw/usb/usb-hcd.h +0
-0
include/hw/usb/usb-hcd.h line 31
Quoted 8 lines
include/hw/usb/usb-hcd.h +5
-0@@ -24,4 +24,10 @@#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"#define TYPE_CHIPIDEA "usb-chipidea" +/* UHCI */ +#define TYPE_PIIX3_USB_UHCI "piix3-usb-uhci" +#define TYPE_PIIX4_USB_UHCI "piix4-usb-uhci" +#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci" +#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #n
What is that #n at the end? Looks like a typo. Does it break compilation?
Regards,
BALATON Zoltan
Quoted 188 lines
include/hw/usb/usb-hcd.h +1
-0+#endif hw/i386/pc_piix.c +2
-1@@ -37,6 +37,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "hw/ide/pci.h" #include "hw/irq.h" @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,#endif if (pcmc->pci_enabled &&machine_usb (machine)) { -pci_create_simple (pci_bus, piix3_devfn +2 ,"piix3-usb-uhci" ); +pci_create_simple (pci_bus, piix3_devfn +2 ,TYPE_PIIX3_USB_UHCI ); }if (pcmc->pci_enabled &&x86_machine_is_acpi_enabled (X86_MACHINE (pcms))) {hw/i386/pc_q35.c +7
-6@@ -51,6 +51,7 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" @@ -68,15 +69,15 @@ struct ehci_companions { };static const struct ehci_companions ich9_1d[] = { - { .name ="ich9-usb-uhci1" , .func =0 , .port =0 }, - { .name ="ich9-usb-uhci2" , .func =1 , .port =2 }, - { .name ="ich9-usb-uhci3" , .func =2 , .port =4 }, + { .name =TYPE_ICH9_USB_UHCI (1 ), .func =0 , .port =0 }, + { .name =TYPE_ICH9_USB_UHCI (2 ), .func =1 , .port =2 }, + { .name =TYPE_ICH9_USB_UHCI (3 ), .func =2 , .port =4 }, };static const struct ehci_companions ich9_1a[] = { - { .name ="ich9-usb-uhci4" , .func =0 , .port =0 }, - { .name ="ich9-usb-uhci5" , .func =1 , .port =2 }, - { .name ="ich9-usb-uhci6" , .func =2 , .port =4 }, + { .name =TYPE_ICH9_USB_UHCI (4 ), .func =0 , .port =0 }, + { .name =TYPE_ICH9_USB_UHCI (5 ), .func =1 , .port =2 }, + { .name =TYPE_ICH9_USB_UHCI (6 ), .func =2 , .port =4 }, };static int ehci_create_ich9_with_companions (PCIBus *bus,int slot)hw/isa/piix4.c +2
-1@@ -29,6 +29,7 @@#include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" +#include "hw/usb/usb-hcd.h" #include "hw/sysbus.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h" @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci =pci_create_simple (pci_bus, devfn +1 ,"piix4-ide" );pci_ide_create_devs (pci); -pci_create_simple (pci_bus, devfn +2 ,"piix4-usb-uhci" ); +pci_create_simple (pci_bus, devfn +2 ,TYPE_PIIX4_USB_UHCI );if (smbus) { *smbus =piix4_pm_init (pci_bus, devfn +3 ,0x1100 ,isa_get_irq (NULL ,9 ),NULL ,0 ,NULL );hw/mips/fuloong2e.c +3
-2@@ -33,6 +33,7 @@#include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide/pci.h" @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc, dev =pci_create_simple (pci_bus,PCI_DEVFN (slot,1 ),"via-ide" );pci_ide_create_devs (dev); -pci_create_simple (pci_bus,PCI_DEVFN (slot,2 ),"vt82c686b-usb-uhci" ); -pci_create_simple (pci_bus,PCI_DEVFN (slot,3 ),"vt82c686b-usb-uhci" ); +pci_create_simple (pci_bus,PCI_DEVFN (slot,2 ),TYPE_VT82C686B_USB_UHCI ); +pci_create_simple (pci_bus,PCI_DEVFN (slot,3 ),TYPE_VT82C686B_USB_UHCI ); *i2c_bus =vt82c686b_pm_init (pci_bus,PCI_DEVFN (slot,4 ),0xeee1 ,NULL );hw/usb/hcd-uhci.c +10
-9@@ -39,6 +39,7 @@#include "qemu/main-loop.h" #include "qemu/module.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define FRAME_TIMER_FREQ 1000@@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)static UHCIInfo uhci_info[] = { { - .name ="piix3-usb-uhci" , + .name =TYPE_PIIX3_USB_UHCI , .vendor_id =PCI_VENDOR_ID_INTEL , .device_id =PCI_DEVICE_ID_INTEL_82371SB_2 , .revision =0x01 , .irq_pin =3 , .unplug = true, },{ - .name ="piix4-usb-uhci" , + .name =TYPE_PIIX4_USB_UHCI , .vendor_id =PCI_VENDOR_ID_INTEL , .device_id =PCI_DEVICE_ID_INTEL_82371AB_2 , .revision =0x01 , .irq_pin =3 , .unplug = true, },{ - .name ="vt82c686b-usb-uhci" , + .name =TYPE_VT82C686B_USB_UHCI , .vendor_id =PCI_VENDOR_ID_VIA , .device_id =PCI_DEVICE_ID_VIA_UHCI , .revision =0x01 ,@@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = { .realize = usb_uhci_vt82c686b_realize, .unplug = true, },{ - .name = "ich9-usb-uhci1", /* 00:1d.0 */ + .name = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci2", /* 00:1d.1 */ + .name = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci3", /* 00:1d.2 */ + .name = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3, .revision = 0x03, .irq_pin = 2, .unplug = false, },{ - .name = "ich9-usb-uhci4", /* 00:1a.0 */ + .name = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci5", /* 00:1a.1 */ + .name = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci6", /* 00:1a.2 */ + .name = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6, .revision = 0x03,
Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
Quoted 26 lines · BALATON Zoltan
Quoted 25 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create UHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/usb/usb-hcd.h| 6 ++++++
hw/i386/pc_piix.c | 3 ++-
hw/i386/pc_q35.c | 13 +++++++------
hw/isa/piix4.c | 3 ++-
hw/mips/fuloong2e.c | 5 +++--
hw/usb/hcd-uhci.c | 19 ++++++++++---------6 files changed, 30 insertions(+), 19 deletions(-)include/hw/usb/usb-hcd.h +0
-0@@ -24,4 +24,10 @@#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"#define TYPE_CHIPIDEA "usb-chipidea"
Quoted 7 lines
include/hw/usb/usb-hcd.h line 31
Quoted 5 lines
include/hw/usb/usb-hcd.h +5
-0+/* UHCI */ +#define TYPE_PIIX3_USB_UHCI "piix3-usb-uhci" +#define TYPE_PIIX4_USB_UHCI "piix4-usb-uhci" +#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci" +#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #nWhat is that #n at the end? Looks like a typo. Does it break compilation?
#n is a C preprocessor feature that expand the 'n' argument to a "n" string, so:
TYPE_ICH9_USB_UHCI(1) = "ich9-usb-uhci" #1
= "ich9-usb-uhci" "1"
= "ich9-usb-uhci1"I'm pretty sure we use that elsewhere. If not, I can add a definition for each 1 ... 6 typenames.
Quoted 202 lines
Regards,
BALATON ZoltanQuoted 198 lines
include/hw/usb/usb-hcd.h +1
-0+#endif hw/i386/pc_piix.c +2
-1@@ -37,6 +37,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "hw/ide/pci.h" #include "hw/irq.h" @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,#endif if (pcmc->pci_enabled && machine_usb(machine)) { - pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); + pci_create_simple(pci_bus, piix3_devfn + 2,TYPE_PIIX3_USB_UHCI ); }if (
pcmc->pci_enabled&&
x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {hw/i386/pc_q35.c +7
-6@@ -51,6 +51,7 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" @@ -68,15 +69,15 @@ struct ehci_companions { };static const struct ehci_companions ich9_1d[] = { - { .name = "ich9-usb-uhci1", .func = 0, .port = 0 }, - { .name = "ich9-usb-uhci2", .func = 1, .port = 2 }, - { .name = "ich9-usb-uhci3", .func = 2, .port = 4 }, + { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 }, + { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 }, + { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 }, };static const struct ehci_companions ich9_1a[] = { - { .name = "ich9-usb-uhci4", .func = 0, .port = 0 }, - { .name = "ich9-usb-uhci5", .func = 1, .port = 2 }, - { .name = "ich9-usb-uhci6", .func = 2, .port = 4 }, + { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 }, + { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 }, + { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 }, };static int ehci_create_ich9_with_companions (PCIBus *bus,int slot)hw/isa/piix4.c +2
-1@@ -29,6 +29,7 @@#include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" +#include "hw/usb/usb-hcd.h" #include "hw/sysbus.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h" @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide"); pci_ide_create_devs(pci); - pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci"); + pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI); if (smbus) { *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);hw/mips/fuloong2e.c +2
-2@@ -33,6 +33,7 @@#include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide/pci.h" @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc, dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide"); pci_ide_create_devs(dev); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); + pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
TYPE_VT82C686B_USB_UHCI);
+pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), TYPE_VT82C686B_USB_UHCI);
*i2c_bus=vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);hw/usb/hcd-uhci.c +4
-3@@ -39,6 +39,7 @@#include "qemu/main-loop.h" #include "qemu/module.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define FRAME_TIMER_FREQ 1000@@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)static UHCIInfo uhci_info[] = { { - .name = "piix3-usb-uhci", + .name = TYPE_PIIX3_USB_UHCI, .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82371SB_2, .revision = 0x01, .irq_pin = 3, .unplug = true, },{ - .name = "piix4-usb-uhci", + .name = TYPE_PIIX4_USB_UHCI, .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82371AB_2, .revision = 0x01, .irq_pin = 3, .unplug = true, },{ - .name = "vt82c686b-usb-uhci", + .name = TYPE_VT82C686B_USB_UHCI, .vendor_id = PCI_VENDOR_ID_VIA, .device_id = PCI_DEVICE_ID_VIA_UHCI,.revision =
0x01,hw/usb/hcd-uhci.c +6
-6@@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = { .realize = usb_uhci_vt82c686b_realize, .unplug = true, },{ - .name = "ich9-usb-uhci1", /* 00:1d.0 */ + .name = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci2", /* 00:1d.1 */ + .name = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci3", /* 00:1d.2 */ + .name = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3, .revision = 0x03, .irq_pin = 2, .unplug = false, },{ - .name = "ich9-usb-uhci4", /* 00:1a.0 */ + .name = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci5", /* 00:1a.1 */ + .name = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci6", /* 00:1a.2 */ + .name = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6, .revision = 0x03,
Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
Quoted 38 lines · Philippe Mathieu-Daudé
Quoted 26 lines · BALATON Zoltan
Quoted 25 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create UHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/usb/usb-hcd.h| 6 ++++++
hw/i386/pc_piix.c | 3 ++-
hw/i386/pc_q35.c | 13 +++++++------
hw/isa/piix4.c | 3 ++-
hw/mips/fuloong2e.c | 5 +++--
hw/usb/hcd-uhci.c | 19 ++++++++++---------6 files changed, 30 insertions(+), 19 deletions(-)include/hw/usb/usb-hcd.h +0
-0@@ -24,4 +24,10 @@#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"#define TYPE_CHIPIDEA "usb-chipidea"Quoted 7 lines
include/hw/usb/usb-hcd.h line 31
Quoted 5 lines
include/hw/usb/usb-hcd.h +5
-0+/* UHCI */ +#define TYPE_PIIX3_USB_UHCI "piix3-usb-uhci" +#define TYPE_PIIX4_USB_UHCI "piix4-usb-uhci" +#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci" +#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #nWhat is that #n at the end? Looks like a typo. Does it break compilation?
#n is a C preprocessor feature that expand the 'n' argument to a "n" string, so:
Quoted 6 lines
TYPE_ICH9_USB_UHCI(1)= "ich9-usb-uhci" #1= "ich9-usb-uhci" "1" = "ich9-usb-uhci1"I'm pretty sure we use that elsewhere. If not, I can add a definition for each 1 ... 6 typenames.
No it's OK, no need to list all defines. I just did not notice the macro argument that's why I was wondering where it comes from. This seems to be used elsewhere at least here:
hw/audio/es1370.c:#define a(n) if (val & CTRL_##n) strcat (buf, " "#n) hw/audio/es1370.c:#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n) hw/audio/es1370.c:#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n)
Maybe writing it without the space between "# is clearer as then it looks more like it's part of the value.
Regards,
BALATON Zoltan
Quoted 200 lines
Quoted 198 lines
Quoted 198 lines
include/hw/usb/usb-hcd.h +1
-0+#endif hw/i386/pc_piix.c +2
-1@@ -37,6 +37,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "hw/ide/pci.h" #include "hw/irq.h" @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,#endif if (pcmc->pci_enabled && machine_usb(machine)) { - pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); + pci_create_simple(pci_bus, piix3_devfn + 2,TYPE_PIIX3_USB_UHCI ); }if (
pcmc->pci_enabled&&
x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {hw/i386/pc_q35.c +7
-6@@ -51,6 +51,7 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" @@ -68,15 +69,15 @@ struct ehci_companions { };static const struct ehci_companions ich9_1d[] = { - { .name = "ich9-usb-uhci1", .func = 0, .port = 0 }, - { .name = "ich9-usb-uhci2", .func = 1, .port = 2 }, - { .name = "ich9-usb-uhci3", .func = 2, .port = 4 }, + { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 }, + { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 }, + { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 }, };static const struct ehci_companions ich9_1a[] = { - { .name = "ich9-usb-uhci4", .func = 0, .port = 0 }, - { .name = "ich9-usb-uhci5", .func = 1, .port = 2 }, - { .name = "ich9-usb-uhci6", .func = 2, .port = 4 }, + { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 }, + { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 }, + { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 }, };static int ehci_create_ich9_with_companions (PCIBus *bus,int slot)hw/isa/piix4.c +2
-1@@ -29,6 +29,7 @@#include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" +#include "hw/usb/usb-hcd.h" #include "hw/sysbus.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h" @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide"); pci_ide_create_devs(pci); - pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci"); + pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI); if (smbus) { *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);hw/mips/fuloong2e.c +2
-2@@ -33,6 +33,7 @@#include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide/pci.h" @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc, dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide"); pci_ide_create_devs(dev); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); + pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
TYPE_VT82C686B_USB_UHCI);
+pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), TYPE_VT82C686B_USB_UHCI);
*i2c_bus=vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);hw/usb/hcd-uhci.c +4
-3@@ -39,6 +39,7 @@#include "qemu/main-loop.h" #include "qemu/module.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define FRAME_TIMER_FREQ 1000@@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)static UHCIInfo uhci_info[] = { { - .name = "piix3-usb-uhci", + .name = TYPE_PIIX3_USB_UHCI, .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82371SB_2, .revision = 0x01, .irq_pin = 3, .unplug = true, },{ - .name = "piix4-usb-uhci", + .name = TYPE_PIIX4_USB_UHCI, .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82371AB_2, .revision = 0x01, .irq_pin = 3, .unplug = true, },{ - .name = "vt82c686b-usb-uhci", + .name = TYPE_VT82C686B_USB_UHCI, .vendor_id = PCI_VENDOR_ID_VIA, .device_id = PCI_DEVICE_ID_VIA_UHCI,.revision =
0x01,hw/usb/hcd-uhci.c +6
-6@@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = { .realize = usb_uhci_vt82c686b_realize, .unplug = true, },{ - .name = "ich9-usb-uhci1", /* 00:1d.0 */ + .name = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci2", /* 00:1d.1 */ + .name = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci3", /* 00:1d.2 */ + .name = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3, .revision = 0x03, .irq_pin = 2, .unplug = false, },{ - .name = "ich9-usb-uhci4", /* 00:1a.0 */ + .name = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci5", /* 00:1a.1 */ + .name = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci6", /* 00:1a.2 */ + .name = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6, .revision = 0x03,
Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
Quoted 51 lines · BALATON Zoltan
Quoted 39 lines · Philippe Mathieu-Daudé
Quoted 26 lines · BALATON Zoltan
Quoted 25 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create UHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/usb/usb-hcd.h| 6 ++++++
hw/i386/pc_piix.c | 3 ++-
hw/i386/pc_q35.c | 13 +++++++------
hw/isa/piix4.c | 3 ++-
hw/mips/fuloong2e.c | 5 +++--
hw/usb/hcd-uhci.c | 19 ++++++++++---------6 files changed, 30 insertions(+), 19 deletions(-)include/hw/usb/usb-hcd.h +0
-0@@ -24,4 +24,10 @@#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"#define TYPE_CHIPIDEA "usb-chipidea"Quoted 8 lines
include/hw/usb/usb-hcd.h line 31
Quoted 5 lines
include/hw/usb/usb-hcd.h +5
-0+/* UHCI */ +#define TYPE_PIIX3_USB_UHCI "piix3-usb-uhci" +#define TYPE_PIIX4_USB_UHCI "piix4-usb-uhci" +#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci" +#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #nWhat is that #n at the end? Looks like a typo. Does it break compilation?
#n is a C preprocessor feature that expand the 'n' argument to a "n" string, so:
Quoted 6 lines
TYPE_ICH9_USB_UHCI(1)= "ich9-usb-uhci" #1
= "ich9-usb-uhci" "1"
= "ich9-usb-uhci1"I'm pretty sure we use that elsewhere. If not, I can add a definition for each 1 ... 6 typenames.
No it's OK, no need to list all defines. I just did not notice the macro argument that's why I was wondering where it comes from. This seems to be used elsewhere at least here:
Quoted 6 lines
hw/audio/es1370.c:#define a(n) if (val & CTRL_##n) strcat (buf, " "#n) hw/audio/es1370.c:#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n) hw/audio/es1370.c:#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n)
Maybe writing it without the space between "# is clearer as then it looks more like it's part of the value.
Ah clever indeed. Thanks!
Quoted 204 lines
Regards,
BALATON ZoltanQuoted 200 lines
Quoted 198 lines
Quoted 198 lines
include/hw/usb/usb-hcd.h +1
-0+#endif hw/i386/pc_piix.c +2
-1@@ -37,6 +37,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "net/net.h" #include "hw/ide/pci.h" #include "hw/irq.h" @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,#endif if (pcmc->pci_enabled && machine_usb(machine)) { - pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); + pci_create_simple(pci_bus, piix3_devfn + 2,TYPE_PIIX3_USB_UHCI ); }if (
pcmc->pci_enabled&&
x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {hw/i386/pc_q35.c +7
-6@@ -51,6 +51,7 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb/usb.h" +#include "hw/usb/usb-hcd.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" @@ -68,15 +69,15 @@ struct ehci_companions { };static const struct ehci_companions ich9_1d[] = { - { .name = "ich9-usb-uhci1", .func = 0, .port = 0 }, - { .name = "ich9-usb-uhci2", .func = 1, .port = 2 }, - { .name = "ich9-usb-uhci3", .func = 2, .port = 4 }, + { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 }, + { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 }, + { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 }, };static const struct ehci_companions ich9_1a[] = { - { .name = "ich9-usb-uhci4", .func = 0, .port = 0 }, - { .name = "ich9-usb-uhci5", .func = 1, .port = 2 }, - { .name = "ich9-usb-uhci6", .func = 2, .port = 4 }, + { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 }, + { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 }, + { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 }, };static int ehci_create_ich9_with_companions (PCIBus *bus,int slot)hw/isa/piix4.c +2
-1@@ -29,6 +29,7 @@#include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" +#include "hw/usb/usb-hcd.h" #include "hw/sysbus.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h" @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide"); pci_ide_create_devs(pci); - pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci"); + pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI); if (smbus) { *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);hw/mips/fuloong2e.c +2
-2@@ -33,6 +33,7 @@#include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/usb/usb-hcd.h" #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide/pci.h" @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc, dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide"); pci_ide_create_devs(dev); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); + pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
TYPE_VT82C686B_USB_UHCI);
+pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), TYPE_VT82C686B_USB_UHCI);
*i2c_bus=vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);hw/usb/hcd-uhci.c +4
-3@@ -39,6 +39,7 @@#include "qemu/main-loop.h" #include "qemu/module.h" #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define FRAME_TIMER_FREQ 1000@@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)static UHCIInfo uhci_info[] = { { - .name = "piix3-usb-uhci", + .name = TYPE_PIIX3_USB_UHCI, .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82371SB_2, .revision = 0x01, .irq_pin = 3, .unplug = true, },{ - .name = "piix4-usb-uhci", + .name = TYPE_PIIX4_USB_UHCI, .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82371AB_2, .revision = 0x01, .irq_pin = 3, .unplug = true, },{ - .name = "vt82c686b-usb-uhci", + .name = TYPE_VT82C686B_USB_UHCI, .vendor_id = PCI_VENDOR_ID_VIA, .device_id = PCI_DEVICE_ID_VIA_UHCI,.revision =
0x01,hw/usb/hcd-uhci.c +6
-6@@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = { .realize = usb_uhci_vt82c686b_realize, .unplug = true, },{ - .name = "ich9-usb-uhci1", /* 00:1d.0 */ + .name = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci2", /* 00:1d.1 */ + .name = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci3", /* 00:1d.2 */ + .name = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3, .revision = 0x03, .irq_pin = 2, .unplug = false, },{ - .name = "ich9-usb-uhci4", /* 00:1a.0 */ + .name = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4, .revision = 0x03, .irq_pin = 0, .unplug = false, },{ - .name = "ich9-usb-uhci5", /* 00:1a.1 */ + .name = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5, .revision = 0x03, .irq_pin = 1, .unplug = false, },{ - .name = "ich9-usb-uhci6", /* 00:1a.2 */ + .name = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */ .vendor_id = PCI_VENDOR_ID_INTEL, .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6, .revision = 0x03,
Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
In reply to BALATON ZoltanQuoted 11 lines · BALATON Zoltan
No it's OK, no need to list all defines. I just did not notice the macro argument that's why I was wondering where it comes from. This seems to be used elsewhere at least here:
hw/audio/es1370.c:#define a(n) if (val & CTRL_##n) strcat (buf, " "#n) hw/audio/es1370.c:#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n) hw/audio/es1370.c:#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n)
Maybe writing it without the space between "# is clearer as then it looks more like it's part of the value.
I think keeping the space is better.
The reason is that CTRL_##n pastes together CTRL_ and n, but " "#n is different:
1) First, it turns n into a string, for example "1"
2) Then, just because there is another string just before, the two are concatenated, as in "CTRL_" "1".
Paolo
PATCH 25/26 hw/usb/usb-hcd: Use XHCI type definitions
In reply to Philippe Mathieu-DaudéVarious machine/board/soc models create XHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
--- hw/usb/hcd-xhci.h | 2 +- include/hw/usb/usb-hcd.h | 3 +++ hw/ppc/spapr.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.h +1 -1
@@ -23,9 +23,9 @@#define HW_USB_HCD_XHCI_H #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define TYPE_XHCI "base-xhci" -#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci"#define XHCI (obj) \
include/hw/usb/usb-hcd.h +3 -0
@@ -30,4 +30,7 @@#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci"#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #n +/* XHCI */ +#define TYPE_NEC_XHCI "nec-usb-xhci" +#endif
hw/ppc/spapr.c +1 -1
@@ -2961,7 +2961,7 @@ static void spapr_machine_init(MachineState *machine)if (smc->use_ohci_by_default) {pci_create_simple (phb->bus,-1 ,TYPE_PCI_OHCI ); }else { -pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); +pci_create_simple (phb->bus,-1 ,TYPE_NEC_XHCI ); }if (spapr->has_graphics) {
Signature · 1 line
2.21.3
Re: [PATCH 25/26] hw/usb/usb-hcd: Use XHCI type definitions
Quoted 19 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create XHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/usb/hcd-xhci.h | 2 +- include/hw/usb/usb-hcd.h | 3 +++ hw/ppc/spapr.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-)hw/usb/hcd-xhci.h +0
-0
hw/usb/hcd-xhci.h line 29
Quoted 8 lines
hw/usb/hcd-xhci.h +1
-1@@ -23,9 +23,9 @@#define HW_USB_HCD_XHCI_H #include "usb-internal.h" +#include "hw/usb/usb-hcd.h" #define TYPE_XHCI "base-xhci" -#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci"
Why is qemu-xhci left here? Should that be moved to public header too? (Maybe no machine adds it but that's a public type too I think.)
Regards.
BALATON Zoltan
Quoted 27 lines
hw/usb/hcd-xhci.h +0
-0#define XHCI (obj) \include/hw/usb/usb-hcd.h +3
-0@@ -30,4 +30,7 @@#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci"#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #n +/* XHCI */ +#define TYPE_NEC_XHCI "nec-usb-xhci" +#endif hw/ppc/spapr.c +1
-1@@ -2961,7 +2961,7 @@ static void spapr_machine_init(MachineState *machine)if (smc->use_ohci_by_default) {pci_create_simple (phb->bus,-1 ,TYPE_PCI_OHCI ); }else { -pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); +pci_create_simple (phb->bus,-1 ,TYPE_NEC_XHCI ); }if (spapr->has_graphics) {
Re: [PATCH 25/26] hw/usb/usb-hcd: Use XHCI type definitions
Quoted 25 lines · BALATON Zoltan
Quoted 24 lines · Philippe Mathieu-Daudé
Various machine/board/soc models create XHCI device instances with the generic QDEV API, and don't need to access USB internals.
Simplify header inclusions by moving the QOM type names into a simple header, with no need to include other "hw/usb" headers.
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/usb/hcd-xhci.h | 2 +-include/hw/usb/usb-hcd.h| 3 +++
hw/ppc/spapr.c | 2 +-3 files changed, 5 insertions(+), 2 deletions(-)hw/usb/hcd-xhci.h +1
-0@@ -23,9 +23,9 @@#define HW_USB_HCD_XHCI_H #include "usb-internal.h" +#include "hw/usb/usb-hcd.h"
Quoted 6 lines
hw/usb/hcd-xhci.h line 29
Quoted 3 lines
hw/usb/hcd-xhci.h +0
-1#define TYPE_XHCI "base-xhci" -#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci"Why is qemu-xhci left here? Should that be moved to public header too? (Maybe no machine adds it but that's a public type too I think.)
I don't know because I never used it, but I guess you are right.
Quoted 32 lines
Regards.
BALATON ZoltanQuoted 28 lines
hw/usb/hcd-xhci.h +0
-0#define XHCI (obj) \include/hw/usb/usb-hcd.h +3
-0@@ -30,4 +30,7 @@#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci"#define TYPE_ICH9_USB_UHCI (n) "ich9-usb-uhci" #n +/* XHCI */ +#define TYPE_NEC_XHCI "nec-usb-xhci" +#endif hw/ppc/spapr.c +1
-1@@ -2961,7 +2961,7 @@ static void spapr_machine_init(MachineState *machine) if (smc->use_ohci_by_default) { pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI); } else { - pci_create_simple(phb->bus, -1, "nec-usb-xhci"); + pci_create_simple(phb->bus, -1, TYPE_NEC_XHCI); }if (
spapr->has_graphics) {
PATCH 26/26 MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation
In reply to Philippe Mathieu-DaudéAdd an section for the dwc2 host controller emulation introduced in commit 153ef1662c.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -1651,6 +1651,12 @@ M: Samuel Thibault <[email protected]> S: Maintained F: hw/usb/dev-serial.c +USB dwc-hsotg (dwc2) +M: Gerd Hoffmann <[email protected]> +R: Paul Zimmerman <[email protected]> +S: Maintained +F: hw/usb/*dwc2* + VFIO M: Alex Williamson <[email protected]> S: Supported
Signature · 1 line
2.21.3
Re: [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation
Quoted 16 lines · Philippe Mathieu-Daudé
Add an section for the dwc2 host controller emulation introduced in commit
153ef1662c.Cc Paul Zimmerman <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)MAINTAINERS +0
-0@@ -1651,6 +1651,12 @@ M: Samuel Thibault <[email protected]> S: Maintained F: hw/usb/dev-serial.c
MAINTAINERS M: Samuel Thibault <[email protected]> · line 1662
Quoted 10 lines
MAINTAINERS +6
-0+USB dwc-hsotg (dwc2) +M: Gerd Hoffmann <[email protected]> +R: Paul Zimmerman <[email protected]> +S: Maintained +F: hw/usb/*dwc2* + VFIO M: Alex Williamson <[email protected]> S: Supported
Quoted 4 lines
--
2.21.3
Quoted 20 lines · Philippe Mathieu-Daudé
Hi,
This is the second time I try to replace a magic typename string by a constant, and Zoltan warns me this is counter productive as "
hw/usb.h" pulls in an insane amount of code.Time to give the usb subsystem some love and move forward.
This series can be decomposed as follow:
1-2: preliminary machine cleanups (arm/ppc) 3-13: usb related headers cleanups 14-15: usb quirks cleanup 16-18: refactor usb_get_dev_path() to add usb_get_port_path() 19: let spapr use usb_get_port_path() to make USBDevice opaque 20: extract the public USB API (for machine/board/soc) 21: make the older "usb.h" internal to hw/usb/ 22-25: use TYPENAME definitions 26: cover dwc2 in MAINTAINERS
Quoted 1 line
Please review.
Looks good overall, I don't fell like squeezing this into 5.1 though. Can you repost (with the few comments addressed) once 5.2 is open for development in roughly a month?
thanks,
Gerd