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

Commit 0774a1f5 authored by Harry Yang's avatar Harry Yang
Browse files

power: smb5-lib: Enable USB_IN 10mA current sink



There are certain charger Type-C insertion use cases in which SMB5
fails to detect a legacy cable.

As a SW workaround,  when boost is enabled or USB is put in suspend
mode, SW should turn off the 10mA current sink otherwise boost
efficiency or USB suspend spec will be violated. Conversely
when other use cases are excited, re-enable the 10mA current sink.

Change-Id: I2e0db74345134b3282853ddf7e4ea10848ae172d
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent a980a6a3
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -990,9 +990,21 @@ int smblib_set_icl_current(struct smb_charger *chg, int icl_ua)
{
	int rc = 0;
	bool hc_mode = false, override = false;
	/* suspend if 25mA or less is requested */
	bool suspend = (icl_ua <= USBIN_25MA);

	/* suspend and return if 25mA or less is requested */
	if (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);

	if (icl_ua == INT_MAX)
+3 −0
Original line number Diff line number Diff line
@@ -210,6 +210,9 @@ enum {
#define SINGLE_DECREMENT_BIT			BIT(1)
#define SINGLE_INCREMENT_BIT			BIT(0)

#define USB_CMD_PULLDOWN_REG			(USBIN_BASE + 0x45)
#define EN_PULLDOWN_USB_IN_BIT			BIT(0)

#define USBIN_ADAPTER_ALLOW_CFG_REG		(USBIN_BASE + 0x60)
enum {
	USBIN_ADAPTER_ALLOW_5V		= 0,