Commit 9ca1b4bab10d8b3a5dbbbd98df46ce75159222b8
Committed by
Marek Vasut
1 parent
5624dfd5aa
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
dm: usb: Add a new USB controller operation 'update_hub_device'
For USB host controllers like xHC, its internal representation of hub needs to be updated after the hub descriptor is fetched. This adds a new op that does this. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 2 changed files with 31 additions and 1 deletions Side-by-side Diff
drivers/usb/host/usb-uclass.c
... | ... | @@ -139,6 +139,17 @@ |
139 | 139 | return ops->reset_root_port(bus, udev); |
140 | 140 | } |
141 | 141 | |
142 | +int usb_update_hub_device(struct usb_device *udev) | |
143 | +{ | |
144 | + struct udevice *bus = udev->controller_dev; | |
145 | + struct dm_usb_ops *ops = usb_get_ops(bus); | |
146 | + | |
147 | + if (!ops->update_hub_device) | |
148 | + return -ENOSYS; | |
149 | + | |
150 | + return ops->update_hub_device(bus, udev); | |
151 | +} | |
152 | + | |
142 | 153 | int usb_stop(void) |
143 | 154 | { |
144 | 155 | struct udevice *bus; |
include/usb.h
... | ... | @@ -758,6 +758,14 @@ |
758 | 758 | * reset_root_port() - Reset usb root port |
759 | 759 | */ |
760 | 760 | int (*reset_root_port)(struct udevice *bus, struct usb_device *udev); |
761 | + | |
762 | + /** | |
763 | + * update_hub_device() - Update HCD's internal representation of hub | |
764 | + * | |
765 | + * After a hub descriptor is fetched, notify HCD so that its internal | |
766 | + * representation of this hub can be updated (xHCI) | |
767 | + */ | |
768 | + int (*update_hub_device)(struct udevice *bus, struct usb_device *udev); | |
761 | 769 | }; |
762 | 770 | |
763 | 771 | #define usb_get_ops(dev) ((struct dm_usb_ops *)(dev)->driver->ops) |
... | ... | @@ -931,6 +939,17 @@ |
931 | 939 | int usb_alloc_device(struct usb_device *dev); |
932 | 940 | |
933 | 941 | /** |
942 | + * update_hub_device() - Update HCD's internal representation of hub | |
943 | + * | |
944 | + * After a hub descriptor is fetched, notify HCD so that its internal | |
945 | + * representation of this hub can be updated. | |
946 | + * | |
947 | + * @dev: Hub device | |
948 | + * @return 0 if OK, -ve on error | |
949 | + */ | |
950 | +int usb_update_hub_device(struct usb_device *dev); | |
951 | + | |
952 | +/** | |
934 | 953 | * usb_emul_setup_device() - Set up a new USB device emulation |
935 | 954 | * |
936 | 955 | * This is normally called when a new emulation device is bound. It tells |
... | ... | @@ -943,7 +962,7 @@ |
943 | 962 | * @desc_list: List of points or USB descriptors, terminated by NULL. |
944 | 963 | * The first entry must be struct usb_device_descriptor, |
945 | 964 | * and others follow on after that. |
946 | - * @return 0 if OK, -ve on error | |
965 | + * @return 0 if OK, -ENOSYS if not implemented, other -ve on error | |
947 | 966 | */ |
948 | 967 | int usb_emul_setup_device(struct udevice *dev, int maxpacketsize, |
949 | 968 | struct usb_string *strings, void **desc_list); |