-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Support multiple devices to connect with usb host if usb hub is used #99591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -447,11 +447,33 @@ | |
| return err; | ||
| } | ||
|
|
||
| struct usb_device *usbh_device_get_root(struct usbh_context *const ctx) | ||
| { | ||
| sys_dnode_t *node; | ||
|
|
||
| node = sys_dlist_peek_head(&ctx->udevs); | ||
| if (node == NULL) { | ||
| /* No devices in the list */ | ||
| return NULL; | ||
| } | ||
|
|
||
| /* Get the usb_device structure from the node */ | ||
| return CONTAINER_OF(node, struct usb_device, node); | ||
| } | ||
|
|
||
| bool usbh_device_is_root(struct usbh_context *const ctx, | ||
| struct usb_device *const udev) | ||
| { | ||
| return sys_dlist_peek_head(&ctx->udevs) == &udev->node; | ||
| } | ||
|
|
||
| int usbh_device_init(struct usb_device *const udev) | ||
| { | ||
| struct usbh_context *const uhs_ctx = udev->ctx; | ||
| uint8_t new_addr; | ||
| int err; | ||
| sys_dnode_t *node; | ||
|
Check warning on line 475 in subsys/usb/host/usbh_device.c
|
||
| uint8_t device_count = 0; | ||
|
|
||
| if (udev->state != USB_STATE_DEFAULT) { | ||
| LOG_ERR("USB device is not in default state"); | ||
|
|
@@ -464,11 +486,17 @@ | |
| return err; | ||
| } | ||
|
|
||
| /* FIXME: The port to which the device is connected should be reset. */ | ||
| err = uhc_bus_reset(uhs_ctx->dev); | ||
| if (err) { | ||
| LOG_ERR("Failed to signal bus reset"); | ||
| return err; | ||
| k_mutex_lock(&uhs_ctx->mutex, K_FOREVER); | ||
| device_count = sys_dlist_len(&uhs_ctx->udevs); | ||
| k_mutex_unlock(&uhs_ctx->mutex); | ||
|
|
||
| /* Only reset bus if this is the root device. */ | ||
| if (device_count == 1U) { | ||
| err = uhc_bus_reset(uhs_ctx->dev); | ||
| if (err) { | ||
| LOG_ERR("Failed to signal bus reset"); | ||
| return err; | ||
| } | ||
|
Comment on lines
+494
to
+499
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about PORT_RESET hub class feature? Where this should be handled? At high-level Linux solves the issue by having a software-only hub at the top level.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hi @tmon-nordic |
||
| } | ||
|
|
||
| /* | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.