Message ID | 20240111071057.2771902-1-venkatesh.abbarapu@amd.com |
---|---|
State | RFC |
Delegated to: | Marek Vasut |
Headers | show |
Series | usb: dwc3: Integrate usb5744 & usb2244 driver support | expand |
First of all I think this should be more RFC. On 1/11/24 08:10, Venkatesh Yadav Abbarapu wrote: > 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@xilinx.com> > Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@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; > + } > + } I don't think this is going to be accepted by Marek to have device specific code in generic code. I did some grepping and I see that there is new CONFIG_USB_ONBOARD_HUB entry. Don't understand why it is in common folder if this is pretty much device specific. But there is a new UCLASS_USB_HUB class. Venkatesh: it should be investigated more how it works. Marek: IIRC you mentioned any support for companion/peer hubs. How do you think it should be integrated to u-boot? Thanks, Michal
On 1/11/24 08:42, Michal Simek wrote: > First of all I think this should be more RFC. > > On 1/11/24 08:10, Venkatesh Yadav Abbarapu wrote: >> 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@xilinx.com> >> Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@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; >> + } >> + } > > I don't think this is going to be accepted by Marek to have device > specific code in generic code. > I did some grepping and I see that there is new CONFIG_USB_ONBOARD_HUB > entry. > Don't understand why it is in common folder if this is pretty much > device specific. But there is a new UCLASS_USB_HUB class. > > Venkatesh: it should be investigated more how it works. > > Marek: IIRC you mentioned any support for companion/peer hubs. > How do you think it should be integrated to u-boot? See common/usb_onboard_hub.c .
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;