Skip to content

Commit 80315f3

Browse files
committed
phy: tegra: xusb: Support USB role default mode
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122414 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git Tested: Verify USB-A and USB-C are functional on Nvidia Orin board, and no regressions on other platforms. commit 3cde1ef Author: Haotien Hsu <haotienh@nvidia.com> Date: Fri Dec 16 12:21:46 2022 +0800 phy: tegra: xusb: Support USB role default mode Support role-switch-default-mode property when usb-role-switch is enabled. Signed-off-by: Haotien Hsu <haotienh@nvidia.com> Link: https://lore.kernel.org/r/20221216042146.99307-1-haotienh@nvidia.com Signed-off-by: Vinod Koul <vkoul@kernel.org> (cherry picked from commit 3cde1ef) Signed-off-by: David Marlin <dmarlin@redhat.com>
1 parent d315996 commit 80315f3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/phy/tegra/xusb.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,22 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port)
718718
return err;
719719
}
720720

721+
static void tegra_xusb_parse_usb_role_default_mode(struct tegra_xusb_port *port)
722+
{
723+
enum usb_role role = USB_ROLE_NONE;
724+
enum usb_dr_mode mode = usb_get_role_switch_default_mode(&port->dev);
725+
726+
if (mode == USB_DR_MODE_HOST)
727+
role = USB_ROLE_HOST;
728+
else if (mode == USB_DR_MODE_PERIPHERAL)
729+
role = USB_ROLE_DEVICE;
730+
731+
if (role != USB_ROLE_NONE) {
732+
usb_role_switch_set_role(port->usb_role_sw, role);
733+
dev_dbg(&port->dev, "usb role default mode is %s", modes[mode]);
734+
}
735+
}
736+
721737
static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
722738
{
723739
struct tegra_xusb_port *port = &usb2->base;
@@ -747,6 +763,7 @@ static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
747763
err = tegra_xusb_setup_usb_role_switch(port);
748764
if (err < 0)
749765
return err;
766+
tegra_xusb_parse_usb_role_default_mode(port);
750767
} else {
751768
dev_err(&port->dev, "usb-role-switch not found for %s mode",
752769
modes[usb2->mode]);

0 commit comments

Comments
 (0)