From 3ff4580f86fc1887ed0df5932f4b2b05278c4ce8 Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Tue, 31 May 2022 15:16:31 +0800 Subject: [PATCH] phy: rockchip: inno_usb2: add submode setting support For Type-C scene, the TCPM notify the USB role to the USB controller driver. However, the USB2-PHY is imperceptible. So use submode to get the desired USB role from the USB controller driver. Later, we can use the phy_set_mode_ext in the USB controller driver to pass the desired USB role to USB2-PHY. With this patch, it can avoid to do battery charger detection if the Type-C USB role is Host. Signed-off-by: Frank Wang Signed-off-by: William Wu Change-Id: I37d3a43d5e0e82e37d45e2e49fb19c4add595b40 --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index a3f0a8e041ea..50a134d10d6d 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -945,6 +946,18 @@ static int rockchip_usb2phy_set_mode(struct phy *phy, switch (mode) { case PHY_MODE_USB_OTG: + if (rphy->edev_self && submode) { + if (submode == USB_ROLE_HOST) { + extcon_set_state(rphy->edev, EXTCON_USB_HOST, true); + extcon_set_state(rphy->edev, EXTCON_USB, false); + } else if (submode == USB_ROLE_DEVICE) { + extcon_set_state(rphy->edev, EXTCON_USB_HOST, false); + extcon_set_state(rphy->edev, EXTCON_USB, true); + } + + return ret; + } + /* * In case of using vbus to detect connect state by u2phy, * enable vbus detect on otg mode.