DECLARE_GLOBAL_DATA_PTR;
+struct sandbox_usb_ctrl {
+ int rootdev;
+};
+
static void usbmon_trace(struct udevice *bus, ulong pipe,
struct devrequest *setup, struct udevice *emul)
{
void *buffer, int length,
struct devrequest *setup)
{
+ struct sandbox_usb_ctrl *ctrl = dev_get_priv(bus);
struct udevice *emul;
int ret;
usbmon_trace(bus, pipe, setup, emul);
if (ret)
return ret;
+
+ if (usb_pipedevice(pipe) == ctrl->rootdev) {
+ if (setup->request == USB_REQ_SET_ADDRESS) {
+ debug("%s: Set root hub's USB address\n", __func__);
+ ctrl->rootdev = le16_to_cpu(setup->value);
+ }
+ }
+
ret = usb_emul_control(emul, udev, pipe, buffer, length, setup);
if (ret < 0) {
debug("ret=%d\n", ret);
static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev)
{
+ struct sandbox_usb_ctrl *ctrl = dev_get_priv(dev);
+
+ /*
+ * Root hub will be the first device to be initailized.
+ * If this device is a root hub, initialize its device speed
+ * to high speed as we are a USB 2.0 controller.
+ */
+ if (ctrl->rootdev == 0)
+ udev->speed = USB_SPEED_HIGH;
+
return 0;
}
.of_match = sandbox_usb_ids,
.probe = sandbox_usb_probe,
.ops = &sandbox_usb_ops,
+ .priv_auto_alloc_size = sizeof(struct sandbox_usb_ctrl),
};