* [PATCH v2 1/6] phy: tegra: xusb: Fix USB2 port regulator disable logic
2026-01-27 15:11 [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
@ 2026-01-27 15:11 ` Diogo Ivo
2026-03-02 9:10 ` [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Diogo Ivo @ 2026-01-27 15:11 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, JC Kuo, Vinod Koul, Kishon Vijay Abraham I,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong
Cc: linux-usb, linux-tegra, linux-kernel, linux-phy, devicetree,
Diogo Ivo, stable
The USB2 PHY mode handling on Tegra210 incorrectly relied on
regulator_is_enabled() when determining whether the VBUS supply should
be disabled during role changes. This is because regulator_is_enabled()
reports exactly what is states and not if there is an unbalanced number
of calls between regulator_enable() and regulator_disable(). For
example, regulator_is_enabled() always reports true on a fixed-regulator
with no enable gpio, which is the case on the Pixel C.
This then leads to the PHY driver wrongfully calling regulator_disable()
when transitioning from USB_ROLE_DEVICE to USB_ROLE_NONE since the driver
did not previously call the corresponding regulator_enable().
Fix this by keeping track of the current role and updating the logic to
disable the regulator only when the previous role was USB_ROLE_HOST.
Cc: stable@vger.kernel.org
Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
---
v1->v2:
- Do not fix typo in comment
---
drivers/phy/tegra/xusb-tegra210.c | 4 +++-
drivers/phy/tegra/xusb.h | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/tegra/xusb-tegra210.c b/drivers/phy/tegra/xusb-tegra210.c
index 3409924498e9..3abdf0182d67 100644
--- a/drivers/phy/tegra/xusb-tegra210.c
+++ b/drivers/phy/tegra/xusb-tegra210.c
@@ -1936,12 +1936,14 @@ 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->role == USB_ROLE_HOST)
regulator_disable(port->supply);
tegra210_xusb_padctl_id_override(padctl, false);
tegra210_xusb_padctl_vbus_override(padctl, false);
}
+
+ port->role = submode;
}
mutex_unlock(&padctl->lock);
diff --git a/drivers/phy/tegra/xusb.h b/drivers/phy/tegra/xusb.h
index d2b5f9565132..273af147dfd3 100644
--- a/drivers/phy/tegra/xusb.h
+++ b/drivers/phy/tegra/xusb.h
@@ -317,6 +317,7 @@ struct tegra_xusb_usb2_port {
enum usb_dr_mode mode;
bool internal;
int usb3_port_fake;
+ enum usb_role role;
};
static inline struct tegra_xusb_usb2_port *
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling
2026-01-27 15:11 [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
2026-01-27 15:11 ` [PATCH v2 1/6] phy: tegra: xusb: Fix USB2 port regulator disable logic Diogo Ivo
@ 2026-03-02 9:10 ` Diogo Ivo
2026-03-02 9:59 ` Vinod Koul
2026-03-23 16:15 ` Diogo Ivo
3 siblings, 0 replies; 5+ messages in thread
From: Diogo Ivo @ 2026-03-02 9:10 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, JC Kuo, Vinod Koul, Kishon Vijay Abraham I,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong
Cc: linux-usb, linux-tegra, linux-kernel, linux-phy, devicetree,
stable
Hello,
Gentle ping on this series.
Best regards,
Diogo
On 1/27/26 15:11, Diogo Ivo wrote:
> Hello,
>
> This patch series contains fixes/improvements for USB role switching on the
> Tegra210 and Tegra186 SoCs.
>
> The first patch addresses a wrong check on the logic that disables the
> VBUS regulator.
>
> The second patch removes a redundant mutex lock when setting the PHY
> mode.
>
> The third patch guarantees proper ordering of events when switching PHY
> roles.
>
> The remaining patches are included to standardize the PHY .set_mode()
> callback between Tegra186 and Tegra210.
>
> With this patch series this feature can only be controlled from userspace,
> by writing the desired role to sysfs as
>
> echo "role" > /sys/class/usb_role/usb2-0-role-switch/role
>
> with role being one of {device, host, none}.
>
> Further patches will enable automatic role switching via the 'cros_ec_typec'
> driver which is currently broken on Smaug.
>
> Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
> ---
> Changes in v2:
> - Remove DT patches already taken to be upstreamed
> - Add standardization between Tegra210 and Tegra186
> - Address review comments from v1, detailed descriptions in each patch
> - Link to v1: https://lore.kernel.org/r/20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt
>
> ---
> Diogo Ivo (6):
> phy: tegra: xusb: Fix USB2 port regulator disable logic
> usb: xhci: tegra: Remove redundant mutex when setting phy mode
> phy: tegra: xusb: Fix ordering issue when switching roles on USB2 ports
> phy: tegra: xusb: Add ID override support to padctl
> phy: tegra: xusb: Move .set_mode() to a shared location
> phy: tegra: xusb: Move T186 .set_mode() to common implementation
>
> drivers/phy/tegra/xusb-tegra186.c | 73 +++++----------------------------
> drivers/phy/tegra/xusb-tegra210.c | 42 +------------------
> drivers/phy/tegra/xusb.c | 80 +++++++++++++++++++++++++++++++++++++
> drivers/phy/tegra/xusb.h | 4 ++
> drivers/usb/gadget/udc/tegra-xudc.c | 4 ++
> drivers/usb/host/xhci-tegra.c | 14 ++++---
> include/linux/phy/tegra/xusb.h | 3 ++
> 7 files changed, 111 insertions(+), 109 deletions(-)
> ---
> base-commit: b02a5530af8abe0d3cd4852ba48990716e962934
> change-id: 20251201-diogo-tegra_phy-86c89cab7377
>
> Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling
2026-01-27 15:11 [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
2026-01-27 15:11 ` [PATCH v2 1/6] phy: tegra: xusb: Fix USB2 port regulator disable logic Diogo Ivo
2026-03-02 9:10 ` [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
@ 2026-03-02 9:59 ` Vinod Koul
2026-03-23 16:15 ` Diogo Ivo
3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2026-03-02 9:59 UTC (permalink / raw)
To: Diogo Ivo, Thierry Reding, Jonathan Hunter
Cc: Mathias Nyman, Greg Kroah-Hartman, JC Kuo, Kishon Vijay Abraham I,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong,
linux-usb, linux-tegra, linux-kernel, linux-phy, devicetree,
stable
On 27-01-26, 15:11, Diogo Ivo wrote:
> Hello,
>
> This patch series contains fixes/improvements for USB role switching on the
> Tegra210 and Tegra186 SoCs.
Thierry, Jonathan
can you folks check this and r-b/t-b please
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling
2026-01-27 15:11 [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
` (2 preceding siblings ...)
2026-03-02 9:59 ` Vinod Koul
@ 2026-03-23 16:15 ` Diogo Ivo
3 siblings, 0 replies; 5+ messages in thread
From: Diogo Ivo @ 2026-03-23 16:15 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, JC Kuo, Vinod Koul, Kishon Vijay Abraham I,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong
Cc: linux-usb, linux-tegra, linux-kernel, linux-phy, devicetree,
stable
Hello,
Ping on this series as it has been quite a while since this was sent out
originally.
Best regards,
Diogo
On 1/27/26 15:11, Diogo Ivo wrote:
> Hello,
>
> This patch series contains fixes/improvements for USB role switching on the
> Tegra210 and Tegra186 SoCs.
>
> The first patch addresses a wrong check on the logic that disables the
> VBUS regulator.
>
> The second patch removes a redundant mutex lock when setting the PHY
> mode.
>
> The third patch guarantees proper ordering of events when switching PHY
> roles.
>
> The remaining patches are included to standardize the PHY .set_mode()
> callback between Tegra186 and Tegra210.
>
> With this patch series this feature can only be controlled from userspace,
> by writing the desired role to sysfs as
>
> echo "role" > /sys/class/usb_role/usb2-0-role-switch/role
>
> with role being one of {device, host, none}.
>
> Further patches will enable automatic role switching via the 'cros_ec_typec'
> driver which is currently broken on Smaug.
>
> Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
> ---
> Changes in v2:
> - Remove DT patches already taken to be upstreamed
> - Add standardization between Tegra210 and Tegra186
> - Address review comments from v1, detailed descriptions in each patch
> - Link to v1: https://lore.kernel.org/r/20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt
>
> ---
> Diogo Ivo (6):
> phy: tegra: xusb: Fix USB2 port regulator disable logic
> usb: xhci: tegra: Remove redundant mutex when setting phy mode
> phy: tegra: xusb: Fix ordering issue when switching roles on USB2 ports
> phy: tegra: xusb: Add ID override support to padctl
> phy: tegra: xusb: Move .set_mode() to a shared location
> phy: tegra: xusb: Move T186 .set_mode() to common implementation
>
> drivers/phy/tegra/xusb-tegra186.c | 73 +++++----------------------------
> drivers/phy/tegra/xusb-tegra210.c | 42 +------------------
> drivers/phy/tegra/xusb.c | 80 +++++++++++++++++++++++++++++++++++++
> drivers/phy/tegra/xusb.h | 4 ++
> drivers/usb/gadget/udc/tegra-xudc.c | 4 ++
> drivers/usb/host/xhci-tegra.c | 14 ++++---
> include/linux/phy/tegra/xusb.h | 3 ++
> 7 files changed, 111 insertions(+), 109 deletions(-)
> ---
> base-commit: b02a5530af8abe0d3cd4852ba48990716e962934
> change-id: 20251201-diogo-tegra_phy-86c89cab7377
>
> Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread