From 8645a77a4676cefbc353aed390becd325dbf9bb5 Mon Sep 17 00:00:00 2001 From: Nicholas Troast Date: Fri, 28 Oct 2016 10:36:45 -0700 Subject: [PATCH 1/2] smb-lib: rerun APSD when any HVDCP adapter is detected If HVDCP authentication starts before it is disabled then HVDCP 2.0 adapters will be detected as HVDCP 3.0. When PD fails, HVDCP authentication and HVDCP autonomous mode are re-enabled, but APSD is currently only rerun if a HVDCP 2.0 adapter was detected. Fix this by re-running APSD when any HVDCP adapter is detected so the HVDCP authentication and HVDCP autonomous mode take effect. Change-Id: I5cc37fc09145f31116efd5104144b32c791e0e27 Signed-off-by: Nicholas Troast --- drivers/power/qcom-charger/smb-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/qcom-charger/smb-lib.c b/drivers/power/qcom-charger/smb-lib.c index 198e77469bbe..ce54f365b308 100644 --- a/drivers/power/qcom-charger/smb-lib.c +++ b/drivers/power/qcom-charger/smb-lib.c @@ -490,7 +490,7 @@ static int try_rerun_apsd_for_hvdcp(struct smb_charger *chg) /* ensure hvdcp is enabled */ if (!get_effective_result(chg->hvdcp_disable_votable)) { apsd_result = smblib_get_apsd_result(chg); - if (apsd_result->pst == POWER_SUPPLY_TYPE_USB_HVDCP) { + if (apsd_result->bit & (QC_2P0_BIT | QC_3P0_BIT)) { /* rerun APSD */ smblib_dbg(chg, PR_MISC, "rerun APSD\n"); smblib_masked_write(chg, CMD_APSD_REG, From ab23ab8211ca5e51184ee9420e0771a5f65d01d5 Mon Sep 17 00:00:00 2001 From: Nicholas Troast Date: Fri, 28 Oct 2016 11:02:03 -0700 Subject: [PATCH 2/2] qpnp-smb2: force HVDCP to 5V before reboot When the MSM resets the USB data lines are pulled low. If an HVDCP adapter is attached and operating at >5V, and the phone reboots then the HVDCP adapter will be in a bad state and the USB input will be suspended. Fix this by forcing the HVDCP adapter to 5V in the shutdown path. Change-Id: I953d42418f90398bd4248f8b761cf63943ce5532 Signed-off-by: Nicholas Troast --- drivers/power/qcom-charger/qpnp-smb2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/power/qcom-charger/qpnp-smb2.c b/drivers/power/qcom-charger/qpnp-smb2.c index f9d76c56aa2e..17d77b7ed873 100644 --- a/drivers/power/qcom-charger/qpnp-smb2.c +++ b/drivers/power/qcom-charger/qpnp-smb2.c @@ -1746,6 +1746,16 @@ static int smb2_remove(struct platform_device *pdev) return 0; } +static void smb2_shutdown(struct platform_device *pdev) +{ + struct smb2 *chip = platform_get_drvdata(pdev); + struct smb_charger *chg = &chip->chg; + + smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG, + HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT, 0); + smblib_write(chg, CMD_HVDCP_2_REG, FORCE_5V_BIT); +} + static const struct of_device_id match_table[] = { { .compatible = "qcom,qpnp-smb2", }, { }, @@ -1759,6 +1769,7 @@ static struct platform_driver smb2_driver = { }, .probe = smb2_probe, .remove = smb2_remove, + .shutdown = smb2_shutdown, }; module_platform_driver(smb2_driver);