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

Commit 2ec32a9a authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qcom: smb5-lib: Update charging status for handling Qnovo"

parents 601ba0e5 19cb0580
Loading
Loading
Loading
Loading
+2 −15
Original line number Diff line number Diff line
@@ -2236,21 +2236,8 @@ static int fg_gen4_esr_fcc_config(struct fg_gen4_chip *chip)
			parallel_en = prop.intval;
	}

	if (usb_psy_initialized(fg)) {
		rc = power_supply_get_property(fg->usb_psy,
			POWER_SUPPLY_PROP_SMB_EN_MODE, &prop);
		if (rc < 0) {
			pr_err("Couldn't read usb SMB_EN_MODE rc=%d\n", rc);
			return rc;
		}

		/*
		 * If SMB_EN_MODE is 1, then charge pump can get enabled for
		 * the charger inserted. However, whether the charge pump
		 * switching happens only if the conditions are met.
		 */
		cp_en = (prop.intval == 1);
	}
	if (chip->cp_disable_votable)
		cp_en = !get_effective_result(chip->cp_disable_votable);

	qnovo_en = is_qnovo_en(fg);

+0 −29
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@
#define QNOVO_OVERALL_VOTER	"QNOVO_OVERALL_VOTER"
#define QNI_PT_VOTER		"QNI_PT_VOTER"

#define HW_OK_TO_QNOVO_VOTER	"HW_OK_TO_QNOVO_VOTER"
#define CHG_READY_VOTER		"CHG_READY_VOTER"
#define USB_READY_VOTER		"USB_READY_VOTER"

@@ -1091,30 +1090,6 @@ static struct attribute *qnovo_class_attrs[] = {
};
ATTRIBUTE_GROUPS(qnovo_class);

static int qnovo5_update_status(struct qnovo *chip)
{
	u8 val = 0;
	int rc;
	bool hw_ok_to_qnovo;

	rc = qnovo5_read(chip, QNOVO_ERROR_STS, &val, 1);
	if (rc < 0) {
		pr_err("Couldn't read error sts rc = %d\n", rc);
		hw_ok_to_qnovo = false;
	} else {
		/*
		 * For CV mode keep qnovo enabled, userspace is expected to
		 * disable it after few runs
		 */
		hw_ok_to_qnovo = (val == ERR_CV_MODE || val == 0) ?
			true : false;
	}

	vote(chip->not_ok_to_qnovo_votable, HW_OK_TO_QNOVO_VOTER,
					!hw_ok_to_qnovo, 0);
	return 0;
}

static void usb_debounce_work(struct work_struct *work)
{
	struct qnovo *chip = container_of(work,
@@ -1152,8 +1127,6 @@ static void status_change_work(struct work_struct *work)
		schedule_delayed_work(&chip->usb_debounce_work,
				msecs_to_jiffies(DEBOUNCE_MS));
	}

	qnovo5_update_status(chip);
}

static int qnovo_notifier_call(struct notifier_block *nb,
@@ -1177,8 +1150,6 @@ static irqreturn_t handle_ptrain_done(int irq, void *data)
{
	struct qnovo *chip = data;

	qnovo5_update_status(chip);

	/*
	 * hw resets pt_en bit once ptrain_done triggers.
	 * vote on behalf of QNI to disable it such that
+19 −0
Original line number Diff line number Diff line
@@ -1583,6 +1583,20 @@ int smblib_get_prop_batt_capacity(struct smb_charger *chg,
	return rc;
}

static bool is_charging_paused(struct smb_charger *chg)
{
	int rc;
	u8 val;

	rc = smblib_read(chg, CHARGING_PAUSE_CMD_REG, &val);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read CHARGING_PAUSE_CMD rc=%d\n", rc);
		return false;
	}

	return val & CHARGING_PAUSE_CMD_BIT;
}

int smblib_get_prop_batt_status(struct smb_charger *chg,
				union power_supply_propval *val)
{
@@ -1648,6 +1662,11 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
		break;
	}

	if (is_charging_paused(chg)) {
		val->intval = POWER_SUPPLY_STATUS_CHARGING;
		return 0;
	}

	if (val->intval != POWER_SUPPLY_STATUS_CHARGING)
		return 0;

+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ enum {
#define CHARGING_ENABLE_CMD_REG			(CHGR_BASE + 0x42)
#define CHARGING_ENABLE_CMD_BIT			BIT(0)

#define CHARGING_PAUSE_CMD_REG			(CHGR_BASE + 0x43)
#define CHARGING_PAUSE_CMD_BIT			BIT(0)

#define CHGR_CFG2_REG				(CHGR_BASE + 0x51)
#define RECHG_MASK				GENMASK(2, 1)
#define VBAT_BASED_RECHG_BIT			BIT(2)