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

Commit 158df674 authored by Harry Yang's avatar Harry Yang
Browse files

power: smb5-lib: Increase OV threshold on ADC USB_IN_V reading



Update USB_IN channel read sequence. This channel read sequence is
done to prevent over voltage in charger.

As part of the read sequence, Increase 12V OV threshold to 14.6V
before and restore to 13.2V after ADC USB_IN_V channel reading.

Change-Id: I1d1e6f50fb1992447f5919661128e75967918896
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 9ea664bf
Loading
Loading
Loading
Loading
+34 −4
Original line number Diff line number Diff line
@@ -2048,12 +2048,42 @@ int smblib_get_prop_usb_voltage_max(struct smb_charger *chg,
int smblib_get_prop_usb_voltage_now(struct smb_charger *chg,
				    union power_supply_propval *val)
{
	if (chg->iio.usbin_v_chan)
		return iio_read_channel_processed(chg->iio.usbin_v_chan,
				&val->intval);
	else
	int rc, ret = 0;

	/* set 12V OV to 14.6V */
	if (chg->smb_version == PM8150B_SUBTYPE) {
		rc = smblib_masked_write(chg, USB_ENG_SSUPPLY_USB2_REG,
				ENG_SSUPPLY_12V_OV_OPT_BIT,
				ENG_SSUPPLY_12V_OV_OPT_BIT);
		if (rc < 0) {
			smblib_err(chg, "Couldn't set USB_ENG_SSUPPLY_USB2_REG rc=%d\n",
					rc);
			return -ENODATA;
		}
	}

	if (chg->iio.usbin_v_chan) {
		rc = iio_read_channel_processed(chg->iio.usbin_v_chan,
				&val->intval);
		if (rc < 0)
			ret = -ENODATA;
	} else {
		ret = -ENODATA;
	}

	/*  restore 12V OV to 13.2V */
	if (chg->smb_version == PM8150B_SUBTYPE) {
		rc = smblib_masked_write(chg, USB_ENG_SSUPPLY_USB2_REG,
				ENG_SSUPPLY_12V_OV_OPT_BIT, 0);
		if (rc < 0) {
			smblib_err(chg, "Couldn't restore USB_ENG_SSUPPLY_USB2_REG rc=%d\n",
					rc);
			ret = -ENODATA;
		}
	}

	return ret;
}

int smblib_get_prop_charger_temp(struct smb_charger *chg,
				 union power_supply_propval *val)
+3 −0
Original line number Diff line number Diff line
@@ -262,6 +262,9 @@ enum {
#define USBIN_AICL_PERIODIC_RERUN_EN_BIT	BIT(4)
#define USBIN_AICL_ADC_EN_BIT			BIT(3)

#define USB_ENG_SSUPPLY_USB2_REG		(USBIN_BASE + 0xC0)
#define ENG_SSUPPLY_12V_OV_OPT_BIT		BIT(1)

/********************************
 *  DCIN Peripheral Registers   *
 ********************************/