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

Commit daca4928 authored by Ashay Jaiswal's avatar Ashay Jaiswal Committed by Harry Yang
Browse files

power: smb135x-charger: Add a DT property for enable-pin polarity



Add ability to configure the polarity of enable-pin in
parallel-charger configuration.

CRs-Fixed: 978046
Change-Id: Ied82dff7afeaa58ea0815f555791c9a0d15e926a
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 8d33b7db
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
/* Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -89,6 +89,7 @@
#define CFG_14_REG			0x14
#define CHG_EN_BY_PIN_BIT		BIT(7)
#define CHG_EN_ACTIVE_LOW_BIT		BIT(6)
#define CHG_EN_ACTIVE_HIGH_BIT		0x0
#define PRE_TO_FAST_REQ_CMD_BIT		BIT(5)
#define DISABLE_CURRENT_TERM_BIT	BIT(3)
#define DISABLE_AUTO_RECHARGE_BIT	BIT(2)
@@ -367,6 +368,7 @@ struct smb135x_chg {
	bool				parallel_charger;
	bool				parallel_charger_present;
	bool				bms_controlled_charging;
	u32				parallel_pin_polarity_setting;

	/* psy */
	struct power_supply		*usb_psy;
@@ -1786,7 +1788,8 @@ static int smb135x_parallel_set_chg_present(struct smb135x_chg *chip,
		rc = smb135x_masked_write(chip, CFG_14_REG,
				CHG_EN_BY_PIN_BIT | CHG_EN_ACTIVE_LOW_BIT
				| DISABLE_AUTO_RECHARGE_BIT,
				CHG_EN_BY_PIN_BIT | CHG_EN_ACTIVE_LOW_BIT);
				CHG_EN_BY_PIN_BIT |
				chip->parallel_pin_polarity_setting);

		/* set bit 0 = 100mA bit 1 = 500mA and set register control */
		rc = smb135x_masked_write(chip, CFG_E_REG,
@@ -4320,6 +4323,15 @@ static int smb135x_parallel_charger_probe(struct i2c_client *client,
	if (rc < 0)
		chip->vfloat_mv = -EINVAL;

	rc = of_property_read_u32(node, "qcom,parallel-en-pin-polarity",
					&chip->parallel_pin_polarity_setting);
	if (rc)
		chip->parallel_pin_polarity_setting = CHG_EN_ACTIVE_LOW_BIT;
	else
		chip->parallel_pin_polarity_setting =
				chip->parallel_pin_polarity_setting ?
				CHG_EN_ACTIVE_HIGH_BIT : CHG_EN_ACTIVE_LOW_BIT;

	mutex_init(&chip->path_suspend_lock);
	mutex_init(&chip->current_change_lock);
	mutex_init(&chip->read_write_lock);