* [PATCH] phy: tegra: xusb: Support USB role default mode
@ 2022-12-16 4:21 Haotien Hsu
2023-01-13 17:50 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Haotien Hsu @ 2022-12-16 4:21 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I
Cc: JC Kuo, Thierry Reding, Jonathan Hunter, Wayne Chang, linux-phy,
linux-tegra, linux-kernel, Haotien Hsu
Support role-switch-default-mode property when usb-role-switch is
enabled.
Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
---
drivers/phy/tegra/xusb.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
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]);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] phy: tegra: xusb: Support USB role default mode
2022-12-16 4:21 [PATCH] phy: tegra: xusb: Support USB role default mode Haotien Hsu
@ 2023-01-13 17:50 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2023-01-13 17:50 UTC (permalink / raw)
To: Haotien Hsu
Cc: Kishon Vijay Abraham I, JC Kuo, Thierry Reding, Jonathan Hunter,
Wayne Chang, linux-phy, linux-tegra, linux-kernel
On 16-12-22, 12:21, Haotien Hsu wrote:
> Support role-switch-default-mode property when usb-role-switch is
> enabled.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-13 17:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-16 4:21 [PATCH] phy: tegra: xusb: Support USB role default mode Haotien Hsu
2023-01-13 17:50 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).