phy: tegra: xusb: track whether the USB2 VBUS supply is enabled

- Remember if this port turned its VBUS regulator on
- Switching to host mode twice no longer enables it a second time, and
  switching to none no longer disables a regulator it never enabled
- Fixes the unbalanced regulator warnings on USB-C role changes
This commit is contained in:
SylveonDeko authored and Thomas Makin committed 2026-10-16 18:03:37 -05:00
1 parent 566df49d42
commit a649219eac
2 files changed
+8 -2

No files matched your search

+7 -2
View File
@@ -2167,7 +2167,10 @@ static int tegra210_usb2_phy_set_mode(struct phy *phy, enum phy_mode mode,
if (submode == USB_ROLE_HOST) {
tegra210_xusb_padctl_id_override(padctl, true);
err = regulator_enable(port->supply);
if (!port->supply_enabled) {
err = regulator_enable(port->supply);
port->supply_enabled = !err;
}
} else if (submode == USB_ROLE_DEVICE) {
tegra210_xusb_padctl_vbus_override(padctl, true);
} else if (submode == USB_ROLE_NONE) {
@@ -2176,8 +2179,10 @@ static int tegra210_usb2_phy_set_mode(struct phy *phy, enum phy_mode mode,
* USB_ROLE_NONE from USB_ROLE_DEVICE, regulator is not
* be enabled.
*/
if (regulator_is_enabled(port->supply))
if (port->supply_enabled) {
regulator_disable(port->supply);
port->supply_enabled = false;
}
tegra210_xusb_padctl_id_override(padctl, false);
tegra210_xusb_padctl_vbus_override(padctl, false);
+1
View File
@@ -314,6 +314,7 @@ struct tegra_xusb_usb2_port {
struct tegra_xusb_port base;
struct regulator *supply;
bool supply_enabled;
enum usb_dr_mode mode;
bool internal;
int usb3_port_fake;