From: Meng Dongyang Date: Tue, 11 Oct 2016 09:08:10 +0000 (+0800) Subject: usb: rockchip-inno-usb2: init cable state when u2phy probe X-Git-Tag: firefly_0821_release~1412 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=454181a86dcc169d34120e2dd3dca89a2112560d;p=firefly-linux-kernel-4.4.55.git usb: rockchip-inno-usb2: init cable state when u2phy probe Id pin interrupt not occur when system start, so we need to check id pin value when u2phy probe and set cable to host if the value is high. Change-Id: I333d5cae2463a159a18b455550a76ebcac704c44 Signed-off-by: Meng Dongyang --- 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 },