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

Commit a74083cd authored by David Keitel's avatar David Keitel Committed by Stephen Boyd
Browse files

power: qpnp-charger: do not reset iusbmax



In the current implementation if the charger_monitor
bit is set and external_power_supply_changed callback
is called the USB input current limit may be reconfigured
to the USB_WALL_THRESHOLD_MA value.

Fix this by only allowing the input current limit for usb
to be changed through the external_power_supply_change
callback if it has changed from the previous requested
value.

CRs-Fixed: 457381
Change-Id: Ic85941740bc3e9131d68feb8e4ec41621c95abb8
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent ba5e5657
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -293,6 +293,7 @@ struct qpnp_chg_chip {
	unsigned int			safe_voltage_mv;
	unsigned int			max_voltage_mv;
	unsigned int			min_voltage_mv;
	int				prev_usb_max_ma;
	int				set_vddmax_mv;
	int				delta_vddmax_mv;
	unsigned int			warm_bat_mv;
@@ -967,6 +968,7 @@ qpnp_chg_usb_usbin_valid_irq_handler(int irq, void *_chip)
		if (!usb_present) {
			qpnp_chg_usb_suspend_enable(chip, 1);
			chip->chg_done = false;
			chip->prev_usb_max_ma = -EINVAL;
		} else {
			schedule_delayed_work(&chip->eoc_work,
				msecs_to_jiffies(EOC_CHECK_PERIOD_MS));
@@ -1528,6 +1530,10 @@ qpnp_batt_external_power_changed(struct power_supply *psy)
	if (qpnp_chg_is_usb_chg_plugged_in(chip)) {
		chip->usb_psy->get_property(chip->usb_psy,
			  POWER_SUPPLY_PROP_CURRENT_MAX, &ret);

		if (chip->prev_usb_max_ma == ret.intval)
			goto skip_set_iusb_max;

		if (ret.intval <= 2 && !chip->use_default_batt_values &&
						get_prop_batt_present(chip)) {
			qpnp_chg_usb_suspend_enable(chip, 1);
@@ -1542,8 +1548,10 @@ qpnp_batt_external_power_changed(struct power_supply *psy)
				qpnp_chg_iusbmax_set(chip, ret.intval / 1000);
			}
		}
		chip->prev_usb_max_ma = ret.intval;
	}

skip_set_iusb_max:
	pr_debug("end of power supply changed\n");
	power_supply_changed(&chip->batt_psy);
}
@@ -3009,6 +3017,7 @@ qpnp_charger_probe(struct spmi_device *spmi)
		return -ENOMEM;
	}

	chip->prev_usb_max_ma = -EINVAL;
	chip->dev = &(spmi->dev);
	chip->spmi = spmi;