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

Commit 29123f0a authored by Ke Liu's avatar Ke Liu
Browse files

power: smb135x-charger: apply OTG workaround for v2 chip only



Currently, the OTG workaround is applied to each different version of SMB
chip. However, this workaround is needed only for v2 chip. Hence update
the driver accrodingly.

Change-Id: Icc71f0509703ae74ba0156205b775a51ce604225
CRs-fixed: 699400
Signed-off-by: default avatarKe Liu <keliu@codeaurora.org>
parent 6eb2af6d
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -1723,6 +1723,19 @@ static void smb135x_external_power_changed(struct power_supply *psy)
		dev_err(chip->dev, "could not set usb online, rc=%d\n", rc);
}

static int smb135x_chg_otg_regulator_enable(struct regulator_dev *rdev)
{
	int rc = 0;
	struct smb135x_chg *chip = rdev_get_drvdata(rdev);

	chip->otg_oc_count = 0;
	rc = smb135x_masked_write(chip, CMD_CHG_REG, OTG_EN, OTG_EN);
	if (rc < 0)
		dev_err(chip->dev, "Couldn't enable OTG mode rc=%d\n", rc);

	return rc;
}

static bool elapsed_msec_greater(struct timeval *start_time,
				struct timeval *end_time, int ms)
{
@@ -1735,7 +1748,7 @@ static bool elapsed_msec_greater(struct timeval *start_time,
}

#define MAX_STEP_MS		10
static int smb135x_chg_otg_regulator_enable(struct regulator_dev *rdev)
static int smb135x_chg_otg_regulator_enable_rev2(struct regulator_dev *rdev)
{
	int rc = 0;
	struct smb135x_chg *chip = rdev_get_drvdata(rdev);
@@ -1849,6 +1862,12 @@ struct regulator_ops smb135x_chg_otg_reg_ops = {
	.is_enabled	= smb135x_chg_otg_regulator_is_enable,
};

struct regulator_ops smb135x_chg_otg_reg_ops_rev2 = {
	.enable		= smb135x_chg_otg_regulator_enable_rev2,
	.disable	= smb135x_chg_otg_regulator_disable,
	.is_enabled	= smb135x_chg_otg_regulator_is_enable,
};

static int smb135x_set_current_tables(struct smb135x_chg *chip)
{
	switch (chip->version) {
@@ -2002,6 +2021,10 @@ static int smb135x_regulator_init(struct smb135x_chg *chip)
	if (init_data->constraints.name) {
		chip->otg_vreg.rdesc.owner = THIS_MODULE;
		chip->otg_vreg.rdesc.type = REGULATOR_VOLTAGE;
		if (chip->revision == REV_2)
			chip->otg_vreg.rdesc.ops =
				&smb135x_chg_otg_reg_ops_rev2;
		else
			chip->otg_vreg.rdesc.ops = &smb135x_chg_otg_reg_ops;
		chip->otg_vreg.rdesc.name = init_data->constraints.name;