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

Commit 91480019 authored by Harry Yang's avatar Harry Yang
Browse files

power: smb5: Fix OTG random disconnection issue



OTG devices get disconnected randomly due to fault conditions from
usbin_mid_comp and usbni_collapse.

Disable both per HW recommendation during typec source mode.

Also in source mode, USB suspend is unnecessary, remove it.

CRs-Fixed: 2393802
Change-Id: I5f2c2000769a73f3cb95287603cf3c15a78f40fb
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent cc7a8b2d
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -5028,11 +5028,23 @@ static bool smblib_src_lpd(struct smb_charger *chg)
	return lpd_flag;
}

static void typec_src_fault_condition_cfg(struct smb_charger *chg, bool src)
{
	int rc;
	u8 mask = USBIN_MID_COMP_FAULT_EN_BIT | USBIN_COLLAPSE_FAULT_EN_BIT;

	rc = smblib_masked_write(chg, OTG_FAULT_CONDITION_CFG_REG, mask,
					src ? 0 : mask);
	if (rc < 0)
		smblib_err(chg, "Couldn't write OTG_FAULT_CONDITION_CFG_REG rc=%d\n",
			rc);
}

static void typec_sink_insertion(struct smb_charger *chg)
{
	int rc;

	vote(chg->usb_icl_votable, OTG_VOTER, true, 0);
	typec_src_fault_condition_cfg(chg, true);
	rc = smblib_set_charge_param(chg, &chg->param.freq_switcher,
					chg->chg_freq.freq_above_otg_threshold);
	if (rc < 0)
@@ -5076,7 +5088,7 @@ static void typec_sink_removal(struct smb_charger *chg)
{
	int rc;

	vote(chg->usb_icl_votable, OTG_VOTER, false, 0);
	typec_src_fault_condition_cfg(chg, false);
	rc = smblib_set_charge_param(chg, &chg->param.freq_switcher,
					chg->chg_freq.freq_removal);
	if (rc < 0)
@@ -5105,6 +5117,7 @@ static void typec_src_removal(struct smb_charger *chg)
		dev_err(chg->dev,
			"Couldn't disable secondary charger rc=%d\n", rc);

	typec_src_fault_condition_cfg(chg, false);
	smblib_hvdcp_detect_enable(chg, false);
	smblib_update_usb_type(chg);

@@ -5131,7 +5144,6 @@ static void typec_src_removal(struct smb_charger *chg)
	vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);
	vote(chg->usb_icl_votable, DCP_VOTER, false, 0);
	vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0);
	vote(chg->usb_icl_votable, OTG_VOTER, false, 0);
	vote(chg->usb_icl_votable, CTM_VOTER, false, 0);
	vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0);
	vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER, false, 0);
+0 −1
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ enum print_reason {
#define OTG_DELAY_VOTER			"OTG_DELAY_VOTER"
#define USBIN_I_VOTER			"USBIN_I_VOTER"
#define WEAK_CHARGER_VOTER		"WEAK_CHARGER_VOTER"
#define OTG_VOTER			"OTG_VOTER"
#define PL_FCC_LOW_VOTER		"PL_FCC_LOW_VOTER"
#define WBC_VOTER			"WBC_VOTER"
#define HW_LIMIT_VOTER			"HW_LIMIT_VOTER"
+4 −0
Original line number Diff line number Diff line
@@ -143,6 +143,10 @@ enum {
#define DCDC_OTG_CFG_REG			(DCDC_BASE + 0x53)
#define OTG_EN_SRC_CFG_BIT			BIT(1)

#define OTG_FAULT_CONDITION_CFG_REG		(DCDC_BASE + 0x56)
#define USBIN_MID_COMP_FAULT_EN_BIT		BIT(5)
#define USBIN_COLLAPSE_FAULT_EN_BIT		BIT(4)

#define DCDC_CFG_REF_MAX_PSNS_REG		(DCDC_BASE + 0x8C)

#define DCDC_ENG_SDCDC_CFG5_REG			(DCDC_BASE + 0xC4)