mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb: onboard-hub: bail out if peer hub is already probed
@ 2024-03-27 16:55 Lucas Stach
  2024-04-02  8:41 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2024-03-27 16:55 UTC (permalink / raw)
  To: barebox

Many physical hub chips include multiple logical hubs to handle both
USB and 2 and 3. Both logical hubs will then match the onboard hub
driver, which means we'll end up with two driver instances trying to
control the reset GPIO that is only present once on the physical chip.

As this doesn't make sense, just bail out of the probe function when
the peer-hub is already probed and can be assumed to handle power,
clocks and reset resources of the chip.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/usb/misc/onboard_usb_hub.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c
index 6339a3e4ec18..9e94caaa8456 100644
--- a/drivers/usb/misc/onboard_usb_hub.c
+++ b/drivers/usb/misc/onboard_usb_hub.c
@@ -53,8 +53,17 @@ static int onboard_hub_power_on(struct onboard_hub *hub)
 
 static int onboard_hub_probe(struct device *dev)
 {
+	struct device_node *peer_node;
+	struct device *peer_dev;
 	struct onboard_hub *hub;
 
+	peer_node = of_parse_phandle(dev->of_node, "peer-hub", 0);
+	if (peer_node) {
+		peer_dev = of_find_device_by_node(peer_node);
+		if (peer_dev && peer_dev->priv)
+			return 0;
+	}
+
 	hub = xzalloc(sizeof(*hub));
 
 	hub->pdata = device_get_match_data(dev);
@@ -71,6 +80,7 @@ static int onboard_hub_probe(struct device *dev)
 				     "failed to get reset GPIO\n");
 
 	hub->dev = dev;
+	dev->priv = hub;
 
 	return onboard_hub_power_on(hub);
 }
-- 
2.44.0




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: onboard-hub: bail out if peer hub is already probed
  2024-03-27 16:55 [PATCH] usb: onboard-hub: bail out if peer hub is already probed Lucas Stach
@ 2024-04-02  8:41 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-04-02  8:41 UTC (permalink / raw)
  To: barebox, Lucas Stach


On Wed, 27 Mar 2024 17:55:54 +0100, Lucas Stach wrote:
> Many physical hub chips include multiple logical hubs to handle both
> USB and 2 and 3. Both logical hubs will then match the onboard hub
> driver, which means we'll end up with two driver instances trying to
> control the reset GPIO that is only present once on the physical chip.
> 
> As this doesn't make sense, just bail out of the probe function when
> the peer-hub is already probed and can be assumed to handle power,
> clocks and reset resources of the chip.
> 
> [...]

Applied, thanks!

[1/1] usb: onboard-hub: bail out if peer hub is already probed
      https://git.pengutronix.de/cgit/barebox/commit/?id=5423885658da (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-02  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 16:55 [PATCH] usb: onboard-hub: bail out if peer hub is already probed Lucas Stach
2024-04-02  8:41 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox