The .bind function is implemented to bind the correct
"half" of the hub that the driver wants to bind,
and returning -ENODEV for the other "half".

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbar...@amd.com>
---
 common/usb_onboard_hub.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/common/usb_onboard_hub.c b/common/usb_onboard_hub.c
index 00808ed45e..9c50ca09c9 100644
--- a/common/usb_onboard_hub.c
+++ b/common/usb_onboard_hub.c
@@ -162,6 +162,25 @@ err:
        return ret;
 }
 
+static int usb_onboard_hub_bind(struct udevice *dev)
+{
+       struct ofnode_phandle_args phandle;
+       const void *fdt = gd->fdt_blob;
+       int ret, off;
+
+       if (dev_read_phandle_with_args(dev, "peer-hub", NULL, 0, 0, &phandle)) {
+               dev_err(dev, "peer-hub not specified\n");
+               return -ENOENT;
+       }
+
+       off = ofnode_to_offset(phandle.node);
+       ret = fdt_node_check_compatible(fdt, off, "usb424,5744");
+       if (!ret)
+               return 0;
+
+       return -ENODEV;
+}
+
 static int usb_onboard_hub_remove(struct udevice *dev)
 {
        struct onboard_hub *hub = dev_get_priv(dev);
@@ -202,6 +221,7 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
 U_BOOT_DRIVER(usb_onboard_hub) = {
        .name   = "usb_onboard_hub",
        .id     = UCLASS_USB_HUB,
+       .bind   = usb_onboard_hub_bind,
        .probe = usb_onboard_hub_probe,
        .remove = usb_onboard_hub_remove,
        .of_match = usb_onboard_hub_ids,
-- 
2.17.1

Reply via email to