From ebe230b32711a0ae979f217aeab8b302dc7f3c83 Mon Sep 17 00:00:00 2001 From: Philip Rakity Date: Wed, 4 Jun 2014 12:37:30 +0100 Subject: [PATCH] usb: phy: tegra: QC2 speed up charger recogniion The QC2 Wall Charger needs to be reset only when we boot or reboot the system. This is because the wall charger will have already defaulted to a DCP. Since the internal logic in the Wall Charger will not see D+/D- programmed during the time available. If we just plug in the charger then it will be recognised in time so no reset is necessary. Removes 1.5s of delay. bug 1424733 Reviewed-on: http://git-master/r/433790 (cherry picked from commit b1a51cad99e8ec7e309aa33a786bdc41bc61f6db) Change-Id: I2b6f698e75f29163e9de4dac3f1b2ef1fb0ec6cc Signed-off-by: Philip Rakity Reviewed-on: http://git-master/r/435646 GVS: Gerrit_Virtual_Submit Reviewed-by: Rakesh Babu Bodla Reviewed-by: Laxman Dewangan --- drivers/usb/phy/tegra11x_usb_phy.c | 27 +++++++++++++++++++++------ drivers/usb/phy/tegra_usb_phy.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/usb/phy/tegra11x_usb_phy.c b/drivers/usb/phy/tegra11x_usb_phy.c index 96a1e6db0a5..33fb6bbdb53 100644 --- a/drivers/usb/phy/tegra11x_usb_phy.c +++ b/drivers/usb/phy/tegra11x_usb_phy.c @@ -1637,12 +1637,27 @@ static bool utmi_phy_qc2_charger_detect(struct tegra_usb_phy *phy, writel(0, base + UTMIP_BAT_CHRG_CFG0); utmi_phy_set_dp_dm_pull_up_down(phy, 0); - /* Force wall charger detection logic to reset */ - org_flags = utmi_phy_set_dp_dm_pull_up_down(phy, - FORCE_PULLDN_DP | FORCE_PULLDN_DM); - ssleep(1); - msleep(500); - utmi_phy_set_dp_dm_pull_up_down(phy, org_flags); + /* + * The QC2 charger can be inserted when the system is + * powered down. In this case it will act as a DCP unless + * it is forced to negotiate voltage. This is because + * the QC2 charger will not see D+/D- voltage signaling + * with in its negotiation timer window. + * We try to detect this condition. We know that if + * we enter suspend then system must be active before + * the QC2 charger was seen. + * In this case no reset of the charger is needed, otherwise + * we force the D+ and D- Pull Up down which will reset a + * QC2 charger but have no effect on a normal DCP. + */ + if (!phy->qc2_no_reset) { + phy->qc2_no_reset = true; + org_flags = utmi_phy_set_dp_dm_pull_up_down(phy, + FORCE_PULLDN_DP | FORCE_PULLDN_DM); + ssleep(1); + msleep(500); + utmi_phy_set_dp_dm_pull_up_down(phy, org_flags); + } /* Enable charger detection logic */ val = readl(base + UTMIP_BAT_CHRG_CFG0); diff --git a/drivers/usb/phy/tegra_usb_phy.h b/drivers/usb/phy/tegra_usb_phy.h index 2f74e48aab7..8c04abbb1a2 100644 --- a/drivers/usb/phy/tegra_usb_phy.h +++ b/drivers/usb/phy/tegra_usb_phy.h @@ -115,6 +115,7 @@ struct tegra_usb_phy { bool linkphy_init; bool hot_plug; bool ctrlr_suspended; + bool qc2_no_reset; }; int usb_phy_reg_status_wait(void __iomem *reg, u32 mask, -- 2.39.2