diff --git a/drivers/phy/phy-rockchip-inno-usb2.c b/drivers/phy/phy-rockchip-inno-usb2.c index 644c61d15db2..9da2af7740b0 100644 --- a/drivers/phy/phy-rockchip-inno-usb2.c +++ b/drivers/phy/phy-rockchip-inno-usb2.c @@ -139,6 +139,7 @@ struct rockchip_chg_det_reg { * @idrise_det_clr: id rise detection clear register. * @utmi_avalid: utmi vbus avalid status register. * @utmi_bvalid: utmi vbus bvalid status register. + * @utmi_iddig: otg port id pin status register. * @utmi_ls: utmi linestate state register. * @utmi_hstdet: utmi host disconnect register. */ @@ -158,6 +159,7 @@ struct rockchip_usb2phy_port_cfg { struct usb2phy_reg idrise_det_clr; struct usb2phy_reg utmi_avalid; struct usb2phy_reg utmi_bvalid; + struct usb2phy_reg utmi_iddig; struct usb2phy_reg utmi_ls; struct usb2phy_reg utmi_hstdet; }; @@ -233,6 +235,7 @@ struct rockchip_usb2phy_port { * @chg_type: USB charger types. * @dcd_retries: The retry count used to track Data contact * detection process. + * @edev_self: represent the source of extcon. * @edev: extcon device for notification registration * @phy_cfg: phy register configuration, assigned by driver data. * @ports: phy port instance. @@ -1068,6 +1071,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, struct device_node *child_np) { int ret; + int iddig; rport->port_id = USB2PHY_PORT_OTG; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; @@ -1126,6 +1130,14 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, dev_err(rphy->dev, "failed to request otg-id irq handle\n"); return ret; } + + iddig = property_enabled(rphy, &rport->port_cfg->utmi_iddig); + if (!iddig) { + extcon_set_state(rphy->edev, EXTCON_USB, false); + extcon_set_state(rphy->edev, EXTCON_USB_HOST, true); + } else { + extcon_set_state(rphy->edev, EXTCON_USB_HOST, false); + } } if (!IS_ERR(rphy->edev)) { @@ -1335,6 +1347,7 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = { .idrise_det_clr = { 0xe3d0, 4, 4, 0, 1 }, .utmi_avalid = { 0xe2ac, 7, 7, 0, 1 }, .utmi_bvalid = { 0xe2ac, 12, 12, 0, 1 }, + .utmi_iddig = { 0xe2ac, 8, 8, 0, 1 }, }, [USB2PHY_PORT_HOST] = { .phy_sus = { 0xe458, 1, 0, 0x2, 0x1 }, @@ -1376,6 +1389,7 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = { .idrise_det_clr = { 0xe3d0, 9, 9, 0, 1 }, .utmi_avalid = { 0xe2ac, 10, 10, 0, 1 }, .utmi_bvalid = { 0xe2ac, 16, 16, 0, 1 }, + .utmi_iddig = { 0xe2ac, 11, 11, 0, 1 }, }, [USB2PHY_PORT_HOST] = { .phy_sus = { 0xe468, 1, 0, 0x2, 0x1 },