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

Commit fc4ee1f6 authored by Umang Agrawal's avatar Umang Agrawal
Browse files

power: smb1390: Add cp_awake votable to hold wake lock



Add cp_awake votable to hold wake lock till charge pump is enabled
to prevent i2c read/write failures.

Change-Id: I69a973d16a90ff566374fe40cb7517c7b3b1e453
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent b1e3702d
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ struct smb1390 {
	struct regmap		*regmap;
	struct notifier_block	nb;
	struct class		cp_class;
	struct wakeup_source	*cp_ws;

	/* work structs */
	struct work_struct	status_change_work;
@@ -114,6 +115,7 @@ struct smb1390 {
	struct votable		*pl_disable_votable;
	struct votable		*fcc_votable;
	struct votable		*hvdcp_hw_inov_dis_votable;
	struct votable		*cp_awake_votable;

	/* power supplies */
	struct power_supply	*usb_psy;
@@ -379,9 +381,11 @@ static int smb1390_disable_vote_cb(struct votable *votable, void *data,
			return rc;

		vote(chip->pl_disable_votable, CP_VOTER, false, 0);
		vote(chip->cp_awake_votable, CP_VOTER, false, 0);
	} else {
		vote(chip->hvdcp_hw_inov_dis_votable, CP_VOTER, true, 0);
		vote(chip->pl_disable_votable, CP_VOTER, true, 0);
		vote(chip->cp_awake_votable, CP_VOTER, true, 0);
		rc = smb1390_masked_write(chip, CORE_CONTROL1_REG,
				   CMD_EN_SWITCHER_BIT, CMD_EN_SWITCHER_BIT);
		if (rc < 0)
@@ -427,6 +431,20 @@ static int smb1390_ilim_vote_cb(struct votable *votable, void *data,
	return rc;
}

static int smb1390_awake_vote_cb(struct votable *votable, void *data,
				int awake, const char *client)
{
	struct smb1390 *chip = data;

	if (awake)
		__pm_stay_awake(chip->cp_ws);
	else
		__pm_relax(chip->cp_ws);

	pr_debug("client: %s awake: %d\n", client, awake);
	return 0;
}

static int smb1390_notifier_cb(struct notifier_block *nb,
			       unsigned long event, void *data)
{
@@ -588,6 +606,11 @@ static int smb1390_create_votables(struct smb1390 *chip)
	if (IS_ERR(chip->ilim_votable))
		return PTR_ERR(chip->ilim_votable);

	chip->cp_awake_votable = create_votable("CP_AWAKE", VOTE_SET_ANY,
			smb1390_awake_vote_cb, chip);
	if (IS_ERR(chip->cp_awake_votable))
		return PTR_ERR(chip->cp_awake_votable);

	return 0;
}

@@ -732,6 +755,10 @@ static int smb1390_probe(struct platform_device *pdev)
		return rc;
	}

	chip->cp_ws = wakeup_source_register("qcom-chargepump");
	if (!chip->cp_ws)
		return rc;

	rc = smb1390_create_votables(chip);
	if (rc < 0) {
		pr_err("Couldn't create votables rc=%d\n", rc);
@@ -778,6 +805,7 @@ static int smb1390_probe(struct platform_device *pdev)
out_work:
	cancel_work(&chip->taper_work);
	cancel_work(&chip->status_change_work);
	wakeup_source_unregister(chip->cp_ws);
	return rc;
}

@@ -793,6 +821,7 @@ static int smb1390_remove(struct platform_device *pdev)
	vote(chip->hvdcp_hw_inov_dis_votable, CP_VOTER, false, 0);
	cancel_work(&chip->taper_work);
	cancel_work(&chip->status_change_work);
	wakeup_source_unregister(chip->cp_ws);
	smb1390_destroy_votables(chip);
	return 0;
}