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

Commit da17976d authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb2: Configure CC threshold voltage to 1.6 V"

parents 30d9e0b0 a0d0d6cf
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -193,6 +193,12 @@ Charger specific properties:
		to be get from these properties defined in battery profile:
		qcom,step-chg-ranges, qcom,jeita-fcc-ranges, qcom,jeita-fv-ranges.

- qcom,disable-stat-sw-override
  Usage:      optional
  Value type: bool
  Definition: Boolean flag which when present disables STAT pin default software
		override configuration.

=============================================
Second Level Nodes - SMB2 Charger Peripherals
=============================================
+45 −9
Original line number Diff line number Diff line
@@ -212,6 +212,9 @@ static int smb2_parse_dt(struct smb2 *chip)
		return -EINVAL;
	}

	chg->reddragon_ipc_wa = of_property_read_bool(node,
				"qcom,qcs605-ipc-wa");

	chg->step_chg_enabled = of_property_read_bool(node,
				"qcom,step-charging-enable");

@@ -326,6 +329,9 @@ static int smb2_parse_dt(struct smb2 *chip)
	if (rc < 0)
		chg->otg_delay_ms = OTG_DEFAULT_DEGLITCH_TIME_MS;

	chg->disable_stat_sw_override = of_property_read_bool(node,
					"qcom,disable-stat-sw-override");

	return 0;
}

@@ -977,6 +983,7 @@ static enum power_supply_property smb2_batt_props[] = {
	POWER_SUPPLY_PROP_CURRENT_NOW,
	POWER_SUPPLY_PROP_CURRENT_QNOVO,
	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_TECHNOLOGY,
	POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED,
@@ -990,6 +997,8 @@ static enum power_supply_property smb2_batt_props[] = {
	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
	POWER_SUPPLY_PROP_CHARGE_COUNTER,
	POWER_SUPPLY_PROP_CHARGE_FULL,
	POWER_SUPPLY_PROP_CYCLE_COUNT,
};

static int smb2_batt_get_prop(struct power_supply *psy,
@@ -1047,9 +1056,6 @@ static int smb2_batt_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_SW_JEITA_ENABLED:
		val->intval = chg->sw_jeita_enabled;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		rc = smblib_get_prop_batt_voltage_now(chg, val);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		val->intval = get_client_vote(chg->fv_votable,
				BATT_PROFILE_VOTER);
@@ -1061,9 +1067,6 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		val->intval = get_client_vote_locked(chg->fv_votable,
				QNOVO_VOTER);
		break;
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		rc = smblib_get_prop_batt_current_now(chg, val);
		break;
	case POWER_SUPPLY_PROP_CURRENT_QNOVO:
		val->intval = get_client_vote_locked(chg->fcc_votable,
				QNOVO_VOTER);
@@ -1072,8 +1075,9 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		val->intval = get_client_vote(chg->fcc_votable,
					      BATT_PROFILE_VOTER);
		break;
	case POWER_SUPPLY_PROP_TEMP:
		rc = smblib_get_prop_batt_temp(chg, val);
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
		val->intval = get_client_vote(chg->fcc_votable,
					      FG_ESR_VOTER);
		break;
	case POWER_SUPPLY_PROP_TECHNOLOGY:
		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
@@ -1102,7 +1106,16 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
		rc = smblib_get_prop_batt_charge_counter(chg, val);
	case POWER_SUPPLY_PROP_CHARGE_FULL:
	case POWER_SUPPLY_PROP_CYCLE_COUNT:
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
	case POWER_SUPPLY_PROP_TEMP:
		rc = smblib_get_prop_from_bms(chg, psp, val);
		break;
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		rc = smblib_get_prop_from_bms(chg, psp, val);
		if (!rc)
			val->intval *= (-1);
		break;
	default:
		pr_err("batt power supply prop %d not supported\n", psp);
@@ -1177,6 +1190,12 @@ static int smb2_batt_set_prop(struct power_supply *psy,
		chg->batt_profile_fcc_ua = val->intval;
		vote(chg->fcc_votable, BATT_PROFILE_VOTER, true, val->intval);
		break;
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
		if (val->intval)
			vote(chg->fcc_votable, FG_ESR_VOTER, true, val->intval);
		else
			vote(chg->fcc_votable, FG_ESR_VOTER, false, 0);
		break;
	case POWER_SUPPLY_PROP_SET_SHIP_MODE:
		/* Not in ship mode as long as the device is active */
		if (!val->intval)
@@ -1448,6 +1467,13 @@ static int smb2_configure_typec(struct smb_charger *chg)
		return rc;
	}

	/* Set CC threshold to 1.6 V in source mode */
	rc = smblib_masked_write(chg, TYPE_C_CFG_2_REG, DFP_CC_1P4V_OR_1P6V_BIT,
				 DFP_CC_1P4V_OR_1P6V_BIT);
	if (rc < 0)
		dev_err(chg->dev,
			"Couldn't configure CC threshold voltage rc=%d\n", rc);

	return rc;
}

@@ -1836,6 +1862,16 @@ static int smb2_init_hw(struct smb2 *chip)
		}
	}

	if (chg->disable_stat_sw_override) {
		rc = smblib_masked_write(chg, STAT_CFG_REG,
				STAT_SW_OVERRIDE_CFG_BIT, 0);
		if (rc < 0) {
			dev_err(chg->dev, "Couldn't disable STAT SW override rc=%d\n",
				rc);
			return rc;
		}
	}

	return rc;
}

