]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/usb-chipidea-grab-the-legacy-usb-phy-by-phandle-firs.patch
a3b72406c67a2ebe81d6e75686240728f862510f
[thirdparty/kernel/stable-queue.git] / queue-4.19 / usb-chipidea-grab-the-legacy-usb-phy-by-phandle-firs.patch
1 From e412980f55225885724a3f3a107e8f48e3ba4bd1 Mon Sep 17 00:00:00 2001
2 From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
3 Date: Wed, 27 Feb 2019 06:51:36 +0000
4 Subject: usb: chipidea: Grab the (legacy) USB PHY by phandle first
5
6 [ Upstream commit 68ef236274793066b9ba3154b16c0acc1c891e5c ]
7
8 According to the chipidea driver bindings, the USB PHY is specified via
9 the "phys" phandle node. However, this only takes effect for USB PHYs
10 that use the common PHY framework. For legacy USB PHYs, a simple lookup
11 based on the USB PHY type is done instead.
12
13 This does not play out well when more than one USB PHY is registered,
14 since the first registered PHY matching the type will always be
15 returned regardless of what the driver was bound to.
16
17 Fix this by looking up the PHY based on the "phys" phandle node.
18 Although generic PHYs are rather matched by their "phys-name" and not
19 the "phys" phandle directly, there is no helper for similar lookup on
20 legacy PHYs and it's probably not worth the effort to add it.
21
22 When no legacy USB PHY is found by phandle, fallback to grabbing any
23 registered USB2 PHY. This ensures backward compatibility if some users
24 were actually relying on this mechanism.
25
26 Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
27 Signed-off-by: Peter Chen <peter.chen@nxp.com>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29 Signed-off-by: Sasha Levin <sashal@kernel.org>
30 ---
31 drivers/usb/chipidea/core.c | 9 ++++++++-
32 1 file changed, 8 insertions(+), 1 deletion(-)
33
34 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
35 index 85fc6db48e44..159b897c5e80 100644
36 --- a/drivers/usb/chipidea/core.c
37 +++ b/drivers/usb/chipidea/core.c
38 @@ -935,8 +935,15 @@ static int ci_hdrc_probe(struct platform_device *pdev)
39 } else if (ci->platdata->usb_phy) {
40 ci->usb_phy = ci->platdata->usb_phy;
41 } else {
42 + ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, "phys",
43 + 0);
44 ci->phy = devm_phy_get(dev->parent, "usb-phy");
45 - ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2);
46 +
47 + /* Fallback to grabbing any registered USB2 PHY */
48 + if (IS_ERR(ci->usb_phy) &&
49 + PTR_ERR(ci->usb_phy) != -EPROBE_DEFER)
50 + ci->usb_phy = devm_usb_get_phy(dev->parent,
51 + USB_PHY_TYPE_USB2);
52
53 /* if both generic PHY and USB PHY layers aren't enabled */
54 if (PTR_ERR(ci->phy) == -ENOSYS &&
55 --
56 2.19.1
57