qcom-charger: WA for legacy bit set on hard reboot

After cold reboot with typec attached, HW can not tell
typec from legacy cable.

The workaround is to reset and re-initiate legacy cable
detection.

CRs-Fixed: 1079373
Change-Id: Ifd7b2b88e7ab4c952b743fede6e24795069d653a
Signed-off-by: Harry Yang <harryy@codeaurora.org>
This commit is contained in:
Harry Yang 2016-11-03 11:43:57 -07:00
parent e95375540c
commit 64e8b62cdf
3 changed files with 47 additions and 0 deletions

View file

@ -1256,6 +1256,13 @@ static int smb2_init_hw(struct smb2 *chip)
return rc;
}
rc = smblib_validate_initial_typec_legacy_status(chg);
if (rc < 0) {
dev_err(chg->dev, "Couldn't validate typec legacy status rc=%d\n",
rc);
return rc;
}
return rc;
}

View file

@ -16,6 +16,7 @@
#include <linux/iio/consumer.h>
#include <linux/power_supply.h>
#include <linux/regulator/driver.h>
#include <linux/qpnp/power-on.h>
#include <linux/irq.h>
#include "smb-lib.h"
#include "smb-reg.h"
@ -3106,3 +3107,40 @@ int smblib_deinit(struct smb_charger *chg)
return 0;
}
int smblib_validate_initial_typec_legacy_status(struct smb_charger *chg)
{
int rc;
u8 stat;
if (qpnp_pon_is_warm_reset())
return 0;
rc = smblib_read(chg, TYPE_C_STATUS_5_REG, &stat);
if (rc < 0) {
smblib_err(chg, "Couldn't read TYPE_C_STATUS_5 rc=%d\n", rc);
return rc;
}
if ((stat & TYPEC_LEGACY_CABLE_STATUS_BIT) == 0)
return 0;
rc = smblib_masked_write(chg, TYPE_C_INTRPT_ENB_SOFTWARE_CTRL_REG,
TYPEC_DISABLE_CMD_BIT, TYPEC_DISABLE_CMD_BIT);
if (rc < 0) {
smblib_err(chg, "Couldn't disable typec rc=%d\n", rc);
return rc;
}
usleep_range(150000, 151000);
rc = smblib_masked_write(chg, TYPE_C_INTRPT_ENB_SOFTWARE_CTRL_REG,
TYPEC_DISABLE_CMD_BIT, 0);
if (rc < 0) {
smblib_err(chg, "Couldn't enable typec rc=%d\n", rc);
return rc;
}
return 0;
}

View file

@ -345,6 +345,8 @@ int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
int smblib_get_prop_slave_current_now(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_validate_initial_typec_legacy_status(struct smb_charger *chg);
int smblib_init(struct smb_charger *chg);
int smblib_deinit(struct smb_charger *chg);
#endif /* __SMB2_CHARGER_H */