[PATCH] usb: dwc3: Integrate usb5744 & usb2244 driver support
Venkatesh Yadav Abbarapu
venkatesh.abbarapu at amd.com
Thu Jan 11 08:10:57 CET 2024
Usb5744 & usb2244 are Microchip based usbhub and usb-2.0 based SD
controller devices. Integrate these devices into dwc3 driver to bind and
probe the respective drivers to get detected by usb controller.
Signed-off-by: T Karthik Reddy <t.karthik.reddy at xilinx.com>
Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu at amd.com>
---
drivers/usb/dwc3/dwc3-generic.c | 67 ++++++++++++++++++++++++---------
1 file changed, 49 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 6fb2de8a5a..a2eb2c8e24 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -430,29 +430,49 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
debug("%s: subnode name: %s\n", __func__, name);
+ if (!ofnode_device_is_compatible(node, "snps,dwc3")) {
+ if (ofnode_device_is_compatible(node,
+ "microchip,usb5744"))
+ driver = "usb5744";
+ else if (ofnode_device_is_compatible
+ (node, "microchip,usb2244"))
+ driver = "usb2244";
+
+ ret = device_bind_driver_to_node(parent, driver, name,
+ node, &dev);
+ if (ret) {
+ printf("Failed to bind: %s, err: %d\n",
+ driver, ret);
+ return ret;
+ }
+ }
+
/* if the parent node doesn't have a mode check the leaf */
dr_mode = usb_get_dr_mode(dev_ofnode(parent));
if (!dr_mode)
dr_mode = usb_get_dr_mode(node);
- if (CONFIG_IS_ENABLED(DM_USB_GADGET) &&
- (dr_mode == USB_DR_MODE_PERIPHERAL || dr_mode == USB_DR_MODE_OTG)) {
- debug("%s: dr_mode: OTG or Peripheral\n", __func__);
- driver = "dwc3-generic-peripheral";
- } else if (CONFIG_IS_ENABLED(USB_HOST) && dr_mode == USB_DR_MODE_HOST) {
- debug("%s: dr_mode: HOST\n", __func__);
- driver = "dwc3-generic-host";
- } else {
- debug("%s: unsupported dr_mode %d\n", __func__, dr_mode);
- return -ENODEV;
- }
+ if (ofnode_device_is_compatible(node, "snps,dwc3")) {
+ if (CONFIG_IS_ENABLED(DM_USB_GADGET) &&
+ (dr_mode == USB_DR_MODE_PERIPHERAL || dr_mode == USB_DR_MODE_OTG)) {
+ debug("%s: dr_mode: OTG or Peripheral\n", __func__);
+ driver = "dwc3-generic-peripheral";
+ } else if (CONFIG_IS_ENABLED(USB_HOST) && dr_mode == USB_DR_MODE_HOST) {
+ debug("%s: dr_mode: HOST\n", __func__);
+ driver = "dwc3-generic-host";
+ } else {
+ debug("%s: unsupported dr_mode %d\n", __func__, dr_mode);
+ return -ENODEV;
+ }
- ret = device_bind_driver_to_node(parent, driver, name,
- node, &dev);
- if (ret) {
- debug("%s: not able to bind usb device mode\n",
- __func__);
- return ret;
+ ret = device_bind_driver_to_node(parent, driver, name,
+ node, &dev);
+
+ if (ret) {
+ debug("%s: not able to bind usb device mode\n",
+ __func__);
+ return ret;
+ }
}
return 0;
@@ -479,7 +499,6 @@ int dwc3_glue_bind(struct udevice *parent)
if (ret)
return ret;
}
-
return 0;
}
@@ -530,6 +549,7 @@ int dwc3_glue_probe(struct udevice *dev)
struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data(dev);
struct dwc3_glue_data *glue = dev_get_plat(dev);
struct udevice *child = NULL;
+ ofnode node;
int index = 0;
int ret;
struct phy phy;
@@ -560,6 +580,17 @@ int dwc3_glue_probe(struct udevice *dev)
return ret;
}
+ ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+ if (!ofnode_device_is_compatible(node, "snps,dwc3")) {
+ ret = uclass_get_device_by_ofnode(UCLASS_MISC, node, &child);
+ if (ret) {
+ printf("could not get device %s, err = %d\n",
+ node.np->name, ret);
+ return ret;
+ }
+ }
+ }
+
device_find_first_child(dev, &child);
if (!child)
return 0;
--
2.25.1
More information about the U-Boot
mailing list