USB class: support multiple USB host controllers#100703
USB class: support multiple USB host controllers#100703fabiobaltieri merged 1 commit intozephyrproject-rtos:mainfrom
Conversation
|
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
551f7e3 to
423c266
Compare
| /** Host initialization handler, before any device is connected */ | ||
| int (*init)(struct usbh_class_data *const c_data, | ||
| struct usbh_context *const uhs_ctx); | ||
| int (*init)(struct usbh_class_data *const c_data); |
There was a problem hiding this comment.
Only bind to a controller after probing.
Something like c_data->uhs_ctx = udev->ctx; is missed here
zephyr/subsys/usb/host/usbh_class.c
Lines 128 to 130 in d6c47f2
Also, c_data->uhs_ctx seems to be redundant.
There was a problem hiding this comment.
I tried to remove the redundacy by removing the uhs_ctx field, available from udev->ctx.
There was a problem hiding this comment.
We may need a helper to get the host support context, like
diff --git a/subsys/usb/host/usbh_class.h b/subsys/usb/host/usbh_class.h
index 0b3d673c058..eb005b0922e 100644
--- a/subsys/usb/host/usbh_class.h
+++ b/subsys/usb/host/usbh_class.h
@@ -60,4 +60,13 @@ void usbh_class_probe_device(struct usb_device *const udev);
*/
void usbh_class_remove_all(struct usb_device *const udev);
+static inline struct usbh_context *usbh_class_get_ctx(struct usbh_class_data *const c_data)
+{
+ if (c_data->udev != NULL) {
+ return c_data->udev->ctx;
+ }
+
+ return NULL;
+}
+
#endif /* ZEPHYR_INCLUDE_USBH_CLASS_H */There was a problem hiding this comment.
Added and rebased on top of latest main.
Edit: that was not the intent to add it now, so removed it in order to keep it for later.
423c266 to
b181a66
Compare
7d72ab0 to
902d4d3
Compare
902d4d3 to
5e601bb
Compare
Only bind to a controller after probing. Wait that a class is matching and assigned to a device to assign a host controller to a class. This allows a class to be used by any of the controller in place. Remove the `c_data->uhs_ctx` field, not used anywhere, in favor of using `c_data->udev->ctx`. Signed-off-by: Josuah Demangeon <me@josuah.net>
|



Dependencies:
Do not bind an USB host controller context during init.
Instead only use the
c_data->udev = udev;assignment that happens inprobe()to give the class the USB context.This means that class can be used by a controller or another depending on which side the USB device is connected, and this shares resources between the ports.