2022-04-26 08:27:02

by Sean Anderson

[permalink] [raw]
Subject: [PATCH v2 0/4] usb: phy: generic: Support enabling/disabling VBUS

The generic USB phy has had VBUS-related code for a long time, but it
has always been broken, since the regulator was never gotten from the
device tree. However, the support itself seems not very useful, since
e.g. usb_phy_vbus_on/off has no users and usb_phy_set_power is only
used by gadgets to make sure they don't draw too much current. Instead,
use the VBUS regulator to implement otg_set_vbus, which is called from
several drivers. This results in a change in semantics of VBUS, but
since support was always broken I don't think this will have any affect.

This got no (non-automated) feedback for an entire release cycle. I'm
sending v2 with a wider CC list so hopefully someone can review it in
time for 5.19.

Changes in v2:
- Fix dt_binding_check errors

Sean Anderson (4):
dt-bindings: usb: usb-nop-xceiv: Repurpose vbus-regulator
usb: phy: generic: Get the vbus supply
usb: phy: generic: Implement otg->set_vbus
usb: phy: generic: Disable vbus on removal

.../bindings/usb/usb-nop-xceiv.yaml | 9 ++-
drivers/usb/phy/phy-generic.c | 55 +++++++++----------
2 files changed, 31 insertions(+), 33 deletions(-)

--
2.35.1.1320.gc452695387.dirty


2022-04-26 22:55:48

by Sean Anderson

[permalink] [raw]
Subject: [PATCH v2 2/4] usb: phy: generic: Get the vbus supply

While support for working with a vbus was added, the regulator was never
actually gotten (despite what was documented). Fix this by actually
getting the supply from the device tree.

Fixes: 7acc9973e3c4 ("usb: phy: generic: add vbus support")
Signed-off-by: Sean Anderson <[email protected]>
---

(no changes since v1)

drivers/usb/phy/phy-generic.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 661a229c105d..34b9f8140187 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -268,6 +268,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
return -EPROBE_DEFER;
}

+ nop->vbus_draw = devm_regulator_get_exclusive(dev, "vbus");
+ if (PTR_ERR(nop->vbus_draw) == -ENODEV)
+ nop->vbus_draw = NULL;
+ if (IS_ERR(nop->vbus_draw))
+ return dev_err_probe(dev, PTR_ERR(nop->vbus_draw),
+ "could not get vbus regulator\n");
+
nop->dev = dev;
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
--
2.35.1.1320.gc452695387.dirty