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

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

Merge "power: smb5: Enable updating of RECHARGE_SOC PSY property"

parents eb2c2d6f e148e353
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1225,6 +1225,9 @@ static int smb5_batt_set_prop(struct power_supply *psy,
		chg->die_health = val->intval;
		power_supply_changed(chg->batt_psy);
		break;
	case POWER_SUPPLY_PROP_RECHARGE_SOC:
		rc = smblib_set_prop_rechg_soc_thresh(chg, val);
		break;
	default:
		rc = -EINVAL;
	}
@@ -1444,6 +1447,7 @@ static int smb5_init_hw(struct smb5 *chip)
	struct smb_charger *chg = &chip->chg;
	int rc, type = 0;
	u8 val = 0;
	union power_supply_propval pval;

	if (chip->dt.no_battery)
		chg->fake_capacity = 50;
@@ -1723,13 +1727,14 @@ static int smb5_init_hw(struct smb5 *chip)

	/* program the auto-recharge threshold */
	if (chip->dt.auto_recharge_soc != -EINVAL) {
		rc = smblib_write(chg, CHARGE_RCHG_SOC_THRESHOLD_CFG_REG,
				(chip->dt.auto_recharge_soc * 255) / 100);
		pval.intval = chip->dt.auto_recharge_soc;
		rc = smblib_set_prop_rechg_soc_thresh(chg, &pval);
		if (rc < 0) {
			dev_err(chg->dev, "Couldn't configure CHG_RCHG_SOC_REG rc=%d\n",
					rc);
			return rc;
		}

		/* Program the sample count for SOC based recharge to 1 */
		rc = smblib_masked_write(chg, CHGR_NO_SAMPLE_TERM_RCHG_CFG_REG,
						NO_OF_SAMPLE_FOR_RCHG, 0);
+19 −0
Original line number Diff line number Diff line
@@ -1618,6 +1618,25 @@ int smblib_set_prop_input_current_limited(struct smb_charger *chg,
	return 0;
}

int smblib_set_prop_rechg_soc_thresh(struct smb_charger *chg,
				const union power_supply_propval *val)
{
	int rc;
	u8 new_thr = DIV_ROUND_CLOSEST(val->intval * 255, 100);

	rc = smblib_write(chg, CHARGE_RCHG_SOC_THRESHOLD_CFG_REG,
			new_thr);
	if (rc < 0) {
		smblib_err(chg, "Couldn't write to RCHG_SOC_THRESHOLD_CFG_REG rc=%d\n",
				rc);
		return rc;
	}

	chg->auto_recharge_soc = val->intval;

	return rc;
}

int smblib_rerun_aicl(struct smb_charger *chg)
{
	int rc;
+2 −0
Original line number Diff line number Diff line
@@ -541,6 +541,8 @@ int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_ship_mode(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_rechg_soc_thresh(struct smb_charger *chg,
				const union power_supply_propval *val);
void smblib_suspend_on_debug_battery(struct smb_charger *chg);
int smblib_rerun_apsd_if_required(struct smb_charger *chg);
int smblib_get_prop_fcc_delta(struct smb_charger *chg,