diff options
author | Lukasz Czechowski <lukasz.czechowski@thaumatec.com> | 2025-07-22 11:55:33 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-07-30 07:57:17 -0600 |
commit | a4446e13dba65f2e56e0d7a97875f76e5199015c (patch) | |
tree | fcdcd0429617dba8c14a1a84f4039aa1209a1197 /common/usb_onboard_hub.c | |
parent | 5a8dd2e0c848135b5c96af291aa96e79acc923ec (diff) |
usb: onboard-hub: Use the ofnode to check if the peer-hub was probed
Currently the check in usb_onboard_hub_bind is relying on specific
compatible string for the Michrochip USB5744. Replace this with
more generic approach that will allow to add new types of devices
to the of_match table. Because the driver only needs to bind one
"half" of the hub, the peer-hub node is used to find out if it
was already done. In case peer-hub was bound, -ENODEV is returned.
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Signed-off-by: Lukasz Czechowski <lukasz.czechowski@thaumatec.com>
Diffstat (limited to 'common/usb_onboard_hub.c')
-rw-r--r-- | common/usb_onboard_hub.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/common/usb_onboard_hub.c b/common/usb_onboard_hub.c index d17c85dd622..7606362a4ee 100644 --- a/common/usb_onboard_hub.c +++ b/common/usb_onboard_hub.c @@ -10,6 +10,7 @@ #include <asm/gpio.h> #include <dm.h> #include <dm/device_compat.h> +#include <dm/uclass-internal.h> #include <i2c.h> #include <linux/delay.h> #include <power/regulator.h> @@ -179,8 +180,8 @@ err: static int usb_onboard_hub_bind(struct udevice *dev) { struct ofnode_phandle_args phandle; - const void *fdt = gd->fdt_blob; - int ret, off; + struct udevice *peerdev; + int ret; ret = dev_read_phandle_with_args(dev, "peer-hub", NULL, 0, 0, &phandle); if (ret == -ENOENT) { @@ -193,10 +194,14 @@ static int usb_onboard_hub_bind(struct udevice *dev) return ret; } - off = ofnode_to_offset(phandle.node); - ret = fdt_node_check_compatible(fdt, off, "usb424,5744"); - if (!ret) + ret = uclass_find_device_by_ofnode(UCLASS_USB_HUB, phandle.node, &peerdev); + if (ret) { + dev_dbg(dev, "binding before peer-hub %s\n", + ofnode_get_name(phandle.node)); return 0; + } + + dev_dbg(dev, "peer-hub %s has been bound\n", peerdev->name); return -ENODEV; } |