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

Commit 1302c053 authored by Harry Yang's avatar Harry Yang Committed by Guru Das Srinagesh
Browse files

power: qpnp-smb5: Add VOLTAGE_VPH property



Add VOLTAGE_VPH property in SMB5 driver to export vph voltage
to user space.

Change-Id: I1a6ce4f37b3a55401baadd819c232d8296e62fb2
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 14e2ca2d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -724,6 +724,7 @@ static enum power_supply_property smb5_usb_props[] = {
	POWER_SUPPLY_PROP_MOISTURE_DETECTED,
	POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED,
	POWER_SUPPLY_PROP_QC_OPTI_DISABLE,
	POWER_SUPPLY_PROP_VOLTAGE_VPH,
};

static int smb5_usb_get_prop(struct power_supply *psy,
@@ -845,6 +846,9 @@ static int smb5_usb_get_prop(struct power_supply *psy,
		if (chg->hw_connector_mitigation)
			val->intval |= POWER_SUPPLY_QC_CTM_DISABLE;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_VPH:
		rc = smblib_get_prop_vph_voltage_now(chg, val);
		break;
	default:
		pr_err("get prop %d is not supported in usb\n", psp);
		rc = -EINVAL;
+20 −5
Original line number Diff line number Diff line
@@ -3105,6 +3105,23 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg,
		return smblib_read_usbin_voltage_chan(chg, val);
}

int smblib_get_prop_vph_voltage_now(struct smb_charger *chg,
				    union power_supply_propval *val)
{
	int rc;

	if (!chg->iio.vph_v_chan)
		return -ENODATA;

	rc = iio_read_channel_processed(chg->iio.vph_v_chan, &val->intval);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read vph channel rc=%d\n", rc);
		return rc;
	}

	return 0;
}

bool smblib_rsbux_low(struct smb_charger *chg, int r_thr)
{
	int r_sbu1, r_sbu2;
@@ -5461,14 +5478,12 @@ irqreturn_t dc_plugin_irq_handler(int irq, void *data)
	int rc, wireless_vout = 0;
	int sec_charger;

	rc = iio_read_channel_processed(chg->iio.vph_v_chan,
			&wireless_vout);
	rc = smblib_get_prop_vph_voltage_now(chg, &pval);
	if (rc < 0)
		return IRQ_HANDLED;

	wireless_vout *= 2;
	wireless_vout /= 100000;
	wireless_vout *= 100000;
	/* 2*VPH, with a granularity of 100mV */
	wireless_vout = ((pval.intval * 2) / 100000) * 100000;

	rc = smblib_is_input_present(chg, &input_present);
	if (rc < 0)
+2 −0
Original line number Diff line number Diff line
@@ -671,6 +671,8 @@ int smblib_get_prop_die_health(struct smb_charger *chg);
int smblib_get_die_health(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_connector_health(struct smb_charger *chg);
int smblib_get_prop_vph_voltage_now(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_set_prop_pd_current_max(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_sdp_current_max(struct smb_charger *chg,