Message ID | 20250122105943.8057-1-henryl@nvidia.com |
---|---|
State | Accepted |
Commit | 55f1a5f7c97c3c92ba469e16991a09274410ceb7 |
Headers | show |
Series | [v2] phy: tegra: xusb: reset VBUS & ID OVERRIDE | expand |
On Wed, 22 Jan 2025 18:59:43 +0800, Henry Lin wrote: > 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. > > [...] Applied, thanks! [1/1] phy: tegra: xusb: reset VBUS & ID OVERRIDE commit: 55f1a5f7c97c3c92ba469e16991a09274410ceb7 Best regards,
diff --git a/drivers/phy/tegra/xusb-tegra186.c b/drivers/phy/tegra/xusb-tegra186.c index 0f60d5d1c167..fae6242aa730 100644 --- a/drivers/phy/tegra/xusb-tegra186.c +++ b/drivers/phy/tegra/xusb-tegra186.c @@ -928,6 +928,7 @@ static int tegra186_utmi_phy_init(struct phy *phy) unsigned int index = lane->index; struct device *dev = padctl->dev; int err; + u32 reg; port = tegra_xusb_find_usb2_port(padctl, index); if (!port) { @@ -935,6 +936,16 @@ static int tegra186_utmi_phy_init(struct phy *phy) return -ENODEV; } + if (port->mode == USB_DR_MODE_OTG || + port->mode == USB_DR_MODE_PERIPHERAL) { + /* reset VBUS&ID OVERRIDE */ + reg = padctl_readl(padctl, USB2_VBUS_ID); + reg &= ~VBUS_OVERRIDE; + reg &= ~ID_OVERRIDE(~0); + reg |= ID_OVERRIDE_FLOATING; + padctl_writel(padctl, reg, USB2_VBUS_ID); + } + if (port->supply && port->mode == USB_DR_MODE_HOST) { err = regulator_enable(port->supply); if (err) {