Hi,
I thought I'd forward this patch ... the patch comments
cover the technical stuff. High Speed OTG support ... ;)
- Dave
Partial OTG support for dummy_hcd, mostly as a framework for further work.
It emulates the new OTG flags in the host and peripheral frameworks, if
that option is configured. But it's incomplete:
- Resetting the peripheral needs to clear the OTG state bits;
a second enumeration won't work correctly.
- This stops modeling HNP right when roles should switch the first time.
It should probably disconnect, then set the usb_bus.is_b_host and
usb_gadget.is_a_peripheral flags; then it'd enumerate almost normally,
except for the role reversal. Roles could then switch a second time,
back to "normal" (with those flags cleared).
- SRP should be modeled as "resume from port-unpowered", which is
a state that usbcore doesn't yet use.
HNP can be triggered by enabling the OTG whitelist and configuring a
gadget driver that's not in that list; or by configuring Gadget Zero
to identify itself as the HNP test device.
--- a/drivers/usb/gadget/Kconfig 2004-10-28 11:05:41 -07:00
+++ b/drivers/usb/gadget/Kconfig 2004-10-28 11:05:41 -07:00
@@ -181,6 +181,15 @@
dynamically linked module called "dummy_hcd" and force all
gadget drivers to also be dynamically linked.
+config USB_OTG
+ boolean "OTG support for Dummy HCD (DEVELOPMENT)"
+ depends on USB_GADGET_DUMMY_HCD
+ help
+ Say "y" build the dummy HCD with API support for USB OTG. This
+ is incomplete, because the "A-Peripheral" and "B-Host" devices
+ are not yet emulated ... only "A-Host" and "B-Peripheral", which
+ behaves as if OTG weren't active at all.
+
config USB_DUMMY_HCD
tristate
depends on USB_GADGET_DUMMY_HCD
--- a/drivers/usb/gadget/dummy_hcd.c 2004-10-28 11:05:41 -07:00
+++ b/drivers/usb/gadget/dummy_hcd.c 2004-10-28 11:05:41 -07:00
@@ -564,8 +564,10 @@
struct dummy *dum;
dum = container_of (_gadget, struct dummy, gadget);
- if ((dum->devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) == 0
- || !(dum->port_status & (1 << USB_PORT_FEAT_SUSPEND)))
+ if (!(dum->port_status & (1 << USB_PORT_FEAT_SUSPEND))
+ || !(dum->devstatus &
+ ( (1 << USB_DEVICE_B_HNP_ENABLE)
+ | (1 << USB_DEVICE_REMOTE_WAKEUP))))
return -EINVAL;
/* hub notices our request, issues downstream resume, etc */
@@ -684,6 +686,9 @@
dum->gadget.ops = &dummy_ops;
dum->gadget.is_dualspeed = 1;
+ /* maybe claim OTG support, though we won't complete HNP */
+ dum->gadget.is_otg = (dum->hcd.self.otg_port != 0);
+
dum->devstatus = 0;
dum->resuming = 0;
@@ -1177,6 +1182,16 @@
switch (setup.wValue) {
case USB_DEVICE_REMOTE_WAKEUP:
break;
+ case USB_DEVICE_B_HNP_ENABLE:
+ dum->gadget.b_hnp_enable = 1;
+ break;
+ case USB_DEVICE_A_HNP_SUPPORT:
+ dum->gadget.a_hnp_support = 1;
+ break;
+ case USB_DEVICE_A_ALT_HNP_SUPPORT:
+ dum->gadget.a_alt_hnp_support
+ = 1;
+ break;
default:
value = -EOPNOTSUPP;
}
@@ -1493,6 +1508,13 @@
spin_unlock (&dum->lock);
dum->driver->suspend (&dum->gadget);
spin_lock (&dum->lock);
+ /* HNP would happen here; for now we
+ * assume b_bus_req is always true.
+ */
+ if (((1 << USB_DEVICE_B_HNP_ENABLE)
+ & dum->devstatus) != 0)
+ dev_dbg (hardware,
+ "no HNP yet!\n");
}
}
break;
@@ -1689,6 +1711,9 @@
/* root hub enters addressed state... */
dum->hcd.state = USB_STATE_RUNNING;
root->speed = USB_SPEED_HIGH;
+#ifdef CONFIG_USB_OTG
+ bus->otg_port = 1;
+#endif
/* ...then configured, so khubd sees us. */
if ((retval = hcd_register_root (root, &dum->hcd)) != 0) {