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

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

Merge "power: smb5: Make DC CURRENT_MAX writeable"

parents 0af88de0 f850df0b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -465,6 +465,7 @@ static struct device_attribute power_supply_attrs[] = {
	POWER_SUPPLY_ATTR(adapter_cc_mode),
	POWER_SUPPLY_ATTR(skin_health),
	POWER_SUPPLY_ATTR(aicl_done),
	POWER_SUPPLY_ATTR(voltage_step),
	/* Charge pump properties */
	POWER_SUPPLY_ATTR(cp_status1),
	POWER_SUPPLY_ATTR(cp_status2),
+8 −0
Original line number Diff line number Diff line
@@ -393,6 +393,7 @@ static enum power_supply_property hl6111r_psy_props[] = {
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_VOLTAGE_AVG,
	POWER_SUPPLY_PROP_CURRENT_AVG,
	POWER_SUPPLY_PROP_VOLTAGE_STEP,
	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
	POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION,
@@ -433,6 +434,13 @@ static int hl6111r_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CURRENT_AVG:
		rc = hl6111r_get_current_avg(chip, val);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_STEP:
		/*
		 * Using only 20 mV for now, to correspond to range 0.
		 * Return value in uV.
		 */
		*val = (hl6111r_vout_range[0].step_mv * 1000);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
		*val = HL6111R_MAX_VOLTAGE_UV;
		break;
+1 −0
Original line number Diff line number Diff line
@@ -1500,6 +1500,7 @@ static int smb5_dc_prop_is_writeable(struct power_supply *psy,
{
	switch (psp) {
	case POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION:
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		return 1;
	default:
		break;
+40 −0
Original line number Diff line number Diff line
@@ -1052,6 +1052,11 @@ static int smblib_notifier_call(struct notifier_block *nb,
		schedule_work(&chg->pl_update_work);
	}

	if (!strcmp(psy->desc->name, "charge_pump_master")) {
		pm_stay_awake(chg->dev);
		schedule_work(&chg->cp_status_change_work);
	}

	return NOTIFY_OK;
}

@@ -7237,6 +7242,38 @@ static void smblib_lpd_detach_work(struct work_struct *work)
		chg->lpd_stage = LPD_STAGE_NONE;
}

static void smblib_cp_status_change_work(struct work_struct *work)
{
	int rc;
	union power_supply_propval pval;
	struct smb_charger *chg = container_of(work, struct smb_charger,
			cp_status_change_work);

	if (!chg->cp_psy)
		chg->cp_psy = power_supply_get_by_name("charge_pump_master");

	if (!chg->cp_psy)
		goto relax;

	if (chg->cp_topo == -EINVAL) {
		rc = power_supply_get_property(chg->cp_psy,
				POWER_SUPPLY_PROP_PARALLEL_OUTPUT_MODE, &pval);
		if (rc < 0) {
			smblib_err(chg, "Couldn't read cp topo rc=%d\n", rc);
			goto relax;
		}

		chg->cp_topo = pval.intval;

		if (chg->cp_topo == POWER_SUPPLY_PL_OUTPUT_VBAT &&
				chg->cp_reason == POWER_SUPPLY_CP_WIRELESS)
			vote(chg->fcc_main_votable, WLS_PL_CHARGING_VOTER, true,
					800000);
	}
relax:
	pm_relax(chg->dev);
}

static int smblib_create_votables(struct smb_charger *chg)
{
	int rc = 0;
@@ -7413,6 +7450,7 @@ int smblib_init(struct smb_charger *chg)
	INIT_WORK(&chg->pl_update_work, pl_update_work);
	INIT_WORK(&chg->jeita_update_work, jeita_update_work);
	INIT_WORK(&chg->dcin_aicl_work, dcin_aicl_work);
	INIT_WORK(&chg->cp_status_change_work, smblib_cp_status_change_work);
	INIT_DELAYED_WORK(&chg->clear_hdc_work, clear_hdc_work);
	INIT_DELAYED_WORK(&chg->icl_change_work, smblib_icl_change_work);
	INIT_DELAYED_WORK(&chg->pl_enable_work, smblib_pl_enable_work);
@@ -7471,6 +7509,7 @@ int smblib_init(struct smb_charger *chg)
	chg->cp_reason = POWER_SUPPLY_CP_NONE;
	chg->thermal_status = TEMP_BELOW_RANGE;
	chg->typec_irq_en = true;
	chg->cp_topo = -EINVAL;

	switch (chg->mode) {
	case PARALLEL_MASTER:
@@ -7567,6 +7606,7 @@ int smblib_deinit(struct smb_charger *chg)
		cancel_work_sync(&chg->jeita_update_work);
		cancel_work_sync(&chg->pl_update_work);
		cancel_work_sync(&chg->dcin_aicl_work);
		cancel_work_sync(&chg->cp_status_change_work);
		cancel_delayed_work_sync(&chg->clear_hdc_work);
		cancel_delayed_work_sync(&chg->icl_change_work);
		cancel_delayed_work_sync(&chg->pl_enable_work);
+2 −0
Original line number Diff line number Diff line
@@ -440,6 +440,7 @@ struct smb_charger {
	struct work_struct	moisture_protection_work;
	struct work_struct	chg_termination_work;
	struct work_struct	dcin_aicl_work;
	struct work_struct	cp_status_change_work;
	struct delayed_work	ps_change_timeout_work;
	struct delayed_work	clear_hdc_work;
	struct delayed_work	icl_change_work;
@@ -463,6 +464,7 @@ struct smb_charger {
	bool			sec_cp_present;
	int			sec_chg_selected;
	int			cp_reason;
	int			cp_topo;

	/* pd */
	int			voltage_min_uv;
Loading