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

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

power: smb5: Only rerun APSD when QC is attached before reboot



In the latest APSD/PD flow, it is required that APSD reruns before
system shutdown, in order for some HVDCP IRQs to be able to re-trigger
after reboot if the QC adaptor has been connected all the way.

Currently, the driver does APSD rerun always, which, if not
finished by then, may cause delay in bootloader stage.

Improve it by limiting rerun only when QC charger is attached.

Change-Id: I79d75feacd467ab9bd4a5144c6858adbc12c658b
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent be4e22c9
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -3342,14 +3342,9 @@ static void smb5_shutdown(struct platform_device *pdev)
		smblib_masked_write(chg, TYPE_C_MODE_CFG_REG,
				TYPEC_POWER_ROLE_CMD_MASK, EN_SNK_ONLY_BIT);

	/* force HVDCP to 5V */
	smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
				HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT, 0);
	smblib_write(chg, CMD_HVDCP_2_REG, FORCE_5V_BIT);

	/* force enable and rerun APSD */
	smblib_apsd_enable(chg, true);
	smblib_masked_write(chg, CMD_APSD_REG, APSD_RERUN_BIT, APSD_RERUN_BIT);
	smblib_hvdcp_exit_config(chg);
}

static const struct of_device_id match_table[] = {
+21 −0
Original line number Diff line number Diff line
@@ -917,6 +917,27 @@ void smblib_hvdcp_detect_enable(struct smb_charger *chg, bool enable)
	return;
}

void smblib_hvdcp_exit_config(struct smb_charger *chg)
{
	u8 stat;
	int rc;

	rc = smblib_read(chg, APSD_RESULT_STATUS_REG, &stat);
	if (rc < 0)
		return;

	if (stat & (QC_3P0_BIT | QC_2P0_BIT)) {
		/* force HVDCP to 5V */
		smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
				HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT, 0);
		smblib_write(chg, CMD_HVDCP_2_REG, FORCE_5V_BIT);

		/* rerun APSD */
		smblib_masked_write(chg, CMD_APSD_REG, APSD_RERUN_BIT,
				APSD_RERUN_BIT);
	}
}

static int smblib_request_dpdm(struct smb_charger *chg, bool enable)
{
	int rc = 0;
+1 −0
Original line number Diff line number Diff line
@@ -719,6 +719,7 @@ enum alarmtimer_restart smblib_lpd_recheck_timer(struct alarm *alarm,
				ktime_t time);
int smblib_toggle_smb_en(struct smb_charger *chg, int toggle);
void smblib_hvdcp_detect_enable(struct smb_charger *chg, bool enable);
void smblib_hvdcp_exit_config(struct smb_charger *chg);
void smblib_apsd_enable(struct smb_charger *chg, bool enable);
int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val);