phy: rockchip-inno-usb2: amend charge detect process
Suspend USB-PHY while doing charge detect and resume it after finishing to ensure the USB-PHY in normal state. In addition, disable idm_sink_en and vdp_src_en after primary detection retry to fix the USB device failed to be enumerated after do charge detect. Change-Id: Id1effb049cc6491bcd876aa1cc0449469b11df06 Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
parent
15e088ea51
commit
a607e103bc
|
|
@ -238,16 +238,19 @@ static bool rockchip_chg_primary_det_retry(struct rockchip_usb2phy *rphy)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rockchip_chg_enable_primary_det(rphy, false);
|
||||||
return vout;
|
return vout;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rockchip_chg_get_type(void)
|
int rockchip_chg_get_type(void)
|
||||||
{
|
{
|
||||||
|
const struct rockchip_usb2phy_port_cfg *port_cfg;
|
||||||
const struct rockchip_usb2phy_cfg *phy_cfgs;
|
const struct rockchip_usb2phy_cfg *phy_cfgs;
|
||||||
enum power_supply_type chg_type;
|
enum power_supply_type chg_type;
|
||||||
struct rockchip_usb2phy rphy;
|
struct rockchip_usb2phy rphy;
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
ofnode u2phy_node, grf_node;
|
ofnode u2phy_node, grf_node;
|
||||||
|
void __iomem *base;
|
||||||
fdt_size_t size;
|
fdt_size_t size;
|
||||||
u32 reg, index;
|
u32 reg, index;
|
||||||
bool is_dcd, vout;
|
bool is_dcd, vout;
|
||||||
|
|
@ -330,6 +333,13 @@ int rockchip_chg_get_type(void)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base = get_reg_base(&rphy);
|
||||||
|
port_cfg = &rphy.phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
|
||||||
|
|
||||||
|
/* Suspend USB-PHY and put the controller in non-driving mode */
|
||||||
|
property_enable(base, &port_cfg->phy_sus, true);
|
||||||
|
property_enable(base, &rphy.phy_cfg->chg_det.opmode, false);
|
||||||
|
|
||||||
rphy.dcd_retries = CHG_DCD_MAX_RETRIES;
|
rphy.dcd_retries = CHG_DCD_MAX_RETRIES;
|
||||||
rphy.primary_retries = CHG_PRI_MAX_RETRIES;
|
rphy.primary_retries = CHG_PRI_MAX_RETRIES;
|
||||||
|
|
||||||
|
|
@ -394,6 +404,10 @@ int rockchip_chg_get_type(void)
|
||||||
chg_type = POWER_SUPPLY_TYPE_USB_CDP;
|
chg_type = POWER_SUPPLY_TYPE_USB_CDP;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
/* Resume USB-PHY and put the controller in normal mode */
|
||||||
|
property_enable(base, &rphy.phy_cfg->chg_det.opmode, true);
|
||||||
|
property_enable(base, &port_cfg->phy_sus, false);
|
||||||
|
|
||||||
debug("charger is %s\n", chg_to_string(chg_type));
|
debug("charger is %s\n", chg_to_string(chg_type));
|
||||||
|
|
||||||
return chg_type;
|
return chg_type;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue