[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 06/18] hw/usb/hcd-dwc2: Add an auto-hub property and leave it off



dwc2 has one root port and runs at full speed, so a second device only
fits behind the hub.

Add auto-hub and leave it off. raspi has no versioned machine type, so
compat cannot reach it. bcm2835_peripherals turns the property on, and
raspi keeps the hub it has today.

Suggested-by: Gerd Hoffmann <kraxel@xxxxxxxxxx>
Signed-off-by: Jamin Lin <jamin_lin@xxxxxxxxxxxxxx>
---
 hw/usb/hcd-dwc2.h            | 1 +
 hw/arm/bcm2835_peripherals.c | 1 +
 hw/usb/hcd-dwc2.c            | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h
index 68877661ca..be06f0b0e7 100644
--- a/hw/usb/hcd-dwc2.h
+++ b/hw/usb/hcd-dwc2.h
@@ -167,6 +167,7 @@ struct DWC2State {
     uint16_t fi;
     uint16_t next_chan;
     bool working;
+    bool auto_hub;
     USBPort uport;
     DWC2Packet packet[DWC2_NB_CHAN];                   /* one packet per chan 
*/
     uint8_t usb_buf[DWC2_NB_CHAN][DWC2_MAX_XFER_SIZE]; /* one buffer per chan 
*/
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 558c180df9..9187376812 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -152,6 +152,7 @@ static void raspi_peripherals_base_init(Object *obj)
 
     /* DWC2 */
     object_initialize_child(obj, "dwc2", &s->dwc2, TYPE_DWC2_USB);
+    qdev_prop_set_bit(DEVICE(&s->dwc2), "auto-hub", true);
 
     /* CPRMAN clock manager */
     object_initialize_child(obj, "cprman", &s->cprman, TYPE_BCM2835_CPRMAN);
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index cd3b61158d..14211e6413 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -1354,6 +1354,7 @@ static void dwc2_realize(DeviceState *dev, Error **errp)
     address_space_init(&s->dma_as, s->dma_mr, "dwc2");
 
     usb_bus_new(&s->bus, sizeof(s->bus), &dwc2_bus_ops, dev);
+    s->bus.auto_hub = s->auto_hub;
     usb_register_port(&s->bus, &s->uport, s, 0, &dwc2_port_ops,
                       USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL |
                       (s->usb_version == 2 ? USB_SPEED_MASK_HIGH : 0));
@@ -1450,6 +1451,7 @@ const VMStateDescription vmstate_dwc2_state = {
 
 static const Property dwc2_usb_properties[] = {
     DEFINE_PROP_UINT32("usb_version", DWC2State, usb_version, 2),
+    DEFINE_PROP_BOOL("auto-hub", DWC2State, auto_hub, false),
 };
 
 static void dwc2_class_init(ObjectClass *klass, const void *data)
-- 
2.43.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.