+8 −45
Original line number Diff line number Diff line
@@ -1601,7 +1601,7 @@ static int _smblib_vbus_regulator_enable(struct regulator_dev *rdev)

	smblib_dbg(chg, PR_OTG, "enabling OTG\n");

	if (chg->wa_flags & OTG_WA) {
	if ((chg->wa_flags & OTG_WA) && (!chg->reddragon_ipc_wa)) {
		rc = smblib_enable_otg_wa(chg);
		if (rc < 0)
			smblib_err(chg, "Couldn't enable OTG rc=%d\n", rc);
@@ -1902,7 +1902,8 @@ int smblib_get_prop_batt_health(struct smb_charger *chg,
		   stat);

	if (stat & CHARGER_ERROR_STATUS_BAT_OV_BIT) {
		rc = smblib_get_prop_batt_voltage_now(chg, &pval);
		rc = smblib_get_prop_from_bms(chg,
				POWER_SUPPLY_PROP_VOLTAGE_NOW, &pval);
		if (!rc) {
			/*
			 * If Vbatt is within 40mV above Vfloat, then don't
@@ -1967,45 +1968,6 @@ int smblib_get_prop_input_current_limited(struct smb_charger *chg,
	return 0;
}

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

	if (!chg->bms_psy)
		return -EINVAL;

	rc = power_supply_get_property(chg->bms_psy,
				       POWER_SUPPLY_PROP_VOLTAGE_NOW, val);
	return rc;
}

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

	if (!chg->bms_psy)
		return -EINVAL;

	rc = power_supply_get_property(chg->bms_psy,
				       POWER_SUPPLY_PROP_CURRENT_NOW, val);
	return rc;
}

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

	if (!chg->bms_psy)
		return -EINVAL;

	rc = power_supply_get_property(chg->bms_psy,
				       POWER_SUPPLY_PROP_TEMP, val);
	return rc;
}

int smblib_get_prop_batt_charge_done(struct smb_charger *chg,
					union power_supply_propval *val)
{
@@ -2041,7 +2003,8 @@ int smblib_get_prop_charge_qnovo_enable(struct smb_charger *chg,
	return 0;
}

int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
int smblib_get_prop_from_bms(struct smb_charger *chg,
				enum power_supply_property psp,
				union power_supply_propval *val)
{
	int rc;
@@ -2049,8 +2012,8 @@ int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
	if (!chg->bms_psy)
		return -EINVAL;

	rc = power_supply_get_property(chg->bms_psy,
				       POWER_SUPPLY_PROP_CHARGE_COUNTER, val);
	rc = power_supply_get_property(chg->bms_psy, psp, val);

	return rc;
}

+6 −8
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ enum print_reason {
#define WBC_VOTER			"WBC_VOTER"
#define OV_VOTER			"OV_VOTER"
#define MOISTURE_VOTER			"MOISTURE_VOTER"
#define FG_ESR_VOTER			"FG_ESR_VOTER"

#define VCONN_MAX_ATTEMPTS	3
#define OTG_MAX_ATTEMPTS	3
@@ -350,6 +351,7 @@ struct smb_charger {
	u8			float_cfg;
	bool			use_extcon;
	bool			otg_present;
	bool			disable_stat_sw_override;

	/* workaround flag */
	u32			wa_flags;
@@ -360,6 +362,7 @@ struct smb_charger {
	int			temp_speed_reading_count;
	int			qc2_max_pulses;
	bool			non_compliant_chg_detected;
	bool			reddragon_ipc_wa;

	/* extcon for VBUS / ID notification to USB for uUSB */
	struct extcon_dev	*extcon;
@@ -442,14 +445,6 @@ int smblib_get_prop_system_temp_level_max(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_input_current_limited(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_voltage_now(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_current_now(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_temp(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_set_prop_input_suspend(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
@@ -541,6 +536,9 @@ int smblib_get_icl_current(struct smb_charger *chg, int *icl_ua);
int smblib_get_charge_current(struct smb_charger *chg, int *total_current_ua);
int smblib_get_prop_pr_swap_in_progress(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_from_bms(struct smb_charger *chg,
				enum power_supply_property psp,
				union power_supply_propval *val);
int smblib_set_prop_pr_swap_in_progress(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_stat_sw_override_cfg(struct smb_charger *chg, bool override);
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -570,7 +570,7 @@ enum {

#define TYPE_C_CFG_2_REG			(USBIN_BASE + 0x59)
#define TYPE_C_DFP_CURRSRC_MODE_BIT		BIT(7)
#define VCONN_ILIM500MA_CFG_BIT			BIT(6)
#define DFP_CC_1P4V_OR_1P6V_BIT			BIT(6)
#define VCONN_SOFTSTART_CFG_MASK		GENMASK(5, 4)
#define EN_TRY_SOURCE_MODE_BIT			BIT(3)
#define USB_FACTORY_MODE_ENABLE_BIT		BIT(2)