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 <frank.wang@rock-chips.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I37d3a43d5e0e82e37d45e2e49fb19c4add595b40
This commit is contained in:
Frank Wang
2022-05-31 15:16:31 +08:00
committed by Tao Huang
parent 619b882219
commit 3ff4580f86

View File

@@ -30,6 +30,7 @@
#include <linux/mfd/syscon.h>
#include <linux/usb/of.h>
#include <linux/usb/otg.h>
#include <linux/usb/role.h>
#include <linux/usb/typec_mux.h>
#include <linux/wakelock.h>
@@ -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.