Skip to contentSkip to conversation

hw/usb/hcd-dwc2: Simplified I/O memory regions

PATCH In review Philippe Mathieu-Daudé 2 participants 2 messages Apr 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/usb/hcd-dwc2: Simplified I/O memory regions

Use 1 container holding 2 regions:
- I/O registers
- FIFOs

Remove all the static base addresses.

Name address space.

---
Sometime a patch is cleaner/quicker than explanations. Suggestion to be squashed on patch:
'dwc-hsotg (dwc2) USB host controller emulation'

Further simplificatio would be to move some exploded read/write functions directly into dwc2_hsotg_read/write.

Based-on: <[email protected]>

---
 hw/usb/hcd-dwc2.h |  17 +----
 hw/usb/hcd-dwc2.c | 181 ++++++++++++++++++++++------------------------
 2 files changed, 88 insertions(+), 110 deletions(-)
hw/usb/hcd-dwc2.h +3 -14
index 403afd1747..7d7ea604a4 100644
@@ -61,20 +61,9 @@ struct DWC2State {
     qemu_irq irq;
     MemoryRegion *dma_mr;
     AddressSpace dma_as;
-    MemoryRegion mem;
-    MemoryRegion mem_glbreg;
-    MemoryRegion mem_fszreg;
-    MemoryRegion mem_hreg0;
-    MemoryRegion mem_hreg1;
-    MemoryRegion mem_pcgreg;
-    MemoryRegion mem_hreg2;
-
-    uint16_t glbregbase;
-    uint16_t fszregbase;
-    uint16_t hreg0base;
-    uint16_t hreg1base;
-    uint16_t pcgregbase;
-    uint16_t hfifobase;
+    MemoryRegion container;
+    MemoryRegion hsotg;
+    MemoryRegion fifos;
 
     union {
 #define DWC2_GLBREG_SIZE    0x70
hw/usb/hcd-dwc2.c +85 -96

322 lines not on this page · raw message

Signature · 1 line
2.21.1
#1 lore raw
Quoted 14 lines · Philippe Mathieu-Daudé

Use 1 container holding 2 regions:
- I/O registers
- FIFOs

Remove all the static base addresses.

Name address space.

---
Sometime a patch is cleaner/quicker than explanations. Suggestion to be squashed on patch:
'dwc-hsotg (dwc2) USB host controller emulation'

Quoted 8 lines

Further simplificatio would be to move some exploded read/write functions directly into dwc2_hsotg_read/write.

Based-on: <[email protected]>

---
  hw/usb/hcd-dwc2.h |  17 +----
  hw/usb/hcd-dwc2.c | 181 ++++++++++++++++++++++------------------------
  2 files changed, 88 insertions(+), 110 deletions(-)

<snip>

Ooh, yes, that looks much cleaner and simpler, thanks! I will test this and fold it into the next version of the patch.

Quoted 3 lines
  static Property dwc2_usb_properties[] = {
      DEFINE_PROP_UINT32("usb_version", DWC2State, usb_version, 2),

+ /* FIXME isn't 'usb_version=2' const? */

This allows to switch between full-speed and high-speed at boot time, which I've found very useful for testing purposes.

Quoted 4 lines

+ DEFINE_PROP_END_OF_LIST()
};

static void dwc2_class_init(ObjectClass *klass, void *data)

Thanks,
Paul