Make hcd-xhci independent of pci hooks
v6 cover Make hcd-xhci independent of pci hooks
This patch series attempts to make 'hcd-xhci' an independent model so it can be used by both pci and system-bus interface.
Changes for V2:
Make XHCIState non-qom
Use container_of functions for retriving pci device instance Initialize the AddressSpace pointer in PATCH 1/3 itself
Changes for V3:
Convert XHCIState to TYPE_DEVICE and register as a child of XHCIPciState.
Changes for V4:
Add DWC3 usb controller
Add versal, usb2-reg module
Connect sysbus xhci to versal virt board
Changes for V5:
Add extra info about dwc3 and usb2_regs devices in commit messages Use only one irq for versal usb controller
Mark the unimplemented registers in dwc3 controller
Rebase the patches over master.
Move few mispalced contents from patch 2/7 to 3/7.
Fix the author names in the header.
Move the inclusion of "sysemu/dma.h" from patch 1/7 to 3/7
Changes for V6:
Fixed style issue in patch 7/7
Renamed usb2_reg model to VersalUsb2CtrlReg
Fixed author in headers
Sai Pavan Boddu (5):
usb/hcd-xhci: Make dma read/writes hooks pci free usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c usb/hcd-xhci: Split pci wrapper for xhci base model
usb: hcd-xhci-sysbus: Attach xhci to sysbus device
misc: Add versal-usb2-ctrl-regs module
Vikram Garhwal (2):
usb: Add DWC3 model
Versal: Connect DWC3 controller with virt-versal
hw/arm/xlnx-versal-virt.c | 55 ++ hw/arm/xlnx-versal.c | 34 ++ hw/misc/meson.build | 1 + hw/misc/xlnx-versal-usb2-ctrl-regs.c | 222 +++++++++ hw/usb/Kconfig | 17 + hw/usb/hcd-dwc3.c | 717 +++++++++++++++++++++++++++ hw/usb/hcd-xhci-nec.c | 18 +- hw/usb/hcd-xhci-pci.c | 244 +++++++++ hw/usb/hcd-xhci-pci.h | 45 ++ hw/usb/hcd-xhci-sysbus.c | 99 ++++ hw/usb/hcd-xhci-sysbus.h | 32 ++ hw/usb/hcd-xhci.c | 260 ++-------- hw/usb/hcd-xhci.h | 22 +- hw/usb/meson.build | 3 + include/hw/arm/xlnx-versal.h | 12 + include/hw/misc/xlnx-versal-usb2-ctrl-regs.h | 45 ++ include/hw/usb/hcd-dwc3.h | 55 ++ 17 files changed, 1656 insertions(+), 225 deletions(-) create mode 100644 hw/misc/xlnx-versal-usb2-ctrl-regs.c create mode 100644 hw/usb/hcd-dwc3.c create mode 100644 hw/usb/hcd-xhci-pci.c create mode 100644 hw/usb/hcd-xhci-pci.h create mode 100644 hw/usb/hcd-xhci-sysbus.c create mode 100644 hw/usb/hcd-xhci-sysbus.h create mode 100644 include/hw/misc/xlnx-versal-usb2-ctrl-regs.h create mode 100644 include/hw/usb/hcd-dwc3.h
Signature · 1 line
2.7.4
PATCH v6 1/7 usb/hcd-xhci: Make dma read/writes hooks pci free
This patch starts making the hcd-xhci.c pci free, as part of this restructuring dma read/writes are handled without passing pci object.
--- hw/usb/hcd-xhci.c | 24 +++++++++++------------- hw/usb/hcd-xhci.h | 1 + 2 files changed, 12 insertions(+), 13 deletions(-)
hw/usb/hcd-xhci.c +11 -13
@@ -495,7 +495,7 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci, dma_addr_t addr,assert ((len %sizeof (uint32_t )) ==0 ); -pci_dma_read (PCI_DEVICE (xhci), addr, buf, len); +dma_memory_read (xhci->as, addr, buf, len);for (i =0 ; i < (len /sizeof (uint32_t )); i++) { buf[i] =le32_to_cpu (buf[i]);
@@ -515,7 +515,7 @@ static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr,for (i =0 ; i < n; i++) { tmp[i] =cpu_to_le32 (buf[i]); } -pci_dma_write (PCI_DEVICE (xhci), addr, tmp, len); +dma_memory_write (xhci->as, addr, tmp, len); }static XHCIPort *xhci_lookup_port (XHCIState *xhci,struct USBPort *uport)
@@ -644,7 +644,6 @@ static void xhci_die(XHCIState *xhci)static void xhci_write_event (XHCIState *xhci,XHCIEvent *event,int v) { -PCIDevice *pci_dev =PCI_DEVICE (xhci);XHCIInterrupter *intr = &xhci->intr[v];XHCITRB ev_trb;dma_addr_t addr;
@@ -663,7 +662,7 @@ static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v) ev_trb.status, ev_trb.control); addr = intr->er_start +TRB_SIZE *intr->er_ep_idx; -pci_dma_write (pci_dev, addr, &ev_trb,TRB_SIZE ); +dma_memory_write (xhci->as, addr, &ev_trb,TRB_SIZE ); intr->er_ep_idx++;if (intr->er_ep_idx >= intr->er_size) {
@@ -720,12 +719,11 @@ static void xhci_ring_init(XHCIState *xhci, XHCIRing *ring,static TRBType xhci_ring_fetch (XHCIState *xhci,XHCIRing *ring,XHCITRB *trb,dma_addr_t *addr) { -PCIDevice *pci_dev =PCI_DEVICE (xhci);uint32_t link_cnt =0 ;while (1 ) {TRBType type; -pci_dma_read (pci_dev, ring->dequeue, trb,TRB_SIZE ); +dma_memory_read (xhci->as, ring->dequeue, trb,TRB_SIZE ); trb->addr = ring->dequeue; trb->ccs = ring->ccs;le64_to_cpus (&trb->parameter);
@@ -762,7 +760,6 @@ static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRing *ring, XHCITRB *trb,static int xhci_ring_chain_length (XHCIState *xhci,const XHCIRing *ring) { -PCIDevice *pci_dev =PCI_DEVICE (xhci);XHCITRB trb;int length =0 ;dma_addr_t dequeue = ring->dequeue;
@@ -773,7 +770,7 @@ static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring)while (1 ) {TRBType type; -pci_dma_read (pci_dev, dequeue, &trb,TRB_SIZE ); +dma_memory_read (xhci->as, dequeue, &trb,TRB_SIZE );le64_to_cpus (&trb.parameter);le32_to_cpus (&trb.status);le32_to_cpus (&trb.control);
@@ -828,7 +825,7 @@ static void xhci_er_reset(XHCIState *xhci, int v)xhci_die (xhci);return ; } -pci_dma_read (PCI_DEVICE (xhci), erstba, &seg,sizeof (seg)); +dma_memory_read (xhci->as, erstba, &seg,sizeof (seg));le32_to_cpus (&seg.addr_low);le32_to_cpus (&seg.addr_high);le32_to_cpus (&seg.size);
@@ -1440,7 +1437,7 @@ static int xhci_xfer_create_sgl(XHCITransfer *xfer, int in_xfer)int i; xfer->int_req = false; -pci_dma_sglist_init (&xfer->sgl,PCI_DEVICE (xhci), xfer->trb_count); +qemu_sglist_init (&xfer->sgl,DEVICE (xhci), xfer->trb_count, xhci->as);for (i =0 ; i < xfer->trb_count; i++) {XHCITRB *trb = &xfer->trbs[i];dma_addr_t addr;
@@ -2104,7 +2101,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,assert (slotid >=1 && slotid <= xhci->numslots); dcbaap =xhci_addr64 (xhci->dcbaap_low, xhci->dcbaap_high); - poctx =ldq_le_pci_dma (PCI_DEVICE (xhci), dcbaap +8 * slotid); + poctx =ldq_le_dma (xhci->as, dcbaap +8 * slotid); ictx =xhci_mask64 (pictx); octx =xhci_mask64 (poctx);
@@ -2442,7 +2439,7 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)/* TODO: actually implement real values here */ bw_ctx[0 ] =0 ;memset (&bw_ctx[1 ],80 , xhci->numports);/* 80% */ -pci_dma_write (PCI_DEVICE (xhci), ctx, bw_ctx,sizeof (bw_ctx)); +dma_memory_write (xhci->as, ctx, bw_ctx,sizeof (bw_ctx));return CC_SUCCESS ; }
@@ -3434,6 +3431,7 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp) }usb_xhci_init (xhci); + xhci->as =pci_get_address_space (dev); xhci->mfwrap_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , xhci_mfwrap_timer, xhci);memory_region_init (&xhci->mem,OBJECT (xhci),"xhci" ,LEN_REGS );
@@ -3534,7 +3532,7 @@ static int usb_xhci_post_load(void *opaque, int version_id)continue ; } slot->ctx = -xhci_mask64 (ldq_le_pci_dma (pci_dev, dcbaap +8 * slotid)); +xhci_mask64 (ldq_le_dma (xhci->as, dcbaap +8 * slotid));xhci_dma_read_u32s (xhci, slot->ctx, slot_ctx,sizeof (slot_ctx)); slot->uport =xhci_lookup_uport (xhci, slot_ctx);if (!slot->uport) {
hw/usb/hcd-xhci.h +1 -0
@@ -190,6 +190,7 @@ struct XHCIState {USBBus bus;MemoryRegion mem; +AddressSpace *as;MemoryRegion mem_cap;MemoryRegion mem_oper;MemoryRegion mem_runtime;
Signature · 1 line
2.7.4
PATCH v6 2/7 usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c
In reply to Sai Pavan BodduMove pci specific devices to new file. This set the environment to move all pci specific hooks in hcd-xhci.c to hcd-xhci-pci.c.
--- hw/usb/Kconfig | 6 +++++ hw/usb/hcd-xhci-pci.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/usb/hcd-xhci.c | 33 ++------------------------ hw/usb/hcd-xhci.h | 4 ++++ hw/usb/meson.build | 1 + 5 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 hw/usb/hcd-xhci-pci.c
hw/usb/Kconfig +6 -0
@@ -36,6 +36,12 @@ config USB_XHCI depends on PCI select USB +config USB_XHCI_PCI + bool + default y if PCI_DEVICES + depends on PCI + select USB_XHCI + config USB_XHCI_NEC bool default y if PCI_DEVICES
hw/usb/hcd-xhci-pci.c new file +66 -0
66 lines not on this page · raw message
hw/usb/hcd-xhci.c +2 -31
@@ -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"
@@ -429,12 +428,12 @@ static const char *ep_state_name(uint32_t state) ARRAY_SIZE(ep_state_names)); } -static bool xhci_get_flag (XHCIState *xhci,enum xhci_flags bit) +bool xhci_get_flag (XHCIState *xhci,enum xhci_flags bit) {return xhci->flags & (1 << bit); } -static void xhci_set_flag (XHCIState *xhci,enum xhci_flags bit) +void xhci_set_flag (XHCIState *xhci,enum xhci_flags bit) { xhci->flags |= (1 << bit); }
@@ -3730,37 +3729,9 @@ static const TypeInfo xhci_info = { }, }; -static void qemu_xhci_class_init (ObjectClass *klass,void *data) -{ -PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); - - k->vendor_id =PCI_VENDOR_ID_REDHAT ; - k->device_id =PCI_DEVICE_ID_REDHAT_XHCI ; - k->revision =0x01 ; -} - -static void qemu_xhci_instance_init (Object *obj) -{ -XHCIState *xhci =XHCI (obj); - - xhci->msi =ON_OFF_AUTO_OFF ; - xhci->msix =ON_OFF_AUTO_AUTO ; - xhci->numintrs =MAXINTRS ; - xhci->numslots =MAXSLOTS ; -xhci_set_flag (xhci,XHCI_FLAG_SS_FIRST ); -} - -static const TypeInfo qemu_xhci_info = { - .name =TYPE_QEMU_XHCI , - .parent =TYPE_XHCI , - .class_init = qemu_xhci_class_init, - .instance_init = qemu_xhci_instance_init, -}; -static void xhci_register_types (void ) {type_register_static (&xhci_info); -type_register_static (&qemu_xhci_info); }type_init (xhci_register_types)
hw/usb/hcd-xhci.h +4 -0
@@ -23,6 +23,8 @@#define HW_USB_HCD_XHCI_H #include "qom/object.h" +#include "hw/usb.h" +#define TYPE_XHCI "base-xhci"#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci"
@@ -231,4 +233,6 @@ struct XHCIState { bool nec_quirks; }; +bool xhci_get_flag (XHCIState *xhci,enum xhci_flags bit); +void xhci_set_flag (XHCIState *xhci,enum xhci_flags bit);#endif
hw/usb/meson.build +1 -0
@@ -21,6 +21,7 @@ softmmu_ss.add(when: 'CONFIG_USB_EHCI', if_true: files('hcd-ehci.c')) softmmu_ss.add(when: 'CONFIG_USB_EHCI_PCI', if_true: files('hcd-ehci-pci.c')) softmmu_ss.add(when: 'CONFIG_USB_EHCI_SYSBUS', if_true: files('hcd-ehci.c', 'hcd-ehci-sysbus.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI', if_true: files('hcd-xhci.c')) +softmmu_ss.add(when: 'CONFIG_USB_XHCI_PCI', if_true: files('hcd-xhci-pci.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) softmmu_ss.add(when: 'CONFIG_USB_MUSB', if_true: files('hcd-musb.c')) softmmu_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c'))
Signature · 1 line
2.7.4
PATCH v6 3/7 usb/hcd-xhci: Split pci wrapper for xhci base model
In reply to Sai Pavan BodduThis patch sets the base to use xhci as sysbus model, for which pci specific hooks are moved to hcd-xhci-pci.c. As a part of this requirment msi/msix interrupts handling is moved under XHCIPCIState. Made required changes for qemu-xhci-nec.
fixup
--- hw/usb/hcd-xhci-nec.c | 18 ++--- hw/usb/hcd-xhci-pci.c | 188 +++++++++++++++++++++++++++++++++++++++++++-- hw/usb/hcd-xhci-pci.h | 45 +++++++++++ hw/usb/hcd-xhci.c | 205 ++++++++++---------------------------------------- hw/usb/hcd-xhci.h | 16 ++-- 5 files changed, 285 insertions(+), 187 deletions(-) create mode 100644 hw/usb/hcd-xhci-pci.h
hw/usb/hcd-xhci-nec.c +9 -9
@@ -25,17 +25,17 @@#include "hw/pci/pci.h" #include "hw/qdev-properties.h" -#include "hcd-xhci.h" +#include "hcd-xhci-pci.h" static Property nec_xhci_properties[] = { -DEFINE_PROP_ON_OFF_AUTO ("msi" , XHCIState, msi,ON_OFF_AUTO_AUTO ), -DEFINE_PROP_ON_OFF_AUTO ("msix" , XHCIState, msix,ON_OFF_AUTO_AUTO ), -DEFINE_PROP_BIT ("superspeed-ports-first" , - XHCIState, flags,XHCI_FLAG_SS_FIRST , true), -DEFINE_PROP_BIT ("force-pcie-endcap" , XHCIState, flags, +DEFINE_PROP_ON_OFF_AUTO ("msi" , XHCIPciState, msi,ON_OFF_AUTO_AUTO ), +DEFINE_PROP_ON_OFF_AUTO ("msix" , XHCIPciState, msix,ON_OFF_AUTO_AUTO ), +DEFINE_PROP_BIT ("superspeed-ports-first" , XHCIPciState, + xhci.flags,XHCI_FLAG_SS_FIRST , true), +DEFINE_PROP_BIT ("force-pcie-endcap" , XHCIPciState, xhci.flags,XHCI_FLAG_FORCE_PCIE_ENDCAP , false), -DEFINE_PROP_UINT32 ("intrs" , XHCIState, numintrs,MAXINTRS ), -DEFINE_PROP_UINT32 ("slots" , XHCIState, numslots,MAXSLOTS ), +DEFINE_PROP_UINT32 ("intrs" , XHCIPciState, xhci.numintrs,MAXINTRS ), +DEFINE_PROP_UINT32 ("slots" , XHCIPciState, xhci.numslots,MAXSLOTS ),DEFINE_PROP_END_OF_LIST (), };
@@ -52,7 +52,7 @@ static void nec_xhci_class_init(ObjectClass *klass, void *data)static const TypeInfo nec_xhci_info = { .name =TYPE_NEC_XHCI , - .parent =TYPE_XHCI , + .parent =TYPE_XHCI_PCI , .class_init = nec_xhci_class_init, };
hw/usb/hcd-xhci-pci.c +183 -5
218 lines not on this page · raw message
hw/usb/hcd-xhci-pci.h new file +45 -0
45 lines not on this page · raw message
hw/usb/hcd-xhci.c +40 -165
364 lines not on this page · raw message
hw/usb/hcd-xhci.h +8 -8
@@ -24,6 +24,7 @@#include "qom/object.h" #include "hw/usb.h" +#include "sysemu/dma.h" #define TYPE_XHCI "base-xhci"#define TYPE_NEC_XHCI "nec-usb-xhci"
@@ -171,7 +172,7 @@ typedef struct XHCIInterrupter {uint32_t erdp_low;uint32_t erdp_high; -bool msix_used, er_pcs; +bool er_pcs;dma_addr_t er_start;uint32_t er_size;
@@ -185,10 +186,8 @@ typedef struct XHCIInterrupter { } XHCIInterrupter; -struct XHCIState { -/*< private >*/ -PCIDevice parent_obj; -/*< public >*/ +typedef struct XHCIState { + DeviceState parent; USBBus bus; MemoryRegion mem;
@@ -205,8 +204,9 @@ struct XHCIState {uint32_t numslots;uint32_t flags;uint32_t max_pstreams_mask; -OnOffAuto msi; -OnOffAuto msix; +void (*intr_update)(XHCIState *s,int n,bool enable); +void (*intr_raise)(XHCIState *s,int n,bool level); +DeviceState *hostOpaque;/* Operational Registers */ uint32_t usbcmd;
@@ -231,7 +231,7 @@ struct XHCIState {XHCIRing cmd_ring;bool nec_quirks; -}; +} XHCIState;bool xhci_get_flag (XHCIState *xhci,enum xhci_flags bit);void xhci_set_flag (XHCIState *xhci,enum xhci_flags bit);
Signature · 1 line
2.7.4
PATCH v6 4/7 usb: hcd-xhci-sysbus: Attach xhci to sysbus device
In reply to Sai Pavan BodduUse XHCI as sysbus device, add memory region property to get the address space instance for dma read/write.
--- hw/usb/Kconfig | 5 +++ hw/usb/hcd-xhci-sysbus.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ hw/usb/hcd-xhci-sysbus.h | 32 ++++++++++++++++ hw/usb/hcd-xhci.h | 1 + hw/usb/meson.build | 1 + 5 files changed, 138 insertions(+) create mode 100644 hw/usb/hcd-xhci-sysbus.c create mode 100644 hw/usb/hcd-xhci-sysbus.h
hw/usb/Kconfig +5 -0
@@ -48,6 +48,11 @@ config USB_XHCI_NEC depends on PCI select USB_XHCI +config USB_XHCI_SYSBUS + bool + default y if USB_XHCI + select USB + config USB_MUSB bool select USB
hw/usb/hcd-xhci-sysbus.c new file +99 -0
99 lines not on this page · raw message
hw/usb/hcd-xhci-sysbus.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* USB xHCI controller for system-bus interface +* +* SPDX-FileCopyrightText: 2020 Xilinx +* SPDX-FileContributor: Author: Sai Pavan Boddu <[email protected]> +* SPDX-sourceInfo: Based on hcd-echi-sysbus +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_USB_HCD_XHCI_SYSBUS_H +#define HW_USB_HCD_XHCI_SYSBUS_H + +#include "hw/usb.h" +#include "hcd-xhci.h" +#include "hw/sysbus.h" + +#define TYPE_XHCI_SYSBUS "sysbus-xhci" +#define XHCI_SYSBUS (obj) \ + OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS) + + +typedef struct XHCISysbusState { +/*< private >*/ +SysBusDevice parent_obj; +/*< public >*/ +XHCIState xhci; +qemu_irq *irq; +}XHCISysbusState ; + +void xhci_sysbus_reset (DeviceState *dev); +#endif
hw/usb/hcd-xhci.h +1 -0
@@ -191,6 +191,7 @@ typedef struct XHCIState {USBBus bus;MemoryRegion mem; +MemoryRegion *dma_mr;AddressSpace *as;MemoryRegion mem_cap;MemoryRegion mem_oper;
hw/usb/meson.build +1 -0
@@ -22,6 +22,7 @@ softmmu_ss.add(when: 'CONFIG_USB_EHCI_PCI', if_true: files('hcd-ehci-pci.c')) softmmu_ss.add(when: 'CONFIG_USB_EHCI_SYSBUS', if_true: files('hcd-ehci.c', 'hcd-ehci-sysbus.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI', if_true: files('hcd-xhci.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI_PCI', if_true: files('hcd-xhci-pci.c')) +softmmu_ss.add(when: 'CONFIG_USB_XHCI_SYSBUS', if_true: files('hcd-xhci-sysbus.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) softmmu_ss.add(when: 'CONFIG_USB_MUSB', if_true: files('hcd-musb.c')) softmmu_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c'))
Signature · 1 line
2.7.4
PATCH v6 5/7 misc: Add versal-usb2-regs module
In reply to Sai Pavan BodduThis module emulates control registers of versal usb2 controller, this is added just to make guest happy. In general this module would control the phy-reset signal from usb controller, data coherency of the transactions, signals the host system errors received from controller.
--- hw/misc/meson.build | 1 + hw/misc/xlnx-versal-usb2-ctrl-regs.c | 221 +++++++++++++++++++++++++++ include/hw/misc/xlnx-versal-usb2-ctrl-regs.h | 46 ++++++ 3 files changed, 268 insertions(+) create mode 100644 hw/misc/xlnx-versal-usb2-ctrl-regs.c create mode 100644 include/hw/misc/xlnx-versal-usb2-ctrl-regs.h
hw/misc/meson.build +1 -0
@@ -109,3 +109,4 @@ specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cp specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c')) specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c')) +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-usb2-ctrl-regs.c'))
hw/misc/xlnx-versal-usb2-ctrl-regs.c new file +221 -0
221 lines not on this page · raw message
include/hw/misc/xlnx-versal-usb2-ctrl-regs.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.7.4
RE: [PATCH v6 5/7] misc: Add versal-usb2-regs module
Hi Gerd,
Please ignore this
Regards,
Sai Pavan
Quoted 347 lines
-----Original Message-----
From: Sai Pavan Boddu <[email protected]>
Sent: Wednesday, September 16, 2020 5:11 PM
To: Peter Maydell <[email protected]>; Markus Armbruster <[email protected]>; 'Marc-André Lureau' <[email protected]>; Paolo Bonzini <[email protected]>; Gerd Hoffmann <[email protected]>; Edgar Iglesias <[email protected]>; Francisco Eduardo Iglesias <[email protected]>
Cc: [email protected]; Alistair Francis <[email protected]>; Eduardo Habkost <[email protected]>; Ying Fang <[email protected]>; 'Philippe Mathieu-Daudé' <[email protected]>; Vikram Garhwal <[email protected]>; Paul Zimmerman <[email protected]>; Sai Pavan Boddu <[email protected]>
Subject: [PATCH v6 5/7] misc: Add versal-usb2-regs moduleThis module emulates control registers of versal usb2 controller, this is added just to make guest happy. In general this module would control the phy-reset signal from usb controller, data coherency of the transactions, signals the host system errors received from controller.
Signed-off-by Sai Pavan Boddu <[email protected]>Signed-off-by Vikram Garhwal <[email protected]>--- hw/misc/meson.build | 1 + hw/misc/xlnx-versal-usb2-ctrl-regs.c | 221 +++++++++++++++++++++++++++ include/hw/misc/xlnx-versal-usb2-ctrl-regs.h | 46 ++++++ 3 files changed, 268 insertions(+) create mode 100644 hw/misc/xlnx-versal-usb2-ctrl-regs.c create mode 100644 include/hw/misc/xlnx-versal-usb2-ctrl-regs.hhw/misc/meson.build index renamed from hw/misc/meson.build +0
-0793d45b..b336dd1 100644
hw/misc/meson.build +0
-0@@ -109,3 +109,4 @@ specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true:files('mips_cmgcr.c', '
mips_cp
specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c'))
specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))hw/misc/meson.build +2
-0+specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: +files('xlnx-versal-usb2-ctrl-regs.c'))hw/misc/xlnx-versal-usb2- renamed from hw/misc/xlnx-versal-usb2-ctrl-regs.c +0
-0
ctrl-regs.c
new file mode 100644
index 0000000..6ddd38bhw/misc/xlnx-versal-usb2-ctrl-regs.c new file +30
-0@@ -0,0 +1,221 @@ +/* +* QEMU model of the XlnxUsb2Regs Register control block/Status for +USB2.0 IP +* +* This module should control phy_reset, permanent device plugs, frame +length +* time adjust & setting of coherency paths. None of which are emulated +in +* present model. +* +* Copyright (c) 2020 Xilinx Inc. Vikram Garhwal +<[email protected]> +* +* Permission is hereby granted, free of charge, to any person +obtaining a copy +* of this software and associated documentation files (the +"Software"), to deal +* in the Software without restriction, including without limitation +the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell +* copies of the Software, and to permit persons to whom the Software +is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be +included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
hw/misc/xlnx-versal-usb2-ctrl-regs.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NOEVENT
+SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES ORhw/misc/xlnx-versal-usb2-ctrl-regs.c new file +188
-0+OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "hw/irq.h" +#include "hw/register.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qom/object.h" +#include "migration/vmstate.h" +#include "hw/misc/xlnx-versal-usb2-ctrl-regs.h" + +#ifndef XILINX_USB2_REGS_ERR_DEBUG +#define XILINX_USB2_REGS_ERR_DEBUG 0 +#endif + +REG32(BUS_FILTER, 0x30) + FIELD(BUS_FILTER, BYPASS, 0, 4) +REG32(PORT, 0x34) + FIELD(PORT, HOST_SMI_BAR_WR, 4, 1) + FIELD(PORT, HOST_SMI_PCI_CMD_REG_WR, 3, 1) + FIELD(PORT, HOST_MSI_ENABLE, 2, 1) + FIELD(PORT, PWR_CTRL_PRSNT, 1, 1) + FIELD(PORT, HUB_PERM_ATTACH, 0, 1) +REG32(JITTER_ADJUST, 0x38) + FIELD(JITTER_ADJUST, FLADJ, 0, 6) +REG32(BIGENDIAN, 0x40) + FIELD(BIGENDIAN, ENDIAN_GS, 0, 1) +REG32(COHERENCY, 0x44) + FIELD(COHERENCY, USB_COHERENCY, 0, 1) REG32(XHC_BME, 0x48) + FIELD(XHC_BME, XHC_BME, 0, 1) +REG32(REG_CTRL, 0x60) + FIELD(REG_CTRL, SLVERR_ENABLE, 0, 1) REG32(IR_STATUS, 0x64) + FIELD(IR_STATUS, HOST_SYS_ERR, 1, 1) + FIELD(IR_STATUS, ADDR_DEC_ERR, 0, 1) REG32(IR_MASK, 0x68) + FIELD(IR_MASK, HOST_SYS_ERR, 1, 1) + FIELD(IR_MASK, ADDR_DEC_ERR, 0, 1) +REG32(IR_ENABLE, 0x6c) + FIELD(IR_ENABLE, HOST_SYS_ERR, 1, 1) + FIELD(IR_ENABLE, ADDR_DEC_ERR, 0, 1) REG32(IR_DISABLE, 0x70) + FIELD(IR_DISABLE, HOST_SYS_ERR, 1, 1) + FIELD(IR_DISABLE, ADDR_DEC_ERR, 0, 1) REG32(USB3, 0x78) + +static void ir_update_irq (XlnxUsb2Regs *s) { +bool pending = s->regs[R_IR_STATUS ] & ~s->regs[R_IR_MASK ]; +qemu_set_irq (s->irq_ir, pending); +} + +static void ir_status_postw (RegisterInfo *reg,uint64_t val64) { +XlnxUsb2Regs *s =XILINX_USB2_REGS (reg->opaque); +/* +* TODO: This should also clear USBSTS.HSE field in USB XHCI register. +* May be combine both the modules. +*/ +ir_update_irq (s); +} + +static uint64_t ir_enable_prew (RegisterInfo *reg,uint64_t val64) { +XlnxUsb2Regs *s =XILINX_USB2_REGS (reg->opaque); +uint32_t val = val64; + + s->regs[R_IR_MASK ] &= ~val; +ir_update_irq (s); +return 0 ; +} + +static uint64_t ir_disable_prew (RegisterInfo *reg,uint64_t val64) { +XlnxUsb2Regs *s =XILINX_USB2_REGS (reg->opaque); +uint32_t val = val64; + + s->regs[R_IR_MASK ] |= val; +ir_update_irq (s); +return 0 ; +} + +static const RegisterAccessInfo usb2_regs_regs_info[] = { + { .name ="BUS_FILTER" , .addr =A_BUS_FILTER , + .rsvd =0xfffffff0 , + },{ .name ="PORT" , .addr =A_PORT , + .rsvd =0xffffffe0 , + },{ .name ="JITTER_ADJUST" , .addr =A_JITTER_ADJUST , + .reset =0x20 , + .rsvd =0xffffffc0 , + },{ .name ="BIGENDIAN" , .addr =A_BIGENDIAN , + .rsvd =0xfffffffe , + },{ .name ="COHERENCY" , .addr =A_COHERENCY , + .rsvd =0xfffffffe , + },{ .name ="XHC_BME" , .addr =A_XHC_BME , + .reset =0x1 , + .rsvd =0xfffffffe , + },{ .name ="REG_CTRL" , .addr =A_REG_CTRL , + .rsvd =0xfffffffe , + },{ .name ="IR_STATUS" , .addr =A_IR_STATUS , + .rsvd =0xfffffffc , + .w1c =0x3 , + .post_write = ir_status_postw, + },{ .name ="IR_MASK" , .addr =A_IR_MASK , + .reset =0x3 , + .rsvd =0xfffffffc , + .ro =0x3 , + },{ .name ="IR_ENABLE" , .addr =A_IR_ENABLE , + .rsvd =0xfffffffc , + .pre_write = ir_enable_prew, + },{ .name ="IR_DISABLE" , .addr =A_IR_DISABLE , + .rsvd =0xfffffffc , + .pre_write = ir_disable_prew, + },{ .name ="USB3" , .addr =A_USB3 , + } +}; + +static void usb2_regs_reset (DeviceState *dev) { +XlnxUsb2Regs *s =XILINX_USB2_REGS (dev); +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (s->regs_info); ++i) { +register_reset (&s->regs_info[i]); + } + +ir_update_irq (s); +} + +static const MemoryRegionOps usb2_regs_ops = { + .read = register_read_memory, + .write = register_write_memory, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 , + }, +}; + +static void usb2_regs_init (Object *obj) { +XlnxUsb2Regs *s =XILINX_USB2_REGS (obj); +SysBusDevice *sbd =SYS_BUS_DEVICE (obj); +RegisterInfoArray *reg_array; + +memory_region_init (&s->iomem, obj,TYPE_XILINX_USB2_REGS , +USB2_REGS_R_MAX *4 ); + reg_array = +register_init_block32 (DEVICE (obj), usb2_regs_regs_info, +ARRAY_SIZE (usb2_regs_regs_info), + s->regs_info, s->regs, + &usb2_regs_ops, +XILINX_USB2_REGS_ERR_DEBUG , +USB2_REGS_R_MAX *4 ); +memory_region_add_subregion (&s->iomem, +0x0 , + ®_array->mem); +sysbus_init_mmio (sbd, &s->iomem); +sysbus_init_irq (sbd, &s->irq_ir); +} + +static const VMStateDescription vmstate_usb2_regs = { + .name =TYPE_XILINX_USB2_REGS , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, XlnxUsb2Regs,USB2_REGS_R_MAX ), +VMSTATE_END_OF_LIST (), + } +}; + +static void usb2_regs_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->reset = usb2_regs_reset; + dc->vmsd = &vmstate_usb2_regs; +} + +static const TypeInfo usb2_regs_info = { + .name =TYPE_XILINX_USB2_REGS , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (XlnxUsb2Regs), + .class_init = usb2_regs_class_init, + .instance_init = usb2_regs_init, +}; + +static void usb2_regs_register_types (void ) { +type_register_static (&usb2_regs_info); +} + +type_init (usb2_regs_register_types)include/hw/misc/xlnx-versal-usb2-ctrl-regs.h new file +25
-0@@ -0,0 +1,46 @@ +/* +* QEMU model of the XlnxUsb2Regs Register control block/Status for +USB2.0 IP +* +* Copyright (c) 2020 Xilinx Inc. +* +* Autogenerated by xregqemu.py 2020-04-08. +* +* Permission is hereby granted, free of charge, to any person +obtaining a copy +* of this software and associated documentation files (the +"Software"), to deal +* in the Software without restriction, including without limitation +the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell +* copies of the Software, and to permit persons to whom the Software +is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be +included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
include/hw/misc/xlnx-versal-usb2-ctrl-regs.h new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NOEVENT
+SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES ORinclude/hw/misc/xlnx-versal-usb2-ctrl-regs.h new file +27
-1+OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef _XLNX_USB2_REGS_H_ +#define _XLNX_USB2_REGS_H_ + +#define TYPE_XILINX_USB2_REGS "xlnx.versal-usb2-ctrl-regs" + +#define XILINX_USB2_REGS (obj) \ + OBJECT_CHECK(XlnxUsb2Regs, (obj), TYPE_XILINX_USB2_REGS) + +#define USB2_REGS_R_MAX ((0x78 / 4) + 1) + +typedef struct XlnxUsb2Regs { +SysBusDevice parent_obj; +MemoryRegion iomem; +qemu_irq irq_ir; + +uint32_t regs[USB2_REGS_R_MAX ]; +RegisterInfo regs_info[USB2_REGS_R_MAX ]; }XlnxUsb2Regs ; + +#endif --2.7.4
PATCH v6 5/7 misc: Add versal-usb2-ctrl-regs module
In reply to Sai Pavan BodduThis module emulates control registers of versal usb2 controller, this is added just to make guest happy. In general this module would control the phy-reset signal from usb controller, data coherency of the transactions, signals the host system errors received from controller.
--- hw/misc/meson.build | 1 + hw/misc/xlnx-versal-usb2-ctrl-regs.c | 222 +++++++++++++++++++++++++++ include/hw/misc/xlnx-versal-usb2-ctrl-regs.h | 45 ++++++ 3 files changed, 268 insertions(+) create mode 100644 hw/misc/xlnx-versal-usb2-ctrl-regs.c create mode 100644 include/hw/misc/xlnx-versal-usb2-ctrl-regs.h
hw/misc/meson.build +1 -0
@@ -109,3 +109,4 @@ specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cp specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c')) specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c')) +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-usb2-ctrl-regs.c'))
hw/misc/xlnx-versal-usb2-ctrl-regs.c new file +222 -0
222 lines not on this page · raw message
include/hw/misc/xlnx-versal-usb2-ctrl-regs.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v6 5/7] misc: Add versal-usb2-ctrl-regs module
Quoted 7 lines · Sai Pavan Boddu
This module emulates control registers of versal usb2 controller, this is added just to make guest happy. In general this module would control the phy-reset signal from usb controller, data coherency of the transactions, signals the host system errors received from controller.
Signed-off-by Sai Pavan Boddu <[email protected]>Signed-off-by Vikram Garhwal <[email protected]>
Huh? Patch 5/7 is twice in this series ...
take care,
Gerd
RE: [PATCH v6 5/7] misc: Add versal-usb2-ctrl-regs module
Hi Gerd,
Quoted 22 lines
-----Original Message-----
From: Gerd Hoffmann <[email protected]>
Sent: Wednesday, September 16, 2020 5:32 PM
To: Sai Pavan Boddu <[email protected]>
Cc: Peter Maydell <[email protected]>; Markus Armbruster <[email protected]>; 'Marc-André Lureau' <[email protected]>; Paolo Bonzini <[email protected]>; Edgar Iglesias <[email protected]>; Francisco Eduardo Iglesias <[email protected]>; [email protected]; Alistair Francis <[email protected]>; Eduardo Habkost <[email protected]>; Ying Fang <[email protected]>; 'Philippe Mathieu-Daudé' <[email protected]>; Vikram Garhwal <[email protected]>; Paul Zimmerman <[email protected]>; Sai Pavan Boddu <[email protected]>
Subject: Re: [PATCH v6 5/7] misc: Add versal-usb2-ctrl-regs moduleQuoted 5 lines · Sai Pavan Boddu
This module emulates control registers of versal usb2 controller, this is added just to make guest happy. In general this module would control the phy-reset signal from usb controller, data coherency of the transactions, signals the host system errors received from controller.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Sai Pavan Boddu <[email protected]>Signed-off-by Vikram Garhwal <[email protected]>Huh? Patch 5/7 is twice in this series ...
[Sai Pavan Boddu] Sorry, that was a mistake. Sending out V7.
Regards,
Sai Pavan
Quoted 3 lines
take care,
Gerd
PATCH v6 6/7 usb: Add DWC3 model
In reply to Sai Pavan BodduFrom: Vikram Garhwal <[email protected]>
This patch adds skeleton model of dwc3 usb controller attached to xhci-sysbus device. It defines global register space of DWC3 controller, global registers control the AXI/AHB interfaces properties, external FIFO support and event count support. All of which are unimplemented at present,we are only supporting core reset and read of ID register.
--- hw/usb/Kconfig | 6 + hw/usb/hcd-dwc3.c | 717 ++++++++++++++++++++++++++++++++++++++++++++++ hw/usb/meson.build | 1 + include/hw/usb/hcd-dwc3.h | 55 ++++ 4 files changed, 779 insertions(+) create mode 100644 hw/usb/hcd-dwc3.c create mode 100644 include/hw/usb/hcd-dwc3.h
hw/usb/Kconfig +6 -0
@@ -116,3 +116,9 @@ config IMX_USBPHY bool default y depends on USB + +config USB_DWC3 + bool + default y if USB_XHCI_SYSBUS + select USB + select REGISTER
hw/usb/hcd-dwc3.c new file +717 -0
717 lines not on this page · raw message
hw/usb/meson.build +1 -0
@@ -26,6 +26,7 @@ softmmu_ss.add(when: 'CONFIG_USB_XHCI_SYSBUS', if_true: files('hcd-xhci-sysbus.c softmmu_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) softmmu_ss.add(when: 'CONFIG_USB_MUSB', if_true: files('hcd-musb.c')) softmmu_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c')) +softmmu_ss.add(when: 'CONFIG_USB_DWC3', if_true: files('hcd-dwc3.c')) softmmu_ss.add(when: 'CONFIG_TUSB6010', if_true: files('tusb6010.c')) softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('chipidea.c'))
include/hw/usb/hcd-dwc3.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 7/7 Versal: Connect DWC3 controller with virt-versal
In reply to Sai Pavan BodduFrom: Vikram Garhwal <[email protected]>
Connect dwc3 controller and usb2-reg module to xlnx-versal SOC, its placed in iou of lpd domain and configure it as dual port host controller. Add the respective guest dts nodes for "xlnx-versal-virt" machine.
--- hw/arm/xlnx-versal-virt.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/arm/xlnx-versal.c | 34 +++++++++++++++++++++++++++ include/hw/arm/xlnx-versal.h | 12 ++++++++++ 3 files changed, 101 insertions(+)
hw/arm/xlnx-versal-virt.c +55 -0
@@ -41,6 +41,8 @@ struct VersalVirt {uint32_t ethernet_phy[2 ];uint32_t clk_125Mhz;uint32_t clk_25Mhz; +uint32_t usb; +uint32_t dwc; } phandle;struct arm_boot_info binfo;
@@ -68,6 +70,8 @@ static void fdt_create(VersalVirt *s) s->phandle.clk_25Mhz =qemu_fdt_alloc_phandle (s->fdt); s->phandle.clk_125Mhz =qemu_fdt_alloc_phandle (s->fdt); + s->phandle.usb =qemu_fdt_alloc_phandle (s->fdt); + s->phandle.dwc =qemu_fdt_alloc_phandle (s->fdt);/* Create /chosen node for load_dtb. */ qemu_fdt_add_subnode (s->fdt,"/chosen" );
@@ -150,6 +154,56 @@ static void fdt_add_timer_nodes(VersalVirt *s) compat, sizeof(compat)); } +static void fdt_add_usb_xhci_nodes (VersalVirt *s) +{ +const char clocknames[] ="bus_clk\0ref_clk" ; +char *name =g_strdup_printf ("/usb@%" PRIx32,MM_USB2_CTRL_REGS ); +const char compat[] ="xlnx,versal-dwc3" ; +qemu_fdt_add_subnode (s->fdt, name); +qemu_fdt_setprop (s->fdt, name,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_USB2_CTRL_REGS , +2 ,MM_USB2_CTRL_REGS_SIZE ); +qemu_fdt_setprop (s->fdt, name,"clock-names" , + clocknames,sizeof (clocknames)); +qemu_fdt_setprop_cells (s->fdt, name,"clocks" , + s->phandle.clk_25Mhz, s->phandle.clk_125Mhz); +qemu_fdt_setprop (s->fdt, name,"ranges" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->fdt, name,"#address-cells" ,2 ); +qemu_fdt_setprop_cell (s->fdt, name,"#size-cells" ,2 ); +qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.usb); +g_free (name); + + { +const char irq_name[] ="dwc_usb3" ; +const char compat[] ="snps,dwc3" ; + name =g_strdup_printf ("/usb@%" PRIx32"/dwc3@%" PRIx32, +MM_USB2_CTRL_REGS ,MM_USB_XHCI_0 ); +qemu_fdt_add_subnode (s->fdt, name); +qemu_fdt_setprop (s->fdt, name,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_USB_XHCI_0 ,2 ,MM_USB_XHCI_0_SIZE ); +qemu_fdt_setprop (s->fdt, name,"interrupt-names" , + irq_name,sizeof (irq_name)); +qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI ,VERSAL_USB0_IRQ_0 , +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop_cell (s->fdt, name, +"snps,quirk-frame-length-adjustment" ,0x20 ); +qemu_fdt_setprop_cells (s->fdt, name,"#stream-id-cells" ,1 ); +qemu_fdt_setprop_string (s->fdt, name,"dr_mode" ,"host" ); +qemu_fdt_setprop_string (s->fdt, name,"phy-names" ,"usb3-phy" ); +qemu_fdt_setprop (s->fdt, name,"snps,dis_u2_susphy_quirk" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,dis_u3_susphy_quirk" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,refclk_fladj" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,mask_phy_reset" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.dwc); +qemu_fdt_setprop_string (s->fdt, name,"maximum-speed" ,"high-speed" ); +g_free (name); + } +}static void fdt_add_uart_nodes (VersalVirt *s) {uint64_t addrs[] = {MM_UART1 ,MM_UART0 };
@@ -517,6 +571,7 @@ static void versal_virt_init(MachineState *machine)fdt_add_gic_nodes (s);fdt_add_timer_nodes (s);fdt_add_zdma_nodes (s); +fdt_add_usb_xhci_nodes (s);fdt_add_sd_nodes (s);fdt_add_rtc_node (s);fdt_add_cpu_nodes (s, psci_conduit);
hw/arm/xlnx-versal.c +34 -0
@@ -145,6 +145,39 @@ static void versal_create_uarts(Versal *s, qemu_irq *pic) } } +static void versal_create_usbs (Versal *s,qemu_irq *pic) +{ +DeviceState *dev, *xhci_dev; +MemoryRegion *mr; + +object_initialize_child (OBJECT (s),"dwc3-0" , &s->lpd.iou.dwc3, +TYPE_USB_DWC3 ); + dev =DEVICE (&s->lpd.iou.dwc3); + xhci_dev =DEVICE (&s->lpd.iou.dwc3.sysbus_xhci); + +object_property_set_link (OBJECT (xhci_dev),"dma" ,OBJECT (&s->mr_ps), + &error_abort); +qdev_prop_set_uint32 (xhci_dev,"intrs" ,1 ); +qdev_prop_set_uint32 (xhci_dev,"slots" ,2 ); + +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB_XHCI_0_DWC3_GLOBAL , mr); + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (xhci_dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB_XHCI_0 , mr); + +sysbus_connect_irq (SYS_BUS_DEVICE (xhci_dev),0 , pic[VERSAL_USB0_IRQ_0 ]); + +object_initialize_child (OBJECT (s),"usb2reg-0" , &s->lpd.iou.Usb2Regs, +TYPE_XILINX_VERSAL_USB2_CTRL_REGS ); + dev =DEVICE (&s->lpd.iou.Usb2Regs); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB2_CTRL_REGS , mr); +} +static void versal_create_gems (Versal *s,qemu_irq *pic) {int i;
@@ -333,6 +366,7 @@ static void versal_realize(DeviceState *dev, Error **errp)versal_create_apu_cpus (s);versal_create_apu_gic (s, pic);versal_create_uarts (s, pic); +versal_create_usbs (s, pic);versal_create_gems (s, pic);versal_create_admas (s, pic);versal_create_sds (s, pic);
include/hw/arm/xlnx-versal.h +12 -0
@@ -21,6 +21,8 @@#include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" +#include "hw/usb/hcd-dwc3.h" +#include "hw/misc/xlnx-versal-usb2-ctrl-regs.h" #define TYPE_XLNX_VERSAL "xlnx-versal"typedef struct Versal Versal ;
@@ -61,6 +63,8 @@ struct Versal {PL011State uart[XLNX_VERSAL_NR_UARTS ];CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ]; +USBDWC3 dwc3; +VersalUsb2CtrlRegs Usb2Regs; } iou; } lpd;
@@ -90,6 +94,7 @@ struct Versal {#define VERSAL_UART0_IRQ_0 18#define VERSAL_UART1_IRQ_0 19 +#define VERSAL_USB0_IRQ_0 22#define VERSAL_GEM0_IRQ_0 56#define VERSAL_GEM0_WAKE_IRQ_0 57#define VERSAL_GEM1_IRQ_0 58
@@ -127,6 +132,13 @@ struct Versal {#define MM_OCM 0xfffc0000U#define MM_OCM_SIZE 0x40000 +#define MM_USB2_CTRL_REGS 0xFF9D0000 +#define MM_USB2_CTRL_REGS_SIZE 0x10000 + +#define MM_USB_XHCI_0 0xFE200000 +#define MM_USB_XHCI_0_SIZE 0x10000 +#define MM_USB_XHCI_0_DWC3_GLOBAL (MM_USB_XHCI_0 + 0xC100) +#define MM_TOP_DDR 0x0#define MM_TOP_DDR_SIZE 0x80000000U#define MM_TOP_DDR_2 0x800000000ULL
Signature · 1 line
2.7.4
Re: [PATCH v6 7/7] Versal: Connect DWC3 controller with virt-versal
Quoted 37 lines · Sai Pavan Boddu
From: Vikram Garhwal <[email protected]>
Connect dwc3 controller and usb2-reg module to xlnx-versal SOC, its placed in iou of lpd domain and configure it as dual port host controller. Add the respective guest dts nodes for "xlnx-versal-virt" machine.
Signed-off-by Vikram Garhwal <[email protected]>Signed-off-by Sai Pavan Boddu <[email protected]>--- hw/arm/xlnx-versal-virt.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/arm/xlnx-versal.c | 34 +++++++++++++++++++++++++++ include/hw/arm/xlnx-versal.h | 12 ++++++++++ 3 files changed, 101 insertions(+)hw/arm/xlnx-versal-virt.c +4
-0@@ -41,6 +41,8 @@ struct VersalVirt {uint32_t ethernet_phy[2 ];uint32_t clk_125Mhz;uint32_t clk_25Mhz; +uint32_t usb; +uint32_t dwc; } phandle;struct arm_boot_info binfo;@@ -68,6 +70,8 @@ static void fdt_create(VersalVirt *s) s->phandle.clk_25Mhz =qemu_fdt_alloc_phandle (s->fdt); s->phandle.clk_125Mhz =qemu_fdt_alloc_phandle (s->fdt); + s->phandle.usb =qemu_fdt_alloc_phandle (s->fdt); + s->phandle.dwc =qemu_fdt_alloc_phandle (s->fdt);/* Create /chosen node for load_dtb. */ qemu_fdt_add_subnode (s->fdt,"/chosen" );
hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s) · line 161
Quoted 8 lines
hw/arm/xlnx-versal-virt.c +5
-0@@ -150,6 +154,56 @@ static void fdt_add_timer_nodes(VersalVirt *s) compat, sizeof(compat)); } +static void fdt_add_usb_xhci_nodes (VersalVirt *s) +{ +const char clocknames[] ="bus_clk\0ref_clk" ; +char *name =g_strdup_printf ("/usb@%" PRIx32,MM_USB2_CTRL_REGS ); +const char compat[] ="xlnx,versal-dwc3" ;
Need a blank line here.
Quoted 9 lines
hw/arm/xlnx-versal-virt.c +9
-0+qemu_fdt_add_subnode (s->fdt, name); +qemu_fdt_setprop (s->fdt, name,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_USB2_CTRL_REGS , +2 ,MM_USB2_CTRL_REGS_SIZE ); +qemu_fdt_setprop (s->fdt, name,"clock-names" , + clocknames,sizeof (clocknames)); + qemu_fdt_setprop_cells(s->fdt, name, "clocks",
hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s) · line 180
Quoted 10 lines
hw/arm/xlnx-versal-virt.c +10
-0+ s->phandle.clk_25Mhz, s->phandle.clk_125Mhz); +qemu_fdt_setprop (s->fdt, name,"ranges" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->fdt, name,"#address-cells" ,2 ); +qemu_fdt_setprop_cell (s->fdt, name,"#size-cells" ,2 ); +qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.usb); +g_free (name); + + { +const char irq_name[] ="dwc_usb3" ; +const char compat[] ="snps,dwc3" ;
Here too.
Quoted 103 lines
hw/arm/xlnx-versal-virt.c +27
-0+ name =g_strdup_printf ("/usb@%" PRIx32"/dwc3@%" PRIx32, +MM_USB2_CTRL_REGS ,MM_USB_XHCI_0 ); +qemu_fdt_add_subnode (s->fdt, name); +qemu_fdt_setprop (s->fdt, name,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_USB_XHCI_0 ,2 ,MM_USB_XHCI_0_SIZE ); +qemu_fdt_setprop (s->fdt, name,"interrupt-names" , + irq_name,sizeof (irq_name)); +qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI ,VERSAL_USB0_IRQ_0 , +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop_cell (s->fdt, name, +"snps,quirk-frame-length-adjustment" ,0x20 ); +qemu_fdt_setprop_cells (s->fdt, name,"#stream-id-cells" ,1 ); +qemu_fdt_setprop_string (s->fdt, name,"dr_mode" ,"host" ); +qemu_fdt_setprop_string (s->fdt, name,"phy-names" ,"usb3-phy" ); +qemu_fdt_setprop (s->fdt, name,"snps,dis_u2_susphy_quirk" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,dis_u3_susphy_quirk" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,refclk_fladj" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,mask_phy_reset" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.dwc); +qemu_fdt_setprop_string (s->fdt, name,"maximum-speed" ,"high-speed" ); +g_free (name); + } +}static void fdt_add_uart_nodes (VersalVirt *s) {uint64_t addrs[] = {MM_UART1 ,MM_UART0 };@@ -517,6 +571,7 @@ static void versal_virt_init(MachineState *machine)fdt_add_gic_nodes (s);fdt_add_timer_nodes (s);fdt_add_zdma_nodes (s); +fdt_add_usb_xhci_nodes (s);fdt_add_sd_nodes (s);fdt_add_rtc_node (s);fdt_add_cpu_nodes (s, psci_conduit);hw/arm/xlnx-versal.c +34
-0@@ -145,6 +145,39 @@ static void versal_create_uarts(Versal *s, qemu_irq *pic) } } +static void versal_create_usbs (Versal *s,qemu_irq *pic) +{ +DeviceState *dev, *xhci_dev; +MemoryRegion *mr; + +object_initialize_child (OBJECT (s),"dwc3-0" , &s->lpd.iou.dwc3, +TYPE_USB_DWC3 ); + dev =DEVICE (&s->lpd.iou.dwc3); + xhci_dev =DEVICE (&s->lpd.iou.dwc3.sysbus_xhci); + +object_property_set_link (OBJECT (xhci_dev),"dma" ,OBJECT (&s->mr_ps), + &error_abort); +qdev_prop_set_uint32 (xhci_dev,"intrs" ,1 ); +qdev_prop_set_uint32 (xhci_dev,"slots" ,2 ); + +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB_XHCI_0_DWC3_GLOBAL , mr); + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (xhci_dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB_XHCI_0 , mr); + +sysbus_connect_irq (SYS_BUS_DEVICE (xhci_dev),0 , pic[VERSAL_USB0_IRQ_0 ]); + +object_initialize_child (OBJECT (s),"usb2reg-0" , &s->lpd.iou.Usb2Regs, +TYPE_XILINX_VERSAL_USB2_CTRL_REGS ); + dev =DEVICE (&s->lpd.iou.Usb2Regs); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB2_CTRL_REGS , mr); +} +static void versal_create_gems (Versal *s,qemu_irq *pic) {int i;@@ -333,6 +366,7 @@ static void versal_realize(DeviceState *dev, Error **errp)versal_create_apu_cpus (s);versal_create_apu_gic (s, pic);versal_create_uarts (s, pic); +versal_create_usbs (s, pic);versal_create_gems (s, pic);versal_create_admas (s, pic);versal_create_sds (s, pic);include/hw/arm/xlnx-versal.h +2
-0@@ -21,6 +21,8 @@#include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" +#include "hw/usb/hcd-dwc3.h" +#include "hw/misc/xlnx-versal-usb2-ctrl-regs.h" #define TYPE_XLNX_VERSAL "xlnx-versal"typedef struct Versal Versal ;
include/hw/arm/xlnx-versal.h struct Versal { · line 67
Quoted 5 lines
include/hw/arm/xlnx-versal.h +2
-0@@ -61,6 +63,8 @@ struct Versal {PL011State uart[XLNX_VERSAL_NR_UARTS ];CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ]; +USBDWC3 dwc3; +VersalUsb2CtrlRegs Usb2Regs;
Can you please add a sub-struct for the usb stuff? e.g:
struct {
USBDWC3 dwc3;
VersalUsb2CtrlRegs regs;
} usb;Quoted 28 lines
include/hw/arm/xlnx-versal.h +8
-0} iou; } lpd;@@ -90,6 +94,7 @@ struct Versal {#define VERSAL_UART0_IRQ_0 18#define VERSAL_UART1_IRQ_0 19 +#define VERSAL_USB0_IRQ_0 22#define VERSAL_GEM0_IRQ_0 56#define VERSAL_GEM0_WAKE_IRQ_0 57#define VERSAL_GEM1_IRQ_0 58@@ -127,6 +132,13 @@ struct Versal {#define MM_OCM 0xfffc0000U#define MM_OCM_SIZE 0x40000 +#define MM_USB2_CTRL_REGS 0xFF9D0000 +#define MM_USB2_CTRL_REGS_SIZE 0x10000 + +#define MM_USB_XHCI_0 0xFE200000 +#define MM_USB_XHCI_0_SIZE 0x10000 +#define MM_USB_XHCI_0_DWC3_GLOBAL (MM_USB_XHCI_0 + 0xC100) +#define MM_TOP_DDR 0x0#define MM_TOP_DDR_SIZE 0x80000000U#define MM_TOP_DDR_2 0x800000000ULLSignature · 1 line
2.7.4
RE: [PATCH v6 7/7] Versal: Connect DWC3 controller with virt-versal
Hi Edgar,
Thanks for suggestions, I will send V7 with those changes.
Regards,
Sai Pavan
Quoted 238 lines
-----Original Message-----
From: Edgar E. Iglesias <[email protected]>
Sent: Wednesday, September 16, 2020 6:01 PM
To: Sai Pavan Boddu <[email protected]>
Cc: Peter Maydell <[email protected]>; Markus Armbruster <[email protected]>; 'Marc-André Lureau' <[email protected]>; Paolo Bonzini <[email protected]>; Gerd Hoffmann <[email protected]>; Edgar Iglesias <[email protected]>; Francisco Eduardo Iglesias <[email protected]>; [email protected]; Alistair Francis <[email protected]>; Eduardo Habkost <[email protected]>; Ying Fang <[email protected]>; 'Philippe Mathieu-Daudé' <[email protected]>; Vikram Garhwal <[email protected]>; Paul Zimmerman <[email protected]>; Sai Pavan Boddu <[email protected]>
Subject: Re: [PATCH v6 7/7] Versal: Connect DWC3 controller with virt-versalQuoted 5 lines · Sai Pavan Boddu
From: Vikram Garhwal <[email protected]>
Connect dwc3 controller and usb2-reg module to xlnx-versal SOC, its placed in iou of lpd domain and configure it as dual port host controller. Add the respective guest dts nodes for "xlnx-versal-virt"
machine.
Quoted 5 lines
Signed-off-by Vikram Garhwal <[email protected]>Signed-off-by Sai Pavan Boddu <[email protected]>--- hw/arm/xlnx-versal-virt.c | 55++++++++++++++++++++++++++++++++++++++++++++
Quoted 27 lines
hw/arm/xlnx-versal.c | 34 +++++++++++++++++++++++++++ include/hw/arm/xlnx-versal.h | 12 ++++++++++ 3 files changed, 101 insertions(+)hw/arm/xlnx-versal-virt.c +4
-0@@ -41,6 +41,8 @@ struct VersalVirt {uint32_t ethernet_phy[2 ];uint32_t clk_125Mhz;uint32_t clk_25Mhz; +uint32_t usb; +uint32_t dwc; } phandle;struct arm_boot_info binfo;@@ -68,6 +70,8 @@ static void fdt_create(VersalVirt *s) s->phandle.clk_25Mhz =qemu_fdt_alloc_phandle (s->fdt); s->phandle.clk_125Mhz =qemu_fdt_alloc_phandle (s->fdt); + s->phandle.usb =qemu_fdt_alloc_phandle (s->fdt); + s->phandle.dwc =qemu_fdt_alloc_phandle (s->fdt);/* Create /chosen node for load_dtb. */ qemu_fdt_add_subnode (s->fdt,"/chosen" );hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s) · line 158
Quoted 5 lines
hw/arm/xlnx-versal-virt.c +3
-0@@ -150,6 +154,56 @@ static void fdt_add_timer_nodes(VersalVirt *s) compat, sizeof(compat)); } +static void fdt_add_usb_xhci_nodes (VersalVirt *s) { +const char clocknames[] ="bus_clk\0ref_clk" ; + char *name = g_strdup_printf("/usb@%" PRIx32,
MM_USB2_CTRL_REGS);hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s) · line 161
Quoted 1 line
hw/arm/xlnx-versal-virt.c +1
-0+const char compat[] ="xlnx,versal-dwc3" ;Need a blank line here.
Quoted 9 lines
hw/arm/xlnx-versal-virt.c +9
-0+qemu_fdt_add_subnode (s->fdt, name); +qemu_fdt_setprop (s->fdt, name,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_USB2_CTRL_REGS , +2 ,MM_USB2_CTRL_REGS_SIZE ); +qemu_fdt_setprop (s->fdt, name,"clock-names" , + clocknames,sizeof (clocknames)); + qemu_fdt_setprop_cells(s->fdt, name, "clocks",hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s) · line 180
Quoted 10 lines
hw/arm/xlnx-versal-virt.c +10
-0+ s->phandle.clk_25Mhz, s->phandle.clk_125Mhz); +qemu_fdt_setprop (s->fdt, name,"ranges" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->fdt, name,"#address-cells" ,2 ); +qemu_fdt_setprop_cell (s->fdt, name,"#size-cells" ,2 ); +qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.usb); +g_free (name); + + { +const char irq_name[] ="dwc_usb3" ; +const char compat[] ="snps,dwc3" ;Here too.
Quoted 8 lines
hw/arm/xlnx-versal-virt.c +8
-0+ name =g_strdup_printf ("/usb@%" PRIx32"/dwc3@%" PRIx32, +MM_USB2_CTRL_REGS ,MM_USB_XHCI_0 ); +qemu_fdt_add_subnode (s->fdt, name); +qemu_fdt_setprop (s->fdt, name,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_USB_XHCI_0 ,2 ,MM_USB_XHCI_0_SIZE ); + qemu_fdt_setprop(s->fdt, name, "interrupt-names",hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s)
Quoted 10 lines
hw/arm/xlnx-versal-virt.c +10
-0+ irq_name, sizeof(irq_name)); +qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI ,VERSAL_USB0_IRQ_0 , +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop_cell (s->fdt, name, +"snps,quirk-frame-length-adjustment" ,0x20 ); +qemu_fdt_setprop_cells (s->fdt, name,"#stream-id-cells" ,1 ); +qemu_fdt_setprop_string (s->fdt, name,"dr_mode" ,"host" ); +qemu_fdt_setprop_string (s->fdt, name,"phy-names" ,"usb3-phy" ); + qemu_fdt_setprop(s->fdt, name, "snps,dis_u2_susphy_quirk", NULL,0);
hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s) · line 197
Quoted 1 line
hw/arm/xlnx-versal-virt.c +1
-0+ qemu_fdt_setprop(s->fdt, name, "snps,dis_u3_susphy_quirk", NULL,0);
hw/arm/xlnx-versal-virt.c static void fdt_add_timer_nodes(VersalVirt *s)
Quoted 4 lines
hw/arm/xlnx-versal-virt.c +4
-0+qemu_fdt_setprop (s->fdt, name,"snps,refclk_fladj" ,NULL ,0 ); +qemu_fdt_setprop (s->fdt, name,"snps,mask_phy_reset" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.dwc); + qemu_fdt_setprop_string(s->fdt, name, "maximum-speed", "high-speed");
hw/arm/xlnx-versal.c static void versal_create_uarts(Versal *s,
Quoted 18 lines
hw/arm/xlnx-versal-virt.c +4
-0+g_free (name); + } +}static void fdt_add_uart_nodes (VersalVirt *s) { uint64_t addrs[] = { MM_UART1, MM_UART0 }; @@ -517,6 +571,7 @@ static void versal_virt_init(MachineState *machine) fdt_add_gic_nodes(s);fdt_add_timer_nodes (s);fdt_add_zdma_nodes (s); +fdt_add_usb_xhci_nodes (s);fdt_add_sd_nodes (s);fdt_add_rtc_node (s); fdt_add_cpu_nodes(s, psci_conduit); diff --git
a/hw/arm/xlnx-versal.cb/hw/arm/xlnx-versal.cindex 12ba6c4..88f7dc8 100644hw/arm/xlnx-versal.c +0
-0@@ -145,6 +145,39 @@ static void versal_create_uarts(Versal *s,
qemu_irq*pic)Quoted 12 lines
hw/arm/xlnx-versal.c +9
-0} } +static void versal_create_usbs (Versal *s,qemu_irq *pic) { +DeviceState *dev, *xhci_dev; +MemoryRegion *mr; + +object_initialize_child (OBJECT (s),"dwc3-0" , &s->lpd.iou.dwc3, +TYPE_USB_DWC3 ); + dev =DEVICE (&s->lpd.iou.dwc3); + xhci_dev =DEVICE (&s->lpd.iou.dwc3.sysbus_xhci); +hw/arm/xlnx-versal.c static void versal_create_uarts(Versal *s, qemu_irq *pic)
Quoted 10 lines
hw/arm/xlnx-versal.c +9
-0+object_property_set_link (OBJECT (xhci_dev),"dma" ,OBJECT (&s- mr_ps), + &error_abort); +qdev_prop_set_uint32 (xhci_dev,"intrs" ,1 ); +qdev_prop_set_uint32 (xhci_dev,"slots" ,2 ); + +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); + memory_region_add_subregion(&s->mr_ps,
MM_USB_XHCI_0_DWC3_GLOBAL, mr);hw/arm/xlnx-versal.c static void versal_create_uarts(Versal *s, qemu_irq *pic)
Quoted 13 lines
hw/arm/xlnx-versal.c +13
-0+ mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (xhci_dev),0 ); +memory_region_add_subregion (&s->mr_ps,MM_USB_XHCI_0 , mr); + +sysbus_connect_irq (SYS_BUS_DEVICE (xhci_dev),0 , + pic[VERSAL_USB0_IRQ_0 ]); + +object_initialize_child (OBJECT (s),"usb2reg-0" , &s->lpd.iou.Usb2Regs, +TYPE_XILINX_VERSAL_USB2_CTRL_REGS ); + dev =DEVICE (&s->lpd.iou.Usb2Regs); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); + memory_region_add_subregion(&s->mr_ps, MM_USB2_CTRL_REGS,mr); }
hw/arm/xlnx-versal.c static void versal_realize(DeviceState *dev, Error
Quoted 4 lines
hw/arm/xlnx-versal.c +1
-0+static void versal_create_gems (Versal *s,qemu_irq *pic) {int i;@@ -333,6 +366,7 @@ static void versal_realize(DeviceState *dev, Error**errp)
Quoted 21 lines
hw/arm/xlnx-versal.c +1
-0versal_create_apu_cpus (s);versal_create_apu_gic (s, pic);versal_create_uarts (s, pic); +versal_create_usbs (s, pic);versal_create_gems (s, pic);versal_create_admas (s, pic);versal_create_sds (s, pic);(quoted diff) +0
-0
b/include/hw/arm/xlnx-versal.hindex eaa9023..a428933 100644include/hw/arm/xlnx-versal.h +2
-0@@ -21,6 +21,8 @@#include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" +#include "hw/usb/hcd-dwc3.h" +#include "hw/misc/xlnx-versal-usb2-ctrl-regs.h" #define TYPE_XLNX_VERSAL "xlnx-versal"typedef struct Versal Versal ;include/hw/arm/xlnx-versal.h struct Versal { · line 67
Quoted 5 lines
include/hw/arm/xlnx-versal.h +2
-0@@ -61,6 +63,8 @@ struct Versal {PL011State uart[XLNX_VERSAL_NR_UARTS ];CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ]; +USBDWC3 dwc3; +VersalUsb2CtrlRegs Usb2Regs;Can you please add a sub-struct for the usb stuff? e.g:
struct { USBDWC3 dwc3; VersalUsb2CtrlRegs regs; } usb;Quoted 28 lines
include/hw/arm/xlnx-versal.h +8
-1} iou; } lpd;@@ -90,6 +94,7 @@ struct Versal {#define VERSAL_UART0_IRQ_0 18#define VERSAL_UART1_IRQ_0 19 +#define VERSAL_USB0_IRQ_0 22#define VERSAL_GEM0_IRQ_0 56#define VERSAL_GEM0_WAKE_IRQ_0 57#define VERSAL_GEM1_IRQ_0 58@@ -127,6 +132,13 @@ struct Versal {#define MM_OCM 0xfffc0000U#define MM_OCM_SIZE 0x40000 +#define MM_USB2_CTRL_REGS 0xFF9D0000 +#define MM_USB2_CTRL_REGS_SIZE 0x10000 + +#define MM_USB_XHCI_0 0xFE200000 +#define MM_USB_XHCI_0_SIZE 0x10000 +#define MM_USB_XHCI_0_DWC3_GLOBAL (MM_USB_XHCI_0 + 0xC100) +#define MM_TOP_DDR 0x0#define MM_TOP_DDR_SIZE 0x80000000U#define MM_TOP_DDR_2 0x800000000ULL --2.7.4