mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 12:25:00 -04:00
typec: Fix COM charging failed when using audio 2-1 adapter
Using Type-C to 3.5mm Headphone 2-in-1 Adapter,COM charging Failed. Because the devices are in off-mode when usb plug-in,bootup process might cause some detection delay. So when DUT power on with typec and the typec vbus is exist,we need to wait some times for check type-c is connected before call smb5_typec_attach_detach_irq_handler. Change-Id: I8ea0e904bc493c13d666a09f81c34d33fdb2663f Signed-off-by: Guocheng Wang <wanggc6@motorola.com> Reviewed-on: https://gerrit.mot.com/2752957 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Haijian Ma <mahj8@motorola.com> Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
06f890cf6f
commit
a4f0de2f15
2 changed files with 46 additions and 0 deletions
|
|
@ -2975,6 +2975,49 @@ static int smb5_init_typec_class(struct smb5 *chip)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int smb5_typec_cable_check(struct smb5 *chip)
|
||||
{
|
||||
struct smb_charger *chg = &chip->chg;
|
||||
int rc = 0;
|
||||
int i = 0;
|
||||
u8 stat = 0;
|
||||
bool usb_input_present = false;
|
||||
|
||||
if (chg->pd_not_supported)
|
||||
return rc;
|
||||
|
||||
rc = smblib_read(chg, USBIN_BASE + INT_RT_STS_OFFSET, &stat);
|
||||
if (rc < 0) {
|
||||
pr_err("%s Couldn't read USBIN_RT_STS rc=%d\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
usb_input_present = stat & USBIN_PLUGIN_RT_STS_BIT;
|
||||
|
||||
rc = smblib_read(chg, TYPE_C_MISC_STATUS_REG, &stat);
|
||||
if (rc < 0) {
|
||||
pr_err("%s Couldn't read TYPE_C_STATUS_4 rc=%d\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
pr_info("%s usb_input_present=%d TYPE_C_STATUS_4=0x%02X\n", __func__, usb_input_present, stat);
|
||||
|
||||
if (usb_input_present || (stat & TYPEC_VBUS_STATUS)) {
|
||||
for (i = 0; i < 10; i++) {
|
||||
rc = smblib_read(chg, TYPE_C_STATE_MACHINE_STATUS_REG, &stat);
|
||||
if (rc < 0) {
|
||||
pr_err("%s Couldn't read TYPE_C_STATE_MACHINE_STATUS rc=%d\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
pr_info("%s index=%d stat=0x%02X\n", __func__, i, stat);
|
||||
if (stat & TYPEC_ATTACH_DETACH_STATE_BIT) {
|
||||
break;
|
||||
}
|
||||
msleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int smb5_of_xlate(struct iio_dev *indio_dev,
|
||||
const struct of_phandle_args *iiospec)
|
||||
{
|
||||
|
|
@ -3256,6 +3299,8 @@ static int smb5_probe(struct platform_device *pdev)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
smb5_typec_cable_check(chip);
|
||||
|
||||
rc = smb5_determine_initial_status(chip);
|
||||
if (rc < 0) {
|
||||
pr_err("Couldn't determine initial status rc=%d\n",
|
||||
|
|
|
|||
|
|
@ -359,6 +359,7 @@ enum {
|
|||
#define TYPE_C_MISC_STATUS_REG (TYPEC_BASE + 0x0B)
|
||||
#define TYPEC_WATER_DETECTION_STATUS_BIT BIT(7)
|
||||
#define SNK_SRC_MODE_BIT BIT(6)
|
||||
#define TYPEC_VBUS_STATUS BIT(5)
|
||||
#define TYPEC_VBUS_ERROR_STATUS_BIT BIT(4)
|
||||
#define TYPEC_TCCDEBOUNCE_DONE_STATUS_BIT BIT(3)
|
||||
#define CC_ORIENTATION_BIT BIT(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue