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

Commit b021dd94 authored by Nicholas Troast's avatar Nicholas Troast Committed by Harry Yang
Browse files

power: supply: qcom: support CONNECTOR_THERM_ZONE property



Use the CONNECTOR_THERM_ZONE property to show the current thermal zone
of the USB connector temperature.

Change-Id: Ia9a85055d68ed08aa9be5b2b66e3e6389ec2e6c3
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 21825e31
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -1955,6 +1955,29 @@ int smblib_get_pe_start(struct smb_charger *chg,
	return 0;
}

int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
						union power_supply_propval *val)
{
	int rc, i;
	u8 stat;

	rc = smblib_read(chg, TEMP_RANGE_STATUS_REG, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read TEMP_RANGE_STATUS_REG rc=%d\n",
									rc);
		return rc;
	}

	i = fls((stat & TEMP_RANGE_MASK) >> TEMP_RANGE_SHIFT) - 1;
	if (i < 0) {
		smblib_err(chg, "TEMP_RANGE is invalid\n");
		return -EINVAL;
	}

	val->intval = i;
	return 0;
}

/*******************
 * USB PSY SETTERS *
 * *****************/
+2 −0
Original line number Diff line number Diff line
@@ -360,6 +360,8 @@ int smblib_get_prop_charger_temp(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_charger_temp_max(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_connector_therm_zone(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_usb_current_max(struct smb_charger *chg,
+2 −0
Original line number Diff line number Diff line
@@ -817,6 +817,8 @@ enum {
#define TEMP_RANGE_STATUS_7_BIT			BIT(7)
#define THERM_REG_ACTIVE_BIT			BIT(6)
#define TLIM_BIT				BIT(5)
#define TEMP_RANGE_MASK				GENMASK(4, 1)
#define TEMP_RANGE_SHIFT			1
#define ALERT_LEVEL_BIT				BIT(4)
#define TEMP_ABOVE_RANGE_BIT			BIT(3)
#define TEMP_WITHIN_RANGE_BIT			BIT(2)
+4 −0
Original line number Diff line number Diff line
@@ -425,6 +425,7 @@ static enum power_supply_property smb138x_parallel_props[] = {
	POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
	POWER_SUPPLY_PROP_MODEL_NAME,
	POWER_SUPPLY_PROP_PARALLEL_MODE,
	POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE,
};

static int smb138x_parallel_get_prop(struct power_supply *psy,
@@ -477,6 +478,9 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_PARALLEL_MODE:
		val->intval = POWER_SUPPLY_PARALLEL_MID_MID;
		break;
	case POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE:
		rc = smblib_get_prop_connector_therm_zone(chg, val);
		break;
	default:
		pr_err("parallel power supply get prop %d not supported\n",
			prop);