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

Commit 88648f53 authored by David Keitel's avatar David Keitel
Browse files

power: qpnp-charger: allow 0 mA iusbmax request



Currently 0 mA requests for qpnp_chg_iusbmax_set
are rejected.
Fix this by allowing 0 mA and configuring IUSB_MAX
to the lowest setting of 100 mA (0x00).

Change-Id: Iff1ee312e85e3fe33d6421630215196125c1136f
CRs-Fixed: 580614
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent 0023b20a
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -835,13 +835,12 @@ qpnp_chg_iusbmax_set(struct qpnp_chg_chip *chip, int mA)
	int rc = 0;
	u8 usb_reg = 0, temp = 8;

	if (mA < QPNP_CHG_I_MAX_MIN_100
			|| mA > QPNP_CHG_I_MAX_MAX_MA) {
	if (mA < 0 || mA > QPNP_CHG_I_MAX_MAX_MA) {
		pr_err("bad mA=%d asked to set\n", mA);
		return -EINVAL;
	}

	if (mA == QPNP_CHG_I_MAX_MIN_100) {
	if (mA <= QPNP_CHG_I_MAX_MIN_100) {
		usb_reg = 0x00;
		pr_debug("current=%d setting %02x\n", mA, usb_reg);
		return qpnp_chg_write(chip, &usb_reg,
@@ -1479,6 +1478,7 @@ qpnp_chg_usb_usbin_valid_irq_handler(int irq, void *_chip)
				chip->chg_done = false;
			}
			qpnp_chg_usb_suspend_enable(chip, 0);
			qpnp_chg_iusbmax_set(chip, QPNP_CHG_I_MAX_MIN_100);
			chip->prev_usb_max_ma = -EINVAL;
			chip->aicl_settled = false;
		} else {
@@ -3662,6 +3662,7 @@ qpnp_batt_power_set_property(struct power_supply *psy,
		qpnp_batt_system_temp_level_set(chip, val->intval);
		break;
	case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX:
		if (qpnp_chg_is_usb_chg_plugged_in(chip))
			qpnp_chg_iusbmax_set(chip, val->intval / 1000);
		break;
	case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: