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

Commit 1b2e4c43 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: smb1398-charger: Toggle UVLO for Slave CP on USB removal



In addition to the master CP, toggle the UVLO config for slave CP
on USB removal to avoid poweroff-leakage.

Change-Id: I1f5d5185d003cfe104b4a67efc1fe88f105f0151
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent b43d06a6
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2020 The Linux Foundation. All rights reserved.
 * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "SMB1398: %s: " fmt, __func__
@@ -1715,6 +1715,10 @@ static void smb1398_status_change_work(struct work_struct *work)
		chip->usb_present = !!pval.intval;
		if (!chip->usb_present) /* USB has been removed */
			smb1398_toggle_uvlo(chip);
		pval.intval = 1;
		if (is_cps_available(chip))
			power_supply_set_property(chip->div2_cp_slave_psy,
				POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER, &pval);
	}

	rc = power_supply_get_property(chip->usb_psy,
@@ -2274,6 +2278,7 @@ static enum power_supply_property div2_cp_slave_props[] = {
	POWER_SUPPLY_PROP_CP_ENABLE,
	POWER_SUPPLY_PROP_INPUT_CURRENT_MAX,
	POWER_SUPPLY_PROP_CURRENT_CAPABILITY,
	POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER,
};

static int div2_cp_slave_get_prop(struct power_supply *psy,
@@ -2297,6 +2302,9 @@ static int div2_cp_slave_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CURRENT_CAPABILITY:
		pval->intval = (int)chip->current_capability;
		break;
	case POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER:
		pval->intval = 0;
		break;
	default:
		dev_err(chip->dev, "read div2_cp_slave property %d is not supported\n",
				prop);
@@ -2329,6 +2337,10 @@ static int div2_cp_slave_set_prop(struct power_supply *psy,
			return rc;
		chip->current_capability = mode;
		break;
	case POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER:
		/* use this case to toggle UVLO */
		rc = smb1398_toggle_uvlo(chip);
		break;
	default:
		dev_err(chip->dev, "write div2_cp_slave property %d is not supported\n",
				prop);