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

Commit 1a2a3728 authored by Harry Yang's avatar Harry Yang
Browse files

power: Add support for faking die temp and CTM health



Allow manually changing die temp and CTM health for debugging
and test purpose.

Change-Id: Iaf297955d59be35a1d385e419d470fd1c6f9a101
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 166b15d3
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1037,7 +1037,10 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_DIE_HEALTH:
		if (chg->die_health == -EINVAL)
			rc = smblib_get_prop_die_health(chg, val);
		else
			val->intval = chg->die_health;
		break;
	case POWER_SUPPLY_PROP_DP_DM:
		val->intval = chg->pulse_cnt;
@@ -1145,6 +1148,10 @@ static int smb2_batt_set_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
		rc = smblib_set_prop_input_current_limited(chg, val);
		break;
	case POWER_SUPPLY_PROP_DIE_HEALTH:
		chg->die_health = val->intval;
		power_supply_changed(chg->batt_psy);
		break;
	default:
		rc = -EINVAL;
	}
@@ -1166,6 +1173,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
	case POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED:
	case POWER_SUPPLY_PROP_SW_JEITA_ENABLED:
	case POWER_SUPPLY_PROP_DIE_HEALTH:
		return 1;
	default:
		break;
@@ -2238,6 +2246,7 @@ static int smb2_probe(struct platform_device *pdev)
	chg->weak_chg_icl_ua = &__weak_chg_icl_ua;
	chg->mode = PARALLEL_MASTER;
	chg->irq_info = smb2_irqs;
	chg->die_health = -EINVAL;
	chg->name = "PMI";

	chg->regmap = dev_get_regmap(chg->dev->parent, NULL);
+2 −0
Original line number Diff line number Diff line
@@ -356,6 +356,8 @@ struct smb_charger {
	/* qnovo */
	int			usb_icl_delta_ua;
	int			pulse_cnt;

	int			die_health;
};

int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
+18 −1
Original line number Diff line number Diff line
@@ -146,6 +146,8 @@ struct smb1355 {

	struct power_supply	*parallel_psy;
	struct pmic_revid_data	*pmic_rev_id;

	int			c_health;
};

static bool is_secure(struct smb1355 *chip, int addr)
@@ -434,7 +436,10 @@ static int smb1355_parallel_get_prop(struct power_supply *psy,
		val->intval = POWER_SUPPLY_PL_USBMID_USBMID;
		break;
	case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
		if (chip->c_health == -EINVAL)
			val->intval = smb1355_get_prop_connector_health(chip);
		else
			val->intval = chip->c_health;
		break;
	default:
		pr_err_ratelimited("parallel psy get prop %d not supported\n",
@@ -497,6 +502,10 @@ static int smb1355_parallel_set_prop(struct power_supply *psy,
		rc = smb1355_set_charge_param(chip, &chip->param.fcc,
						val->intval);
		break;
	case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
		chip->c_health = val->intval;
		power_supply_changed(chip->parallel_psy);
		break;
	default:
		pr_debug("parallel power supply set prop %d not supported\n",
			prop);
@@ -509,6 +518,13 @@ static int smb1355_parallel_set_prop(struct power_supply *psy,
static int smb1355_parallel_prop_is_writeable(struct power_supply *psy,
					      enum power_supply_property prop)
{
	switch (prop) {
	case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
		return 1;
	default:
		break;
	}

	return 0;
}

@@ -714,6 +730,7 @@ static int smb1355_probe(struct platform_device *pdev)

	chip->dev = &pdev->dev;
	chip->param = v1_params;
	chip->c_health = -EINVAL;
	chip->name = "smb1355";
	mutex_init(&chip->write_lock);