diff options
author | Haotien Hsu <haotienh@nvidia.com> | 2022-12-16 07:21:46 +0300 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-01-13 20:50:30 +0300 |
commit | 3cde1ef6f84aba34e3cbc8fd57644781ded617e3 (patch) | |
tree | 03646713dcf54eff95d26bb0123a94e22858bf88 /drivers/phy/tegra | |
parent | 724dbe3c2f8a1564e76d73985b02bcefff1cea83 (diff) | |
download | linux-3cde1ef6f84aba34e3cbc8fd57644781ded617e3.tar.xz |
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>
Diffstat (limited to 'drivers/phy/tegra')
-rw-r--r-- | drivers/phy/tegra/xusb.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index 3707a0b5c1ae..78045bd6c214 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -718,6 +718,22 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port) return err; } +static void tegra_xusb_parse_usb_role_default_mode(struct tegra_xusb_port *port) +{ + enum usb_role role = USB_ROLE_NONE; + enum usb_dr_mode mode = usb_get_role_switch_default_mode(&port->dev); + + if (mode == USB_DR_MODE_HOST) + role = USB_ROLE_HOST; + else if (mode == USB_DR_MODE_PERIPHERAL) + role = USB_ROLE_DEVICE; + + if (role != USB_ROLE_NONE) { + usb_role_switch_set_role(port->usb_role_sw, role); + dev_dbg(&port->dev, "usb role default mode is %s", modes[mode]); + } +} + static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2) { 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) err = tegra_xusb_setup_usb_role_switch(port); if (err < 0) return err; + tegra_xusb_parse_usb_role_default_mode(port); } else { dev_err(&port->dev, "usb-role-switch not found for %s mode", modes[usb2->mode]); |