]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
usb: phy: tegra: QC2 speed up charger recogniion
authorPhilip Rakity <prakity@nvidia.com>
Wed, 4 Jun 2014 11:37:30 +0000 (12:37 +0100)
committerMandar Padmawar <mpadmawar@nvidia.com>
Thu, 10 Jul 2014 12:32:52 +0000 (05:32 -0700)
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 <prakity@nvidia.com>
Reviewed-on: http://git-master/r/435646
GVS: Gerrit_Virtual_Submit
Reviewed-by: Rakesh Babu Bodla <rbodla@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
drivers/usb/phy/tegra11x_usb_phy.c
drivers/usb/phy/tegra_usb_phy.h

index 96a1e6db0a58c97d03f08e302350e1d3b2b783ee..33fb6bbdb5378234aa7faf670efacb47d4e60f7b 100644 (file)
@@ -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);
index 2f74e48aab745caf5bb4c5d9aa106f5692d095f1..8c04abbb1a2bf4a10738952db9653152628e79ca 100644 (file)
@@ -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,