Skip to content

Commit 55f1a5f

Browse files
BH Hsiehvinodkoul
authored andcommitted
phy: tegra: xusb: reset VBUS & ID OVERRIDE
Observed VBUS_OVERRIDE & ID_OVERRIDE might be programmed with unexpected value prior to XUSB PADCTL driver, this could also occur in virtualization scenario. For example, UEFI firmware programs ID_OVERRIDE=GROUNDED to set a type-c port to host mode and keeps the value to kernel. If the type-c port is connected a usb host, below errors can be observed right after usb host mode driver gets probed. The errors would keep until usb role class driver detects the type-c port as device mode and notifies usb device mode driver to set both ID_OVERRIDE and VBUS_OVERRIDE to correct value by XUSB PADCTL driver. [ 173.765814] usb usb3-port2: Cannot enable. Maybe the USB cable is bad? [ 173.765837] usb usb3-port2: config error Taking virtualization into account, asserting XUSB PADCTL reset would break XUSB functions used by other guest OS, hence only reset VBUS & ID OVERRIDE of the port in utmi_phy_init. Fixes: bbf7116 ("phy: tegra: xusb: Add Tegra186 support") Cc: [email protected] Change-Id: Ic63058d4d49b4a1f8f9ab313196e20ad131cc591 Signed-off-by: BH Hsieh <[email protected]> Signed-off-by: Henry Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 5ab90f4 commit 55f1a5f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/phy/tegra/xusb-tegra186.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,24 @@ static int tegra186_utmi_phy_init(struct phy *phy)
928928
unsigned int index = lane->index;
929929
struct device *dev = padctl->dev;
930930
int err;
931+
u32 reg;
931932

932933
port = tegra_xusb_find_usb2_port(padctl, index);
933934
if (!port) {
934935
dev_err(dev, "no port found for USB2 lane %u\n", index);
935936
return -ENODEV;
936937
}
937938

939+
if (port->mode == USB_DR_MODE_OTG ||
940+
port->mode == USB_DR_MODE_PERIPHERAL) {
941+
/* reset VBUS&ID OVERRIDE */
942+
reg = padctl_readl(padctl, USB2_VBUS_ID);
943+
reg &= ~VBUS_OVERRIDE;
944+
reg &= ~ID_OVERRIDE(~0);
945+
reg |= ID_OVERRIDE_FLOATING;
946+
padctl_writel(padctl, reg, USB2_VBUS_ID);
947+
}
948+
938949
if (port->supply && port->mode == USB_DR_MODE_HOST) {
939950
err = regulator_enable(port->supply);
940951
if (err) {

0 commit comments

Comments
 (0)