mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-12 02:06:59 +02:00
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>
This commit is contained in:
parent
5a8dd2e0c8
commit
a4446e13db
@ -10,6 +10,7 @@
|
|||||||
#include <asm/gpio.h>
|
#include <asm/gpio.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <dm/device_compat.h>
|
#include <dm/device_compat.h>
|
||||||
|
#include <dm/uclass-internal.h>
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <power/regulator.h>
|
#include <power/regulator.h>
|
||||||
@ -179,8 +180,8 @@ err:
|
|||||||
static int usb_onboard_hub_bind(struct udevice *dev)
|
static int usb_onboard_hub_bind(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct ofnode_phandle_args phandle;
|
struct ofnode_phandle_args phandle;
|
||||||
const void *fdt = gd->fdt_blob;
|
struct udevice *peerdev;
|
||||||
int ret, off;
|
int ret;
|
||||||
|
|
||||||
ret = dev_read_phandle_with_args(dev, "peer-hub", NULL, 0, 0, &phandle);
|
ret = dev_read_phandle_with_args(dev, "peer-hub", NULL, 0, 0, &phandle);
|
||||||
if (ret == -ENOENT) {
|
if (ret == -ENOENT) {
|
||||||
@ -193,10 +194,14 @@ static int usb_onboard_hub_bind(struct udevice *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
off = ofnode_to_offset(phandle.node);
|
ret = uclass_find_device_by_ofnode(UCLASS_USB_HUB, phandle.node, &peerdev);
|
||||||
ret = fdt_node_check_compatible(fdt, off, "usb424,5744");
|
if (ret) {
|
||||||
if (!ret)
|
dev_dbg(dev, "binding before peer-hub %s\n",
|
||||||
|
ofnode_get_name(phandle.node));
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_dbg(dev, "peer-hub %s has been bound\n", peerdev->name);
|
||||||
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user