Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 046c7ab8 authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

power: smb5: Disable/enable USBIN pulldown upon Type-C attach/detach



It is observed that commit 91480019 ("power: smb5: Fix OTG random
disconnection issue") causes an increase in bottom current when a Type-C
sink is connected. Fix this issue by disabling the pulldown on USBIN
whenever a Type-C sink or source is attached, and enabling it when it
has been detached.

CRs-Fixed: 2535589
Change-Id: If2a2ef612588464f1f0401a1b93ca3a0baacd4dc
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent fe4636bb
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -1329,17 +1329,6 @@ int smblib_set_icl_current(struct smb_charger *chg, int icl_ua)
	/* suspend if 25mA or less is requested */
	bool suspend = (icl_ua <= USBIN_25MA);

	if (chg->connector_type == POWER_SUPPLY_CONNECTOR_TYPEC) {
		rc = smblib_masked_write(chg, USB_CMD_PULLDOWN_REG,
				EN_PULLDOWN_USB_IN_BIT,
				suspend ? 0 : EN_PULLDOWN_USB_IN_BIT);
		if (rc < 0) {
			smblib_err(chg, "Couldn't write %s to EN_PULLDOWN_USB_IN_BIT rc=%d\n",
				suspend ? "disable" : "enable", rc);
			goto out;
		}
	}

	if (suspend)
		return smblib_set_usb_suspend(chg, true);

@@ -5923,6 +5912,7 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
	struct smb_irq_data *irq_data = data;
	struct smb_charger *chg = irq_data->parent_data;
	u8 stat;
	bool attached = false;
	int rc;

	smblib_dbg(chg, PR_INTERRUPT, "IRQ: %s\n", irq_data->name);
@@ -5934,8 +5924,9 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
		return IRQ_HANDLED;
	}

	if (stat & TYPEC_ATTACH_DETACH_STATE_BIT) {
	attached = !!(stat & TYPEC_ATTACH_DETACH_STATE_BIT);

	if (attached) {
		smblib_lpd_clear_ra_open_work(chg);

		rc = smblib_read(chg, TYPE_C_MISC_STATUS_REG, &stat);
@@ -5986,6 +5977,13 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
					msecs_to_jiffies(1000));
	}

	rc = smblib_masked_write(chg, USB_CMD_PULLDOWN_REG,
			EN_PULLDOWN_USB_IN_BIT,
			attached ?  0 : EN_PULLDOWN_USB_IN_BIT);
	if (rc < 0)
		smblib_err(chg, "Couldn't configure pulldown on USB_IN rc=%d\n",
				rc);

	power_supply_changed(chg->usb_psy);

	return IRQ_HANDLED;